@readmagic/workmate 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Vmmm7p1c.js → AddWorkspaceDirectory-ag2JTpmU.js} +1 -1
  2. package/dist/chunks/App-BuKmqFPm.js +1 -0
  3. package/dist/chunks/ApproveApiKey-CIWOi_7v.js +1 -0
  4. package/dist/chunks/ApproveApiKey-M6U-NafA.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-Pnpl3Ixx.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-CLSACUmo.js → BypassPermissionsModeDialog-B05t83wa.js} +1 -1
  7. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BqNxQOXJ.js → ClaudeMdExternalIncludesDialog-CSywJdVL.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-D-w166RC.js +1 -0
  9. package/dist/chunks/ConsoleOAuthFlow-CV6PcJOP.js +1 -0
  10. package/dist/chunks/{DiffDialog-9AYwtupw.js → DiffDialog-DUbFrzKu.js} +2 -2
  11. package/dist/chunks/Doctor-BcnUfJ4I.js +1 -0
  12. package/dist/chunks/Doctor-Dz4TuYas.js +3 -0
  13. package/dist/chunks/ExitFlow-BwyAtIHx.js +2 -0
  14. package/dist/chunks/{Grove-B9-hhkZA.js → Grove-BDoVj02t.js} +2 -2
  15. package/dist/chunks/{HybridTransport-MxJ_W_np.js → HybridTransport-C_U0IJfz.js} +4 -4
  16. package/dist/chunks/InvalidConfigDialog-bih293Xt.js +1 -0
  17. package/dist/chunks/{InvalidSettingsDialog-YyQcHocx.js → InvalidSettingsDialog-Br8kQOHz.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-B9n4SXN4.js +1 -0
  19. package/dist/chunks/MCPToolListView-DJ06N1DG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-BCpfHaBK.js → McpParsingWarnings-COa71S9q.js} +1 -1
  21. package/dist/chunks/MessageSelector-o4ULADFg.js +3 -0
  22. package/dist/chunks/Messages-qqwHuAW5.js +11 -0
  23. package/dist/chunks/{Onboarding-ClwHS5rh.js → Onboarding-BzuQjney.js} +1 -1
  24. package/dist/chunks/{PromptInputFooterSuggestions-BSA9NrZc.js → PromptInputFooterSuggestions-to5eYBvI.js} +1 -1
  25. package/dist/chunks/{PromptInputHelpMenu-Bb4KdIX_.js → PromptInputHelpMenu-CfMFx-TF.js} +1 -1
  26. package/dist/chunks/QueryEngine-Dt0BKUeF.js +1 -0
  27. package/dist/chunks/REPL-CUbEDqEl.js +133 -0
  28. package/dist/chunks/REPL-DMaKNhTa.js +1 -0
  29. package/dist/chunks/{RemoteSessionManager-CS6mywIn.js → RemoteSessionManager-Bf44A0Ol.js} +2 -2
  30. package/dist/chunks/ResumeConversation-Ctw5Q1g9.js +1 -0
  31. package/dist/chunks/{SSETransport-CoxQ8YpH.js → SSETransport-DN4tCDEh.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C80OdtPZ.js +1 -0
  33. package/dist/chunks/Settings-DfdcmvOV.js +2 -0
  34. package/dist/chunks/{TeleportProgress-Doucj-50.js → TeleportProgress-C2LQVLav.js} +1 -1
  35. package/dist/chunks/TeleportRepoMismatchDialog-BZL8Zblz.js +1 -0
  36. package/dist/chunks/{TeleportResumeWrapper-D6kpr2c6.js → TeleportResumeWrapper-wPiIs8xg.js} +1 -1
  37. package/dist/chunks/{ThemePicker-DrC8tlp0.js → ThemePicker-BT_NaRQC.js} +1 -1
  38. package/dist/chunks/{TrustDialog-Fk4m_Sy4.js → TrustDialog-ACaJ_m7A.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-D_OUa4RT.js → ValidationErrorsList-C-hWdy_8.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DvfQHnZY.js → WelcomeV2-ZQRKlcT4.js} +1 -1
  41. package/dist/chunks/add-dir-SAKTkw0S.js +1 -0
  42. package/dist/chunks/{agentDisplay-B755vMZE.js → agentDisplay-CuSHqgZc.js} +1 -1
  43. package/dist/chunks/{agents-CIvP8l0s.js → agents-CMC0iQP4.js} +1 -1
  44. package/dist/chunks/agents-ZgRKpjHv.js +103 -0
  45. package/dist/chunks/allErrors-_cOQksHC.js +1 -0
  46. package/dist/chunks/{api-nSHc_GIQ.js → api-BbJfMXRS.js} +1 -1
  47. package/dist/chunks/api-DS1MiW01.js +1 -0
  48. package/dist/chunks/{auth-5QB6tsfB.js → auth-7mJGtlZp.js} +2 -2
  49. package/dist/chunks/auth-DGZzCbU0.js +1 -0
  50. package/dist/chunks/auth-DN1MUpB8.js +1 -0
  51. package/dist/chunks/{autoMode-BnUiK9Cu.js → autoMode-CBtY7ACs.js} +6 -6
  52. package/dist/chunks/{autonomy-Src6sKCp.js → autonomy-DuQmYhq6.js} +9 -9
  53. package/dist/chunks/{autonomy-C1aSgWPQ.js → autonomy-lJV7yWUl.js} +1 -1
  54. package/dist/chunks/autonomyPanel-DAQm6lDz.js +1 -0
  55. package/dist/chunks/backgroundHousekeeping-BTy71bcY.js +1 -0
  56. package/dist/chunks/backgroundHousekeeping-Cc7Ag7JG.js +17 -0
  57. package/dist/chunks/{banner-D0P7wXdw.js → banner-1Wyeyawe.js} +1 -1
  58. package/dist/chunks/{bg-DAPORXF3.js → bg-CJ0YWFli.js} +2 -2
  59. package/dist/chunks/bg-CeUrRz_7.js +1 -0
  60. package/dist/chunks/{branch-DFWa4Oxo.js → branch-k3kirqbA.js} +2 -2
  61. package/dist/chunks/{break-cache-Chj9i9MP.js → break-cache-CAoZ9b72.js} +1 -1
  62. package/dist/chunks/bridgeConfig-CzRUPn-D.js +1 -0
  63. package/dist/chunks/{bridgeConfig-Bb6URf4Q.js → bridgeConfig-UgaUfuP6.js} +1 -1
  64. package/dist/chunks/{bridgeMessaging-C3huGcR3.js → bridgeMessaging-Ci5H68MX.js} +1 -1
  65. package/dist/chunks/{bridgePointer-DLYyvRKb.js → bridgePointer-BL8-lGvN.js} +1 -1
  66. package/dist/chunks/{bridgeStatusUtil-DFMftajD.js → bridgeStatusUtil-C36w15ge.js} +1 -1
  67. package/dist/chunks/btw-nVoVuIae.js +1 -0
  68. package/dist/chunks/caches-B8sM3Zys.js +1 -0
  69. package/dist/chunks/caches-Bp9MZ7IE.js +1 -0
  70. package/dist/chunks/{capacityWake-amzeeBz0.js → capacityWake-BOySRJUJ.js} +1 -1
  71. package/dist/chunks/ccrClient-Br4LAofR.js +1 -0
  72. package/dist/chunks/{claudeDesktop-CsJfF1b-.js → claudeDesktop-Bgds1-YT.js} +1 -1
  73. package/dist/chunks/{clear-ClFDpWVJ.js → clear-C4Vtnbye.js} +1 -1
  74. package/dist/chunks/{cliLaunch-BWcoyZDP.js → cliLaunch-BTpfAGGI.js} +1 -1
  75. package/dist/chunks/{client-DFlE4fYh.js → client-B9404qIP.js} +1 -1
  76. package/dist/chunks/client-BCAbKdNz.js +1 -0
  77. package/dist/chunks/client-CJE6gEvU.js +1 -0
  78. package/dist/chunks/commands-DL-BzoMQ.js +1 -0
  79. package/dist/chunks/compact-Cx7BPXLU.js +2 -0
  80. package/dist/chunks/config-S5OW4Xqr.js +1 -0
  81. package/dist/chunks/{config-Do1870_d.js → config-aRiTrtCv.js} +2 -2
  82. package/dist/chunks/{config-CVHMRMwd.js → config-kB2eazPX.js} +1 -1
  83. package/dist/chunks/context-BN7DEjoH.js +1 -0
  84. package/dist/chunks/{context-noninteractive-D5iQhasu.js → context-noninteractive-D91W2B8e.js} +5 -5
  85. package/dist/chunks/context-noninteractive-DPacEFJ1.js +1 -0
  86. package/dist/chunks/conversation-D5Nbu9eT.js +1 -0
  87. package/dist/chunks/conversation-hcUx9e-C.js +1 -0
  88. package/dist/chunks/{createSSHSession-CJtzNQdZ.js → createSSHSession-DecOR6M5.js} +6 -6
  89. package/dist/chunks/createSession-D27zvmOs.js +1 -0
  90. package/dist/chunks/createSession-DRqkLZWt.js +1 -0
  91. package/dist/chunks/crossProjectResume-Bw3U0Ty6.js +40 -0
  92. package/dist/chunks/{datadog-DjeJThpV.js → datadog-bm551AVV.js} +1 -1
  93. package/dist/chunks/debug-BecbSVoN.js +39 -0
  94. package/dist/chunks/{debugUtils-DX0KAXNK.js → debugUtils-CmJfIUxW.js} +1 -1
  95. package/dist/chunks/{detached-X_yjYR7x.js → detached-CIyF0M5O.js} +1 -1
  96. package/dist/chunks/detectRepository-C15umvKN.js +1 -0
  97. package/dist/chunks/detectRepository-DDfLfKcM.js +1 -0
  98. package/dist/chunks/{diff-jEJJe58I.js → diff-DeK4bwjw.js} +1 -1
  99. package/dist/chunks/{directoryCompletion-BbXR2bfy.js → directoryCompletion-BJCu19HJ.js} +1 -1
  100. package/dist/chunks/doctor-BJORBomU.js +1 -0
  101. package/dist/chunks/{entry-oIqjxIjQ.js → entry-mdegyj8z.js} +3 -3
  102. package/dist/chunks/{esm-Cf4nSRjF.js → esm-Ka3lhafK.js} +1 -1
  103. package/dist/chunks/{execFileNoThrow-Dwu6psHW.js → execFileNoThrow-DHyW8FMX.js} +2 -2
  104. package/dist/chunks/execSyncWrapper-CDzB0BM1.js +1 -0
  105. package/dist/chunks/exit-CF3KBl-S.js +1 -0
  106. package/dist/chunks/{extraUsage-Mi66JwFZ.js → extraUsage-BrKbpBK-.js} +1 -1
  107. package/dist/chunks/extractMemories-4lBn134y.js +1 -0
  108. package/dist/chunks/fast-0Vi354KI.js +1 -0
  109. package/dist/chunks/{fast-BU4iUZ8E.js → fast-DWn40OcQ.js} +1 -1
  110. package/dist/chunks/{fileSuggestions-BMfQIDdW.js → fileSuggestions-C7Pwq2yj.js} +3 -3
  111. package/dist/chunks/{firstPartyEventLogger-B3cXgR67.js → firstPartyEventLogger-BHjBQH0J.js} +2 -2
  112. package/dist/chunks/firstPartyEventLogger-BNBnLYPK.js +1 -0
  113. package/dist/chunks/{flushGate-DgSDVGKZ.js → flushGate-DdJjxCes.js} +1 -1
  114. package/dist/chunks/gemini-DHv2iVfy.js +1 -0
  115. package/dist/chunks/generateSessionName-DhS_6oHd.js +1 -0
  116. package/dist/chunks/{genericProcessUtils-CmsUPyRz.js → genericProcessUtils-B2HcDYhg.js} +1 -1
  117. package/dist/chunks/git-DBlOv64X.js +6 -0
  118. package/dist/chunks/git-DF4RFFaT.js +1 -0
  119. package/dist/chunks/githubRepoPathMapping-CK56bUDe.js +1 -0
  120. package/dist/chunks/{goal-ZmSRBx4q.js → goal-BZG4gtnb.js} +3 -3
  121. package/dist/chunks/{grok-BXMvezWb.js → grok-BS57ZhyW.js} +1 -1
  122. package/dist/chunks/{grove-CeOjTaY6.js → grove-_zlQ83yR.js} +2 -2
  123. package/dist/chunks/{help-5DNZO6_H.js → help-C_2tdXHC.js} +1 -1
  124. package/dist/chunks/{hooks-C637tFtd.js → hooks-C7Bn7MBe.js} +2 -2
  125. package/dist/chunks/hooks-DT80Arzc.js +1 -0
  126. package/dist/chunks/{initReplBridge-D1h10vQ9.js → initReplBridge-NkZRcM77.js} +1 -1
  127. package/dist/chunks/{install-C-6ItpH0.js → install-Du-DSVzj.js} +1 -1
  128. package/dist/chunks/{instrumentation-DaiPDUst.js → instrumentation-DMs3b82f.js} +5 -5
  129. package/dist/chunks/{job-BeYzQUiR.js → job-rbX1VZmp.js} +1 -1
  130. package/dist/chunks/jwtUtils-OzxN2zts.js +1 -0
  131. package/dist/chunks/keybindings-CwdC_8S0.js +2 -0
  132. package/dist/chunks/{launchLocalMemory-CE4J98xO.js → launchLocalMemory-BLRCK1_o.js} +2 -2
  133. package/dist/chunks/{launchOnboarding-BfTdC6vp.js → launchOnboarding-Al_X75Vz.js} +1 -1
  134. package/dist/chunks/{loadAgentsDir-C7lOqvfh.js → loadAgentsDir-BL93ulMm.js} +619 -619
  135. package/dist/chunks/loadAgentsDir-eVKq8efm.js +1 -0
  136. package/dist/chunks/loadPluginHooks-B0au35a4.js +1 -0
  137. package/dist/chunks/{localSearch-BKrznW5x.js → localSearch-C5ipegd9.js} +1 -1
  138. package/dist/chunks/localSearch-CZlFfR_X.js +1 -0
  139. package/dist/chunks/{log-CezCRpAN.js → log-Dauqle-Z.js} +1 -1
  140. package/dist/chunks/{logoV2Utils-BkQfyQ1-.js → logoV2Utils-CkvOihX7.js} +1 -1
  141. package/dist/chunks/{magicDocs-BpVcON9o.js → magicDocs-DLav5QK0.js} +3 -3
  142. package/dist/chunks/main-CVNWNAoh.js +513 -0
  143. package/dist/chunks/{main-CvOv59-7.js → main-LMyE3jXY.js} +2 -2
  144. package/dist/chunks/managedEnv-CYepSnm8.js +1 -0
  145. package/dist/chunks/{managedEnv-DhWRJ5DK.js → managedEnv-DJSCuqCb.js} +1 -1
  146. package/dist/chunks/{mappers-bOab8ipV.js → mappers-DQxMcezy.js} +1 -1
  147. package/dist/chunks/mcp-BAbbEaBA.js +1 -0
  148. package/dist/chunks/mcp-Ct4Sum6A.js +6 -0
  149. package/dist/chunks/{mcp-VcGPYCkW.js → mcp-D5HkCqUh.js} +2 -2
  150. package/dist/chunks/{memoize-DsqYrbeR.js → memoize-FeyE7JEh.js} +1 -1
  151. package/dist/chunks/memory-COa7aUbx.js +1 -0
  152. package/dist/chunks/{mode-DlKnUM8l.js → mode-Bl2RZC8M.js} +2 -2
  153. package/dist/chunks/model-B7rtZ7KV.js +1 -0
  154. package/dist/chunks/{model-BsZ4sP_H.js → model-Bgh_r4lg.js} +1 -1
  155. package/dist/chunks/model-DiuEAv6h.js +1 -0
  156. package/dist/chunks/{modelOptions-CxP067Qv.js → modelOptions-BtEZe5BB.js} +1 -1
  157. package/dist/chunks/nativeInstaller-BEwayifa.js +1 -0
  158. package/dist/chunks/omit--yH_T4rf.js +1 -0
  159. package/dist/chunks/onChangeAppState-ZdwI7boX.js +1 -0
  160. package/dist/chunks/{openai-B9C2XN5Q.js → openai-DWs4D-nQ.js} +3 -3
  161. package/dist/chunks/panel-CoNfXy3K.js +1 -0
  162. package/dist/chunks/{parser-BwPXQomy.js → parser-BH4u7QiV.js} +1 -1
  163. package/dist/chunks/parser-BMIaRErw.js +1 -0
  164. package/dist/chunks/{partition-D-UhsUCx.js → partition-DLcW5Oo_.js} +1 -1
  165. package/dist/chunks/permissions-CaucYK3s.js +3 -0
  166. package/dist/chunks/pidLock-DgOBc1Xo.js +3 -0
  167. package/dist/chunks/{plan-CyU2zrCK.js → plan-BNYDTnQd.js} +1 -1
  168. package/dist/chunks/{platform-BMPbglug.js → platform-B0uTQc9P.js} +1 -1
  169. package/dist/chunks/plugin-BN-of1_H.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-BBU9Jn4p.js +1 -0
  171. package/dist/chunks/pluginBlocklist-DXQlbG0P.js +1 -0
  172. package/dist/chunks/pluginCliCommands-CfdVNs8D.js +1 -0
  173. package/dist/chunks/pluginFlagging-DcJ_FQuv.js +1 -0
  174. package/dist/chunks/pluginOperations-DnhzFbYI.js +2 -0
  175. package/dist/chunks/pluginStartupCheck-CKBFaMFr.js +1 -0
  176. package/dist/chunks/pluginStartupCheck-CpNB4jxG.js +1 -0
  177. package/dist/chunks/plugins-CBW7kPyp.js +4 -0
  178. package/dist/chunks/{poorMode-DEwQOAJt.js → poorMode-B_xEvuEV.js} +1 -1
  179. package/dist/chunks/poorMode-yH1o41cQ.js +1 -0
  180. package/dist/chunks/{print-eCRv_Li-.js → print-BZOx09SU.js} +16 -16
  181. package/dist/chunks/processBashCommand-dcCNCiBp.js +1 -0
  182. package/dist/chunks/processSlashCommand-YDiM63Qr.js +5 -0
  183. package/dist/chunks/prompt-CXGy0llt.js +1 -0
  184. package/dist/chunks/prompt-DovNDmcx.js +1 -0
  185. package/dist/chunks/{prompt-M2lu8_Oa.js → prompt-Dx7IWhBt.js} +2 -2
  186. package/dist/chunks/{promptEditor-DhcZY-iu.js → promptEditor-WCkmpejM.js} +2 -2
  187. package/dist/chunks/{protocolHandler-CkFaJKKo.js → protocolHandler-BiVWrpHi.js} +4 -4
  188. package/dist/chunks/{proxy-CuMaO_YV.js → proxy-CVn7o19p.js} +3 -3
  189. package/dist/chunks/reconciler-C2Nd_e4n.js +1 -0
  190. package/dist/chunks/refresh-B84H2Ezd.js +1 -0
  191. package/dist/chunks/{registerProtocol-CsNYRZKr.js → registerProtocol-E0Iu5hEx.js} +2 -2
  192. package/dist/chunks/{reload-plugins-B7JAE3b4.js → reload-plugins-D-3AUT9g.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-CFLJhsB6.js → remoteBridgeCore-CV6we3ZA.js} +1 -1
  194. package/dist/chunks/remoteManagedSettings-D26Q09-7.js +1 -0
  195. package/dist/chunks/{rename-BCp2Vtqu.js → rename-CSavuBIE.js} +1 -1
  196. package/dist/chunks/{renderOptions-Q5oCLFIC.js → renderOptions-DDLbSMQU.js} +1 -1
  197. package/dist/chunks/resume-CROylN3J.js +2 -0
  198. package/dist/chunks/ripgrep-2M1GkXqJ.js +1 -0
  199. package/dist/chunks/{ripgrep-DvOOsDMv.js → ripgrep-C1ydIMzT.js} +5 -5
  200. package/dist/chunks/{runtimeObserver-CS_3BDNo.js → runtimeObserver-L7pSIWBT.js} +2 -2
  201. package/dist/chunks/{runtimeObserver-DYUva6g-.js → runtimeObserver-OU8KrZQG.js} +1 -1
  202. package/dist/chunks/sandbox-adapter-6UwMLh6e.js +1 -0
  203. package/dist/chunks/{sandbox-toggle--zNSKce_.js → sandbox-toggle-YrQNWGsr.js} +1 -1
  204. package/dist/chunks/searchExtraTools-Bdv5HJ74.js +1 -0
  205. package/dist/chunks/{session-CO3gEqQP.js → session-DUYsfPy_.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-Czen7Ejz.js +1 -0
  207. package/dist/chunks/sessionObserver-B0zucj_c.js +1 -0
  208. package/dist/chunks/{sessionObserver-YkRHC-Aa.js → sessionObserver-Dv3Ba8eA.js} +2 -2
  209. package/dist/chunks/{sessionState-Bifmu95-.js → sessionState-D-SaBzWD.js} +2 -2
  210. package/dist/chunks/sessionStorage-BM1x51Z7.js +1 -0
  211. package/dist/chunks/{sessionTitle-COBSgSXS.js → sessionTitle-uCuYaNif.js} +2 -2
  212. package/dist/chunks/{sessionTracing-BrNx1k2V.js → sessionTracing-Bqb3vJTt.js} +3 -3
  213. package/dist/chunks/settings-BG15IFYx.js +1 -0
  214. package/dist/chunks/settings-D4CpDv2y.js +20 -0
  215. package/dist/chunks/settingsSync-BSrpnyqo.js +1 -0
  216. package/dist/chunks/setup-C62oq4AZ.js +3 -0
  217. package/dist/chunks/{shadowedRuleDetection-DEaw-X5j.js → shadowedRuleDetection-BzAZ57p2.js} +1 -1
  218. package/dist/chunks/{shellQuote-BYeOv3Ip.js → shellQuote-DS6WrivY.js} +2 -2
  219. package/dist/chunks/{sideQuestion-D0OKljee.js → sideQuestion-CvMBBjI8.js} +2 -2
  220. package/dist/chunks/sinks-WJ7nzLQs.js +1 -0
  221. package/dist/chunks/sinks-f7qYjbKJ.js +2 -0
  222. package/dist/chunks/skillChangeDetector-U5kRU5nd.js +1 -0
  223. package/dist/chunks/{skillGapStore-N_kmvXML.js → skillGapStore-CqaT8c0C.js} +2 -2
  224. package/dist/chunks/{skillLifecycle-C4F5RXuh.js → skillLifecycle-CnR8IqJM.js} +2 -2
  225. package/dist/chunks/skillSearchPanel-D9qrOXpI.js +21 -0
  226. package/dist/chunks/{skills-C4CTRN9o.js → skills-BgcFh0vy.js} +1 -1
  227. package/dist/chunks/startupProfiler-B4HBBbHN.js +1 -0
  228. package/dist/chunks/{startupProfiler-L_UWZ03w.js → startupProfiler-CmH_aVy2.js} +2 -2
  229. package/dist/chunks/{stats-IzV0_vEc.js → stats-B8uQ-UDi.js} +1 -1
  230. package/dist/chunks/{status-CeVP_uDT.js → status-BekdWoIj.js} +1 -1
  231. package/dist/chunks/status-D6KlRJmR.js +2 -0
  232. package/dist/chunks/{statusNoticeHelpers-Bb9gxdSt.js → statusNoticeHelpers-BMM8_uJ1.js} +1 -1
  233. package/dist/chunks/{stringUtils-C84IJ91d.js → stringUtils-C8PaYpQF.js} +1 -1
  234. package/dist/chunks/switcher-Ck9CrXrr.js +1 -0
  235. package/dist/chunks/{switcher-CCs9xl1z.js → switcher-DnAhkyIn.js} +1 -1
  236. package/dist/chunks/syncCache-ClP9aBqK.js +1 -0
  237. package/dist/chunks/{tasks-DZDhgx0w.js → tasks-Dmh6qikm.js} +1 -1
  238. package/dist/chunks/teleport-DH3IuAUQ.js +1 -0
  239. package/dist/chunks/{templateJobs-CrNPEKkh.js → templateJobs-CxqU-s5i.js} +1 -1
  240. package/dist/chunks/{terminalSetup-CBqcwQll.js → terminalSetup-BKGcmlWp.js} +1 -1
  241. package/dist/chunks/{terminalSetup-D-N8YPiQ.js → terminalSetup-Cy19F1Js.js} +4 -4
  242. package/dist/chunks/{theme-Dazsirbw.js → theme-U7lMFHQ0.js} +1 -1
  243. package/dist/chunks/{tmux-DewYVEBm.js → tmux-D5EvHWi3.js} +1 -1
  244. package/dist/chunks/{toolEventObserver-lnHJ9fLQ.js → toolEventObserver-D9qjoVl5.js} +1 -1
  245. package/dist/chunks/toolPool-69mfSPAs.js +1 -0
  246. package/dist/chunks/trustedDevice-B6AKlsl_.js +1 -0
  247. package/dist/chunks/trustedDevice-DL0pWP4_.js +1 -0
  248. package/dist/chunks/{types-3j8PS-Du.js → types-DafcFtmb.js} +2 -2
  249. package/dist/chunks/udsClient-CWnfsgFP.js +1 -0
  250. package/dist/chunks/{updateCCB-BPe9_FW6.js → updateCCB-C6XftzIG.js} +6 -6
  251. package/dist/chunks/{upstreamproxy-DF00RzGG.js → upstreamproxy-CXmjxHpl.js} +2 -2
  252. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js → useExitOnCtrlCDWithKeybindings-DEEJhm_W.js} +1 -1
  253. package/dist/chunks/useMainLoopModel-6w7mhwhU.js +1 -0
  254. package/dist/chunks/useManagePlugins-CjnsO-Of.js +1 -0
  255. package/dist/chunks/{useMergedTools-Dk5cPqLc.js → useMergedTools-DbhqKk1-.js} +1 -1
  256. package/dist/chunks/{useSearchInput-C7Y1I9P9.js → useSearchInput-gUDbkLaC.js} +1 -1
  257. package/dist/chunks/{useSettingsErrors-DAEO7AyB.js → useSettingsErrors-CgPad-H0.js} +1 -1
  258. package/dist/chunks/{userAgent-CIq27vUR.js → userAgent-CU7Ndh79.js} +1 -1
  259. package/dist/chunks/util-B4oMhJKh.js +1 -0
  260. package/dist/chunks/validatePlugin-y_O_tCEL.js +1 -0
  261. package/dist/chunks/{vim-EYQn94Kx.js → vim-w37BfGZ5.js} +1 -1
  262. package/dist/chunks/{which-DzFN5TNM.js → which-BRWBO7Gu.js} +1 -1
  263. package/dist/chunks/windowsPaths-BY-IVNwQ.js +1 -0
  264. package/dist/chunks/windowsPaths-DtWHLjmE.js +1 -0
  265. package/dist/chunks/{workSecret-DUqdPy44.js → workSecret-BEhXgH2M.js} +1 -1
  266. package/dist/chunks/{workerRegistry-C07BcZIw.js → workerRegistry-Bq9bS5pw.js} +5 -5
  267. package/dist/chunks/worktree-4SUJ4dtz.js +1 -0
  268. package/dist/cli.js +1 -1
  269. package/package.json +2 -3
  270. package/dist/chunks/App-C2yQjBgY.js +0 -1
  271. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +0 -1
  272. package/dist/chunks/ApproveApiKey-MscC-ssL.js +0 -1
  273. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +0 -2
  274. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +0 -1
  275. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +0 -1
  276. package/dist/chunks/Doctor-DmgAwce2.js +0 -1
  277. package/dist/chunks/Doctor-jEs9chPk.js +0 -3
  278. package/dist/chunks/ExitFlow-DVKxFdpX.js +0 -2
  279. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +0 -1
  280. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +0 -1
  281. package/dist/chunks/MCPToolListView-CvqB4nCw.js +0 -1
  282. package/dist/chunks/MessageSelector-BLzw172f.js +0 -3
  283. package/dist/chunks/Messages-4K5sLmNh.js +0 -11
  284. package/dist/chunks/QueryEngine-DPHLSsax.js +0 -1
  285. package/dist/chunks/REPL-Bf46iQCN.js +0 -1
  286. package/dist/chunks/REPL-DIaAo9M9.js +0 -133
  287. package/dist/chunks/ResumeConversation-Br2KsBoe.js +0 -1
  288. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +0 -1
  289. package/dist/chunks/Settings-BMXysXIx.js +0 -2
  290. package/dist/chunks/TeleportRepoMismatchDialog-B5I73j7Y.js +0 -1
  291. package/dist/chunks/add-dir-CZ6Clvq8.js +0 -1
  292. package/dist/chunks/agents-DHnNg4h6.js +0 -103
  293. package/dist/chunks/allErrors-CU89tF-z.js +0 -1
  294. package/dist/chunks/api-BSeE6MwB.js +0 -1
  295. package/dist/chunks/auth-BIGJth5U.js +0 -1
  296. package/dist/chunks/auth-CDQMhIZP.js +0 -1
  297. package/dist/chunks/autonomyPanel-DnHpuiy4.js +0 -1
  298. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +0 -17
  299. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +0 -1
  300. package/dist/chunks/bg-50rllUNh.js +0 -1
  301. package/dist/chunks/bridgeConfig-BeqChxJC.js +0 -1
  302. package/dist/chunks/btw-DSK9R2C8.js +0 -1
  303. package/dist/chunks/caches-BTQAW9zc.js +0 -1
  304. package/dist/chunks/caches-BVtSCnV1.js +0 -1
  305. package/dist/chunks/ccrClient-Bu7Tf1Z5.js +0 -1
  306. package/dist/chunks/client-BWQ4-rN7.js +0 -1
  307. package/dist/chunks/client-c-3-PW1F.js +0 -1
  308. package/dist/chunks/commands-Bi7k3Wg-.js +0 -1
  309. package/dist/chunks/compact-J-h0Yf4b.js +0 -2
  310. package/dist/chunks/config-yyFe87vW.js +0 -1
  311. package/dist/chunks/context-Tb1Ca2Q-.js +0 -1
  312. package/dist/chunks/context-noninteractive-soPYKAc9.js +0 -1
  313. package/dist/chunks/conversation-CSEtUxOY.js +0 -1
  314. package/dist/chunks/conversation-Dk1WDQuN.js +0 -1
  315. package/dist/chunks/createSession-DkT1GL8y.js +0 -1
  316. package/dist/chunks/createSession-eE8mswkv.js +0 -1
  317. package/dist/chunks/crossProjectResume-04n3Ppy9.js +0 -40
  318. package/dist/chunks/debug-RAynG_nM.js +0 -39
  319. package/dist/chunks/detectRepository-DgpNd87p.js +0 -1
  320. package/dist/chunks/detectRepository-ctF9KDbb.js +0 -1
  321. package/dist/chunks/doctor-B-Wag4C1.js +0 -1
  322. package/dist/chunks/execSyncWrapper-BTZJjCuv.js +0 -1
  323. package/dist/chunks/exit-BtW7LfRX.js +0 -1
  324. package/dist/chunks/extractMemories-CUrdiNcr.js +0 -1
  325. package/dist/chunks/fast-C60p6AqJ.js +0 -1
  326. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +0 -1
  327. package/dist/chunks/gemini-BwvSxGgn.js +0 -1
  328. package/dist/chunks/generateSessionName-DlrdedOk.js +0 -1
  329. package/dist/chunks/git-2c7WlGDL.js +0 -6
  330. package/dist/chunks/git-XtKbtJMc.js +0 -1
  331. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +0 -1
  332. package/dist/chunks/hooks-DWg07LmS.js +0 -1
  333. package/dist/chunks/jwtUtils-CUPXdX3W.js +0 -1
  334. package/dist/chunks/keybindings-DgIPdBy9.js +0 -2
  335. package/dist/chunks/loadAgentsDir-zikjxLvn.js +0 -1
  336. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +0 -1
  337. package/dist/chunks/localSearch-ZFyFy5FN.js +0 -1
  338. package/dist/chunks/main-9r5gLzUW.js +0 -605
  339. package/dist/chunks/managedEnv-B61yLpwp.js +0 -1
  340. package/dist/chunks/mcp-BckPBjaM.js +0 -6
  341. package/dist/chunks/mcp-CS1DA3JL.js +0 -1
  342. package/dist/chunks/memory-C5ohwh-T.js +0 -1
  343. package/dist/chunks/model-BGu1AGq0.js +0 -1
  344. package/dist/chunks/model-D19IIcll.js +0 -1
  345. package/dist/chunks/nativeInstaller-QB8cEJ18.js +0 -1
  346. package/dist/chunks/omit-DDUIPHnl.js +0 -1
  347. package/dist/chunks/onChangeAppState-RBl6H7ho.js +0 -1
  348. package/dist/chunks/panel-KW-wmEvU.js +0 -1
  349. package/dist/chunks/parser-xSBaQRLH.js +0 -1
  350. package/dist/chunks/permissions-BoLXYN1j.js +0 -3
  351. package/dist/chunks/pidLock-nJHbufJN.js +0 -3
  352. package/dist/chunks/plugin-C6-GQke5.js +0 -17
  353. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +0 -1
  354. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +0 -1
  355. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +0 -1
  356. package/dist/chunks/pluginFlagging-DZaYzecY.js +0 -1
  357. package/dist/chunks/pluginOperations-D90IRawu.js +0 -2
  358. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +0 -1
  359. package/dist/chunks/pluginStartupCheck-CB2q2dLv.js +0 -1
  360. package/dist/chunks/plugins-B9eSjLSA.js +0 -4
  361. package/dist/chunks/poorMode-BAnubpn1.js +0 -1
  362. package/dist/chunks/processBashCommand-B5F2Cl7K.js +0 -1
  363. package/dist/chunks/processSlashCommand-BC_D3cH5.js +0 -5
  364. package/dist/chunks/prompt-C1JPqinc.js +0 -1
  365. package/dist/chunks/prompt-DZhBz_Vu.js +0 -1
  366. package/dist/chunks/reconciler-B4GDm_iC.js +0 -1
  367. package/dist/chunks/refresh-DBVizOzg.js +0 -1
  368. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +0 -1
  369. package/dist/chunks/resume-DVCSzKvv.js +0 -2
  370. package/dist/chunks/ripgrep-e-iewvTf.js +0 -1
  371. package/dist/chunks/sandbox-adapter-BFZFHplu.js +0 -1
  372. package/dist/chunks/searchExtraTools-ui5y2VSE.js +0 -1
  373. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +0 -1
  374. package/dist/chunks/sessionObserver-Ba7um95p.js +0 -1
  375. package/dist/chunks/sessionStorage-CedwLLQs.js +0 -1
  376. package/dist/chunks/settings-DkDH7WQT.js +0 -1
  377. package/dist/chunks/settings-DnptdP79.js +0 -20
  378. package/dist/chunks/settingsSync-PmU7SmkU.js +0 -1
  379. package/dist/chunks/setup-BEsBuzsk.js +0 -3
  380. package/dist/chunks/sinks-BJHgxz6Y.js +0 -1
  381. package/dist/chunks/sinks-D5-yhcgU.js +0 -2
  382. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +0 -1
  383. package/dist/chunks/skillSearchPanel-CftorvAM.js +0 -21
  384. package/dist/chunks/startupProfiler-D4FBdEQr.js +0 -1
  385. package/dist/chunks/status-Dzuw3hBv.js +0 -2
  386. package/dist/chunks/switcher-4KzBvuKH.js +0 -1
  387. package/dist/chunks/syncCache-CBRiRU5x.js +0 -1
  388. package/dist/chunks/teleport-Bw0jSxe9.js +0 -1
  389. package/dist/chunks/toolPool-CkXFlqsn.js +0 -1
  390. package/dist/chunks/trustedDevice-CFf5yaG-.js +0 -1
  391. package/dist/chunks/trustedDevice-CuwSv8dG.js +0 -1
  392. package/dist/chunks/udsClient-e9dIkwVA.js +0 -1
  393. package/dist/chunks/useMainLoopModel-2-eujv0n.js +0 -1
  394. package/dist/chunks/useManagePlugins-CYBIkaB1.js +0 -1
  395. package/dist/chunks/util-VO98TdOz.js +0 -1
  396. package/dist/chunks/validatePlugin-Kk6pxnO2.js +0 -1
  397. package/dist/chunks/windowsPaths-BU3yQWTB.js +0 -1
  398. package/dist/chunks/windowsPaths-DgZ3YY4a.js +0 -1
  399. package/dist/chunks/worktree-dFUkhVE_.js +0 -1
@@ -0,0 +1,103 @@
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{$ as o,$l as s,$x as c,AC as l,Ah as u,BE as d,Ba as f,Dh as p,Fh as m,Fp as h,GC as g,Gl as ee,Iu as _,Jl as v,Jp as te,Oh as y,Ph as ne,Pp as b,Pu as re,RE as ie,RS as ae,Sg as oe,Sh as se,Ta as ce,Wl as le,Xp as ue,Ya as de,Yl as fe,Yp as pe,_v as me,_x as he,aE as ge,bv as _e,c as ve,cm as ye,dd as be,dm as xe,eS as Se,ed as Ce,el as we,em as Te,ep as Ee,eu as De,fh as Oe,gx as ke,hx as Ae,im as je,it as Me,jp as Ne,kC as Pe,kh as Fe,kp as Ie,l as Le,lm as Re,nm as ze,np as Be,o as Ve,oE as He,ot as Ue,ph as We,r as Ge,rm as Ke,rp as qe,s as Je,t as Ye,td as Xe,tl as Ze,tm as Qe,tp as $e,tt as et,ud as tt,vx as nt,wg as rt,xg as it,xh as at,xv as ot,zE as st,zS as ct}from"./loadAgentsDir-BL93ulMm.js";import{C as lt,D as x,I as S,P as C,T as w,Wt as T,di as ut,fi as E,t as D,ui as dt,y as ft}from"./src-P_wYS_NJ2.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{n as pt,t as mt}from"./cwd-Cfdf7z7s.js";import{F as ht,R as gt,S as _t,U as vt,W as yt,Z as bt,x as xt}from"./debug-BecbSVoN.js";import{J as St,Ln as Ct,Q as wt,Qt as Tt,Rn as Et,Xt as Dt,at as Ot,it as kt,ln as At,sn as jt}from"./settings-D4CpDv2y.js";import{M as Mt,P as Nt}from"./config-aRiTrtCv.js";import{o as Pt,s as Ft}from"./log-Dauqle-Z.js";import{n as It,r as Lt}from"./analytics-DJobLaWP.js";import{C as Rt,v as zt}from"./startupProfiler-CmH_aVy2.js";import{l as Bt,n as Vt,o as Ht}from"./stringUtils-C8PaYpQF.js";import{bn as Ut,yn as Wt}from"./prompt-Dx7IWhBt.js";import{at as Gt}from"./sessionState-D-SaBzWD.js";import{a as Kt,i as qt,n as Jt,o as Yt,r as Xt,t as Zt}from"./agentDisplay-CuSHqgZc.js";import{n as Qt,t as $t}from"./useExitOnCtrlCDWithKeybindings-DEEJhm_W.js";import{n as en,t as tn}from"./useMergedTools-DbhqKk1-.js";import{n as nn,r as rn,t as an}from"./promptEditor-WCkmpejM.js";import{n as on,t as sn}from"./useMainLoopModel-6w7mhwhU.js";import{join as k}from"path";import{mkdir as cn,open as ln,unlink as un}from"fs/promises";var A,dn=e((()=>{A={FOLDER_NAME:`.claude`,AGENTS_DIR:`agents`}}));function fn(e,t,n,r,i,a,o){return`---
2
+ name: ${e}
3
+ description: "${t.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\\\n`)}"${n===void 0||n.length===1&&n[0]===`*`?``:`\ntools: ${n.join(`, `)}`}${a?`\nmodel: ${a}`:``}${i?`\ncolor: ${i}`:``}${o?`\nmemory: ${o}`:``}
4
+ ---
5
+
6
+ ${r}
7
+ `}function pn(e){switch(e){case`flagSettings`:throw Error(`Cannot get directory path for ${e} agents`);case`userSettings`:return k(n(),A.AGENTS_DIR);case`projectSettings`:return k(mt(),A.FOLDER_NAME,A.AGENTS_DIR);case`policySettings`:return k(Dt(),A.FOLDER_NAME,A.AGENTS_DIR);case`localSettings`:return k(mt(),A.FOLDER_NAME,A.AGENTS_DIR)}}function mn(e){switch(e){case`projectSettings`:return k(`.`,A.FOLDER_NAME,A.AGENTS_DIR);default:return pn(e)}}function hn(e){return k(pn(e.source),`${e.agentType}.md`)}function gn(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return k(pn(e.source),`${e.filename||e.agentType}.md`)}function _n(e){return e.source===`built-in`?`Built-in`:k(mn(e.source),`${e.agentType}.md`)}function vn(e){return Je(e)?`Built-in`:Le(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:k(mn(e.source),`${e.filename||e.agentType}.md`)}async function yn(e){let t=pn(e);return await cn(t,{recursive:!0}),t}async function bn(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await yn(e);let l=hn({source:e,agentType:t}),u=fn(t,n,r,i,o,s,c);try{await Cn(l,u,a?`wx`:`w`)}catch(e){throw ht(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function xn(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await Cn(gn(e),fn(e.agentType,t,n,r,i,a,o))}async function Sn(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=gn(e);try{await un(t)}catch(e){if(ht(e)!==`ENOENT`)throw e}}async function Cn(e,t,n=`w`){let r=await ln(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var wn=e((()=>{Tt(),Ve(),pt(),r(),gt(),dn()}));function Tn({agent:e,tools:t,onBack:n}){let r=ue(e,t,!1),i=vn(e),o=ze(e.agentType);T(`confirm:no`,n,{context:`Confirmation`});let s=e=>{e.key===`return`&&(e.preventDefault(),n())};function c(){return r.hasWildcard?(0,j.jsx)(C,{children:`All tools`}):!e.tools||e.tools.length===0?(0,j.jsx)(C,{children:`None`}):(0,j.jsxs)(j.Fragment,{children:[r.validTools.length>0&&(0,j.jsx)(C,{children:r.validTools.join(`, `)}),r.invalidTools.length>0&&(0,j.jsxs)(C,{color:`warning`,children:[a.warning,` Unrecognized: `,r.invalidTools.join(`, `)]})]})}return(0,j.jsxs)(S,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,j.jsx)(C,{dimColor:!0,children:i}),(0,j.jsxs)(S,{flexDirection:`column`,children:[(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Description`}),` (tells Claude when to use this agent):`]}),(0,j.jsx)(S,{marginLeft:2,children:(0,j.jsx)(C,{children:e.whenToUse})})]}),(0,j.jsxs)(S,{children:[(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Tools`}),`:`,` `]}),c()]}),(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Model`}),`: `,ye(e.model)]}),e.permissionMode&&(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Permission mode`}),`: `,e.permissionMode]}),e.memory&&(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Memory`}),`: `,ie(e.memory)]}),e.hooks&&Object.keys(e.hooks).length>0&&(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Hooks`}),`: `,Object.keys(e.hooks).join(`, `)]}),e.skills&&e.skills.length>0&&(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Skills`}),`:`,` `,e.skills.length>10?`${e.skills.length} skills`:e.skills.join(`, `)]}),o&&(0,j.jsx)(S,{children:(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`Color`}),`:`,` `,(0,j.jsxs)(C,{backgroundColor:o,color:`inverseText`,children:[` `,e.agentType,` `]})]})}),!Je(e)&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(S,{children:(0,j.jsxs)(C,{children:[(0,j.jsx)(C,{bold:!0,children:`System prompt`}),`:`]})}),(0,j.jsx)(S,{marginLeft:2,marginRight:2,children:(0,j.jsx)(Ie,{children:e.getSystemPrompt()})})]})]})}var j,En=e((()=>{i(),E(),D(),g(),Ke(),st(),pe(),Ve(),xe(),Ne(),wn(),j=O()}));function Dn({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,On.useState)(Math.max(0,kn.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:kn.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<kn.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=kn[r];n(t===`automatic`?void 0:t)}},s=kn[r];return(0,M.jsxs)(S,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,M.jsx)(S,{flexDirection:`column`,children:kn.map((e,t)=>{let n=t===r;return(0,M.jsxs)(S,{flexDirection:`row`,gap:1,children:[(0,M.jsx)(C,{color:n?`suggestion`:void 0,children:n?a.pointer:` `}),e===`automatic`?(0,M.jsx)(C,{bold:n,children:`Automatic color`}):(0,M.jsxs)(S,{gap:1,children:[(0,M.jsx)(C,{backgroundColor:Qe[e],color:`inverseText`,children:` `}),(0,M.jsx)(C,{bold:n,children:Vt(e)})]})]},e)})}),(0,M.jsxs)(S,{marginTop:1,children:[(0,M.jsx)(C,{children:`Preview: `}),s===void 0||s===`automatic`?(0,M.jsxs)(C,{inverse:!0,bold:!0,children:[` `,`@`,e,` `]}):(0,M.jsxs)(C,{backgroundColor:Qe[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var On,M,kn,An=e((()=>{i(),On=t(E(),1),D(),Ke(),Ht(),M=O(),kn=[`automatic`,...Te]}));function jn({initialModel:e,onComplete:t,onCancel:n}){let r=Mn.useMemo(()=>{let t=Re();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,Nn.jsxs)(S,{flexDirection:`column`,children:[(0,Nn.jsx)(S,{marginBottom:1,children:(0,Nn.jsx)(C,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,Nn.jsx)(Ce,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var Mn,Nn,Pn=e((()=>{Mn=t(E(),1),D(),xe(),Xe(),Nn=O()}));function Fn(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([p.name,Fe.name,le.name,Pe.name,at.name,s.name,v.name,ae.name,he.name])},EDIT:{name:`Edit tools`,toolNames:new Set([Be.name,ne.name,Ee.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([Oe.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function In(e){let t=new Map;return e.forEach(e=>{if(Se(e)){let n=Ot(e.name);if(n?.serverName){let r=t.get(n.serverName)||[];r.push(e),t.set(n.serverName,r)}}}),Array.from(t.entries()).map(([e,t])=>({serverName:e,tools:t})).sort((e,t)=>e.serverName.localeCompare(t.serverName))}function Ln({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,N.useMemo)(()=>te({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[o,s]=(0,N.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[c,l]=(0,N.useState)(0),[u,d]=(0,N.useState)(!1),f=(0,N.useMemo)(()=>{let e=new Set(i.map(e=>e.name));return o.filter(t=>e.has(t))},[o,i]),p=new Set(f),m=f.length===i.length&&i.length>0,h=e=>{e&&s(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},g=(e,t)=>{s(n=>{if(t){let t=e.filter(e=>!n.includes(e));return[...n,...t]}else return n.filter(t=>!e.includes(t))})},ee=()=>{let e=i.map(e=>e.name);n(f.length===e.length&&e.every(e=>f.includes(e))?void 0:f)},_=(0,N.useMemo)(()=>{let e=Fn(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{Se(n)?t.mcp.push(n):e.READ_ONLY.toolNames.has(n.name)?t.readOnly.push(n):e.EDIT.toolNames.has(n.name)?t.edit.push(n):e.EXECUTION.toolNames.has(n.name)?t.execution.push(n):n.name!==`Agent`&&t.other.push(n)}),t},[i]),v=e=>{let t=Ct(e,e=>p.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);g(n,t)}},y=[];y.push({id:`continue`,label:`Continue`,action:ee,isContinue:!0}),y.push({id:`bucket-all`,label:`${m?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);g(e,!m)}});let ne=Fn();[{id:`bucket-readonly`,name:ne.READ_ONLY.name,tools:_.readOnly},{id:`bucket-edit`,name:ne.EDIT.name,tools:_.edit},{id:`bucket-execution`,name:ne.EXECUTION.name,tools:_.execution},{id:`bucket-mcp`,name:ne.MCP.name,tools:_.mcp},{id:`bucket-other`,name:ne.OTHER.name,tools:_.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=Ct(n,e=>p.has(e.name))===n.length;y.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:v(n)})});let b=y.length;y.push({id:`toggle-individual`,label:u?`Hide advanced options`:`Show advanced options`,action:()=>{d(!u),u&&c>b&&l(b)},isToggle:!0});let re=(0,N.useMemo)(()=>In(i),[i]);return u&&(re.length>0&&(y.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),re.forEach(({serverName:e,tools:t})=>{let n=Ct(t,e=>p.has(e.name))===t.length;y.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${Bt(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);g(e,!n)}})}),y.push({id:`tools-header`,label:`Individual Tools:`,action:()=>{},isHeader:!0})),i.forEach(e=>{let t=e.name;if(e.name.startsWith(`mcp__`)){let n=Ot(e.name);t=n?`${n.toolName} (${n.serverName})`:e.name}y.push({id:`tool-${e.name}`,label:`${p.has(e.name)?a.checkboxOn:a.checkboxOff} ${t}`,action:()=>h(e.name)})})),T(`confirm:no`,(0,N.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,P.jsxs)(S,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(e.key===`return`){e.preventDefault();let t=y[c];t&&!t.isHeader&&t.action()}else if(e.key===`up`){e.preventDefault();let t=c-1;for(;t>0&&y[t]?.isHeader;)t--;l(Math.max(0,t))}else if(e.key===`down`){e.preventDefault();let t=c+1;for(;t<y.length-1&&y[t]?.isHeader;)t++;l(Math.min(y.length-1,t))}},children:[(0,P.jsxs)(C,{color:c===0?`suggestion`:void 0,bold:c===0,children:[c===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,P.jsx)(lt,{width:40}),y.slice(1).map((e,t)=>{let n=t+1===c,r=e.isToggle,i=e.isHeader;return(0,P.jsxs)(N.Fragment,{children:[r&&(0,P.jsx)(lt,{width:40}),i&&t>0&&(0,P.jsx)(S,{marginTop:1}),(0,P.jsxs)(C,{color:i?void 0:n?`suggestion`:void 0,dimColor:i,bold:r&&n,children:[i?``:n?`${a.pointer} `:` `,r?`[ ${e.label} ]`:e.label]})]},e.id)}),(0,P.jsx)(S,{marginTop:1,flexDirection:`column`,children:(0,P.jsx)(C,{dimColor:!0,children:m?`All tools selected`:`${p.size} of ${i.length} tools selected`})})]})}var N,P,Rn=e((()=>{i(),N=t(E(),1),kt(),c(),pe(),wt(),We(),ee(),qe(),l(),m(),y(),u(),ct(),$e(),nt(),fe(),De(),se(),D(),g(),Et(),Ht(),P=O()}));function zn(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:ge(jt(e))}var Bn=e((()=>{He(),At()}));function Vn({agent:e,tools:t,onSaved:n,onBack:r}){let i=rt(),[o,s]=(0,F.useState)(`menu`),[c,l]=(0,F.useState)(0),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(e.color),m=(0,F.useCallback)(async()=>{let t=await an(gn(e));t.error?d(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),h=(0,F.useCallback)(async(t={})=>{let{tools:r,color:a,model:o}=t,s=a??f,c=r!==void 0,l=o!==void 0,u=s!==e.color;if(!c&&!l&&!u)return!1;try{return!ve(e)&&!Le(e)?!1:(await xn(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&je(e.agentType,s),i(t=>{let n=t.agentDefinitions.allAgents.map(t=>t.agentType===e.agentType?{...t,tools:r??t.tools,color:s,model:o??t.model}:t);return{...t,agentDefinitions:{...t.agentDefinitions,activeAgents:Ge(n),allAgents:n}}}),n(`Updated agent: ${dt.bold(e.agentType)}`),!0)}catch(e){return d(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,f,n,i]),g=(0,F.useMemo)(()=>[{label:`Open in editor`,action:m},{label:`Edit tools`,action:()=>s(`edit-tools`)},{label:`Edit model`,action:()=>s(`edit-model`)},{label:`Edit color`,action:()=>s(`edit-color`)}],[m]),ee=(0,F.useCallback)(()=>{d(null),o===`menu`?r():s(`menu`)},[o,r]),_=(0,F.useCallback)(e=>{if(e.key===`up`)e.preventDefault(),l(e=>Math.max(0,e-1));else if(e.key===`down`)e.preventDefault(),l(e=>Math.min(g.length-1,e+1));else if(e.key===`return`){e.preventDefault();let t=g[c];t&&t.action()}},[g,c]);T(`confirm:no`,ee,{context:`Confirmation`});let v=()=>(0,I.jsxs)(S,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:_,children:[(0,I.jsxs)(C,{dimColor:!0,children:[`Source: `,zn(e.source)]}),(0,I.jsx)(S,{marginTop:1,flexDirection:`column`,children:g.map((e,t)=>(0,I.jsxs)(C,{color:t===c?`suggestion`:void 0,children:[t===c?`${a.pointer} `:` `,e.label]},e.label))}),u&&(0,I.jsx)(S,{marginTop:1,children:(0,I.jsx)(C,{color:`error`,children:u})})]});switch(o){case`menu`:return v();case`edit-tools`:return(0,I.jsx)(Ln,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await h({tools:e})}});case`edit-color`:return(0,I.jsx)(Dn,{agentName:e.agentType,currentColor:f||e.color||`automatic`,onConfirm:async e=>{p(e),s(`menu`),await h({color:e})}});case`edit-model`:return(0,I.jsx)(jn,{initialModel:e.model,onComplete:async e=>{s(`menu`),await h({model:e})}});default:return null}}var F,I,Hn=e((()=>{ut(),i(),E(),F=t(E(),1),it(),D(),g(),Ke(),Ve(),rn(),wn(),An(),Pn(),Rn(),Bn(),I=O()}));function Un({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Qt();return(0,Wn.jsx)(S,{marginLeft:2,children:(0,Wn.jsx)(C,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Wn,Gn=e((()=>{E(),$t(),D(),Wn=O()}));function Kn({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:o}){let[s,c]=qn.useState(null),[l,u]=qn.useState(!0),d=qn.useMemo(()=>[...t].sort(Jt),[t]),f=e=>({isOverridden:!!e.overriddenBy,overriddenBy:e.overriddenBy||null}),p=()=>(0,L.jsxs)(S,{children:[(0,L.jsx)(C,{color:l?`suggestion`:void 0,children:l?`${a.pointer} `:` `}),(0,L.jsx)(C,{color:l?`suggestion`:void 0,children:`Create new agent`})]}),m=e=>{let t=e.source===`built-in`,n=!t&&!l&&s?.agentType===e.agentType&&s?.source===e.source,{isOverridden:r,overriddenBy:i}=f(e),o=t||r,c=!t&&n?`suggestion`:void 0,u=Kt(e);return(0,L.jsxs)(S,{children:[(0,L.jsx)(C,{dimColor:o&&!n,color:c,children:t?``:n?`${a.pointer} `:` `}),(0,L.jsx)(C,{dimColor:o&&!n,color:c,children:e.agentType}),u&&(0,L.jsxs)(C,{dimColor:!0,color:c,children:[` · `,u]}),e.memory&&(0,L.jsxs)(C,{dimColor:!0,color:c,children:[` · `,e.memory,` memory`]}),i&&(0,L.jsxs)(C,{dimColor:!n,color:n?`warning`:void 0,children:[` `,a.warning,` shadowed by `,Xt(i)]})]},`${e.agentType}-${e.source}`)},h=qn.useMemo(()=>{let t=d.filter(e=>e.source!==`built-in`);return e===`all`?Zt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[d,e]);qn.useEffect(()=>{!s&&!l&&h.length>0&&(i?u(!0):c(h[0]||null))},[h,s,l,i]);let g=e=>{if(e.key===`return`){e.preventDefault(),l&&i?i():s&&r(s);return}if(e.key!==`up`&&e.key!==`down`)return;e.preventDefault();let t=!!i,n=h.length+ +!!t;if(n===0)return;let a=0;if(!l&&s){let e=h.findIndex(e=>e.agentType===s.agentType&&e.source===s.source);e>=0&&(a=t?e+1:e)}let o=e.key===`up`?a===0?n-1:a-1:a===n-1?0:a+1;if(t&&o===0)u(!0),c(null);else{let e=t?o-1:o,n=h[e];n&&(u(!1),c(n))}},ee=(e=`Built-in (always available):`)=>{let t=d.filter(e=>e.source===`built-in`);return(0,L.jsxs)(S,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,L.jsx)(C,{bold:!0,dimColor:!0,children:e}),t.map(m)]})},_=(e,t)=>{if(!t.length)return null;let n=t[0]?.baseDir;return(0,L.jsxs)(S,{flexDirection:`column`,marginBottom:1,children:[(0,L.jsxs)(S,{paddingLeft:2,children:[(0,L.jsx)(C,{bold:!0,dimColor:!0,children:e}),n&&(0,L.jsxs)(C,{dimColor:!0,children:[` (`,n,`)`]})]}),t.map(e=>m(e))]})},v=zn(e),te=d.filter(e=>e.source===`built-in`);return!d.length||e!==`built-in`&&!d.some(e=>e.source!==`built-in`)?(0,L.jsx)(ft,{title:v,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,L.jsxs)(S,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[i&&(0,L.jsx)(S,{children:p()}),(0,L.jsx)(C,{dimColor:!0,children:`No agents found. Create specialized subagents that Claude can delegate to.`}),(0,L.jsx)(C,{dimColor:!0,children:`Each subagent has its own context window, custom system prompt, and specific tools.`}),(0,L.jsx)(C,{dimColor:!0,children:`Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer.`}),e!==`built-in`&&d.some(e=>e.source===`built-in`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(lt,{}),ee()]})]})}):(0,L.jsxs)(ft,{title:v,subtitle:`${Ct(d,e=>!e.overriddenBy)} agents`,onCancel:n,hideInputGuide:!0,children:[o&&o.length>0&&(0,L.jsx)(S,{marginTop:1,children:(0,L.jsx)(C,{dimColor:!0,children:o[o.length-1]})}),(0,L.jsxs)(S,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[i&&(0,L.jsx)(S,{marginBottom:1,children:p()}),e===`all`?(0,L.jsxs)(L.Fragment,{children:[Zt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,L.jsx)(qn.Fragment,{children:_(e,d.filter(e=>e.source===t))},t)),te.length>0&&(0,L.jsxs)(S,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,L.jsxs)(C,{dimColor:!0,children:[(0,L.jsx)(C,{bold:!0,children:`Built-in agents`}),` (always available)`]}),te.map(m)]})]}):e===`built-in`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{dimColor:!0,italic:!0,children:`Built-in agents are provided by default and cannot be modified.`}),(0,L.jsx)(S,{marginTop:1,flexDirection:`column`,children:d.map(e=>m(e))})]}):(0,L.jsxs)(L.Fragment,{children:[d.filter(e=>e.source!==`built-in`).map(e=>m(e)),d.some(e=>e.source===`built-in`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(lt,{}),ee()]})]})]})]})}var qn,L,Jn=e((()=>{i(),qn=t(E(),1),D(),qt(),Et(),Bn(),L=O()}));function Yn({steps:e,initialData:t={},onComplete:n,onCancel:r,children:i,title:a,showStepCounter:o=!0}){let[s,c]=(0,R.useState)(0),[l,u]=(0,R.useState)(t),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)([]);Qt(),(0,R.useEffect)(()=>{d&&(m([]),n(l))},[d,l,n]);let h=(0,R.useCallback)(()=>{s<e.length-1?(p.length>0&&m(e=>[...e,s]),c(e=>e+1)):f(!0)},[s,e.length,p]),g=(0,R.useCallback)(()=>{if(p.length>0){let e=p[p.length-1];e!==void 0&&(m(e=>e.slice(0,-1)),c(e))}else s>0?c(e=>e-1):r&&r()},[s,p,r]),ee=(0,R.useCallback)(t=>{t>=0&&t<e.length&&(m(e=>[...e,s]),c(t))},[s,e.length]),_=(0,R.useCallback)(()=>{m([]),r&&r()},[r]),v=(0,R.useCallback)(e=>{u(t=>({...t,...e}))},[]),te=(0,R.useMemo)(()=>({currentStepIndex:s,totalSteps:e.length,wizardData:l,setWizardData:u,updateWizardData:v,goNext:h,goBack:g,goToStep:ee,cancel:_,title:a,showStepCounter:o}),[s,e.length,l,v,h,g,ee,_,a,o]),y=e[s];return!y||d?null:(0,Xn.jsx)(Zn.Provider,{value:te,children:i||(0,Xn.jsx)(y,{})})}var R,Xn,Zn,Qn=e((()=>{R=t(E(),1),$t(),Xn=O(),Zn=(0,R.createContext)(null)}));function z(){let e=(0,$n.useContext)(Zn);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var $n,er=e((()=>{$n=t(E(),1),Qn()}));function tr({instructions:e=(0,nr.jsxs)(w,{children:[(0,nr.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,nr.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,nr.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})}){let t=Qt();return(0,nr.jsx)(S,{marginLeft:3,marginTop:1,children:(0,nr.jsx)(C,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var nr,rr=e((()=>{$t(),D(),h(),nr=O()}));function B({title:e,color:t=`suggestion`,children:n,subtitle:r,footerText:i}){let{currentStepIndex:a,totalSteps:o,title:s,showStepCounter:c,goBack:l}=z();return(0,ir.jsxs)(ir.Fragment,{children:[(0,ir.jsx)(ft,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,ir.jsx)(tr,{instructions:i})]})}var ir,V=e((()=>{D(),er(),rr(),ir=O()})),H=e((()=>{er(),V(),rr(),Qn()}));function ar(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=z();return T(`confirm:no`,t,{context:`Confirmation`}),(0,U.jsx)(B,{subtitle:`Choose background color`,footerText:(0,U.jsxs)(w,{children:[(0,U.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,U.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,U.jsx)(S,{children:(0,U.jsx)(Dn,{agentName:r.agentType||`agent`,currentColor:`automatic`,onConfirm:t=>{n({selectedColor:t,finalAgent:{agentType:r.agentType,whenToUse:r.whenToUse,getSystemPrompt:()=>r.systemPrompt,tools:r.selectedTools,...r.selectedModel?{model:r.selectedModel}:{},...t?{color:t}:{},source:r.location}}),e()}})})})}var U,or=e((()=>{D(),g(),h(),H(),V(),An(),U=O()}));function sr(e){return e?/^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/.test(e)?e.length<3?`Agent type must be at least 3 characters long`:e.length>50?`Agent type must be less than 50 characters`:null:`Agent type must start and end with alphanumeric characters and contain only letters, numbers, and hyphens`:`Agent type is required`}function cr(e,t,n){let r=[],i=[];if(!e.agentType)r.push(`Agent type is required`);else{let t=sr(e.agentType);t&&r.push(t);let i=n.find(t=>t.agentType===e.agentType&&t.source!==e.source);i&&r.push(`Agent type "${e.agentType}" already exists in ${zn(i.source)}`)}if(e.whenToUse?e.whenToUse.length<10?i.push(`Description should be more descriptive (at least 10 characters)`):e.whenToUse.length>5e3&&i.push(`Description is very long (over 5000 characters)`):r.push(`Description (description) is required`),e.tools!==void 0&&!Array.isArray(e.tools))r.push(`Tools must be an array`);else{e.tools===void 0?i.push(`Agent has access to all tools`):e.tools.length===0&&i.push(`No tools selected - agent will have very limited capabilities`);let n=ue(e,t,!1);n.invalidTools.length>0&&r.push(`Invalid tools: ${n.invalidTools.join(`, `)}`)}let a=e.getSystemPrompt();return a?a.length<20?r.push(`System prompt is too short (minimum 20 characters)`):a.length>1e4&&i.push(`System prompt is very long (over 10,000 characters)`):r.push(`System prompt is required`),{isValid:r.length===0,errors:r,warnings:i}}var lr=e((()=>{pe(),Bn()}));function ur({tools:e,existingAgents:t,onSave:n,onSaveAndEdit:r,error:i}){let{goBack:a,wizardData:o}=z();T(`confirm:no`,a,{context:`Confirmation`});let s=e=>{e.key===`s`||e.key===`return`?(e.preventDefault(),n()):e.key===`e`&&(e.preventDefault(),r())},c=o.finalAgent,l=cr(c,e,t),u=Rt(c.getSystemPrompt(),240),d=Rt(c.whenToUse,240),f=e=>e===void 0?`All tools`:e.length===0?`None`:e.length===1?e[0]||`None`:e.length===2?e.join(` and `):`${e.slice(0,-1).join(`, `)}, and ${e[e.length-1]}`,p=Nt()?(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Memory`}),`: `,ie(c.memory)]}):null;return(0,W.jsx)(B,{subtitle:`Confirm and save`,footerText:(0,W.jsxs)(w,{children:[(0,W.jsx)(x,{shortcut:`s/Enter`,action:`save`}),(0,W.jsx)(x,{shortcut:`e`,action:`edit in your editor`}),(0,W.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,W.jsxs)(S,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Name`}),`: `,c.agentType]}),(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Location`}),`:`,` `,_n({source:o.location,agentType:c.agentType})]}),(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Tools`}),`: `,f(c.tools)]}),(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Model`}),`: `,ye(c.model)]}),p,(0,W.jsx)(S,{marginTop:1,children:(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`Description`}),` (tells Claude when to use this agent):`]})}),(0,W.jsx)(S,{marginLeft:2,marginTop:1,children:(0,W.jsx)(C,{children:d})}),(0,W.jsx)(S,{marginTop:1,children:(0,W.jsxs)(C,{children:[(0,W.jsx)(C,{bold:!0,children:`System prompt`}),`:`]})}),(0,W.jsx)(S,{marginLeft:2,marginTop:1,children:(0,W.jsx)(C,{children:u})}),l.warnings.length>0&&(0,W.jsxs)(S,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(C,{color:`warning`,children:`Warnings:`}),l.warnings.map((e,t)=>(0,W.jsxs)(C,{dimColor:!0,children:[` `,`• `,e]},t))]}),l.errors.length>0&&(0,W.jsxs)(S,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(C,{color:`error`,children:`Errors:`}),l.errors.map((e,t)=>(0,W.jsxs)(C,{color:`error`,children:[` `,`• `,e]},t))]}),i&&(0,W.jsx)(S,{marginTop:1,children:(0,W.jsx)(C,{color:`error`,children:i})}),(0,W.jsx)(S,{marginTop:2,children:(0,W.jsxs)(C,{color:`success`,children:[`Press `,(0,W.jsx)(C,{bold:!0,children:`s`}),` or `,(0,W.jsx)(C,{bold:!0,children:`Enter`}),` to save, `,(0,W.jsx)(C,{bold:!0,children:`e`}),` to save and edit`]})})]})})}var W,dr=e((()=>{D(),g(),Mt(),st(),zt(),xe(),h(),H(),V(),wn(),lr(),W=O()}));function fr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=z(),[i,a]=(0,pr.useState)(null),o=rt(),s=(0,pr.useCallback)(async e=>{if(r?.finalAgent)try{await bn(r.location,r.finalAgent.agentType,r.finalAgent.whenToUse,r.finalAgent.tools,r.finalAgent.getSystemPrompt(),!0,r.finalAgent.color,r.finalAgent.model,r.finalAgent.memory),o(e=>{if(!r.finalAgent)return e;let t=e.agentDefinitions.allAgents.concat(r.finalAgent);return{...e,agentDefinitions:{...e.agentDefinitions,activeAgents:Ge(t),allAgents:t}}}),Ye(),e&&await an(hn({source:r.location,agentType:r.finalAgent.agentType})),Lt(`tengu_agent_created`,{agent_type:r.finalAgent.agentType,generation_method:r.wasGenerated?`generated`:`manual`,source:r.location,tool_count:r.finalAgent.tools?.length??`all`,has_custom_model:!!r.finalAgent.model,has_custom_color:!!r.finalAgent.color,has_memory:!!r.finalAgent.memory,memory_scope:r.finalAgent.memory??`none`,...e?{opened_in_editor:!0}:{}}),n(e?`Created agent: ${dt.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${dt.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,mr.jsx)(ur,{tools:e,existingAgents:t,onSave:(0,pr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,pr.useCallback)(()=>s(!0),[s]),error:i})}var pr,mr,hr=e((()=>{ut(),pr=t(E(),1),It(),it(),Ve(),rn(),H(),wn(),dr(),mr=O()}));function gr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=z(),[i,a]=(0,_r.useState)(r.whenToUse||``),[o,s]=(0,_r.useState)(i.length),[c,l]=(0,_r.useState)(null);return T(`confirm:no`,t,{context:`Settings`}),T(`chat:externalEditor`,(0,_r.useCallback)(async()=>{let e=await nn(i);e.content!==null&&(a(e.content),s(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Claude when to use this agent)`,footerText:(0,G.jsxs)(w,{children:[(0,G.jsx)(x,{shortcut:`Type`,action:`enter text`}),(0,G.jsx)(x,{shortcut:`Enter`,action:`continue`}),(0,G.jsx)(b,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,G.jsx)(b,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,G.jsxs)(S,{flexDirection:`column`,children:[(0,G.jsx)(C,{children:`When should Claude use this agent?`}),(0,G.jsx)(S,{marginTop:1,children:(0,G.jsx)(tt,{value:i,onChange:a,onSubmit:t=>{let r=t.trim();if(!r){l(`Description is required`);return}l(null),n({whenToUse:r}),e()},placeholder:`e.g., use this agent after you're done writing code...`,columns:80,cursorOffset:o,onChangeCursorOffset:s,focus:!0,showCursor:!0})}),c&&(0,G.jsx)(S,{marginTop:1,children:(0,G.jsx)(C,{color:`error`,children:c})})]})})}var _r,G,vr=e((()=>{_r=t(E(),1),D(),g(),rn(),h(),be(),H(),V(),G=O()}));async function yr(e,t,n,r){let i=ce({content:`Create an agent configuration based on this request: "${e}".${n.length>0?`\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${n.join(`, `)}`:``}
8
+ Return ONLY the JSON object, no other text.`}),a=await _e(),o=Ue([i],a),s=Nt()?br+xr:br,c=await et({messages:de(o),systemPrompt:Gt([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>Wt(),model:t,toolChoice:void 0,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,querySource:`agent_creation`,mcpTools:[]}}),l=(Array.isArray(c.message.content)?c.message.content:[]).filter(e=>e.type===`text`).map(e=>e.text).join(`
9
+ `),u;try{u=_t(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=_t(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return Lt(`tengu_agent_definition_generated`,{agent_identifier:u.identifier}),{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var br,xr,Sr=e((()=>{ot(),o(),Ut(),wt(),Me(),f(),Mt(),It(),xt(),me(),br=`You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
10
+
11
+ **Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
12
+
13
+ When a user describes what they want an agent to do, you will:
14
+
15
+ 1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
16
+
17
+ 2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
18
+
19
+ 3. **Architect Comprehensive Instructions**: Develop a system prompt that:
20
+ - Establishes clear behavioral boundaries and operational parameters
21
+ - Provides specific methodologies and best practices for task execution
22
+ - Anticipates edge cases and provides guidance for handling them
23
+ - Incorporates any specific requirements or preferences mentioned by the user
24
+ - Defines output format expectations when relevant
25
+ - Aligns with project-specific coding standards and patterns from CLAUDE.md
26
+
27
+ 4. **Optimize for Performance**: Include:
28
+ - Decision-making frameworks appropriate to the domain
29
+ - Quality control mechanisms and self-verification steps
30
+ - Efficient workflow patterns
31
+ - Clear escalation or fallback strategies
32
+
33
+ 5. **Create Identifier**: Design a concise, descriptive identifier that:
34
+ - Uses lowercase letters, numbers, and hyphens only
35
+ - Is typically 2-4 words joined by hyphens
36
+ - Clearly indicates the agent's primary function
37
+ - Is memorable and easy to type
38
+ - Avoids generic terms like "helper" or "assistant"
39
+
40
+ 6 **Example agent descriptions**:
41
+ - in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
42
+ - examples should be of the form:
43
+ - <example>
44
+ Context: The user is creating a test-runner agent that should be called after a logical chunk of code is written.
45
+ user: "Please write a function that checks if a number is prime"
46
+ assistant: "Here is the relevant function: "
47
+ <function call omitted for brevity only for this example>
48
+ <commentary>
49
+ Since a significant piece of code was written, use the ${St} tool to launch the test-runner agent to run the tests.
50
+ </commentary>
51
+ assistant: "Now let me use the test-runner agent to run the tests"
52
+ </example>
53
+ - <example>
54
+ Context: User is creating an agent to respond to the word "hello" with a friendly jok.
55
+ user: "Hello"
56
+ assistant: "I'm going to use the ${St} tool to launch the greeting-responder agent to respond with a friendly joke"
57
+ <commentary>
58
+ Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
59
+ </commentary>
60
+ </example>
61
+ - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
62
+ - NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
63
+
64
+ Your output must be a valid JSON object with exactly these fields:
65
+ {
66
+ "identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'test-runner', 'api-docs-writer', 'code-formatter')",
67
+ "whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
68
+ "systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
69
+ }
70
+
71
+ Key principles for your system prompts:
72
+ - Be specific rather than generic - avoid vague instructions
73
+ - Include concrete examples when they would clarify behavior
74
+ - Balance comprehensiveness with clarity - every instruction should add value
75
+ - Ensure the agent has enough context to handle variations of the core task
76
+ - Make the agent proactive in seeking clarification when needed
77
+ - Build in quality assurance and self-correction mechanisms
78
+
79
+ Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
80
+ `,xr=`
81
+
82
+ 7. **Agent Memory Instructions**: If the user mentions "memory", "remember", "learn", "persist", or similar concepts, OR if the agent would benefit from building up knowledge across conversations (e.g., code reviewers learning patterns, architects learning codebase structure, etc.), include domain-specific memory update instructions in the systemPrompt.
83
+
84
+ Add a section like this to the systemPrompt, tailored to the agent's specific domain:
85
+
86
+ "**Update your agent memory** as you discover [domain-specific items]. This builds up institutional knowledge across conversations. Write concise notes about what you found and where.
87
+
88
+ Examples of what to record:
89
+ - [domain-specific item 1]
90
+ - [domain-specific item 2]
91
+ - [domain-specific item 3]"
92
+
93
+ Examples of domain-specific memory instructions:
94
+ - For a code-reviewer: "Update your agent memory as you discover code patterns, style conventions, common issues, and architectural decisions in this codebase."
95
+ - For a test-runner: "Update your agent memory as you discover test patterns, common failure modes, flaky tests, and testing best practices."
96
+ - For an architect: "Update your agent memory as you discover codepaths, library locations, key architectural decisions, and component relationships."
97
+ - For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
98
+
99
+ The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
100
+ `}));function Cr(){let{updateWizardData:e,goBack:t,goToStep:n,wizardData:r}=z(),[i,a]=(0,K.useState)(r.generationPrompt||``),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(i.length),f=on(),p=(0,K.useRef)(null);T(`confirm:no`,(0,K.useCallback)(()=>{p.current&&(p.current.abort(),p.current=null,s(!1),l(`Generation cancelled`))},[]),{context:`Settings`,isActive:o}),T(`chat:externalEditor`,(0,K.useCallback)(async()=>{let e=await nn(i);e.content!==null&&(a(e.content),d(e.content.length))},[i]),{context:`Chat`,isActive:!o}),T(`confirm:no`,(0,K.useCallback)(()=>{e({generationPrompt:``,agentType:``,systemPrompt:``,whenToUse:``,generatedAgent:void 0,wasGenerated:!1}),a(``),l(null),t()},[e,t]),{context:`Settings`,isActive:!o});let m=async()=>{let t=i.trim();if(!t){l(`Please describe what the agent should do`);return}l(null),s(!0),e({generationPrompt:t,isGenerating:!0});let r=Ae();p.current=r;try{let i=await yr(t,f,[],r.signal);e({agentType:i.identifier,whenToUse:i.whenToUse,systemPrompt:i.systemPrompt,generatedAgent:i,isGenerating:!1,wasGenerated:!0}),n(6)}catch(t){t instanceof bt||t instanceof Error&&!t.message.includes(`No assistant message found`)&&l(t.message||`Failed to generate agent`),e({isGenerating:!1})}finally{s(!1),p.current=null}},h=`Describe what this agent should do and when it should be used (be comprehensive for best results)`;return o?(0,q.jsx)(B,{subtitle:h,footerText:(0,q.jsx)(b,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`}),children:(0,q.jsxs)(S,{flexDirection:`row`,alignItems:`center`,children:[(0,q.jsx)(re,{}),(0,q.jsx)(C,{color:`suggestion`,children:` Generating agent from description...`})]})}):(0,q.jsx)(B,{subtitle:h,footerText:(0,q.jsxs)(w,{children:[(0,q.jsx)(b,{action:`confirm:yes`,context:`Confirmation`,fallback:`Enter`,description:`submit`}),(0,q.jsx)(b,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,q.jsx)(b,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,q.jsxs)(S,{flexDirection:`column`,children:[c&&(0,q.jsx)(S,{marginBottom:1,children:(0,q.jsx)(C,{color:`error`,children:c})}),(0,q.jsx)(tt,{value:i,onChange:a,onSubmit:m,placeholder:`e.g., Help me write unit tests for my code...`,columns:80,cursorOffset:u,onChangeCursorOffset:d,focus:!0,showCursor:!0})]})})}var K,q,wr=e((()=>{yt(),K=t(E(),1),sn(),D(),g(),ke(),rn(),h(),_(),be(),H(),V(),Sr(),q=O()}));function Tr(){let{goNext:e,updateWizardData:t,cancel:n}=z();return(0,J.jsx)(B,{subtitle:`Choose location`,footerText:(0,J.jsxs)(w,{children:[(0,J.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,J.jsx)(S,{children:(0,J.jsx)(Ce,{options:[{label:`Project (.claude/agents/)`,value:`projectSettings`},{label:`Personal (~/.claude/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var J,Er=e((()=>{D(),h(),Xe(),H(),V(),J=O()}));function Dr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=z();T(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.claude/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.claude/agent-memory/)`,value:`project`},{label:`Local scope (.claude/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.claude/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.claude/agent-memory/)`,value:`user`},{label:`Local scope (.claude/agent-memory-local/)`,value:`local`}];return(0,Y.jsx)(B,{subtitle:`Configure agent memory`,footerText:(0,Y.jsxs)(w,{children:[(0,Y.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Y.jsx)(S,{children:(0,Y.jsx)(Ce,{options:i,onChange:t=>{let i=t===`none`?void 0:t,a=r.finalAgent?.agentType;n({selectedMemory:i,finalAgent:r.finalAgent?{...r.finalAgent,memory:i,getSystemPrompt:Nt()&&i&&a?()=>r.systemPrompt+`
101
+
102
+ `+d(a,i):()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,Or=e((()=>{D(),g(),Mt(),st(),h(),Xe(),H(),V(),Y=O()}));function kr(){let{goNext:e,goBack:t,updateWizardData:n,goToStep:r}=z();return(0,X.jsx)(B,{subtitle:`Creation method`,footerText:(0,X.jsxs)(w,{children:[(0,X.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,X.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,X.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,X.jsx)(S,{children:(0,X.jsx)(Ce,{options:[{label:`Generate with Claude (recommended)`,value:`generate`},{label:`Manual configuration`,value:`manual`}],onChange:t=>{let i=t;n({method:i,wasGenerated:i===`generate`}),i===`generate`?e():r(3)},onCancel:()=>t()},`method-select`)})})}var X,Ar=e((()=>{D(),h(),Xe(),H(),V(),X=O()}));function jr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=z();return(0,Mr.jsx)(B,{subtitle:`Select model`,footerText:(0,Mr.jsxs)(w,{children:[(0,Mr.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,Mr.jsx)(x,{shortcut:`Enter`,action:`select`}),(0,Mr.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Mr.jsx)(jn,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var Mr,Nr=e((()=>{h(),D(),H(),V(),Pn(),Mr=O()}));function Pr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=z(),[i,a]=(0,Fr.useState)(r.systemPrompt||``),[o,s]=(0,Fr.useState)(i.length),[c,l]=(0,Fr.useState)(null);return T(`confirm:no`,t,{context:`Settings`}),T(`chat:externalEditor`,(0,Fr.useCallback)(async()=>{let e=await nn(i);e.content!==null&&(a(e.content),s(e.content.length))},[i]),{context:`Chat`}),(0,Z.jsx)(B,{subtitle:`System prompt`,footerText:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(x,{shortcut:`Type`,action:`enter text`}),(0,Z.jsx)(x,{shortcut:`Enter`,action:`continue`}),(0,Z.jsx)(b,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,Z.jsx)(b,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Z.jsxs)(S,{flexDirection:`column`,children:[(0,Z.jsx)(C,{children:`Enter the system prompt for your agent:`}),(0,Z.jsx)(C,{dimColor:!0,children:`Be comprehensive for best results`}),(0,Z.jsx)(S,{marginTop:1,children:(0,Z.jsx)(tt,{value:i,onChange:a,onSubmit:()=>{let t=i.trim();if(!t){l(`System prompt is required`);return}l(null),n({systemPrompt:t}),e()},placeholder:`You are a helpful code reviewer who...`,columns:80,cursorOffset:o,onChangeCursorOffset:s,focus:!0,showCursor:!0})}),c&&(0,Z.jsx)(S,{marginTop:1,children:(0,Z.jsx)(C,{color:`error`,children:c})})]})})}var Fr,Z,Ir=e((()=>{Fr=t(E(),1),D(),g(),rn(),h(),be(),H(),V(),Z=O()}));function Lr({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=z(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,Rr.jsx)(B,{subtitle:`Select tools`,footerText:(0,Rr.jsxs)(w,{children:[(0,Rr.jsx)(x,{shortcut:`Enter`,action:`toggle selection`}),(0,Rr.jsx)(x,{shortcut:`↑↓`,action:`navigate`}),(0,Rr.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Rr.jsx)(Ln,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var Rr,zr=e((()=>{D(),h(),H(),V(),Rn(),Rr=O()}));function Br(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=z(),[a,o]=(0,Vr.useState)(i.agentType||``),[s,c]=(0,Vr.useState)(null),[l,u]=(0,Vr.useState)(a.length);return T(`confirm:no`,n,{context:`Settings`}),(0,Q.jsx)(B,{subtitle:`Agent type (identifier)`,footerText:(0,Q.jsxs)(w,{children:[(0,Q.jsx)(x,{shortcut:`Type`,action:`enter text`}),(0,Q.jsx)(x,{shortcut:`Enter`,action:`continue`}),(0,Q.jsx)(b,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Q.jsxs)(S,{flexDirection:`column`,children:[(0,Q.jsx)(C,{children:`Enter a unique identifier for your agent:`}),(0,Q.jsx)(S,{marginTop:1,children:(0,Q.jsx)(tt,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=sr(n);if(i){c(i);return}c(null),r({agentType:n}),t()},placeholder:`e.g., test-runner, tech-lead, etc`,columns:60,cursorOffset:l,onChangeCursorOffset:u,focus:!0,showCursor:!0})}),s&&(0,Q.jsx)(S,{marginTop:1,children:(0,Q.jsx)(C,{color:`error`,children:s})})]})})}var Vr,Q,Hr=e((()=>{Vr=t(E(),1),D(),g(),h(),be(),H(),V(),lr(),Q=O()}));function Ur({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Wr.jsx)(Yn,{steps:[Tr,kr,Cr,()=>(0,Wr.jsx)(Br,{existingAgents:t}),Pr,gr,()=>(0,Wr.jsx)(Lr,{tools:e}),jr,ar,...Nt()?[Dr]:[],()=>(0,Wr.jsx)(fr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Wr,Gr=e((()=>{Mt(),H(),or(),hr(),vr(),wr(),Er(),Or(),Ar(),Nr(),Ir(),zr(),Hr(),Wr=O()}));function Kr({tools:e,onExit:t}){let[n,r]=(0,qr.useState)({mode:`list-agents`,source:`all`}),i=oe(e=>e.agentDefinitions),a=oe(e=>e.mcp.tools),o=oe(e=>e.toolPermissionContext),s=rt(),{allAgents:c,activeAgents:l}=i,[u,d]=(0,qr.useState)([]),f=en(e,a,o);Qt();let p=(0,qr.useMemo)(()=>({"built-in":c.filter(e=>e.source===`built-in`),userSettings:c.filter(e=>e.source===`userSettings`),projectSettings:c.filter(e=>e.source===`projectSettings`),policySettings:c.filter(e=>e.source===`policySettings`),localSettings:c.filter(e=>e.source===`localSettings`),flagSettings:c.filter(e=>e.source===`flagSettings`),plugin:c.filter(e=>e.source===`plugin`),all:c}),[c]),m=(0,qr.useCallback)(e=>{d(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),h=(0,qr.useCallback)(async e=>{try{await Sn(e),s(t=>{let n=t.agentDefinitions.allAgents.filter(t=>!(t.agentType===e.agentType&&t.source===e.source));return{...t,agentDefinitions:{...t.agentDefinitions,allAgents:n,activeAgents:Ge(n)}}}),d(t=>[...t,`Deleted agent: ${dt.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Ft(vt(e))}},[s]);switch(n.mode){case`list-agents`:{let e=Yt(n.source===`all`?[...p[`built-in`],...p.userSettings,...p.projectSettings,...p.localSettings,...p.policySettings,...p.flagSettings,...p.plugin]:p[n.source],l);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kn,{source:n.source,agents:e,onBack:()=>{t((u.length>0?`Agent changes:\n${u.join(`
103
+ `)}`:void 0)??`Agents dialog dismissed`,{display:u.length===0?`system`:void 0})},onSelect:e=>r({mode:`agent-menu`,agent:e,previousMode:n}),onCreateNew:()=>r({mode:`create-agent`}),changes:u}),(0,$.jsx)(Un,{})]})}case`create-agent`:return(0,$.jsx)(Ur,{tools:f,existingAgents:l,onComplete:m,onCancel:()=>r({mode:`list-agents`,source:`all`})});case`agent-menu`:{let e=c.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent,t=[{label:`View agent`,value:`view`},...e.source!==`built-in`&&e.source!==`plugin`&&e.source!==`flagSettings`?[{label:`Edit agent`,value:`edit`},{label:`Delete agent`,value:`delete`}]:[],{label:`Back`,value:`back`}];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ft,{title:n.agent.agentType,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsxs)(S,{flexDirection:`column`,children:[(0,$.jsx)(Ce,{options:t,onChange:t=>{switch(t){case`view`:r({mode:`view-agent`,agent:e,previousMode:n.previousMode});break;case`edit`:r({mode:`edit-agent`,agent:e,previousMode:n});break;case`delete`:r({mode:`delete-confirm`,agent:e,previousMode:n});break;case`back`:r(n.previousMode);break}},onCancel:()=>r(n.previousMode)}),u.length>0&&(0,$.jsx)(S,{marginTop:1,children:(0,$.jsx)(C,{dimColor:!0,children:u[u.length-1]})})]})}),(0,$.jsx)(Un,{})]})}case`view-agent`:{let e=c.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ft,{title:e.agentType,onCancel:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode}),hideInputGuide:!0,children:(0,$.jsx)(Tn,{agent:e,tools:f,allAgents:c,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Un,{instructions:`Press Enter or Esc to go back`})]})}case`delete-confirm`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ft,{title:`Delete agent`,onCancel:()=>{`previousMode`in n&&r(n.previousMode)},color:`error`,children:[(0,$.jsxs)(C,{children:[`Are you sure you want to delete the agent `,(0,$.jsx)(C,{bold:!0,children:n.agent.agentType}),`?`]}),(0,$.jsx)(S,{marginTop:1,children:(0,$.jsxs)(C,{dimColor:!0,children:[`Source: `,n.agent.source]})}),(0,$.jsx)(S,{marginTop:1,children:(0,$.jsx)(Ce,{options:[{label:`Yes, delete`,value:`yes`},{label:`No, cancel`,value:`no`}],onChange:e=>{e===`yes`?h(n.agent):`previousMode`in n&&r(n.previousMode)},onCancel:()=>{`previousMode`in n&&r(n.previousMode)}})})]}),(0,$.jsx)(Un,{instructions:`Press ↑↓ to navigate, Enter to select, Esc to cancel`})]});case`edit-agent`:{let e=c.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ft,{title:`Edit agent: ${e.agentType}`,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsx)(Vn,{agent:e,tools:f,onSaved:e=>{m(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Un,{})]})}default:return null}}var qr,$,Jr=e((()=>{ut(),E(),qr=t(E(),1),$t(),tn(),D(),it(),qt(),Ve(),gt(),Pt(),Xe(),En(),Hn(),Gn(),Jn(),wn(),Gr(),$=O()}));async function Yr(e,t){let n=t.getAppState().toolPermissionContext;return(0,Xr.jsx)(Kr,{tools:we(n),onExit:e})}var Xr;e((()=>{E(),Jr(),Ze(),Xr=O()}))();export{Yr as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{fS as t,uS as n}from"./loadAgentsDir-BL93ulMm.js";import{g as r,u as i}from"./settings-D4CpDv2y.js";function a(){let e=i(),t=[`user`,`project`,`local`].flatMap(e=>n(e).errors);return{settings:e.settings,errors:[...e.errors,...t]}}var o=e((()=>{t(),r()}));export{o as n,a as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{i as r,n as i,r as a,t as o}from"./lazySchema-B4D4qJVE.js";import{F as s,S as c,W as l,a as u,l as d,w as f,z as p}from"./debug-RAynG_nM.js";import{h as m}from"./config-Do1870_d.js";import{o as h,s as g}from"./log-CezCRpAN.js";import{l as _,u as v}from"./oauth-C9VBDB0Y.js";import{Bt as y,Fr as b,Ot as x,Pr as S,_n as C,vn as w}from"./model-BsZ4sP_H.js";import{a as T,i as E}from"./detectRepository-DgpNd87p.js";import{randomUUID as D}from"crypto";function O(e){return t.isAxiosError(e)?!e.response||e.response.status>=500:!1}async function k(e,n){let r;for(let i=0;i<=R;i++)try{return await t.get(e,n)}catch(e){if(r=e,!O(e))throw e;if(i>=R)throw d(`Teleport request failed after ${i+1} attempts: ${s(e)}`),e;let t=L[i]??2e3;d(`Teleport request failed (attempt ${i+1}/${R+1}), retrying in ${t}ms: ${s(e)}`),await w(t)}throw r}async function A(){let e=x()?.accessToken;if(e===void 0)throw Error(`Work Mate web sessions require authentication with a Claude.ai account. API key authentication is not sufficient.`);let t=await S();if(!t)throw Error(`Unable to get organization UUID`);return{accessToken:e,orgUUID:t}}async function j(){let{accessToken:e,orgUUID:t}=await A(),n=`${_().BASE_API_URL}/v1/sessions`;try{let r=await k(n,{headers:{...M(e),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":t}});if(r.status!==200)throw Error(`Failed to fetch code sessions: ${r.statusText}`);return r.data.data.map(e=>{let t=e.session_context.sources.find(e=>e.type===`git_repository`),n=null;if(t?.url){let e=T(t.url);if(e){let[r,i]=e.split(`/`);r&&i&&(n={name:i,owner:{login:r},default_branch:t.revision||void 0})}}return{id:e.id,title:e.title||`Untitled`,description:``,status:e.session_status,repo:n,turns:[],created_at:e.created_at,updated_at:e.updated_at}})}catch(e){throw g(l(e)),e}}function M(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`}}async function N(e){let{accessToken:n,orgUUID:r}=await A(),i=`${_().BASE_API_URL}/v1/sessions/${e}`,a={...M(n),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":r},o=await t.get(i,{headers:a,timeout:15e3,validateStatus:e=>e<500});if(o.status!==200){let t=o.data?.error?.message;throw o.status===404?Error(`Session not found: ${e}`):o.status===401?Error(`Session expired.`):Error(t||`Failed to fetch session: ${o.status} ${o.statusText}`)}return o.data}function P(e){return(e.session_context.outcomes?.find(e=>e.type===`git_repository`))?.git_info?.branches[0]}async function F(e,n,r){try{let{accessToken:i,orgUUID:a}=await A(),o=`${_().BASE_API_URL}/v1/sessions/${e}/events`,s={...M(i),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":a},c={events:[{uuid:r?.uuid??D(),session_id:e,type:`user`,parent_tool_use_id:null,message:{role:`user`,content:n}}]};d(`[sendEventToRemoteSession] Sending event to session ${e}`);let l=await t.post(o,c,{headers:s,validateStatus:e=>e<500,timeout:3e4});return l.status===200||l.status===201?(d(`[sendEventToRemoteSession] Successfully sent event to session ${e}`),!0):(d(`[sendEventToRemoteSession] Failed with status ${l.status}: ${f(l.data)}`),!1)}catch(e){return d(`[sendEventToRemoteSession] Error: ${s(e)}`),!1}}async function I(e,n){try{let{accessToken:r,orgUUID:i}=await A(),a=`${_().BASE_API_URL}/v1/sessions/${e}`,o={...M(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i};d(`[updateSessionTitle] Updating title for session ${e}: "${n}"`);let s=await t.patch(a,{title:n},{headers:o,validateStatus:e=>e<500});return s.status===200?(d(`[updateSessionTitle] Successfully updated title for session ${e}`),!0):(d(`[updateSessionTitle] Failed with status ${s.status}: ${f(s.data)}`),!1)}catch(e){return d(`[updateSessionTitle] Error: ${s(e)}`),!1}}var L,R,z=e((()=>{n(),v(),b(),a(),y(),m(),u(),E(),p(),o(),h(),C(),c(),L=[2e3,4e3,8e3,16e3],R=L.length,i(()=>r.object({id:r.string(),title:r.string(),description:r.string(),status:r.enum([`idle`,`working`,`waiting`,`completed`,`archived`,`cancelled`,`rejected`]),repo:r.object({name:r.string(),owner:r.object({login:r.string()}),default_branch:r.string().optional()}).nullable(),turns:r.array(r.string()),created_at:r.string(),updated_at:r.string()}))}));export{M as a,A as c,P as i,F as l,j as n,z as o,N as r,O as s,k as t,I as u};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{i as r,n as i,r as a,t as o}from"./lazySchema-B4D4qJVE.js";import{C as s,P as c,R as l,U as u,c as d,i as f,x as p}from"./debug-BecbSVoN.js";import{h as m}from"./config-aRiTrtCv.js";import{o as h,s as g}from"./log-Dauqle-Z.js";import{l as _,u as v}from"./oauth-C9VBDB0Y.js";import{Bt as y,Fr as b,Ot as x,Pr as S,_n as C,vn as w}from"./model-Bgh_r4lg.js";import{a as T,i as E}from"./detectRepository-C15umvKN.js";import{randomUUID as D}from"crypto";function O(e){return t.isAxiosError(e)?!e.response||e.response.status>=500:!1}async function k(e,n){let r;for(let i=0;i<=R;i++)try{return await t.get(e,n)}catch(e){if(r=e,!O(e))throw e;if(i>=R)throw d(`Teleport request failed after ${i+1} attempts: ${c(e)}`),e;let t=L[i]??2e3;d(`Teleport request failed (attempt ${i+1}/${R+1}), retrying in ${t}ms: ${c(e)}`),await w(t)}throw r}async function A(){let e=x()?.accessToken;if(e===void 0)throw Error(`Work Mate web sessions require authentication with a Claude.ai account. API key authentication is not sufficient.`);let t=await S();if(!t)throw Error(`Unable to get organization UUID`);return{accessToken:e,orgUUID:t}}async function j(){let{accessToken:e,orgUUID:t}=await A(),n=`${_().BASE_API_URL}/v1/sessions`;try{let r=await k(n,{headers:{...M(e),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":t}});if(r.status!==200)throw Error(`Failed to fetch code sessions: ${r.statusText}`);return r.data.data.map(e=>{let t=e.session_context.sources.find(e=>e.type===`git_repository`),n=null;if(t?.url){let e=T(t.url);if(e){let[r,i]=e.split(`/`);r&&i&&(n={name:i,owner:{login:r},default_branch:t.revision||void 0})}}return{id:e.id,title:e.title||`Untitled`,description:``,status:e.session_status,repo:n,turns:[],created_at:e.created_at,updated_at:e.updated_at}})}catch(e){throw g(u(e)),e}}function M(e){return{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,"anthropic-version":`2023-06-01`}}async function N(e){let{accessToken:n,orgUUID:r}=await A(),i=`${_().BASE_API_URL}/v1/sessions/${e}`,a={...M(n),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":r},o=await t.get(i,{headers:a,timeout:15e3,validateStatus:e=>e<500});if(o.status!==200){let t=o.data?.error?.message;throw o.status===404?Error(`Session not found: ${e}`):o.status===401?Error(`Session expired.`):Error(t||`Failed to fetch session: ${o.status} ${o.statusText}`)}return o.data}function P(e){return(e.session_context.outcomes?.find(e=>e.type===`git_repository`))?.git_info?.branches[0]}async function F(e,n,r){try{let{accessToken:i,orgUUID:a}=await A(),o=`${_().BASE_API_URL}/v1/sessions/${e}/events`,c={...M(i),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":a},l={events:[{uuid:r?.uuid??D(),session_id:e,type:`user`,parent_tool_use_id:null,message:{role:`user`,content:n}}]};d(`[sendEventToRemoteSession] Sending event to session ${e}`);let u=await t.post(o,l,{headers:c,validateStatus:e=>e<500,timeout:3e4});return u.status===200||u.status===201?(d(`[sendEventToRemoteSession] Successfully sent event to session ${e}`),!0):(d(`[sendEventToRemoteSession] Failed with status ${u.status}: ${s(u.data)}`),!1)}catch(e){return d(`[sendEventToRemoteSession] Error: ${c(e)}`),!1}}async function I(e,n){try{let{accessToken:r,orgUUID:i}=await A(),a=`${_().BASE_API_URL}/v1/sessions/${e}`,o={...M(r),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":i};d(`[updateSessionTitle] Updating title for session ${e}: "${n}"`);let c=await t.patch(a,{title:n},{headers:o,validateStatus:e=>e<500});return c.status===200?(d(`[updateSessionTitle] Successfully updated title for session ${e}`),!0):(d(`[updateSessionTitle] Failed with status ${c.status}: ${s(c.data)}`),!1)}catch(e){return d(`[updateSessionTitle] Error: ${c(e)}`),!1}}var L,R,z=e((()=>{n(),v(),b(),a(),y(),m(),f(),E(),l(),o(),h(),C(),p(),L=[2e3,4e3,8e3,16e3],R=L.length,i(()=>r.object({id:r.string(),title:r.string(),description:r.string(),status:r.enum([`idle`,`working`,`waiting`,`completed`,`archived`,`cancelled`,`rejected`]),repo:r.object({name:r.string(),owner:r.object({login:r.string()}),default_branch:r.string().optional()}).nullable(),turns:r.array(r.string()),created_at:r.string(),updated_at:r.string()}))}));export{M as a,A as c,P as i,F as l,j as n,z as o,N as r,O as s,k as t,I as u};
@@ -0,0 +1 @@
1
+ import{a as e,o as t}from"./api-BbJfMXRS.js";t();export{e as getOAuthHeaders};
@@ -1,4 +1,4 @@
1
- import{d as e,o as t}from"./envUtils-BDhHQY0-.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{LS as o,RS as s,df as c,ff as l}from"./loadAgentsDir-C7lOqvfh.js";import{F as u,S as ee,a as te,l as d,w as ne,z as re}from"./debug-RAynG_nM.js";import{g as f,n as p}from"./settings-DnptdP79.js";import{c as m,h,y as g}from"./config-Do1870_d.js";import{o as _,s as v}from"./log-CezCRpAN.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-C9VBDB0Y.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Fr as T,Ft as E,Lr as D,Mr as O,Nr as k,Ot as A,Sn as j,St as M,Ur as N,Vr as P,Wr as F,ai as I,fn as L,gn as R,jn as z,jr as B,jt as V,kr as H,mn as U,nn as W,nr as G,pn as K,si as le,un as ue,yt as de,zr as fe}from"./model-BsZ4sP_H.js";import{n as pe,t as me}from"./userAgent-CIq27vUR.js";import{H as q,M as he}from"./sessionState-Bifmu95-.js";import{d as ge,u as _e}from"./firstPartyEventLogger-B3cXgR67.js";import{n as ve}from"./trustedDevice-CFf5yaG-.js";import{i as ye,r as be}from"./grove-CeOjTaY6.js";import{t as xe}from"./remoteManagedSettings-xh_MViZH.js";import{d as Se,n as Ce,t as we}from"./status-Dzuw3hBv.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),z(),h(),oe(),R(),_e();async function Y(){A.cache?.clear?.(),ve(),ce(),U(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await c()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-DaiPDUst.js`);await t(),await ue(),j().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),re(),ee(),te(),y(),f(),le(),F(),T(),he(),a(),S(),h(),G(),_(),pe();async function Oe(){try{if(m().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}o(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=C(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),T(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=H({...i,isManual:!0}),o=H({...i,isManual:!1}),c=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await s(o))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await B(c,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await k(e.access_token);if(l){let t=D(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:D(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),T(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await N(e.accessToken);t?P({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&P({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=L(e);if(de(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await O(e.accessToken).catch(e=>d(String(e),{level:`error`})),C(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await ae(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
1
+ import{d as e,o as t}from"./envUtils-BDhHQY0-.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{n as i,t as a}from"./axios-DaWTGg7G.js";import{FS as o,IS as s,lf as c,uf as l}from"./loadAgentsDir-BL93ulMm.js";import{C as ee,P as u,R as te,c as d,i as ne,x as re}from"./debug-BecbSVoN.js";import{g as f,n as p}from"./settings-D4CpDv2y.js";import{c as m,h,y as g}from"./config-aRiTrtCv.js";import{o as _,s as v}from"./log-Dauqle-Z.js";import{n as y,r as b}from"./analytics-DJobLaWP.js";import{l as x,u as S}from"./oauth-C9VBDB0Y.js";import{$n as ie,Ar as ae,Br as C,Bt as w,Cn as oe,Dt as se,En as ce,Fr as T,Ft as E,Lr as D,Mr as O,Nr as k,Ot as A,Sn as j,St as M,Ur as N,Vr as P,Wr as F,ai as I,fn as L,gn as R,jn as z,jr as B,jt as V,kr as H,mn as U,nn as W,nr as G,pn as K,si as le,un as ue,yt as de,zr as fe}from"./model-Bgh_r4lg.js";import{n as pe,t as me}from"./userAgent-CU7Ndh79.js";import{H as q,M as he}from"./sessionState-D-SaBzWD.js";import{d as ge,u as _e}from"./firstPartyEventLogger-BHjBQH0J.js";import{n as ve}from"./trustedDevice-DL0pWP4_.js";import{i as ye,r as be}from"./grove-_zlQ83yR.js";import{t as xe}from"./remoteManagedSettings-D26Q09-7.js";import{d as Se,n as Ce,t as we}from"./status-D6KlRJmR.js";import{createHash as Te,randomBytes as J}from"crypto";import{createServer as Ee}from"http";l(),w(),z(),h(),oe(),R(),_e();async function Y(){A.cache?.clear?.(),ve(),ce(),U(),ge(),be.cache?.clear?.(),ye.cache?.clear?.(),await xe(),await c()}async function De({clearOnboarding:e=!1}){let{flushTelemetry:t}=await import(`./instrumentation-DMs3b82f.js`);await t(),await ue(),j().delete(),await Y(),g(t=>{let n={...t};return e&&(n.hasCompletedOnboarding=!1,n.subscriptionNoticeCount=0,n.hasAvailableSubscription=!1,n.customApiKeyResponses?.approved&&(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]})),n.oauthAccount=void 0,n})}t(),n(),te(),re(),ne(),y(),f(),le(),F(),T(),he(),a(),S(),h(),G(),_(),pe();async function Oe(){try{if(m().claudeCodeFirstTokenDate!==void 0)return;let e=ie();if(e.error){v(Error(`Failed to get auth headers: ${e.error}`));return}let t=`${x().BASE_API_URL}/api/organization/claude_code_first_token_date`,n=(await i.get(t,{headers:{...e.headers,"User-Agent":me()},timeout:1e4})).data?.first_token_date??null;if(n!==null){let e=new Date(n).getTime();if(isNaN(e)){v(Error(`Received invalid first_token_date from API: ${n}`));return}}g(e=>({...e,claudeCodeFirstTokenDate:n}))}catch(e){v(e)}}o(),S(),_();var ke=class{constructor(e=`/callback`){r(this,`localServer`,void 0),r(this,`port`,0),r(this,`promiseResolver`,null),r(this,`promiseRejecter`,null),r(this,`expectedState`,null),r(this,`pendingResponse`,null),r(this,`callbackPath`,void 0),this.localServer=Ee(),this.callbackPath=e}async start(e){return new Promise((t,n)=>{this.localServer.once(`error`,e=>{n(Error(`Failed to start OAuth callback server: ${e.message}`))}),this.localServer.listen(e??0,`localhost`,()=>{let e=this.localServer.address();this.port=e.port,t(this.port)})})}getPort(){return this.port}hasPendingResponse(){return this.pendingResponse!==null}async waitForAuthorization(e,t){return new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r,this.expectedState=e,this.startLocalListener(t)})}handleSuccessRedirect(e,t){if(!this.pendingResponse)return;if(t){t(this.pendingResponse,e),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{custom_handler:!0});return}let n=C(e)?x().CLAUDEAI_SUCCESS_URL:x().CONSOLE_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:n}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect`,{})}handleErrorRedirect(){if(!this.pendingResponse)return;let e=x().CLAUDEAI_SUCCESS_URL;this.pendingResponse.writeHead(302,{Location:e}),this.pendingResponse.end(),this.pendingResponse=null,b(`tengu_oauth_automatic_redirect_error`,{})}startLocalListener(e){this.localServer.on(`request`,this.handleRedirect.bind(this)),this.localServer.on(`error`,this.handleError.bind(this)),e()}handleRedirect(e,t){let n=new URL(e.url||``,`http://${e.headers.host||`localhost`}`);if(n.pathname!==this.callbackPath){t.writeHead(404),t.end();return}let r=n.searchParams.get(`code`)??void 0,i=n.searchParams.get(`state`)??void 0;this.validateAndRespond(r,i,t)}validateAndRespond(e,t,n){if(!e){n.writeHead(400),n.end(`Authorization code not found`),this.reject(Error(`No authorization code received`));return}if(t!==this.expectedState){n.writeHead(400),n.end(`Invalid state parameter`),this.reject(Error(`Invalid state parameter`));return}this.pendingResponse=n,this.resolve(e)}handleError(e){v(e),this.close(),this.reject(e)}resolve(e){this.promiseResolver&&(this.promiseResolver(e),this.promiseResolver=null,this.promiseRejecter=null)}reject(e){this.promiseRejecter&&(this.promiseRejecter(e),this.promiseResolver=null,this.promiseRejecter=null)}close(){this.pendingResponse&&this.handleErrorRedirect(),this.localServer&&(this.localServer.removeAllListeners(),this.localServer.close())}};function X(e){return e.toString(`base64`).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Z(){return X(J(32))}function Ae(e){let t=Te(`sha256`);return t.update(e),X(t.digest())}function je(){return X(J(32))}y(),T(),n();var Q=class{constructor(){r(this,`codeVerifier`,void 0),r(this,`authCodeListener`,null),r(this,`port`,null),r(this,`manualAuthCodeResolver`,null),this.codeVerifier=Z()}async startOAuthFlow(e,t){this.authCodeListener=new ke,this.port=await this.authCodeListener.start();let n=Ae(this.codeVerifier),r=je(),i={codeChallenge:n,state:r,port:this.port,loginWithClaudeAi:t?.loginWithClaudeAi,inferenceOnly:t?.inferenceOnly,orgUUID:t?.orgUUID,loginHint:t?.loginHint,loginMethod:t?.loginMethod},a=H({...i,isManual:!0}),o=H({...i,isManual:!1}),c=await this.waitForAuthorizationCode(r,async()=>{t?.skipBrowserOpen?await e(a,o):(await e(a),await s(o))}),l=this.authCodeListener?.hasPendingResponse()??!1;b(`tengu_oauth_auth_code_received`,{automatic:l});try{let e=await B(c,r,this.codeVerifier,this.port,!l,t?.expiresIn),n=await k(e.access_token);if(l){let t=D(e.scope);this.authCodeListener?.handleSuccessRedirect(t)}return this.formatTokens(e,n.subscriptionType,n.rateLimitTier,n.rawProfile)}catch(e){throw l&&this.authCodeListener?.handleErrorRedirect(),e}finally{this.authCodeListener?.close()}}async waitForAuthorizationCode(e,t){return new Promise((n,r)=>{this.manualAuthCodeResolver=n,this.authCodeListener?.waitForAuthorization(e,t).then(e=>{this.manualAuthCodeResolver=null,n(e)}).catch(e=>{this.manualAuthCodeResolver=null,r(e)})})}handleManualAuthCodeInput(e){this.manualAuthCodeResolver&&(this.manualAuthCodeResolver(e.authorizationCode),this.manualAuthCodeResolver=null,this.authCodeListener?.close())}formatTokens(e,t,n,r){return{accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:Date.now()+e.expires_in*1e3,scopes:D(e.scope),subscriptionType:t,rateLimitTier:n,profile:r,tokenAccount:e.account?{uuid:e.account.uuid,emailAddress:e.account.email_address,organizationUuid:e.organization?.uuid}:void 0}}cleanup(){this.authCodeListener?.close(),this.manualAuthCodeResolver=null}};y(),T(),w(),h(),_(),Se();async function $(e){await De({clearOnboarding:!1});let t=e.profile??await N(e.accessToken);t?P({accountUuid:t.account.uuid,emailAddress:t.account.email,organizationUuid:t.organization.uuid,displayName:t.account.display_name||void 0,hasExtraUsageEnabled:t.organization.has_extra_usage_enabled??void 0,billingType:t.organization.billing_type??void 0,subscriptionCreatedAt:t.organization.subscription_created_at??void 0,accountCreatedAt:t.account.created_at}):e.tokenAccount&&P({accountUuid:e.tokenAccount.uuid,emailAddress:e.tokenAccount.emailAddress,organizationUuid:e.tokenAccount.organizationUuid});let n=L(e);if(de(),n.warning&&b(`tengu_oauth_storage_warning`,{warning:n.warning}),await O(e.accessToken).catch(e=>d(String(e),{level:`error`})),C(e.scopes))await Oe().catch(e=>d(String(e),{level:`error`}));else if(!await ae(e.accessToken))throw Error(`Unable to create API key. The server accepted the request but did not return a key.`);await Y()}async function Me({email:e,sso:t,console:n,claudeai:r}){n&&r&&(process.stderr.write(`Error: --console and --claudeai cannot be used together.
2
2
  `),process.exit(1));let i=p(),a=i.forceLoginMethod?i.forceLoginMethod===`claudeai`:!n,o=i.forceLoginOrgUUID,s=process.env.CLAUDE_CODE_OAUTH_REFRESH_TOKEN;if(s){let e=process.env.CLAUDE_CODE_OAUTH_SCOPES;e||(process.stderr.write(`CLAUDE_CODE_OAUTH_SCOPES is required when using CLAUDE_CODE_OAUTH_REFRESH_TOKEN.
3
3
  Set it to the space-separated scopes the refresh token was issued with
4
4
  (e.g. "user:inference" or "user:profile user:inference user:sessions:claude_code user:mcp_servers").
@@ -11,5 +11,5 @@ Set it to the space-separated scopes the refresh token was issued with
11
11
  `),process.exit(0)}catch(e){v(e);let t=q(e);process.stderr.write(`Login failed: ${u(e)}\n${t?t+`
12
12
  `:``}`),process.exit(1)}finally{l.cleanup()}}async function Ne(t){let{source:n,hasToken:r}=se(),{source:i}=M(),a=!!process.env.ANTHROPIC_API_KEY&&!e(),o=V(),s=E(),c=W(),l=r||i!==`none`||a||c,u=`none`;if(c?u=`third_party`:n===`claude.ai`?u=`claude.ai`:n===`apiKeyHelper`?u=`api_key_helper`:n===`none`?i===`ANTHROPIC_API_KEY`||a?u=`api_key`:i===`/login managed key`&&(u=`claude.ai`):u=`oauth_token`,t.text){let e=[...Ce(),...we()],t=!1;for(let n of e){let e=typeof n.value==`string`?n.value:Array.isArray(n.value)?n.value.join(`, `):null;e===null||e===`none`||(t=!0,n.label?process.stdout.write(`${n.label}: ${e}\n`):process.stdout.write(`${e}\n`))}!t&&a&&process.stdout.write(`API key: ANTHROPIC_API_KEY
13
13
  `),l||process.stdout.write(`Not logged in.
14
- `)}else{let e=I(),t=i===`none`?a?`ANTHROPIC_API_KEY`:null:i,n={loggedIn:l,authMethod:u,apiProvider:e};t&&(n.apiKeySource=t),u===`claude.ai`&&(n.email=o?.emailAddress??null,n.orgId=o?.organizationUuid??null,n.orgName=o?.organizationName??null,n.subscriptionType=s??null),process.stdout.write(ne(n,null,2)+`
14
+ `)}else{let e=I(),t=i===`none`?a?`ANTHROPIC_API_KEY`:null:i,n={loggedIn:l,authMethod:u,apiProvider:e};t&&(n.apiKeySource=t),u===`claude.ai`&&(n.email=o?.emailAddress??null,n.orgId=o?.organizationUuid??null,n.orgName=o?.organizationName??null,n.subscriptionType=s??null),process.stdout.write(ee(n,null,2)+`
15
15
  `)}process.exit(+!l)}export{Q as i,Ne as n,$ as r,Me as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./auth-7mJGtlZp.js";export{t as authLogin,e as authStatus};
@@ -0,0 +1 @@
1
+ import{Bt as e,It as t,Ot as n,mt as r,yt as i}from"./model-Bgh_r4lg.js";e();export{r as checkAndRefreshOAuthTokenIfNeeded,i as clearOAuthTokenCache,n as getClaudeAIOAuthTokens,t as handleOAuth401Error};
@@ -1,5 +1,5 @@
1
- import{$p as e,DT as t,ET as n,em as r,tm as i}from"./loadAgentsDir-C7lOqvfh.js";import{F as a,S as o,w as s,z as c}from"./debug-RAynG_nM.js";import{g as l,t as u}from"./settings-DnptdP79.js";import{C as d,_ as f,h as p,u as m}from"./model-BsZ4sP_H.js";import{n as h,t as g}from"./poorMode-DEwQOAJt.js";c(),f(),i(),l(),g(),n(),o();function _(e){process.stdout.write(s(e,null,2)+`
2
- `)}function v(){_(r())}function y(){let e=u(),t=r();_({allow:e?.allow?.length?e.allow:t.allow,soft_deny:e?.soft_deny?.length?e.soft_deny:t.soft_deny,environment:e?.environment?.length?e.environment:t.environment})}var b=`You are an expert reviewer of auto mode classifier rules for Work Mate.
1
+ import{$p as e,Qp as t,TT as n,Zp as r,wT as i}from"./loadAgentsDir-BL93ulMm.js";import{C as a,P as o,R as s,x as c}from"./debug-BecbSVoN.js";import{g as l,t as u}from"./settings-D4CpDv2y.js";import{C as d,_ as f,h as p,u as m}from"./model-Bgh_r4lg.js";import{n as h,t as g}from"./poorMode-B_xEvuEV.js";s(),f(),e(),l(),g(),i(),c();function _(e){process.stdout.write(a(e,null,2)+`
2
+ `)}function v(){_(t())}function y(){let e=u(),n=t();_({allow:e?.allow?.length?e.allow:n.allow,soft_deny:e?.soft_deny?.length?e.soft_deny:n.soft_deny,environment:e?.environment?.length?e.environment:n.environment})}var b=`You are an expert reviewer of auto mode classifier rules for Work Mate.
3
3
 
4
4
  Work Mate has an "auto mode" that uses an AI classifier to decide whether tool calls should be auto-approved or require user confirmation. Users can write custom rules in three categories:
5
5
 
@@ -15,13 +15,13 @@ For each rule, evaluate:
15
15
  3. **Conflicts**: Do any of the rules conflict with each other?
16
16
  4. **Actionability**: Is the rule specific enough for the classifier to act on?
17
17
 
18
- Be concise and constructive. Only comment on rules that could be improved. If all rules look good, say so.`;async function x(n){let i=u();if(!((i?.allow?.length??0)>0||(i?.soft_deny?.length??0)>0||(i?.environment?.length??0)>0)){process.stdout.write(`No custom auto mode rules found.
18
+ Be concise and constructive. Only comment on rules that could be improved. If all rules look good, say so.`;async function x(e){let i=u();if(!((i?.allow?.length??0)>0||(i?.soft_deny?.length??0)>0||(i?.environment?.length??0)>0)){process.stdout.write(`No custom auto mode rules found.
19
19
 
20
20
  Add rules to your settings file under autoMode.{allow, soft_deny, environment}.
21
21
  Run \`claude auto-mode defaults\` to see the default rules for reference.
22
- `);return}let o=n.model?d(n.model):h()?p():m(),s=r(),c=e(),l=S(`allow`,i?.allow??[],s.allow)+S(`soft_deny`,i?.soft_deny??[],s.soft_deny)+S(`environment`,i?.environment??[],s.environment);process.stdout.write(`Analyzing your auto mode rules…
22
+ `);return}let a=e.model?d(e.model):h()?p():m(),s=t(),c=r(),l=S(`allow`,i?.allow??[],s.allow)+S(`soft_deny`,i?.soft_deny??[],s.soft_deny)+S(`environment`,i?.environment??[],s.environment);process.stdout.write(`Analyzing your auto mode rules…
23
23
 
24
- `);let f;try{f=await t({querySource:`auto_mode_critique`,model:o,system:b,skipSystemPromptPrefix:!0,max_tokens:4096,messages:[{role:`user`,content:`Here is the full classifier system prompt that the auto mode classifier receives:
24
+ `);let f;try{f=await n({querySource:`auto_mode_critique`,model:a,system:b,skipSystemPromptPrefix:!0,max_tokens:4096,messages:[{role:`user`,content:`Here is the full classifier system prompt that the auto mode classifier receives:
25
25
 
26
26
  <classifier_system_prompt>
27
27
  `+c+`
@@ -30,7 +30,7 @@ Run \`claude auto-mode defaults\` to see the default rules for reference.
30
30
  Here are the user's custom rules that REPLACE the corresponding default sections:
31
31
 
32
32
  `+l+`
33
- Please critique these custom rules.`}]})}catch(e){process.stderr.write(`Failed to analyze rules: `+a(e)+`
33
+ Please critique these custom rules.`}]})}catch(e){process.stderr.write(`Failed to analyze rules: `+o(e)+`
34
34
  `),process.exitCode=1;return}let g=f.content.find(e=>e.type===`text`);g?.type===`text`?process.stdout.write(g.text+`
35
35
  `):process.stdout.write(`No critique was generated. Please try again.
36
36
  `)}function S(e,t,n){if(t.length===0)return``;let r=t.map(e=>`- `+e).join(`
@@ -1,15 +1,15 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Bm as r,C as i,E as a,El as ee,Gm as o,Hm as te,Im as s,Iy as ne,Jm as re,Km as c,Lm as l,Rm as u,Tl as d,Ty as f,Um as p,Vm as m,Wm as h,jy as g,qm as _,wl as ie,x as ae,zm as v}from"./loadAgentsDir-C7lOqvfh.js";import{Wt as oe,it as se}from"./state-BemZdQIl.js";import{o as ce}from"./log-CezCRpAN.js";import{s as le,u as ue}from"./types-3j8PS-Du.js";import{a as y,n as b,o as x,t as S}from"./bridgeConfig-Bb6URf4Q.js";import{i as C,o as w}from"./bg-DAPORXF3.js";import{n as T,t as E}from"./state-BAGmpVBn.js";import{join as D}from"path";import"crypto";import{readFile as O,readdir as k}from"fs/promises";import"net";import"events";function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return typeof e==`string`&&B.includes(e)}function M(e){return typeof e==`string`&&V.includes(e)}function N(e){return!A(e)||typeof e.name!=`string`||!M(e.status)?null:{name:e.name,...typeof e.prompt==`string`?{prompt:e.prompt}:{},status:e.status,...typeof e.startedAt==`number`?{startedAt:e.startedAt}:{},...typeof e.completedAt==`number`?{completedAt:e.completedAt}:{}}}function P(e){if(!A(e)||typeof e.runId!=`string`||typeof e.workflow!=`string`||!j(e.status)||typeof e.createdAt!=`number`||typeof e.updatedAt!=`number`||typeof e.currentStepIndex!=`number`||!Array.isArray(e.steps))return null;let t=e.steps.map(N).filter(e=>e!==null);return t.length===e.steps.length?{runId:e.runId,workflow:e.workflow,...typeof e.args==`string`?{args:e.args}:{},status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,currentStepIndex:e.currentStepIndex,steps:t}:null}async function F(e,t){try{return P(ue(await O(D(e,R,`${t}.json`),`utf-8`),!1))}catch{return null}}async function I(e=se()){let t;try{t=await k(D(e,R))}catch{return[]}let n=t.filter(e=>e.endsWith(`.json`));return(await Promise.all(n.slice(0,z).map(t=>F(e,t.slice(0,-5))))).filter(e=>e!==null).sort((e,t)=>t.updatedAt-e.updatedAt)}function L(e){if(e.length===0)return[`Workflow runs: 0`,` none`].join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{Bm as r,C as i,Cl as a,Cy as ee,E as o,Fm as s,Gm as c,Hm as l,Im as u,Km as d,Lm as f,Pm as p,Py as m,Rm as h,Sl as g,Um as _,Vm as v,Wm as y,ky as te,wl as ne,x as re,zm as ie}from"./loadAgentsDir-BL93ulMm.js";import{Wt as ae,it as oe}from"./state-BemZdQIl.js";import{o as se}from"./log-Dauqle-Z.js";import{s as ce,u as le}from"./types-DafcFtmb.js";import{a as ue,n as b,o as x,t as S}from"./bridgeConfig-UgaUfuP6.js";import{i as C,o as w}from"./bg-CJ0YWFli.js";import{n as T,t as E}from"./state-BAGmpVBn.js";import{join as D}from"path";import"crypto";import{readFile as O,readdir as k}from"fs/promises";import"net";import"events";function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e){return typeof e==`string`&&B.includes(e)}function M(e){return typeof e==`string`&&V.includes(e)}function N(e){return!A(e)||typeof e.name!=`string`||!M(e.status)?null:{name:e.name,...typeof e.prompt==`string`?{prompt:e.prompt}:{},status:e.status,...typeof e.startedAt==`number`?{startedAt:e.startedAt}:{},...typeof e.completedAt==`number`?{completedAt:e.completedAt}:{}}}function P(e){if(!A(e)||typeof e.runId!=`string`||typeof e.workflow!=`string`||!j(e.status)||typeof e.createdAt!=`number`||typeof e.updatedAt!=`number`||typeof e.currentStepIndex!=`number`||!Array.isArray(e.steps))return null;let t=e.steps.map(N).filter(e=>e!==null);return t.length===e.steps.length?{runId:e.runId,workflow:e.workflow,...typeof e.args==`string`?{args:e.args}:{},status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,currentStepIndex:e.currentStepIndex,steps:t}:null}async function F(e,t){try{return P(le(await O(D(e,R,`${t}.json`),`utf-8`),!1))}catch{return null}}async function I(e=oe()){let t;try{t=await k(D(e,R))}catch{return[]}let n=t.filter(e=>e.endsWith(`.json`));return(await Promise.all(n.slice(0,z).map(t=>F(e,t.slice(0,-5))))).filter(e=>e!==null).sort((e,t)=>t.updatedAt-e.updatedAt)}function L(e){if(e.length===0)return[`Workflow runs: 0`,` none`].join(`
2
2
  `);let t=e.filter(e=>e.status===`running`).length,n=e.filter(e=>e.status===`completed`).length,r=e.filter(e=>e.status===`cancelled`).length,i=[`Workflow runs: ${e.length}`,` Running: ${t}`,` Completed: ${n}`,` Cancelled: ${r}`];for(let t of e.slice(0,10)){let e=t.steps[t.currentStepIndex];i.push(` ${t.runId}: ${t.workflow}: ${t.status} step=${e?.name??`none`} updated=${new Date(t.updatedAt).toLocaleString()}`)}return e.length>10&&i.push(` ... ${e.length-10} more workflow run(s)`),i.join(`
3
- `)}var R,z,B,V,H=e((()=>{oe(),le(),R=D(`.claude`,`workflow-runs`),z=200,B=[`running`,`completed`,`cancelled`],V=[`pending`,`running`,`completed`,`cancelled`]}));function U(){return D(t(),`pipes`)}var de=e((()=>{n(),ce()}));function fe(){return D(U(),`registry.json`)}async function pe(){try{let e=await O(fe(),`utf8`),t=JSON.parse(e);return t.version===1?t:{...W}}catch{return{...W}}}var W,me=e((()=>{de(),W={version:1,mainMachineId:null,main:null,subs:[]}}));async function he(){return ge(await pe())}function ge(e){let t=[`Pipe registry: ${+!!e.main} main, ${e.subs.length} sub(s)`];e.mainMachineId&&t.push(` main_machine=${e.mainMachineId.slice(0,8)}...`),e.main&&t.push(` [main] ${e.main.pipeName} pid=${e.main.pid} host=${e.main.hostname} tcp=${e.main.tcpPort??`none`}`);for(let n of e.subs.slice(0,10))t.push(` [sub-${n.subIndex}] ${n.pipeName} pid=${n.pid} host=${n.hostname} bound=${n.boundToMain??`none`} tcp=${n.tcpPort??`none`}`);return!e.main&&e.subs.length===0&&t.push(` none`),e.subs.length>10&&t.push(` ... ${e.subs.length-10} more sub pipe(s)`),t.join(`
3
+ `)}var R,z,B,V,H=e((()=>{ae(),ce(),R=D(`.claude`,`workflow-runs`),z=200,B=[`running`,`completed`,`cancelled`],V=[`pending`,`running`,`completed`,`cancelled`]}));function U(){return D(t(),`pipes`)}var de=e((()=>{n(),se()}));function fe(){return D(U(),`registry.json`)}async function pe(){try{let e=await O(fe(),`utf8`),t=JSON.parse(e);return t.version===1?t:{...W}}catch{return{...W}}}var W,me=e((()=>{de(),W={version:1,mainMachineId:null,main:null,subs:[]}}));async function he(){return ge(await pe())}function ge(e){let t=[`Pipe registry: ${+!!e.main} main, ${e.subs.length} sub(s)`];e.mainMachineId&&t.push(` main_machine=${e.mainMachineId.slice(0,8)}...`),e.main&&t.push(` [main] ${e.main.pipeName} pid=${e.main.pid} host=${e.main.hostname} tcp=${e.main.tcpPort??`none`}`);for(let n of e.subs.slice(0,10))t.push(` [sub-${n.subIndex}] ${n.pipeName} pid=${n.pid} host=${n.hostname} bound=${n.boundToMain??`none`} tcp=${n.tcpPort??`none`}`);return!e.main&&e.subs.length===0&&t.push(` none`),e.subs.length>10&&t.push(` ... ${e.subs.length-10} more sub pipe(s)`),t.join(`
4
4
  `)}var _e=e((()=>{me()}));function ve(){try{let e=x(),t=S();return[`Remote Control: ${e?`self-hosted`:`official`}`,` base_url=${b()}`,` token=${t?`present`:`missing`}`,` entitlement=checked at remote-control startup`].join(`
5
5
  `)}catch(e){return[`Remote Control: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
6
- `)}}var ye=e((()=>{y()}));async function be(){let e=T(),t=await w(),n=[`Daemon: ${e.status}${e.state?` pid=${e.state.pid} workers=${e.state.workerKinds.join(`,`)}`:``}`,`Background sessions: ${t.length}`];for(let e of t.slice(0,8))n.push(` pid=${e.pid} kind=${e.kind} status=${e.status??`unknown`} cwd=${e.cwd}`);return t.length>8&&n.push(` ... ${t.length-8} more session(s)`),n.join(`
7
- `)}function xe(){let e=!1,t=null;try{e=a(),t=ae()}catch(e){return[`Auto mode: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
6
+ `)}}var ye=e((()=>{ue()}));async function be(){let e=T(),t=await w(),n=[`Daemon: ${e.status}${e.state?` pid=${e.state.pid} workers=${e.state.workerKinds.join(`,`)}`:``}`,`Background sessions: ${t.length}`];for(let e of t.slice(0,8))n.push(` pid=${e.pid} kind=${e.kind} status=${e.status??`unknown`} cwd=${e.cwd}`);return t.length>8&&n.push(` ... ${t.length-8} more session(s)`),n.join(`
7
+ `)}function xe(){let e=!1,t=null;try{e=o(),t=re()}catch(e){return[`Auto mode: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
8
8
  `)}return[`Auto mode: ${e?`available`:`unavailable`}`,` reason=${t??`none`}`].join(`
9
- `)}async function G({runs:e,flows:t,nowMs:n=Date.now()}){return Promise.all([Promise.resolve({id:`auto-mode`,title:`Auto Mode`,content:xe()}),Promise.resolve({id:`runs`,title:`Runs`,content:l(e)}),Promise.resolve({id:`flows`,title:`Flows`,content:h(t)}),I().then(e=>({id:`workflow-runs`,title:`Workflow Runs`,content:L(e)})),he().then(e=>({id:`pipes`,title:`Pipes`,content:e})),be().then(e=>({id:`runtime`,title:`Runtime`,content:e})),Promise.resolve({id:`remote-control`,title:`Remote Control`,content:ve()}),ee().then(e=>({id:`remote-trigger`,title:`RemoteTrigger`,content:ie(e)}))])}async function Se(e){return(await G(e)).map((e,t)=>[t===0?`# Autonomy Deep Status`:`## ${e.title}`,e.content].join(`
9
+ `)}async function G({runs:e,flows:t,nowMs:n=Date.now()}){return Promise.all([Promise.resolve({id:`auto-mode`,title:`Auto Mode`,content:xe()}),Promise.resolve({id:`runs`,title:`Runs`,content:s(e)}),Promise.resolve({id:`flows`,title:`Flows`,content:l(t)}),I().then(e=>({id:`workflow-runs`,title:`Workflow Runs`,content:L(e)})),he().then(e=>({id:`pipes`,title:`Pipes`,content:e})),be().then(e=>({id:`runtime`,title:`Runtime`,content:e})),Promise.resolve({id:`remote-control`,title:`Remote Control`,content:ve()}),ne().then(e=>({id:`remote-trigger`,title:`RemoteTrigger`,content:g(e)}))])}async function Se(e){return(await G(e)).map((e,t)=>[t===0?`# Autonomy Deep Status`:`## ${e.title}`,e.content].join(`
10
10
  `)).join(`
11
11
 
12
- `)}var Ce=e((()=>{E(),C(),c(),u(),i(),d(),H(),_e(),ye()}));function we(e){let[t=`status`,n,r]=e.trim().split(/\s+/,3);return t===``||t===`status`?{type:`status`,deep:n===`--deep`}:t===`runs`?{type:`runs`,limit:n}:t===`flows`?{type:`flows`,limit:n}:t===`flow`?n===`cancel`?r?{type:`flow-cancel`,flowId:r}:{type:`usage`}:n===`resume`?r?{type:`flow-resume`,flowId:r}:{type:`usage`}:n?{type:`flow-detail`,flowId:n}:{type:`usage`}:{type:`usage`}}var K,Te=e((()=>{K=`Usage: /autonomy [status [--deep]|runs [limit]|flows [limit]|flow <id>|flow cancel <id>|flow resume <id>]`}));function q(e){let t=typeof e==`number`?e:Number.parseInt(e??``,10);return!Number.isFinite(t)||t<=0?10:Math.min(t,50)}async function J(e){let t=e?.rootDir,[n,r]=await Promise.all([v(t),_(t)]);return e?.deep?Se({runs:n,flows:r}):[l(n),h(r)].join(`
13
- `)}async function Ee(e,t){let[n,r]=await Promise.all([v(t?.rootDir),_(t?.rootDir)]),i=(await G({runs:n,flows:r})).find(t=>t.id===e);return i?[`# ${i.title}`,i.content].join(`
14
- `):`Autonomy deep status section not found: ${e}`}async function De(e){process.stdout.write(`${await J(e)}\n`)}async function Y(e,t){return s(await v(t?.rootDir),q(e))}async function Oe(e){process.stdout.write(`${await Y(e)}\n`)}async function X(e,t){return p(await _(t?.rootDir),q(e))}async function ke(e){process.stdout.write(`${await X(e)}\n`)}async function Z(e,t){return te(await o(e,t?.rootDir))}async function Ae(e){process.stdout.write(`${await Z(e)}\n`)}async function Q(e,t){let n=await re({flowId:e,rootDir:t?.rootDir});if(!n)return`Autonomy flow not found.`;if(!n.accepted)return`Autonomy flow ${e} is already terminal (${n.flow.status}).`;let i=0;if(t?.removeQueuedInMemory){let n=ne(t=>t.autonomy?.flowId===e);i=n.length;for(let e of n)e.autonomy?.runId&&await r(e.autonomy.runId,t?.rootDir)}else{for(let e of n.queuedRunIds)await r(e,t?.rootDir);i=n.queuedRunIds.length}return n.flow.status===`running`?`Cancellation requested for flow ${e}. The current step is still running, and no new steps will be started.`:`Cancelled flow ${e}. Removed ${i} queued step(s).`}async function je(e){process.stdout.write(`${await Q(e)}\n`)}async function $(e,t){let n=await m({flowId:e,rootDir:t?.rootDir,currentDir:t?.currentDir});if(!n)return`Autonomy flow is not waiting or was not found.`;if(t?.enqueueInMemory)return f(n),`Queued the next managed step for flow ${e}.`;let r=n.autonomy?.runId??`unknown`;return[`Prepared the next managed step for flow ${e}.`,`Run ID: ${r}`,``,`Prompt:`,typeof n.value==`string`?n.value:String(n.value)].join(`
15
- `)}async function Me(e){process.stdout.write(`${await $(e)}\n`)}async function Ne(e,t){let n=we(e);switch(n.type){case`status`:return J({deep:n.deep});case`runs`:return Y(n.limit);case`flows`:return X(n.limit);case`flow-detail`:return Z(n.flowId);case`flow-cancel`:return Q(n.flowId,{removeQueuedInMemory:t?.removeQueuedInMemory});case`flow-resume`:return $(n.flowId,{enqueueInMemory:t?.enqueueInMemory});case`usage`:return K}}var Pe=e((()=>{c(),u(),Ce(),Te(),g()}));export{Oe as a,Ne as c,X as d,Y as f,$ as g,q as h,ke as i,Ee as l,Pe as m,Ae as n,De as o,J as p,Me as r,Q as s,je as t,Z as u};
12
+ `)}var Ce=e((()=>{E(),C(),y(),u(),i(),a(),H(),_e(),ye()}));function we(e){let[t=`status`,n,r]=e.trim().split(/\s+/,3);return t===``||t===`status`?{type:`status`,deep:n===`--deep`}:t===`runs`?{type:`runs`,limit:n}:t===`flows`?{type:`flows`,limit:n}:t===`flow`?n===`cancel`?r?{type:`flow-cancel`,flowId:r}:{type:`usage`}:n===`resume`?r?{type:`flow-resume`,flowId:r}:{type:`usage`}:n?{type:`flow-detail`,flowId:n}:{type:`usage`}:{type:`usage`}}var K,Te=e((()=>{K=`Usage: /autonomy [status [--deep]|runs [limit]|flows [limit]|flow <id>|flow cancel <id>|flow resume <id>]`}));function q(e){let t=typeof e==`number`?e:Number.parseInt(e??``,10);return!Number.isFinite(t)||t<=0?10:Math.min(t,50)}async function J(e){let t=e?.rootDir,[n,r]=await Promise.all([f(t),c(t)]);return e?.deep?Se({runs:n,flows:r}):[s(n),l(r)].join(`
13
+ `)}async function Ee(e,t){let[n,r]=await Promise.all([f(t?.rootDir),c(t?.rootDir)]),i=(await G({runs:n,flows:r})).find(t=>t.id===e);return i?[`# ${i.title}`,i.content].join(`
14
+ `):`Autonomy deep status section not found: ${e}`}async function De(e){process.stdout.write(`${await J(e)}\n`)}async function Y(e,t){return p(await f(t?.rootDir),q(e))}async function Oe(e){process.stdout.write(`${await Y(e)}\n`)}async function X(e,t){return v(await c(t?.rootDir),q(e))}async function ke(e){process.stdout.write(`${await X(e)}\n`)}async function Z(e,t){return r(await _(e,t?.rootDir))}async function Ae(e){process.stdout.write(`${await Z(e)}\n`)}async function Q(e,t){let n=await d({flowId:e,rootDir:t?.rootDir});if(!n)return`Autonomy flow not found.`;if(!n.accepted)return`Autonomy flow ${e} is already terminal (${n.flow.status}).`;let r=0;if(t?.removeQueuedInMemory){let n=m(t=>t.autonomy?.flowId===e);r=n.length;for(let e of n)e.autonomy?.runId&&await h(e.autonomy.runId,t?.rootDir)}else{for(let e of n.queuedRunIds)await h(e,t?.rootDir);r=n.queuedRunIds.length}return n.flow.status===`running`?`Cancellation requested for flow ${e}. The current step is still running, and no new steps will be started.`:`Cancelled flow ${e}. Removed ${r} queued step(s).`}async function je(e){process.stdout.write(`${await Q(e)}\n`)}async function $(e,t){let n=await ie({flowId:e,rootDir:t?.rootDir,currentDir:t?.currentDir});if(!n)return`Autonomy flow is not waiting or was not found.`;if(t?.enqueueInMemory)return ee(n),`Queued the next managed step for flow ${e}.`;let r=n.autonomy?.runId??`unknown`;return[`Prepared the next managed step for flow ${e}.`,`Run ID: ${r}`,``,`Prompt:`,typeof n.value==`string`?n.value:String(n.value)].join(`
15
+ `)}async function Me(e){process.stdout.write(`${await $(e)}\n`)}async function Ne(e,t){let n=we(e);switch(n.type){case`status`:return J({deep:n.deep});case`runs`:return Y(n.limit);case`flows`:return X(n.limit);case`flow-detail`:return Z(n.flowId);case`flow-cancel`:return Q(n.flowId,{removeQueuedInMemory:t?.removeQueuedInMemory});case`flow-resume`:return $(n.flowId,{enqueueInMemory:t?.enqueueInMemory});case`usage`:return K}}var Pe=e((()=>{y(),u(),Ce(),Te(),te()}));export{Oe as a,Ne as c,X as d,Y as f,$ as g,q as h,ke as i,Ee as l,Pe as m,Ae as n,De as o,J as p,Me as r,Q as s,je as t,Z as u};
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,m as r,n as i,o as a,r as o,t as s}from"./autonomy-Src6sKCp.js";r();export{s as autonomyFlowCancelHandler,i as autonomyFlowHandler,o as autonomyFlowResumeHandler,n as autonomyFlowsHandler,e as autonomyRunsHandler,a as autonomyStatusHandler,t as getAutonomyCommandText};
1
+ import{a as e,c as t,i as n,m as r,n as i,o as a,r as o,t as s}from"./autonomy-DuQmYhq6.js";r();export{s as autonomyFlowCancelHandler,i as autonomyFlowHandler,o as autonomyFlowResumeHandler,n as autonomyFlowsHandler,e as autonomyRunsHandler,a as autonomyStatusHandler,t as getAutonomyCommandText};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Gm as n,Wm as r,id as i,sd as a}from"./loadAgentsDir-BL93ulMm.js";import{I as o,P as s,fi as c,hn as l,t as u,y as d}from"./src-P_wYS_NJ2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{c as p,l as m,m as h,p as g}from"./autonomy-DuQmYhq6.js";function _(){return S}function v({onDone:e}){a(`autonomy-panel`);let[t,r]=(0,b.useState)(0),[i,c]=(0,b.useState)([]);(0,b.useEffect)(()=>{let e=!1;return n().then(t=>{e||c(t.slice(0,5))}),()=>{e=!0}},[]);let u=(0,b.useMemo)(()=>{let e=[{label:`Overview`,description:`显示 run 和 flow 数量以及最近的自动活动`,run:()=>g()},{label:`Full deep status`,description:`在一份诊断报告里打印所有本地 autonomy 表面`,run:()=>g({deep:!0})},{label:`Auto mode`,description:`检查自动权限模式是否可用及其原因`,run:()=>m(`auto-mode`)},{label:`Runs summary`,description:`显示 queued/running/completed/failed 的运行总数与最近一次运行`,run:()=>m(`runs`)},{label:`Recent runs`,description:`列出最近的 autonomy 运行 ID、触发器、状态与 prompt`,run:()=>p(`runs 10`)},{label:`Flows summary`,description:`显示跨 queued/running/waiting 状态的托管 flow 总数`,run:()=>m(`flows`)},{label:`Recent flows`,description:`列出最近的托管 flow ID、状态、当前步骤与 goal`,run:()=>p(`flows 10`)},{label:`Workflow runs`,description:`显示已持久化的 WorkflowTool 运行及其当前 workflow 步骤`,run:()=>m(`workflow-runs`)},{label:`Pipes`,description:`显示用于终端消息的 UDS/named-pipe 与 LAN 注册表`,run:()=>m(`pipes`)},{label:`Runtime`,description:`显示 daemon 状态与运行中的后台或交互式会话`,run:()=>m(`runtime`)},{label:`Remote Control`,description:`显示 bridge 模式、base URL、token 状态与 entitlement 说明`,run:()=>m(`remote-control`)},{label:`RemoteTrigger`,description:`显示最近的远程 trigger 审计记录、失败与最近一次调用`,run:()=>m(`remote-trigger`)}],t=i.flatMap(e=>{let t=e.flowId.slice(0,8),n=[{label:`Flow ${t}`,description:`${e.status}:${e.goal}`,run:()=>p(`flow ${e.flowId}`)}];return e.status===`waiting`&&n.push({label:`Resume ${t}`,description:e.currentStep?`恢复等待中的步骤:${e.currentStep}`:`恢复等待中的 flow`,run:()=>p(`flow resume ${e.flowId}`,{enqueueInMemory:!0})}),(e.status===`queued`||e.status===`running`||e.status===`waiting`||e.status===`blocked`)&&n.push({label:`Cancel ${t}`,description:`取消处于 ${e.status} 状态的 flow`,run:()=>p(`flow cancel ${e.flowId}`,{removeQueuedInMemory:!0})}),n});return[...e,...t]},[i]),f=()=>{let n=u[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return l((e,t)=>{if(t.upArrow){r(e=>Math.max(0,e-1));return}if(t.downArrow){r(e=>Math.min(u.length-1,e+1));return}t.return&&f()}),(0,x.jsx)(d,{title:`Autonomy`,subtitle:`${u.length} actions`,onCancel:()=>e(`Autonomy panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,x.jsxs)(o,{flexDirection:`column`,children:[u.map((e,n)=>(0,x.jsxs)(o,{flexDirection:`row`,children:[(0,x.jsx)(s,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(C)}),(0,x.jsx)(s,{dimColor:!0,children:e.description})]},`${e.label}-${n}`)),(0,x.jsx)(o,{marginTop:1,children:(0,x.jsx)(s,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function y(e,t,n){let r=n?.trim()??``;return r?(e(await p(r,{enqueueInMemory:!0,removeQueuedInMemory:!0}),{display:`system`}),null):(0,x.jsx)(v,{onDone:e})}var b,x,S,C;e((()=>{b=t(c(),1),u(),i(),h(),r(),x=f(),S=14,C=24}))();export{y as call,_ as getAutonomyPanelBaseActionCountForTests};
@@ -0,0 +1 @@
1
+ import{t as e}from"./backgroundHousekeeping-Cc7Ag7JG.js";export{e as startBackgroundHousekeeping};
@@ -0,0 +1,17 @@
1
+ import{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{$ as r,Ba as i,Cr as a,Da as o,Hd as s,Mc as c,Oa as ee,Ta as te,Tt as l,Vd as u,_v as d,ap as ne,fr as f,gx as p,hx as m,jc as h,mt as g,rw as _,sp as re,tt as ie,tw as ae,vm as oe}from"./loadAgentsDir-BL93ulMm.js";import{R as v,W as y,Wt as b}from"./state-BemZdQIl.js";import{n as x,t as S}from"./cwd-Cfdf7z7s.js";import{R as C,U as w,c as T,f as E,i as D,u as O,x as k}from"./debug-BecbSVoN.js";import{f as A,g as j,y as M}from"./settings-D4CpDv2y.js";import{S as N}from"./config-aRiTrtCv.js";import{o as P,s as F,v as I,y as L}from"./log-Dauqle-Z.js";import{n as R,r as z}from"./analytics-DJobLaWP.js";import{_ as B,h as V}from"./model-Bgh_r4lg.js";import{bn as H,yn as U}from"./prompt-Dx7IWhBt.js";import{at as W}from"./sessionState-D-SaBzWD.js";import{i as se,t as G}from"./nativeInstaller-BEwayifa.js";import{n as K,t as ce}from"./allErrors-_cOQksHC.js";import{r as le}from"./magicDocs-DLav5QK0.js";import{n as ue,t as de}from"./pluginAutoupdate-BBU9Jn4p.js";import{n as fe,r as pe}from"./registerProtocol-E0Iu5hEx.js";import"os";import{join as q}from"path";import"crypto";n(),b(),x(),k(),E(),D(),L(),j(),H(),B(),c(),a(),le(),r(),P(),C(),i(),d(),r(),p(),C(),P(),i(),d(),oe();async function me(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(S(),`.claude`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{F(Error(`Failed to read skill file for improvement: ${i}`));return}let s=t.map(e=>`- ${e.section}: ${e.change}`).join(`
2
+ `),c=V(),l=await ie({messages:[te({content:`You are editing a skill definition file. Apply the following improvements to the skill.
3
+
4
+ <current_skill_file>
5
+ ${a}
6
+ </current_skill_file>
7
+
8
+ <improvements>
9
+ ${s}
10
+ </improvements>
11
+
12
+ Rules:
13
+ - Integrate the improvements naturally into the existing structure
14
+ - Preserve frontmatter (--- block) exactly as-is
15
+ - Preserve the overall format and style
16
+ - Do not remove existing content unless an improvement explicitly replaces it
17
+ - Output the complete updated file inside <updated_file> tags`})],systemPrompt:W([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:m().signal,options:{getToolPermissionContext:async()=>U(),model:c,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),u=o(ee(Array.isArray(l.message.content)?l.message.content:[]).trim(),`updated_file`);if(!u){F(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,u,`utf-8`)}catch(e){F(w(e))}}R(),re(),N(),P(),G(),s(),K(),_(),l();var he=30;function J(){let e=((A()||{}).cleanupPeriodDays??he)*24*60*60*1e3;return new Date(Date.now()-e)}function ge(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function _e(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function Y(e,t,n){let r={messages:0,errors:0};try{let i=await O().readdir(e);for(let a of i)try{_e(a.name)<t&&(await O().unlink(q(e,a.name)),n?r.messages++:r.errors++)}catch(e){F(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&F(e)}return r}async function ve(){let e=O(),t=J(),n=I.errors(),r=I.baseLogs(),i=await Y(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>q(r,e.name));for(let n of a)i=ge(i,await Y(n,t,!0)),await Z(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&F(e)}return i}async function X(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Z(e,t){try{await t.rmdir(e)}catch{}}async function ye(){let e=J(),t={messages:0,errors:0},n=f(),r=O(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=q(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=q(i,n.name),o=q(a,ae),s;try{s=await r.readdir(o)}catch{await Z(a,r);continue}for(let n of s)if(n.isFile())try{await X(q(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=q(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await X(q(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Z(i,r)}await Z(o,r),await Z(a,r)}await Z(i,r)}return t}async function be(e,t,n=!0){let r=J(),i={messages:0,errors:0},a=O(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await X(q(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Z(e,a),i}function xe(){return be(q(t(),`plans`),`.md`)}async function Se(){let e=J(),n={messages:0,errors:0},r=O();try{let i=q(t(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));await Promise.all(o.map(async t=>{try{(await r.stat(t)).mtime<e&&(await r.rm(t,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await Z(i,r)}catch(e){F(e)}return n}async function Ce(){let e=J(),n={messages:0,errors:0},r=O();try{let i=q(t(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>q(i,e.name));for(let t of o)try{(await r.stat(t)).mtime<e&&(await r.rm(t,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await Z(i,r)}catch(e){F(e)}return n}async function we(){let e=J(),n={messages:0,errors:0},r=O(),i=q(t(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let t of a)if(!(!t.isFile()||!t.name.endsWith(`.txt`)||t.name===`latest`))try{await X(q(i,t.name),e,r)&&n.messages++}catch{n.errors++}return n}async function Q(){let{errors:e}=ce();if(e.length>0&&M(`cleanupPeriodDays`)){T(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await ve(),await ye(),await xe(),await Se(),await Ce(),await we(),await ne(),await u(J());let t=await g(J());t>0&&z(`tengu_worktree_cleanup`,{removed:t})}b(),G(),ue();var Te=(fe(),e(pe)),$=600*1e3;function Ee(){import(`./extractMemories-4lBn134y.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),h(),de(),v()&&Te.ensureDeepLinkProtocolRegistered();let e=!0;async function t(){if(v()&&y()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Q()),v()&&y()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await se()}setTimeout(t,$).unref()}export{me as n,Ee as t};
@@ -1,2 +1,2 @@
1
- import{S as e,m as t,s as n,y as r}from"./git-2c7WlGDL.js";import{f as i,m as a,v as o}from"./startupProfiler-L_UWZ03w.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";o(),e(),t();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — CLAUDE.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${i(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
1
+ import{S as e,m as t,s as n,y as r}from"./git-DBlOv64X.js";import{f as i,m as a,v as o}from"./startupProfiler-CmH_aVy2.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";o(),e(),t();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — CLAUDE.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${i(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
2
2
  `)}async function m(e){let t=await n(e);if(!t)return;let i=await r(t),[a,o]=await Promise.all([h(c(t,`FETCH_HEAD`)),i?h(c(i,`FETCH_HEAD`)):Promise.resolve(void 0)]);return a&&o?a>o?a:o:a??o}async function h(e){try{let{mtime:t}=await u(e);return t}catch{return}}function g(e){let t=s();return e===t?`~`:e.startsWith(t+l)?`~`+e.slice(t.length):e}export{m as n,p as t};
@@ -1,5 +1,5 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{C as r,S as i}from"./debug-RAynG_nM.js";import{a,i as o}from"./genericProcessUtils-CmsUPyRz.js";import{join as s}from"path";import{randomUUID as c}from"crypto";import{readFile as l,readdir as u,unlink as d}from"fs/promises";async function f(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-X_yjYR7x.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-DewYVEBm.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-X_yjYR7x.js`);return new n}var p=e((()=>{}));function m(){return s(t(),`sessions`)}async function h(){let e=m(),t;try{t=await u(e)}catch{return[]}let n=[];for(let i of t)if(/^\d+\.json$/.test(i)){if(!a(parseInt(i.slice(0,-5),10))){d(s(e,i)).catch(()=>{});continue}try{let t=r(await l(s(e,i),`utf-8`));n.push(t)}catch{}}return n}function g(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function _(e){return new Date(e).toLocaleString()}function v(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function y(e){let t=await h();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=v(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${_(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
2
- `)),console.log()}}async function b(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await l(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function x(e){let t=await h();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=v(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=v(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-DewYVEBm.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-X_yjYR7x.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function S(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),a(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);d(s(m(),`${n.pid}.json`)).catch(()=>{})}async function C(e){let n=await f(),r=e.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-BDhHQY0-.js";import{S as r,x as i}from"./debug-BecbSVoN.js";import{a,i as o}from"./genericProcessUtils-B2HcDYhg.js";import{join as s}from"path";import{randomUUID as c}from"crypto";import{readFile as l,readdir as u,unlink as d}from"fs/promises";async function f(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-CIyF0M5O.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-D5EvHWi3.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-CIyF0M5O.js`);return new n}var p=e((()=>{}));function m(){return s(t(),`sessions`)}async function h(){let e=m(),t;try{t=await u(e)}catch{return[]}let n=[];for(let i of t)if(/^\d+\.json$/.test(i)){if(!a(parseInt(i.slice(0,-5),10))){d(s(e,i)).catch(()=>{});continue}try{let t=r(await l(s(e,i),`utf-8`));n.push(t)}catch{}}return n}function g(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function _(e){return new Date(e).toLocaleString()}function v(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function y(e){let t=await h();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=v(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${_(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
2
+ `)),console.log()}}async function b(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await l(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function x(e){let t=await h();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=v(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=v(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-D5EvHWi3.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-CIyF0M5O.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function S(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),a(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);d(s(m(),`${n.pid}.json`)).catch(()=>{})}async function C(e){let n=await f(),r=e.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
3
3
  The detached engine has no terminal for interactive input.
4
4
 
5
5
  Usage:
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,r,s as i,t as a}from"./bg-CJ0YWFli.js";n();export{a as attachHandler,r as handleBgStart,e as killHandler,i as logsHandler,t as psHandler};
@@ -1,3 +1,3 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Cr as t,dr as n,hi as r,kr as i,li as a,vr as o,yr as s}from"./loadAgentsDir-C7lOqvfh.js";import{Wt as c,et as l,pt as u}from"./state-BemZdQIl.js";import{S as d,w as f}from"./debug-RAynG_nM.js";import{c as p,s as m}from"./types-3j8PS-Du.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-C84IJ91d.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let t=y(),r=u(),a=n(l()),c=s(t),d=o();await b(a,{recursive:!0,mode:448});let m;try{m=await x(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>i(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(f(n)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(f(e))}return await S(c,C.join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Cr as t,dr as n,hi as r,kr as i,li as a,vr as o,yr as s}from"./loadAgentsDir-BL93ulMm.js";import{Wt as c,et as l,pt as u}from"./state-BemZdQIl.js";import{C as d,x as f}from"./debug-BecbSVoN.js";import{c as p,s as m}from"./types-DafcFtmb.js";import{n as h,r as g}from"./analytics-DJobLaWP.js";import{i as _,o as v}from"./stringUtils-C8PaYpQF.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let t=y(),r=u(),a=n(l()),c=s(t),f=o();await b(a,{recursive:!0,mode:448});let m;try{m=await x(f)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>i(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(d(n)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(d(e))}return await S(c,C.join(`
2
2
  `)+`
3
- `,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await r(t,{exact:!0})).length===0)return t;let n=await r(`${e} (Branch`),i=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(a);t&&(t[1]?i.add(parseInt(t[1],10)):i.add(1))}let o=2;for(;i.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=u();try{let{sessionId:n,title:o,forkPath:s,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(o??d);await a(n,f,s),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!o});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:s,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=o?` "${o}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),t(),d(),v()}))();export{E as call,C as deriveFirstPrompt};
3
+ `,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:c,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await r(t,{exact:!0})).length===0)return t;let n=await r(`${e} (Branch`),i=new Set([1]),a=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(a);t&&(t[1]?i.add(parseInt(t[1],10)):i.add(1))}let o=2;for(;i.has(o);)o++;return`${e} (Branch ${o})`}async function E(e,t,n){let r=n?.trim()||void 0,i=u();try{let{sessionId:n,title:o,forkPath:s,serializedMessages:c,contentReplacementRecords:l}=await w(r),u=new Date,d=C(c.find(e=>e.type===`user`)),f=await T(o??d);await a(n,f,s),g(`tengu_conversation_forked`,{message_count:c.length,has_custom_title:!!o});let p={date:u.toISOString().split(`T`)[0],messages:c,fullPath:s,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:c.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=o?` "${o}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${i}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{c(),h(),m(),t(),f(),v()}))();export{E as call,C as deriveFirstPrompt};
@@ -5,4 +5,4 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./e
5
5
  `)};if(t===``||t===`once`){let e=new Date().toISOString();d(n,e,`utf8`),_();let t=h();return{type:`text`,value:[`## Cache break scheduled`,``,`Marker written: \`${n}\``,`Timestamp: ${e}`,``,`The next API call will append a random nonce to the system prompt,`,`causing a cache miss. The marker is removed automatically after use.`,``,"To cancel before the next call: `/break-cache --clear`","For every call: `/break-cache always`",``,`Total breaks this session: ${t.totalBreaks}`,``,`_How it works: The prompt cache keys on the system-prompt prefix hash._`,`_A unique nonce invalidates the hash, forcing a fresh compute._`].join(`
6
6
  `)}}return{type:`text`,value:[`Unknown scope: "${t}"`,``,y].join(`
7
7
  `)}}var y,b,x,S=e((()=>{r(),n(),y=[`Usage: /break-cache [scope]`,``,` (no args) Schedule a one-time cache break for the next API call`,` once Same as no args`,` always Enable persistent cache-break mode (every request)`,` off Disable always mode and clear any pending marker`,` --clear Clear the pending once marker (cancel before next call)`,` status Show current break-cache status and stats`,``,`How it works:`,` The prompt cache keys on the system-prompt prefix hash.`,` A unique nonce invalidates the hash, forcing a fresh compute.`,` This is useful when you want to ensure a clean context window.`].join(`
8
- `),b={type:`local-jsx`,name:`break-cache`,description:`Manage prompt-cache breaking. Open actions or run: once, status, always, off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-KW-wmEvU.js`)},x={type:`local`,name:`break-cache`,description:`Force the next (or all) API call(s) to miss prompt cache. Scopes: once, status, always, off`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
8
+ `),b={type:`local-jsx`,name:`break-cache`,description:`管理 prompt cache 的打断。打开操作面板,或运行:oncestatusalwaysoff`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,load:()=>import(`./panel-CoNfXy3K.js`)},x={type:`local`,name:`break-cache`,description:`强制下一次(或所有)API 调用不命中 prompt cache。作用域:oncestatusalwaysoff`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,o as n,t as r}from"./bridgeConfig-UgaUfuP6.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-C9VBDB0Y.js";import{Bt as r,Ot as i}from"./model-BsZ4sP_H.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-C9VBDB0Y.js";import{Bt as r,Ot as i}from"./model-Bgh_r4lg.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
@@ -1 +1 @@
1
- import{o as e}from"./envUtils-BDhHQY0-.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{C as r,F as i,S as a,a as o,l as s,z as c}from"./debug-RAynG_nM.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-CezCRpAN.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{M as b,st as x}from"./sessionState-Bifmu95-.js";import{n as S,t as C}from"./rcDebugLog-CARUIORE.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),o(),C(),g(),c(),a(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,a,o,c){try{let i=w(r(e));if(j(i)){s(`[bridge:repl] Ingress message type=control_response`),o?.(i);return}if(M(i)){s(`[bridge:repl] Inbound control_request subtype=${i.request.subtype}`),c?.(i);return}if(!A(i))return;let l=`uuid`in i&&typeof i.uuid==`string`?i.uuid:void 0;if(l&&t.has(l)){s(`[bridge:repl] Ignoring echo: type=${i.type} uuid=${l}`);return}if(l&&n.has(l)){s(`[bridge:repl] Ignoring re-delivered inbound: type=${i.type} uuid=${l}`);return}s(`[bridge:repl] Ingress message type=${i.type}${l?` uuid=${l}`:``}`),i.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),a?.(i)):s(`[bridge:repl] Ignoring non-user inbound message: type=${i.type}`)}catch(e){s(`[bridge:repl] Failed to parse ingress message: ${i(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:o,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){s(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),s(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:o?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),s(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
1
+ import{o as e}from"./envUtils-BDhHQY0-.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{P as r,R as i,S as a,c as o,i as s,x as c}from"./debug-BecbSVoN.js";import{B as l,F as u,H as d,I as f,O as p,b as m,g as h,m as g,q as _}from"./log-Dauqle-Z.js";import{n as v,r as y}from"./analytics-DJobLaWP.js";import{M as b,st as x}from"./sessionState-D-SaBzWD.js";import{n as S,t as C}from"./rcDebugLog-CARUIORE.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";e();async function E(){return!1}function D(){return!1}function O(){return!0}function k(){return null}v(),b(),s(),C(),g(),i(),c(),_(),t();function A(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function j(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function M(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function N(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function P(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return h(n)||void 0}var F=`system-reminder`,I=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,L=new Set([m,p,u,f,l,d]);function R(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function z(e){let t=e.trim();if(!t)return null;I.lastIndex=0;let n=[];for(;I.lastIndex<t.length;){let e=I.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function B(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=z(R(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==F&&L.has(e))}function V(e){return e.some(B)}function H(e,t,n,i,s,c){try{let r=w(a(e));if(j(r)){o(`[bridge:repl] Ingress message type=control_response`),s?.(r);return}if(M(r)){o(`[bridge:repl] Inbound control_request subtype=${r.request.subtype}`),c?.(r);return}if(!A(r))return;let l=`uuid`in r&&typeof r.uuid==`string`?r.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${r.type} uuid=${l}`);return}if(l&&n.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${r.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${r.type}${l?` uuid=${l}`:``}`),r.type===`user`?(l&&n.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(r)):o(`[bridge:repl] Ignoring non-user inbound message: type=${r.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${r(e)}`)}}var U=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function W(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:U}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function G(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var K=class{constructor(e){n(this,`capacity`,void 0),n(this,`ring`,void 0),n(this,`set`,new Set),n(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{N as a,V as c,O as d,D as f,W as i,k as l,P as n,G as o,H as r,B as s,K as t,E as u};
@@ -1 +1 @@
1
- import{A as e,l as t,w as n}from"./external-CEp-aPkt.js";import{n as r,r as i,t as a}from"./lazySchema-B4D4qJVE.js";import{C as o,S as s,V as c,a as l,l as u,w as d,z as f}from"./debug-RAynG_nM.js";import{_ as p,c as m,l as h,m as g}from"./sessionStoragePortable-JZnGwqUM.js";import{dirname as _,join as v}from"path";import{mkdir as y,readFile as b,stat as x,unlink as S,writeFile as C}from"fs/promises";i(),l(),f(),p(),a(),h(),s();var w=r(()=>n({sessionId:e(),environmentId:e(),source:t([`standalone`,`repl`])}));function T(e){return v(m(),g(e),`bridge-pointer.json`)}async function E(e,t){let n=T(e);try{await y(_(n),{recursive:!0}),await C(n,d(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function D(e){let t=T(e),n,r;try{r=(await x(t)).mtimeMs,n=await b(t,`utf8`)}catch{return null}let i=w().safeParse(k(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await O(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await O(e),null):{...i.data,ageMs:a}}async function O(e){let t=T(e);try{await S(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){c(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function k(e){try{return o(e)}catch{return null}}export{O as clearBridgePointer,D as readBridgePointer,E as writeBridgePointer};
1
+ import{A as e,l as t,w as n}from"./external-CEp-aPkt.js";import{n as r,r as i,t as a}from"./lazySchema-B4D4qJVE.js";import{B as o,C as s,R as c,S as l,c as u,i as d,x as f}from"./debug-BecbSVoN.js";import{_ as p,c as m,l as h,m as g}from"./sessionStoragePortable-JZnGwqUM.js";import{dirname as _,join as v}from"path";import{mkdir as y,readFile as b,stat as x,unlink as S,writeFile as C}from"fs/promises";i(),d(),c(),p(),a(),h(),f();var w=r(()=>n({sessionId:e(),environmentId:e(),source:t([`standalone`,`repl`])}));function T(e){return v(m(),g(e),`bridge-pointer.json`)}async function E(e,t){let n=T(e);try{await y(_(n),{recursive:!0}),await C(n,s(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function D(e){let t=T(e),n,r;try{r=(await x(t)).mtimeMs,n=await b(t,`utf8`)}catch{return null}let i=w().safeParse(k(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await O(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await O(e),null):{...i.data,ageMs:a}}async function O(e){let t=T(e);try{await S(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){o(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function k(e){try{return l(e)}catch{return null}}export{O as clearBridgePointer,D as readBridgePointer,E as writeBridgePointer};