@readmagic/workmate 0.0.6 → 0.0.7

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 (409) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-ClHi-Dr6.js → AddWorkspaceDirectory-CFrrXnt9.js} +1 -1
  2. package/dist/chunks/{App-BP06lHmf.js → App-Buad9Llp.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-Bsy8kr2a.js → ApproveApiKey-B2HJUD7h.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-BQbHdvc3.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-CcocKoTJ.js → AssistantSessionChooser-4lm4eXQ8.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-D4qA0M5O.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-BKj_3Idm.js → BypassPermissionsModeDialog-DllL8dxU.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--ywODh81.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BD-7yAZh.js → ClaudeMdExternalIncludesDialog-BZSyRqeq.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-Wkfw7Ts-.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-BmPmCfT3.js → DesktopHandoff-DaP4Riar.js} +1 -1
  12. package/dist/chunks/{DiffDialog-C4XSSjvV.js → DiffDialog-B7hx8i_Y.js} +2 -2
  13. package/dist/chunks/Doctor-89OgoAUA.js +1 -0
  14. package/dist/chunks/Doctor-CuKJ-nGt.js +3 -0
  15. package/dist/chunks/ExitFlow-DnPydE17.js +2 -0
  16. package/dist/chunks/{Feedback-BaYA8-SU.js → Feedback-SmGiR3mf.js} +2 -2
  17. package/dist/chunks/{Grove-BJziCbZH.js → Grove-CjN9DO47.js} +1 -1
  18. package/dist/chunks/Grove-Cq88VBmM.js +1 -0
  19. package/dist/chunks/{HybridTransport-B8V6O6rM.js → HybridTransport-rK83Qijz.js} +1 -1
  20. package/dist/chunks/{InvalidConfigDialog-CHzBSJDf.js → InvalidConfigDialog-DdO0AxyF.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-BKenH3bD.js → InvalidSettingsDialog-s1G0DwXF.js} +1 -1
  22. package/dist/chunks/MCPConnectionManager-NRfIjdlj.js +1 -0
  23. package/dist/chunks/{McpParsingWarnings-Bj2-YL8o.js → McpParsingWarnings-Du5IxZos.js} +1 -1
  24. package/dist/chunks/MessageSelector-iIroHvXo.js +3 -0
  25. package/dist/chunks/Messages-D4Hm4gaY.js +11 -0
  26. package/dist/chunks/{Onboarding-BrAJp0aL.js → Onboarding-BiZByBK-.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-Ds1cB7RC.js → OverageCreditUpsell-BM7szLgm.js} +1 -1
  28. package/dist/chunks/PluginSettings-uY5KTCtK.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-egs9VvUs.js → PromptInputFooterSuggestions-BmsFdOu9.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-SieM5NoY.js → PromptInputHelpMenu-DX-0wEDo.js} +1 -1
  31. package/dist/chunks/QueryEngine-CGYaShXD.js +1 -0
  32. package/dist/chunks/REPL-CRJB2t2z.js +142 -0
  33. package/dist/chunks/REPL-u4Yq29Du.js +1 -0
  34. package/dist/chunks/{RemoteCallout-Cs-ro8_i.js → RemoteCallout-B-tyvQOe.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-B740Dp6m.js → RemoteSessionManager-DCd0O5_l.js} +2 -2
  36. package/dist/chunks/ResumeConversation-DAAXlOCd.js +1 -0
  37. package/dist/chunks/{SSETransport-DtpMDekF.js → SSETransport-5VK5okFv.js} +1 -1
  38. package/dist/chunks/SearchExtraToolsTool-B-7Bworf.js +1 -0
  39. package/dist/chunks/Settings-CUjWlncb.js +2 -0
  40. package/dist/chunks/{TeleportProgress-rYaHIEfe.js → TeleportProgress-DxN0bQL2.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-DY97YZMB.js → TeleportRepoMismatchDialog-A5Ss0kuk.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-jaQzyTCh.js → TeleportResumeWrapper-Bz14mUqR.js} +1 -1
  43. package/dist/chunks/{ThemePicker-BViWzLp3.js → ThemePicker-CVSRqTzW.js} +1 -1
  44. package/dist/chunks/TrustDialog-CY8an_Tg.js +1 -0
  45. package/dist/chunks/{ValidationErrorsList-B8pRiGuy.js → ValidationErrorsList-BYsDtAvX.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-DqnbSdIu.js → WelcomeV2-C1BfrqC5.js} +1 -1
  47. package/dist/chunks/{add-dir-C2Hu3oE4.js → add-dir-DfLYgwox.js} +1 -1
  48. package/dist/chunks/{agentDisplay-XoDJhr03.js → agentDisplay-CMmHIl86.js} +1 -1
  49. package/dist/chunks/{agents-C4QXeHIJ.js → agents-DE_4mAHG.js} +1 -1
  50. package/dist/chunks/agents-DJtPfvnL.js +103 -0
  51. package/dist/chunks/allErrors-CQE2k0zO.js +1 -0
  52. package/dist/chunks/{ant-B6k6cBts.js → ant-ClQkuQjZ.js} +1 -1
  53. package/dist/chunks/{api-gqTA-D7n.js → api-2cdIPaeq.js} +1 -1
  54. package/dist/chunks/api-CG-lhKe-.js +1 -0
  55. package/dist/chunks/{assistant-DJ9hd4uC.js → assistant-Bje16tQx.js} +1 -1
  56. package/dist/chunks/auth-DMfEiQrC.js +1 -0
  57. package/dist/chunks/auth-D_cGl8WD.js +1 -0
  58. package/dist/chunks/{auth-BnSrKyJe.js → auth-DqcKPbw8.js} +1 -1
  59. package/dist/chunks/{autoMode-BNukrVAB.js → autoMode-ZW70mpr0.js} +5 -5
  60. package/dist/chunks/{autonomy-BEmI7WVW.js → autonomy-CwbWsCnv.js} +1 -1
  61. package/dist/chunks/autonomy-Oui8yK8G.js +15 -0
  62. package/dist/chunks/{autonomyPanel-fhge09AG.js → autonomyPanel-Mq50H7iM.js} +1 -1
  63. package/dist/chunks/backgroundHousekeeping-BpLtI45r.js +1 -0
  64. package/dist/chunks/backgroundHousekeeping-DtJNx4Ja.js +17 -0
  65. package/dist/chunks/{branch-Bpe-gocq.js → branch-DU5O9KZ0.js} +1 -1
  66. package/dist/chunks/{bridge-D12Shbkj.js → bridge-DNNxtPlz.js} +2 -2
  67. package/dist/chunks/{bridgeConfig-BhxRF2vm.js → bridgeConfig-CE6dMsiJ.js} +1 -1
  68. package/dist/chunks/bridgeConfig-DP9dD1Cv.js +1 -0
  69. package/dist/chunks/{bridgeEnabled-SbB-6zdY.js → bridgeEnabled-Cc0mGlTb.js} +1 -1
  70. package/dist/chunks/bridgeEnabled-D8wP3DWQ.js +1 -0
  71. package/dist/chunks/bridgeMain-CwxMa_pd.js +1 -0
  72. package/dist/chunks/bridgeMain-D11t1BYQ.js +68 -0
  73. package/dist/chunks/{bridgeMessaging-DHc5dOhB.js → bridgeMessaging-DdvApEqW.js} +1 -1
  74. package/dist/chunks/{bridgePointer-MqLe5Asm.js → bridgePointer-DqHMHa2B.js} +1 -1
  75. package/dist/chunks/{btw-D9hMM5d2.js → btw-CejSEdNl.js} +1 -1
  76. package/dist/chunks/{caches-UeVVM3T0.js → caches-5HVQSevy.js} +2 -2
  77. package/dist/chunks/caches-B-nJoHLM.js +1 -0
  78. package/dist/chunks/{ccrClient-Iza0L8Zw.js → ccrClient-BFyfO67b.js} +1 -1
  79. package/dist/chunks/{claudeDesktop-Cx31Ugjp.js → claudeDesktop-Fe-QL-sN.js} +1 -1
  80. package/dist/chunks/{clear-B4d38ssF.js → clear-D8m2utXW.js} +1 -1
  81. package/dist/chunks/client-C6MbjvOB.js +17 -0
  82. package/dist/chunks/client-DKXCfdde.js +1 -0
  83. package/dist/chunks/client-xxikkAoZ.js +1 -0
  84. package/dist/chunks/{color-D8VOyoYl.js → color-DWhgZH7A.js} +1 -1
  85. package/dist/chunks/commands-CxJpmEKF.js +1 -0
  86. package/dist/chunks/commitAttribution-DM6SBMwl.js +1 -0
  87. package/dist/chunks/{commitAttribution-ChAgixdj.js → commitAttribution-DPnHHKSA.js} +1 -1
  88. package/dist/chunks/compact-CblM7306.js +2 -0
  89. package/dist/chunks/config-BLVBFi5v.js +1 -0
  90. package/dist/chunks/config-CMnqm6Se.js +1 -0
  91. package/dist/chunks/{config-DmomySWC.js → config-DRDuVyzE.js} +2 -2
  92. package/dist/chunks/{context-Cl6BJ2vm.js → context-CdSMMM-0.js} +1 -1
  93. package/dist/chunks/context-noninteractive-CPkf2vB9.js +1 -0
  94. package/dist/chunks/{context-noninteractive-9hELVC29.js → context-noninteractive-DNury4JI.js} +5 -5
  95. package/dist/chunks/conversation-DCMw_rsE.js +1 -0
  96. package/dist/chunks/conversation-pUtvc-cE.js +1 -0
  97. package/dist/chunks/{createSSHSession-BM-5pbv6.js → createSSHSession-BOdTAX3N.js} +1 -1
  98. package/dist/chunks/{createSession-Cvl1Q50F.js → createSession-8Ei-Lj7V.js} +1 -1
  99. package/dist/chunks/createSession-CjqxVh_Q.js +1 -0
  100. package/dist/chunks/crossProjectResume-Bj_Pe8oe.js +40 -0
  101. package/dist/chunks/{datadog-CpqEQbHa.js → datadog-DqHxqiwY.js} +1 -1
  102. package/dist/chunks/{desktop-B_L6T6jI.js → desktop-Z5FAfunZ.js} +1 -1
  103. package/dist/chunks/{diff-CVzOodeg.js → diff-CJEKvOA5.js} +1 -1
  104. package/dist/chunks/doctor-BA2ZLDTl.js +1 -0
  105. package/dist/chunks/{entry-DHVYCR26.js → entry-DE0uMIf0.js} +4 -4
  106. package/dist/chunks/envLessBridgeConfig-B-LKYNvv.js +1 -0
  107. package/dist/chunks/envLessBridgeConfig-DyD9XCda.js +1 -0
  108. package/dist/chunks/{esm-D5q6s4l8.js → esm-5w3xFBnt.js} +1 -1
  109. package/dist/chunks/exit-Dt9kHtJO.js +1 -0
  110. package/dist/chunks/{extra-usage-zDHVtWKZ.js → extra-usage-C7E2Z1p1.js} +1 -1
  111. package/dist/chunks/extra-usage-D0Kkjp-2.js +1 -0
  112. package/dist/chunks/{extra-usage-core-BFOolqoi.js → extra-usage-core-DjdaD1qO.js} +1 -1
  113. package/dist/chunks/{extra-usage-noninteractive-cUGZy0en.js → extra-usage-noninteractive-BnD1RhKK.js} +1 -1
  114. package/dist/chunks/{extraUsage-Dq66zzqR.js → extraUsage-CpgRTcMk.js} +1 -1
  115. package/dist/chunks/extractMemories-DhUprYa7.js +1 -0
  116. package/dist/chunks/{fast-MS7WZpD8.js → fast-C4ZevUNL.js} +1 -1
  117. package/dist/chunks/fast-CChxlAAF.js +1 -0
  118. package/dist/chunks/{feedback-Fw4m28ZC.js → feedback-BIhBhV6n.js} +1 -1
  119. package/dist/chunks/{firstPartyEventLogger-CoSUd0a1.js → firstPartyEventLogger-BXY1IJ2D.js} +2 -2
  120. package/dist/chunks/firstPartyEventLogger-CnkGSojw.js +1 -0
  121. package/dist/chunks/{flushGate-De-yppeo.js → flushGate-CgHq81Gw.js} +1 -1
  122. package/dist/chunks/{gemini-BPziscyN.js → gemini-C1J-x1g7.js} +1 -1
  123. package/dist/chunks/generateRecap-C0jjCg0Z.js +1 -0
  124. package/dist/chunks/generateSessionName-w0BMtwS7.js +1 -0
  125. package/dist/chunks/{githubRepoPathMapping-qAoiyj6P.js → githubRepoPathMapping-8D0kpsif.js} +1 -1
  126. package/dist/chunks/{goal-CFx4eRkf.js → goal-B4GsR54_.js} +3 -3
  127. package/dist/chunks/grok-ffNyU3Lt.js +1 -0
  128. package/dist/chunks/{grove-CpqjcGCb.js → grove-BQisE2JM.js} +1 -1
  129. package/dist/chunks/{heapdump-C4kPlqGt.js → heapdump-DiCjAPR3.js} +1 -1
  130. package/dist/chunks/{help-B1h-faJ3.js → help-2hn8VK2-.js} +1 -1
  131. package/dist/chunks/hooks-CBmrBO-J.js +1 -0
  132. package/dist/chunks/{hooks-X6J03MnA.js → hooks-CkA9bhHl.js} +2 -2
  133. package/dist/chunks/inboundAttachments-C5K3XPTC.js +1 -0
  134. package/dist/chunks/{inboundAttachments-CUJE3KaU.js → inboundAttachments-IH-g95jo.js} +1 -1
  135. package/dist/chunks/initReplBridge-C-P4dgAG.js +1 -0
  136. package/dist/chunks/{install-D5YORIJL.js → install-Dzlm4u58.js} +1 -1
  137. package/dist/chunks/{instrumentation-Bw3CxPQf.js → instrumentation-Yt31gxWN.js} +3 -3
  138. package/dist/chunks/{job-DOWtcltx.js → job-BXujwZNa.js} +1 -1
  139. package/dist/chunks/{keybindings-BLw5J-Zj.js → keybindings-D8FXoO89.js} +2 -2
  140. package/dist/chunks/language-Baosud0X.js +1 -0
  141. package/dist/chunks/{language-C6Fq-XOZ.js → language-Ca4B018X.js} +1 -1
  142. package/dist/chunks/{launchAgentsPlatform-jWWf-Lk9.js → launchAgentsPlatform-D6DmNuDt.js} +1 -1
  143. package/dist/chunks/{launchLocalMemory-kHeD0I0y.js → launchLocalMemory-C0FzUq7x.js} +2 -2
  144. package/dist/chunks/{launchLocalVault-DLqkOjmb.js → launchLocalVault-DkYAre4O.js} +3 -3
  145. package/dist/chunks/{launchMemoryStores-Ct7AVXrO.js → launchMemoryStores-D2rKWAPs.js} +1 -1
  146. package/dist/chunks/{launchOnboarding-Cc6WwPX9.js → launchOnboarding-gOVAFEFp.js} +1 -1
  147. package/dist/chunks/{launchSchedule-ZyvuvjgU.js → launchSchedule-IZdFstT_.js} +1 -1
  148. package/dist/chunks/{launchSkillStore-BejQnLog.js → launchSkillStore-B7LamM1d.js} +1 -1
  149. package/dist/chunks/{launchTeleport-8CuYUfIR.js → launchTeleport-C2BQMfYP.js} +3 -3
  150. package/dist/chunks/{launchVault-DIvIOuPh.js → launchVault-C60WUcCI.js} +1 -1
  151. package/dist/chunks/{lazySchema-DcIJE_0i.js → lazySchema-DULtBUCI.js} +1 -1
  152. package/dist/chunks/loadAgentsDir-B9c3Emvg.js +1 -0
  153. package/dist/chunks/{loadAgentsDir-D206qwP3.js → loadAgentsDir-x3rlgED4.js} +690 -692
  154. package/dist/chunks/loadPluginHooks-BhNdAjeY.js +1 -0
  155. package/dist/chunks/localSearch-BLCGsdyM.js +1 -0
  156. package/dist/chunks/{localSearch-CzrbOklu.js → localSearch-DtplGF-l.js} +1 -1
  157. package/dist/chunks/{logoV2Utils-8M56V7oN.js → logoV2Utils-gGK9gErT.js} +1 -1
  158. package/dist/chunks/{magicDocs-DWjL2k7P.js → magicDocs-qdDB_mKb.js} +2 -2
  159. package/dist/chunks/{main-BohPzJFF.js → main-OWFSddRx.js} +82 -82
  160. package/dist/chunks/managedEnv-Aq5BXfY7.js +1 -0
  161. package/dist/chunks/managedEnv-BHoeDjpS.js +1 -0
  162. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +1 -0
  163. package/dist/chunks/{mappers-BDMZFgKx.js → mappers-04gNXJ3w.js} +1 -1
  164. package/dist/chunks/mcp-BSNdwbxR.js +1 -0
  165. package/dist/chunks/mcp-CMnDNI-4.js +6 -0
  166. package/dist/chunks/mcp-D1yA9E56.js +2 -0
  167. package/dist/chunks/memory-D1zbyjxN.js +1 -0
  168. package/dist/chunks/{mode-CUkHFkju.js → mode-DY087x_x.js} +2 -2
  169. package/dist/chunks/{model-CKkOnnnx.js → model-CZViyZnE.js} +1 -1
  170. package/dist/chunks/{model-BY3auM2c.js → model-D0EfJBuw.js} +1 -1
  171. package/dist/chunks/model-DLLkVV6S.js +1 -0
  172. package/dist/chunks/{nativeInstaller-CA5d6_G7.js → nativeInstaller-yj81F75v.js} +1 -1
  173. package/dist/chunks/onChangeAppState-DhGKPG9g.js +1 -0
  174. package/dist/chunks/{openai-Cbomn0Ws.js → openai-EYRnUsco.js} +3 -3
  175. package/dist/chunks/{overageCreditGrant-DsUrmeBh.js → overageCreditGrant-Du3dOYVu.js} +1 -1
  176. package/dist/chunks/{panelCall-BsVoL1uF.js → panelCall-dMvRPAGE.js} +1 -1
  177. package/dist/chunks/{partition-BAakXjvj.js → partition-C4FWzYVm.js} +1 -1
  178. package/dist/chunks/{passes-CLRt7Cvm.js → passes-Daz-ARWD.js} +1 -1
  179. package/dist/chunks/permissions-DF8tAmDF.js +3 -0
  180. package/dist/chunks/{pidLock-D5rUnDB-.js → pidLock-CbC_il6r.js} +2 -2
  181. package/dist/chunks/{plan-SYZ4DXR8.js → plan-rsb_83Fo.js} +1 -1
  182. package/dist/chunks/{plugin-Bfjzhmrk.js → plugin-Cm31-nej.js} +1 -1
  183. package/dist/chunks/pluginAutoupdate-0k03PVff.js +1 -0
  184. package/dist/chunks/pluginBlocklist-wPFCUPdm.js +1 -0
  185. package/dist/chunks/pluginCliCommands-DhL9LbH0.js +1 -0
  186. package/dist/chunks/{pluginFlagging-D9HKAGBC.js → pluginFlagging-CAdaFV_D.js} +1 -1
  187. package/dist/chunks/pluginOperations-Cs_Z4C6O.js +2 -0
  188. package/dist/chunks/pluginStartupCheck-BRXGKGjG.js +1 -0
  189. package/dist/chunks/pluginStartupCheck-KeU0efTj.js +1 -0
  190. package/dist/chunks/{plugins-Dn6ceWrT.js → plugins-CQNKZmjP.js} +4 -4
  191. package/dist/chunks/policyLimits-D2s8M8P2.js +1 -0
  192. package/dist/chunks/{pollConfig-DH2oCtFS.js → pollConfig-2nFzv6Hy.js} +1 -1
  193. package/dist/chunks/{poor-j-y-bv8o.js → poor-DXumVTR4.js} +1 -1
  194. package/dist/chunks/{poorMode-DhzFKpPl.js → poorMode-CBOtooa0.js} +1 -1
  195. package/dist/chunks/poorMode-yNZL5uYf.js +1 -0
  196. package/dist/chunks/print-uxCF5ka5.js +23 -0
  197. package/dist/chunks/{privacy-settings-DHMJREbb.js → privacy-settings-BncbJCV0.js} +1 -1
  198. package/dist/chunks/processBashCommand-CGdwvPmD.js +1 -0
  199. package/dist/chunks/processSlashCommand-DQarepEb.js +5 -0
  200. package/dist/chunks/prompt-BgOdcHkd.js +1 -0
  201. package/dist/chunks/{prompt-BNHtszmZ.js → prompt-CE3sFmZV.js} +5 -5
  202. package/dist/chunks/prompt-CLJKFebn.js +1 -0
  203. package/dist/chunks/{promptEditor-DeMrXUir.js → promptEditor-CyTzyjwG.js} +2 -2
  204. package/dist/chunks/{protocolHandler-BHxBy84Z.js → protocolHandler-JR8pASdH.js} +1 -1
  205. package/dist/chunks/rate-limit-options-C-EqWjeI.js +1 -0
  206. package/dist/chunks/{rcDebugLog-CUy1_F23.js → rcDebugLog-DBB9r8aw.js} +1 -1
  207. package/dist/chunks/reconciler-CYD_XpG4.js +4 -0
  208. package/dist/chunks/{referral-CUaIo_vT.js → referral-CKmHHxj_.js} +1 -1
  209. package/dist/chunks/refresh-ZqZdmLK5.js +1 -0
  210. package/dist/chunks/{registerProtocol-B7Fzdofu.js → registerProtocol-wZv2uiW_.js} +1 -1
  211. package/dist/chunks/{release-notes-fbfv2DC0.js → release-notes-B5K7wVqZ.js} +1 -1
  212. package/dist/chunks/{releaseNotes-CxAHFLPl.js → releaseNotes-B8gbyFFJ.js} +2 -2
  213. package/dist/chunks/{reload-plugins-B9IT9CFA.js → reload-plugins-B9ApSp2m.js} +1 -1
  214. package/dist/chunks/{remote-env-BOklGlll.js → remote-env-CAt1dHIS.js} +1 -1
  215. package/dist/chunks/{remoteBridgeCore-j0bG1zjv.js → remoteBridgeCore-Bk3UdSLJ.js} +1 -1
  216. package/dist/chunks/remoteManagedSettings-bswzAB6W.js +1 -0
  217. package/dist/chunks/rename-CE_U6KE6.js +1 -0
  218. package/dist/chunks/{resume-y7MCTZHJ.js → resume-BicEjsPd.js} +2 -2
  219. package/dist/chunks/{runtimeObserver-CyzLASla.js → runtimeObserver-BrGF5QWX.js} +4 -4
  220. package/dist/chunks/{runtimeObserver-BZcJ1FbH.js → runtimeObserver-CiwnPFjK.js} +1 -1
  221. package/dist/chunks/sandbox-adapter-BtMiHImm.js +1 -0
  222. package/dist/chunks/{sandbox-toggle-CWpBO228.js → sandbox-toggle-D8eebdyI.js} +1 -1
  223. package/dist/chunks/searchExtraTools-hLLPuh7c.js +1 -0
  224. package/dist/chunks/{session-DL4cA_8l.js → session-BZIlR9Gc.js} +2 -2
  225. package/dist/chunks/{sessionDiscovery-DAfNKqp1.js → sessionDiscovery-DfDqTrF1.js} +1 -1
  226. package/dist/chunks/sessionFileAccessHooks-Bm8wiqwe.js +1 -0
  227. package/dist/chunks/sessionMemory-D37S0-jX.js +1 -0
  228. package/dist/chunks/sessionMemory-DmlAG3jq.js +1 -0
  229. package/dist/chunks/sessionMemoryUtils-6EWDHSGU.js +1 -0
  230. package/dist/chunks/sessionObserver-BUw2rzKl.js +1 -0
  231. package/dist/chunks/{sessionObserver-ShbCwJ8x.js → sessionObserver-KgquhGWw.js} +1 -1
  232. package/dist/chunks/sessionStorage-CucBSK5Q.js +1 -0
  233. package/dist/chunks/{sessionTitle-coed9IuJ.js → sessionTitle-DAnM73S0.js} +2 -2
  234. package/dist/chunks/{sessionTracing-D9rUyiq0.js → sessionTracing-_Hh5VXxt.js} +1 -1
  235. package/dist/chunks/settings-BeLFUeie.js +19 -0
  236. package/dist/chunks/settings-Cl16Haug.js +1 -0
  237. package/dist/chunks/settingsSync-BNvFYH3c.js +1 -0
  238. package/dist/chunks/setup-D8kXv3ts.js +3 -0
  239. package/dist/chunks/{shadowedRuleDetection-D1wsAdpp.js → shadowedRuleDetection-C6R5zOUe.js} +1 -1
  240. package/dist/chunks/{sideQuestion-wSi38p81.js → sideQuestion-hUhxls9r.js} +3 -3
  241. package/dist/chunks/{sinks-C_Dl1p4K.js → sinks-BuE17DeZ.js} +2 -2
  242. package/dist/chunks/sinks-FevoYQqP.js +1 -0
  243. package/dist/chunks/{skill-learning-B5tmc7EX.js → skill-learning-CMdxGtxr.js} +1 -1
  244. package/dist/chunks/skillChangeDetector-C65ZLSYV.js +1 -0
  245. package/dist/chunks/{skillGapStore-Df5BWAk5.js → skillGapStore-D18LRJAM.js} +2 -2
  246. package/dist/chunks/{skillGapStore-D-kQKVDZ.js → skillGapStore-Ep62R-2_.js} +1 -1
  247. package/dist/chunks/{skillGenerator-DbcdpAkw.js → skillGenerator-Bc7WwNT8.js} +2 -2
  248. package/dist/chunks/{skillLearning-ClRiDcJH.js → skillLearning-Cs9fJgkV.js} +1 -1
  249. package/dist/chunks/skillLearning-duPZl69A.js +1 -0
  250. package/dist/chunks/{skillPanel-LBd4E-MM.js → skillPanel-Cyzby746.js} +3 -3
  251. package/dist/chunks/{skillSearchPanel-CErRnUwo.js → skillSearchPanel-Cll9ccA5.js} +4 -4
  252. package/dist/chunks/{skills-CBKhfg_a.js → skills-BPPeYBy7.js} +1 -1
  253. package/dist/chunks/{stats-BY4dskVg.js → stats-CqfF4Axp.js} +1 -1
  254. package/dist/chunks/{status-DU-B4SMW.js → status-CC9Q-2Yn.js} +1 -1
  255. package/dist/chunks/{status-BnJIXtKl.js → status-D4IQpsNK.js} +2 -2
  256. package/dist/chunks/statusNoticeHelpers-CEGvdm5d.js +1 -0
  257. package/dist/chunks/syncCache-CANQZ9mQ.js +1 -0
  258. package/dist/chunks/{tag-B-wVW9Aj.js → tag-DDbNqBMu.js} +2 -2
  259. package/dist/chunks/{tasks-CBVL005y.js → tasks-CZvWJYGr.js} +1 -1
  260. package/dist/chunks/teleport-Dk5j03Ix.js +1 -0
  261. package/dist/chunks/{templateJobs-D6998LcG.js → templateJobs-D1BdhZsv.js} +1 -1
  262. package/dist/chunks/{terminalSetup-CuV-qU6v.js → terminalSetup-3JNy6i_J.js} +5 -5
  263. package/dist/chunks/{terminalSetup-0SBdyKF5.js → terminalSetup-Cn6jeYw1.js} +1 -1
  264. package/dist/chunks/{theme-p0AooruD.js → theme-Cg4GNOoQ.js} +1 -1
  265. package/dist/chunks/thinkback-p-vKIRW_.js +1 -0
  266. package/dist/chunks/thinkback-play-DnPTDE8B.js +1 -0
  267. package/dist/chunks/{thinkback-DI2NpvG-.js → thinkback-rFA1do6F.js} +1 -1
  268. package/dist/chunks/{toolEventObserver-DlH73w-S.js → toolEventObserver-CzsCuUMc.js} +1 -1
  269. package/dist/chunks/{toolEventObserver-DTccwC3c.js → toolEventObserver-SFwURL5F.js} +1 -1
  270. package/dist/chunks/toolPool-BR27AMJO.js +1 -0
  271. package/dist/chunks/trustedDevice-BYt39fui.js +1 -0
  272. package/dist/chunks/{trustedDevice-BTYoQCkC.js → trustedDevice-CKedohmT.js} +1 -1
  273. package/dist/chunks/{types-C-MRCL8J.js → types-Dut4311z.js} +2 -2
  274. package/dist/chunks/{ultrareviewCommand-BDFUS3hf.js → ultrareviewCommand-C_4OSBTW.js} +2 -2
  275. package/dist/chunks/{undercover-vuTpCnQJ.js → undercover-D30rKimg.js} +1 -1
  276. package/dist/chunks/undercover-DRSwLozU.js +1 -0
  277. package/dist/chunks/{updateCCB-DFL5Wt_I.js → updateCCB-C2G-U-qA.js} +1 -1
  278. package/dist/chunks/upgrade-Bi-bIz7R.js +1 -0
  279. package/dist/chunks/{upgrade-D5qwcaWQ.js → upgrade-Chs-OQFd.js} +1 -1
  280. package/dist/chunks/{upload-B_yADHX9.js → upload-D8FWMSQx.js} +1 -1
  281. package/dist/chunks/{usage-C0SnnC-i.js → usage-BxVeUt60.js} +1 -1
  282. package/dist/chunks/usage-DUO7Yy1f.js +1 -0
  283. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DKIqRraH.js → useExitOnCtrlCDWithKeybindings-BwsZ5f0s.js} +1 -1
  284. package/dist/chunks/useMainLoopModel-Gy1Vv4Qr.js +1 -0
  285. package/dist/chunks/useManagePlugins-B11_87VN.js +1 -0
  286. package/dist/chunks/useMergedTools-CR56my9t.js +1 -0
  287. package/dist/chunks/{useSearchInput-D1Vr2Js1.js → useSearchInput-C5OzQnX6.js} +1 -1
  288. package/dist/chunks/{useSettingsErrors-B7BXHchG.js → useSettingsErrors-B9vOZL41.js} +1 -1
  289. package/dist/chunks/{util-BaDs-wL5.js → util-8EHwfg4A.js} +1 -1
  290. package/dist/chunks/validatePlugin-6q1qmnAC.js +1 -0
  291. package/dist/chunks/{vim-C-icQDz1.js → vim-CNDzwoTd.js} +1 -1
  292. package/dist/chunks/{workerRegistry-ChqPPIaO.js → workerRegistry-CvyHvwx-.js} +1 -1
  293. package/dist/chunks/worktree-ogmNCIpz.js +1 -0
  294. package/dist/cli.js +1 -1
  295. package/package.json +1 -1
  296. package/dist/chunks/ApproveApiKey-a2ZonQ3n.js +0 -1
  297. package/dist/chunks/BackgroundTasksDialog-DNeBhGCf.js +0 -2
  298. package/dist/chunks/ClaudeMdExternalIncludesDialog-DFivNFuo.js +0 -1
  299. package/dist/chunks/ConsoleOAuthFlow-CS3zjEPF.js +0 -1
  300. package/dist/chunks/Doctor-BhD-ZzZm.js +0 -1
  301. package/dist/chunks/Doctor-DEQe2q16.js +0 -3
  302. package/dist/chunks/ExitFlow-BttnAv-O.js +0 -2
  303. package/dist/chunks/Grove-sWm-oLBf.js +0 -1
  304. package/dist/chunks/MCPConnectionManager-CNh9dNlk.js +0 -1
  305. package/dist/chunks/MessageSelector-DdR6wJhh.js +0 -3
  306. package/dist/chunks/Messages-Ch6cboMV.js +0 -11
  307. package/dist/chunks/PluginSettings-CGqEzejq.js +0 -17
  308. package/dist/chunks/QueryEngine-CZZMl3PB.js +0 -1
  309. package/dist/chunks/REPL-CG2N7E4Q.js +0 -142
  310. package/dist/chunks/REPL-DvA910N_.js +0 -1
  311. package/dist/chunks/ResumeConversation-DzV2zmuX.js +0 -1
  312. package/dist/chunks/SearchExtraToolsTool-C4uO-Zx3.js +0 -1
  313. package/dist/chunks/Settings-XKw6FI_m.js +0 -2
  314. package/dist/chunks/TrustDialog-DGJ_BisZ.js +0 -1
  315. package/dist/chunks/agents-BIHTGDYh.js +0 -103
  316. package/dist/chunks/allErrors-1896uQA1.js +0 -1
  317. package/dist/chunks/api-BsFW57_Q.js +0 -1
  318. package/dist/chunks/auth-8Vd3_U8t.js +0 -1
  319. package/dist/chunks/auth-DRTjfnGy.js +0 -1
  320. package/dist/chunks/autonomy-DGcy5Rml.js +0 -15
  321. package/dist/chunks/backgroundHousekeeping-3i_d_WW5.js +0 -1
  322. package/dist/chunks/backgroundHousekeeping-BVMf_Tjn.js +0 -17
  323. package/dist/chunks/bridgeConfig-CqIQ_rvD.js +0 -1
  324. package/dist/chunks/bridgeEnabled-D0XC5kNh.js +0 -1
  325. package/dist/chunks/bridgeMain-DHUpZFgL.js +0 -68
  326. package/dist/chunks/bridgeMain-DUbQjgCp.js +0 -1
  327. package/dist/chunks/caches-CWzT7e6Y.js +0 -1
  328. package/dist/chunks/client-BzKQTXzF.js +0 -1
  329. package/dist/chunks/commands-DDamMmo4.js +0 -1
  330. package/dist/chunks/commitAttribution-CgohL8vD.js +0 -1
  331. package/dist/chunks/compact-IFHwxjZ9.js +0 -2
  332. package/dist/chunks/config-DY5-_kk_.js +0 -1
  333. package/dist/chunks/config-WxgxrQoP.js +0 -1
  334. package/dist/chunks/context-noninteractive-Beij5MfU.js +0 -1
  335. package/dist/chunks/conversation-BBB91hEw.js +0 -1
  336. package/dist/chunks/conversation-BWVTM40Y.js +0 -1
  337. package/dist/chunks/createSession-CoQtL5Rj.js +0 -1
  338. package/dist/chunks/crossProjectResume-BasMLl2n.js +0 -40
  339. package/dist/chunks/doctor-1L0TFuGw.js +0 -1
  340. package/dist/chunks/envLessBridgeConfig-CN0_44-p.js +0 -1
  341. package/dist/chunks/envLessBridgeConfig-Ck2-KMq0.js +0 -1
  342. package/dist/chunks/exit-Bm1S_f3i.js +0 -1
  343. package/dist/chunks/extra-usage-UHAWtypK.js +0 -1
  344. package/dist/chunks/extractMemories-BcaklA33.js +0 -1
  345. package/dist/chunks/fast-DALAHO3d.js +0 -1
  346. package/dist/chunks/firstPartyEventLogger-CS9jVz6D.js +0 -1
  347. package/dist/chunks/generateRecap-jGDLI_wU.js +0 -1
  348. package/dist/chunks/generateSessionName-hDJ6HBJ1.js +0 -1
  349. package/dist/chunks/grok-Byblph7F.js +0 -1
  350. package/dist/chunks/hooks-DPLIIpAD.js +0 -1
  351. package/dist/chunks/inboundAttachments-BekVc0W-.js +0 -1
  352. package/dist/chunks/initReplBridge-JQ-afRx9.js +0 -1
  353. package/dist/chunks/language-Cqw5gYJR.js +0 -1
  354. package/dist/chunks/loadAgentsDir-TZjwTqdr.js +0 -1
  355. package/dist/chunks/loadPluginHooks-Ddhsyn0_.js +0 -1
  356. package/dist/chunks/localSearch-DrOAL6f4.js +0 -1
  357. package/dist/chunks/mcp-Bt1ITh-Z.js +0 -1
  358. package/dist/chunks/mcp-CwJ-AIpt.js +0 -6
  359. package/dist/chunks/mcp-W0LFoyFR.js +0 -2
  360. package/dist/chunks/memory-3wV7m7UU.js +0 -1
  361. package/dist/chunks/model-DRXcJyU9.js +0 -1
  362. package/dist/chunks/onChangeAppState-DBmy2Ow_.js +0 -1
  363. package/dist/chunks/permissions-BVSFuwNP.js +0 -3
  364. package/dist/chunks/pluginAutoupdate-reO2PgtQ.js +0 -1
  365. package/dist/chunks/pluginBlocklist-C3H2afWG.js +0 -1
  366. package/dist/chunks/pluginCliCommands-lqdxdkQp.js +0 -1
  367. package/dist/chunks/pluginOperations-EN3EKLux.js +0 -2
  368. package/dist/chunks/pluginStartupCheck-BY73BMT2.js +0 -1
  369. package/dist/chunks/pluginStartupCheck-CwWOlveD.js +0 -1
  370. package/dist/chunks/policyLimits-CkTI5KEt.js +0 -1
  371. package/dist/chunks/poorMode-V11s-3cf.js +0 -1
  372. package/dist/chunks/print-Db_VXmfO.js +0 -23
  373. package/dist/chunks/processBashCommand-BcM_fhV9.js +0 -1
  374. package/dist/chunks/processSlashCommand-DEVo3GPX.js +0 -5
  375. package/dist/chunks/prompt-CrX31AGm.js +0 -1
  376. package/dist/chunks/prompt-IAvMxKDl.js +0 -1
  377. package/dist/chunks/rate-limit-options-DIudL9fb.js +0 -1
  378. package/dist/chunks/reconciler-BXpPyfSY.js +0 -4
  379. package/dist/chunks/refresh-CuaVBIQ0.js +0 -1
  380. package/dist/chunks/remoteManagedSettings-Cq994lyc.js +0 -1
  381. package/dist/chunks/rename-Iev7wQsI.js +0 -1
  382. package/dist/chunks/sandbox-adapter-Cu1FYrkh.js +0 -1
  383. package/dist/chunks/searchExtraTools-BUOUds7p.js +0 -1
  384. package/dist/chunks/sessionFileAccessHooks-2cgIIxPk.js +0 -1
  385. package/dist/chunks/sessionMemory-BS8_TbKj.js +0 -1
  386. package/dist/chunks/sessionMemory-D5fSHXvZ.js +0 -1
  387. package/dist/chunks/sessionMemoryUtils-BWUztNh6.js +0 -1
  388. package/dist/chunks/sessionObserver-ChfQtK2m.js +0 -1
  389. package/dist/chunks/sessionStorage-Cf5wmnyB.js +0 -1
  390. package/dist/chunks/settings-BovzmwMP.js +0 -19
  391. package/dist/chunks/settingsSync-PqU9XGJq.js +0 -1
  392. package/dist/chunks/setup-B_FOvNpp.js +0 -3
  393. package/dist/chunks/sinks-BpcRrN_T.js +0 -1
  394. package/dist/chunks/skillChangeDetector-DNqohXxz.js +0 -1
  395. package/dist/chunks/skillLearning-C5cXZE6_.js +0 -1
  396. package/dist/chunks/statusNoticeHelpers-CzTuGNuC.js +0 -1
  397. package/dist/chunks/teleport-dtqQXM4x.js +0 -1
  398. package/dist/chunks/thinkback-Catprqs_.js +0 -1
  399. package/dist/chunks/thinkback-play-CqrIRx2o.js +0 -1
  400. package/dist/chunks/toolPool-B64V-jmK.js +0 -1
  401. package/dist/chunks/trustedDevice-CiwjT_Y6.js +0 -1
  402. package/dist/chunks/undercover-XYapZ_SS.js +0 -1
  403. package/dist/chunks/upgrade-DIg3j929.js +0 -1
  404. package/dist/chunks/usage-CYJKE8N6.js +0 -1
  405. package/dist/chunks/useMainLoopModel-XetDUXd-.js +0 -1
  406. package/dist/chunks/useManagePlugins-B2KhKiu5.js +0 -1
  407. package/dist/chunks/useMergedTools-CKvwz_Zt.js +0 -1
  408. package/dist/chunks/validatePlugin-DtiYlXby.js +0 -1
  409. package/dist/chunks/worktree-DAn8ooa1.js +0 -1
@@ -1 +0,0 @@
1
- import{t as e}from"./REPL-CG2N7E4Q.js";export{e as REPL};
@@ -1 +0,0 @@
1
- import{a as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,Wt as i,dr as a,fi as o,ot as ee,t as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{en as l,vr as te}from"./state-ix0xIunV.js";import{Fb as u,Hr as ne,Hy as d,Il as f,Jn as re,KS as ie,Nb as p,Nr as ae,RC as oe,US as m,Uy as h,Vl as se,WS as ce,aC as g,ar as le,fi as ue,jr as _,nd as de,op as v,pi as y,qr as b,rd as x,sp as S,ti as fe,zC as C}from"./loadAgentsDir-D206qwP3.js";import{o as w,s as T}from"./log-BMCygSzM.js";import{n as E,r as D}from"./analytics-BotDBGh0.js";import{u as O}from"./referral-CUaIo_vT.js";import{r as pe}from"./asciicast-CbAjUHT_.js";import{a as me,n as k,s as A}from"./skillChangeDetector-DNqohXxz.js";import{a as j,i as M,n as N,o as P,r as F,t as I}from"./crossProjectResume-BasMLl2n.js";import{t as L}from"./REPL-CG2N7E4Q.js";import{dirname as R}from"path";var z=t(o(),1);g(),l(),P(),u(),v(),s(),O(),E(),m(),C(),M(),f(),d(),N(),w(),_();var B=c();function he(e){let t=parseInt(e,10);if(!isNaN(t)&&t>0)return t;let n=e.match(/github\.com\/[^/]+\/[^/]+\/pull\/(\d+)/);return n?.[1]?parseInt(n[1],10):null}function V({commands:t,worktreePaths:i,initialTools:o,mcpClients:s,dynamicMcpConfig:c,debug:l,mainThreadAgentDefinition:u,autoConnectIdeFlag:d,strictMcpConfig:f=!1,systemPrompt:m,appendSystemPrompt:g,initialSearchQuery:_,disableSlashCommands:v=!1,forkSession:C,taskListId:w,filterByPr:E,thinkingConfig:O,onTurnComplete:M}){let{rows:N}=ee(),P=ce(e=>e.agentDefinitions),V=ie(),[H,U]=z.useState([]),[ve,W]=z.useState(!0),[ye,be]=z.useState(!1),[G,xe]=z.useState(!1),[K,q]=z.useState(null),[J,Se]=z.useState(null),Y=z.useRef(null),X=z.useRef(0),Z=z.useMemo(()=>{let e=H.filter(e=>!e.isSidechain);if(E!==void 0){if(E===!0)e=e.filter(e=>e.prNumber!==void 0);else if(typeof E==`number`)e=e.filter(e=>e.prNumber===E);else if(typeof E==`string`){let t=he(E);t!==null&&(e=e.filter(e=>e.prNumber===t))}}return e},[H,E]),Ce=ae();z.useEffect(()=>{b(i).then(e=>{Y.current=e,X.current=e.logs.length,U(e.logs),W(!1)}).catch(e=>{T(e),W(!1)})},[i]);let Q=z.useCallback(e=>{let t=Y.current;!t||t.nextIndex>=t.allStatLogs.length||le(t.allStatLogs,t.nextIndex,e).then(n=>{if(t.nextIndex=n.nextIndex,n.logs.length>0){let e=X.current;n.logs.forEach((t,n)=>{t.value=e+n}),U(e=>e.concat(n.logs)),X.current+=n.logs.length}else t.nextIndex<t.allStatLogs.length&&Q(e)})},[]),$=z.useCallback(e=>{W(!0),(e?ne():b(i)).then(e=>{Y.current=e,X.current=e.logs.length,U(e.logs)}).catch(e=>{T(e)}).finally(()=>{W(!1)})},[i]),we=z.useCallback(()=>{let e=!G;xe(e),$(e)},[G,$]);function Te(){process.exit(1)}async function Ee(t){be(!0);let n=performance.now(),r=I(t,G,i);if(r.isCrossProject&&!r.isSameRepoWorktree){let e=r.command,t=await a(e);t&&process.stdout.write(t),Se(e);return}try{let r=await h(t,void 0);if(!r)throw Error(`Failed to load conversation`);r.sessionId&&!C?(te(oe(r.sessionId),t.fullPath?R(t.fullPath):null),await pe(),await ue(),S(r.sessionId)):C&&r.contentReplacements?.length&&await fe(r.contentReplacements);let{agentDefinition:i}=me(r.agentSetting,u,P);V(e=>({...e,agent:i?.agentType}));let a=k(r.agentName,r.agentColor);if(a&&V(e=>({...e,standaloneAgentContext:a})),se(r.agentName),y(C?{...r,worktreeSession:void 0}:r),C||(A(r.worktreeSession),r.sessionId&&re()),r.goal&&r.sessionId){let{hydrateGoalFromTranscript:t}=(x(),e(de)),n=new Map;n.set(r.sessionId,r.goal),t(n,r.sessionId)}D(`tengu_session_resumed`,{entrypoint:`picker`,success:!0,resume_duration_ms:Math.round(performance.now()-n)}),U([]),q({messages:r.messages,fileHistorySnapshots:r.fileHistorySnapshots,contentReplacements:r.contentReplacements,agentName:r.agentName,agentColor:r.agentColor==="default"?void 0:r.agentColor,mainThreadAgentDefinition:i})}catch(e){throw D(`tengu_session_resumed`,{entrypoint:`picker`,success:!1}),T(e),e}}return J?(0,B.jsx)(_e,{command:J}):K?(0,B.jsx)(L,{debug:l,commands:t,initialTools:o,initialMessages:K.messages,initialFileHistorySnapshots:K.fileHistorySnapshots,initialContentReplacements:K.contentReplacements,initialAgentName:K.agentName,initialAgentColor:K.agentColor,mcpClients:s,dynamicMcpConfig:c,strictMcpConfig:f,systemPrompt:m,appendSystemPrompt:g,mainThreadAgentDefinition:K.mainThreadAgentDefinition,autoConnectIdeFlag:d,disableSlashCommands:v,taskListId:w,thinkingConfig:O,onTurnComplete:M}):ve?(0,B.jsxs)(n,{children:[(0,B.jsx)(p,{}),(0,B.jsx)(r,{children:` Loading conversations…`})]}):ye?(0,B.jsxs)(n,{children:[(0,B.jsx)(p,{}),(0,B.jsx)(r,{children:` Resuming conversation…`})]}):Z.length===0?(0,B.jsx)(ge,{}):(0,B.jsx)(j,{logs:Z,maxHeight:N,onCancel:Te,onSelect:Ee,onLogsChanged:Ce?()=>$(G):void 0,onLoadMore:Q,initialSearchQuery:_,showAllProjects:G,onToggleAllProjects:we,onAgenticSearch:F})}function ge(){return i(`app:interrupt`,()=>{process.exit(1)},{context:`Global`}),(0,B.jsxs)(n,{flexDirection:`column`,children:[(0,B.jsx)(r,{children:`No conversations found to resume.`}),(0,B.jsx)(r,{dimColor:!0,children:`Press Ctrl+C to exit and start a new conversation.`})]})}function _e({command:e}){return z.useEffect(()=>{let e=setTimeout(()=>{process.exit(0)},100);return()=>clearTimeout(e)},[]),(0,B.jsxs)(n,{flexDirection:`column`,gap:1,children:[(0,B.jsx)(r,{children:`This conversation is from a different directory.`}),(0,B.jsxs)(n,{flexDirection:`column`,children:[(0,B.jsx)(r,{children:`To resume, run:`}),(0,B.jsxs)(r,{children:[` `,e]})]}),(0,B.jsx)(r,{dimColor:!0,children:`(Command copied to clipboard)`})]})}export{V as ResumeConversation};
@@ -1 +0,0 @@
1
- import{iE as e,rE as t}from"./loadAgentsDir-D206qwP3.js";e();export{t as clearSearchExtraToolsDescriptionCache};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{d as r,l as i,o as a}from"./envUtils-DSxRz_kt.js";import{n as o,t as s}from"./figures-5ThXQEtq.js";import{D as c,Gt as l,H as u,I as d,P as f,T as p,U as ee,Wt as te,Xn as ne,a as re,d as ie,di as m,fi as h,k as ae,n as oe,ot as se,r as ce,t as g,ui as _,x as v,y as le}from"./src-CDCSSo0U2.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{en as b,gr as ue,ht as x,qt as de}from"./state-ix0xIunV.js";import{BE as fe,C as S,Dg as pe,Eg as me,F as he,Fx as C,GS as ge,Hx as _e,KS as ve,LE as ye,Px as be,S as xe,Sx as w,US as Se,Ux as Ce,VE as we,WS as T,aC as E,af as Te,ah as Ee,as as D,fx as O,if as De,is as k,jg as Oe,jr as A,mr as ke,mx as Ae,oh as je,op as j,os as M,px as Me,rp as Ne,v as Pe,xx as N,zE as Fe}from"./loadAgentsDir-D206qwP3.js";import{n as Ie,t as Le}from"./cwd-CYmmnQVS.js";import{S as Re,w as ze}from"./debug-BrXObCdR.js";import{Ft as Be,Ht as Ve,Lt as He,Rt as Ue,c as We,g as P,n as Ge,y as F,zt as Ke}from"./settings-BovzmwMP.js";import{a as qe,b as I,c as L,g as Je,i as Ye,m as Xe,o as Ze}from"./config-DmomySWC.js";import{o as R,s as Qe}from"./log-BMCygSzM.js";import{n as $e,r as z}from"./analytics-BotDBGh0.js";import{b as et,g as tt}from"./startupProfiler-xa3NmN7Z.js";import{r as nt}from"./permissions-Cn_6f8CB.js";import{Bt as rt,Ft as it,G as at,K as ot,Tr as st,_ as ct,b as lt,et as ut,it as dt,q as ft,rt as pt,tt as mt,wr as B,x as ht}from"./model-CKkOnnnx.js";import{r as gt,t as _t}from"./poorMode-DhzFKpPl.js";import{u as vt}from"./referral-CUaIo_vT.js";import{i as yt,r as bt}from"./bridgeEnabled-SbB-6zdY.js";import{a as V,c as H,d as U,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as W}from"./status-BnJIXtKl.js";import{n as Ot,t as kt}from"./useExitOnCtrlCDWithKeybindings-DKIqRraH.js";import{i as At,n as G,r as jt}from"./modalContext-DFjKLCB6.js";import{n as Mt,t as Nt}from"./ThemePicker-BViWzLp3.js";import{i as Pt,n as Ft,r as It,t as Lt}from"./extraUsage-Dq66zzqR.js";import{n as Rt,t as zt}from"./ClaudeMdExternalIncludesDialog-BD-7yAZh.js";import{t as Bt}from"./SearchBox-vfLXEPed.js";import{n as Vt,t as Ht}from"./useSearchInput-D1Vr2Js1.js";import{n as Ut,t as Wt}from"./usage-C0SnnC-i.js";import{a as Gt,i as Kt,t as qt}from"./OverageCreditUpsell-Ds1cB7RC.js";function Jt(){let e=x();return[{label:`Version`,value:`0.0.6`},{label:`Session name`,value:ke(e)??(0,K.jsx)(f,{dimColor:!0,children:`/rename to add a name`})},{label:`Session ID`,value:e},{label:`cwd`,value:Le()},...Ct(),...Dt()]}function Yt({mainLoopModel:e,mcp:t,theme:n,context:r}){return[{label:`Model`,value:W(e)},...Tt(t.clients,r.options.ideInstallationStatus,n),...wt(t.clients,n),...H(),...St()]}async function Xt(){return[...await xt(),...await V(),...await Et()]}function Zt({value:e}){return Array.isArray(e)?(0,K.jsx)(d,{flexWrap:`wrap`,columnGap:1,flexShrink:99,children:e.map((t,n)=>(0,K.jsxs)(f,{children:[t,n<e.length-1?`,`:``]},n))}):typeof e==`string`?(0,K.jsx)(f,{children:e}):e}function Qt({context:e,diagnosticsPromise:t}){let n=T(e=>e.mainLoopModel),r=T(e=>e.mcp),[i]=u(),a=en.useMemo(()=>[Jt(),Yt({mainLoopModel:n,mcp:r,theme:i,context:e})],[n,r,i,e]),o=jt()?1:void 0;return(0,K.jsxs)(d,{flexDirection:`column`,flexGrow:o,children:[(0,K.jsxs)(d,{flexDirection:`column`,gap:1,flexGrow:o,children:[a.map((e,t)=>e.length>0&&(0,K.jsx)(d,{flexDirection:`column`,children:e.map(({label:e,value:t},n)=>(0,K.jsxs)(d,{flexDirection:`row`,gap:1,flexShrink:0,children:[e!==void 0&&(0,K.jsxs)(f,{bold:!0,children:[e,`:`]}),(0,K.jsx)(Zt,{value:t})]},n))},t)),(0,K.jsx)(tn.Suspense,{fallback:null,children:(0,K.jsx)($t,{promise:t})})]}),(0,K.jsx)(f,{dimColor:!0,children:(0,K.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})})]})}function $t({promise:e}){let t=(0,tn.use)(e);return t.length===0?null:(0,K.jsxs)(d,{flexDirection:`column`,paddingBottom:1,children:[(0,K.jsx)(f,{bold:!0,children:`System Diagnostics`}),t.map((e,t)=>(0,K.jsxs)(d,{flexDirection:`row`,gap:1,paddingX:1,children:[(0,K.jsx)(f,{color:`error`,children:s.warning}),typeof e==`string`?(0,K.jsx)(f,{wrap:`wrap`,children:e}):e]},t))]})}var en,tn,K,nn=t((()=>{o(),en=n(h(),1),tn=n(h(),1),b(),G(),g(),Se(),Ie(),A(),U(),w(),K=y()}));function rn({currentVersion:e,onChoice:t}){function n(e){t(e)}function r(){t(`cancel`)}return(0,an.jsxs)(le,{title:`Switch to Stable Channel`,onCancel:r,color:`permission`,hideBorder:!0,hideInputGuide:!0,children:[(0,an.jsxs)(f,{children:[`The stable channel may have an older version than what you're currently running (`,e,`).`]}),(0,an.jsx)(f,{dimColor:!0,children:`How would you like to handle this?`}),(0,an.jsx)(Me,{options:[{label:`Allow possible downgrade to stable version`,value:`downgrade`},{label:`Stay on current version (${e}) until stable catches up`,value:`stay`}],onChange:n})]})}var an,on=t((()=>{h(),g(),O(),an=y()}));function sn(e){return Object.entries(e).map(([e,t])=>({label:t?.name??un,value:e,description:t?.description??dn}))}function cn({initialStyle:e,onComplete:t,onCancel:n,isStandaloneCommand:r}){let[i,a]=(0,ln.useState)([]),[o,s]=(0,ln.useState)(!0);(0,ln.useEffect)(()=>{D(Le()).then(e=>{let t=sn(e);a(t),s(!1)}).catch(()=>{let e=sn(k);a(e),s(!1)})},[]);let c=(0,ln.useCallback)(e=>{t(e)},[t]);return(0,q.jsx)(le,{title:`Preferred output style`,onCancel:n,hideInputGuide:!r,hideBorder:!r,children:(0,q.jsxs)(d,{flexDirection:`column`,gap:1,children:[(0,q.jsx)(d,{marginTop:1,children:(0,q.jsx)(f,{dimColor:!0,children:`This changes how Claude Code communicates with you`})}),o?(0,q.jsx)(f,{dimColor:!0,children:`Loading output styles…`}):(0,q.jsx)(Me,{options:i,onChange:c,visibleOptionCount:10,defaultValue:e})]})})}var ln,q,un,dn,fn=t((()=>{h(),ln=n(h(),1),M(),g(),Ie(),Ae(),q=y(),un=`Default`,dn=`Claude completes coding tasks efficiently and provides concise responses`}));function pn({initialLanguage:e,onComplete:t,onCancel:n}){let[r,i]=(0,mn.useState)(e),[a,o]=(0,mn.useState)((e??``).length);te(`confirm:no`,n,{context:`Settings`});function c(){let e=r?.trim();t(e||void 0)}return(0,J.jsxs)(d,{flexDirection:`column`,gap:1,children:[(0,J.jsx)(f,{children:`Enter your preferred response and voice language:`}),(0,J.jsxs)(d,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(f,{children:s.pointer}),(0,J.jsx)(be,{value:r??``,onChange:i,onSubmit:c,focus:!0,showCursor:!0,placeholder:`e.g., Japanese, 日本語, Español${s.ellipsis}`,columns:60,cursorOffset:a,onChangeCursorOffset:o})]}),(0,J.jsx)(f,{dimColor:!0,children:`Leave empty for default (English)`})]})}var mn,J,hn=t((()=>{o(),mn=n(h(),1),g(),vt(),C(),J=y()}));function gn({onClose:t,context:n,setTabsHidden:a,onIsSearchModeChange:o,contentHeight:ie}){let{headerFocused:m,focusHeader:h}=re(),oe=jt(),[,ce]=u(),g=ee(),[v,y]=(0,X.useState)(L()),b=Y.useRef(L()),[x,S]=(0,X.useState)(Ge()),pe=Y.useRef(Ge()),[C,_e]=(0,X.useState)(x?.outputStyle||`default`),be=Y.useRef(C),[w,Se]=(0,X.useState)(x?.language),we=Y.useRef(w),[E,Ee]=(0,X.useState)(0),[D,O]=(0,X.useState)(0),[k,A]=(0,X.useState)(!1),ke=ne(),{rows:Ae}=se(),je=ie??Math.min(Math.floor(Ae*.8),30),j=Math.max(5,je-10),M=T(e=>e.mainLoopModel),Ne=T(e=>e.verbose),Ie=T(e=>e.thinkingEnabled),Le=T(e=>pt()?e.fastMode:!1);T(e=>e.promptSuggestionEnabled);let Re=Ue(x?.permissions?.defaultMode??`default`),ze=xe()||Pe()===`enabled`,Be=(Te(),e(De)).isBriefEntitled(),P=ve(),[Je,R]=(0,X.useState)({}),$e=Y.useRef(Ie),[et]=(0,X.useState)(()=>We(`localSettings`)),[tt]=(0,X.useState)(()=>We(`userSettings`)),rt=Y.useRef(g),it=ge(),[ct]=(0,X.useState)(()=>{let e=it.getState();return{mainLoopModel:e.mainLoopModel,mainLoopModelForSession:e.mainLoopModelForSession,verbose:e.verbose,thinkingEnabled:e.thinkingEnabled,fastMode:e.fastMode,promptSuggestionEnabled:e.promptSuggestionEnabled,isBriefOnly:e.isBriefOnly,replBridgeEnabled:e.replBridgeEnabled,replBridgeOutboundOnly:e.replBridgeOutboundOnly,settings:e.settings}}),[ut]=(0,X.useState)(()=>de()),B=Y.useRef(!1),[vt,bt]=(0,X.useState)(!1),[V,H]=(0,X.useState)(null),{query:U,setQuery:xt,cursorOffset:St}=Vt({isActive:k&&V===null&&!m,onExit:()=>A(!1),onExitUp:h,passthroughCtrlKeys:[`c`,`d`]}),Ct=k&&!m;Y.useEffect(()=>{o?.(Ct)},[Ct,o]);let wt=me(n.options.mcpClients),Tt=!i(process.env.CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING),Et=Y.use(Fe(!0)),Dt=fe(Et),W=qe();function Ot(e){z(`tengu_config_model_changed`,{from_model:M,to_model:e}),P(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null})),R(t=>{let n=ht(e)+(Ft(e,!1,lt())?` · Billed as extra usage`:``);if(`model`in t){let{model:e,...r}=t;return{...r,model:n}}return{...t,model:n}})}function kt(e){I(t=>({...t,verbose:e})),y({...L(),verbose:e}),P(t=>({...t,verbose:e})),R(t=>{if(`verbose`in t){let{verbose:e,...n}=t;return n}return{...t,verbose:e}})}let At=[{id:`autoCompactEnabled`,label:`Auto-compact`,value:v.autoCompactEnabled,type:`boolean`,onChange(e){I(t=>({...t,autoCompactEnabled:e})),y({...L(),autoCompactEnabled:e}),z(`tengu_auto_compact_setting_changed`,{enabled:e})}},{id:`spinnerTipsEnabled`,label:`Show tips`,value:x?.spinnerTipsEnabled??!0,type:`boolean`,onChange(e){F(`localSettings`,{spinnerTipsEnabled:e}),S(t=>({...t,spinnerTipsEnabled:e})),z(`tengu_tips_setting_changed`,{enabled:e})}},{id:`cacheWarningEnabled`,label:`Cache warnings`,value:x?.cacheWarningEnabled??!0,type:`boolean`,onChange(e){F(`localSettings`,{cacheWarningEnabled:e}),S(t=>({...t,cacheWarningEnabled:e})),z(`tengu_cache_warning_setting_changed`,{enabled:e})}},{id:`prefersReducedMotion`,label:`Reduce motion`,value:x?.prefersReducedMotion??!1,type:`boolean`,onChange(e){F(`localSettings`,{prefersReducedMotion:e}),S(t=>({...t,prefersReducedMotion:e})),P(t=>({...t,settings:{...t.settings,prefersReducedMotion:e}})),z(`tengu_reduce_motion_setting_changed`,{enabled:e})}},{id:`thinkingEnabled`,label:`Thinking mode`,value:Ie??!0,type:`boolean`,onChange(e){P(t=>({...t,thinkingEnabled:e})),F(`userSettings`,{alwaysThinkingEnabled:e?void 0:!1}),z(`tengu_thinking_toggled`,{enabled:e})}},...pt()&&mt()?[{id:`fastMode`,label:`Fast mode (${at} only)`,value:!!Le,type:`boolean`,onChange(e){ot(),F(`userSettings`,{fastMode:e?!0:void 0}),e?(P(e=>({...e,mainLoopModel:ft(),mainLoopModelForSession:null,fastMode:!0})),R(e=>({...e,model:ft(),"Fast mode":`ON`}))):(P(e=>({...e,fastMode:!1})),R(e=>({...e,"Fast mode":`OFF`})))}}]:[],{id:`poorMode`,label:`Poor mode (save tokens)`,value:(_t(),e(gt)).isPoorModeActive(),type:`boolean`,onChange(t){(_t(),e(gt)).setPoorMode(t),P(e=>({...e,promptSuggestionEnabled:!t}))}},...process.env.USER_TYPE===`ant`?[{id:`speculationEnabled`,label:`Speculative execution`,value:v.speculationEnabled??!0,type:`boolean`,onChange(e){I(t=>t.speculationEnabled===e?t:{...t,speculationEnabled:e}),y({...L(),speculationEnabled:e}),z(`tengu_speculation_setting_changed`,{enabled:e})}}]:[],...Tt?[{id:`fileCheckpointingEnabled`,label:`Rewind code (checkpoints)`,value:v.fileCheckpointingEnabled,type:`boolean`,onChange(e){I(t=>({...t,fileCheckpointingEnabled:e})),y({...L(),fileCheckpointingEnabled:e}),z(`tengu_file_history_snapshots_setting_changed`,{enabled:e})}}]:[],{id:`verbose`,label:`Verbose output`,value:Ne,type:`boolean`,onChange:kt},{id:`terminalProgressBarEnabled`,label:`Terminal progress bar`,value:v.terminalProgressBarEnabled,type:`boolean`,onChange(e){I(t=>({...t,terminalProgressBarEnabled:e})),y({...L(),terminalProgressBarEnabled:e}),z(`tengu_terminal_progress_bar_setting_changed`,{enabled:e})}},{id:`showTurnDuration`,label:`Show turn duration`,value:v.showTurnDuration,type:`boolean`,onChange(e){I(t=>({...t,showTurnDuration:e})),y({...L(),showTurnDuration:e}),z(`tengu_show_turn_duration_setting_changed`,{enabled:e})}},{id:`defaultPermissionMode`,label:`Default permission mode`,value:Re,options:(()=>{let e=[`default`,`plan`];return[...e,...nt.filter(t=>!e.includes(t))]})(),type:`enum`,onChange(e){let t=Ue(e),n=t===`auto`?t:He(t)?Ve(t):t,r=F(`userSettings`,{permissions:{...x?.permissions,defaultMode:n}});if(r.error){Qe(r.error);return}S(e=>({...e,permissions:{...e?.permissions,defaultMode:n}})),R(t=>({...t,defaultPermissionMode:e})),z(`tengu_config_changed`,{setting:`defaultPermissionMode`,value:e})}},...ze?[{id:`useAutoModeDuringPlan`,label:`Use auto mode during plan`,value:x?.useAutoModeDuringPlan??!0,type:`boolean`,onChange(e){F(`userSettings`,{useAutoModeDuringPlan:e}),S(t=>({...t,useAutoModeDuringPlan:e})),P(e=>{let t=he(e.toolPermissionContext);return t===e.toolPermissionContext?e:{...e,toolPermissionContext:t}}),R(t=>({...t,"Use auto mode during plan":e}))}}]:[],{id:`respectGitignore`,label:`Respect .gitignore in file picker`,value:v.respectGitignore,type:`boolean`,onChange(e){I(t=>({...t,respectGitignore:e})),y({...L(),respectGitignore:e}),z(`tengu_respect_gitignore_setting_changed`,{enabled:e})}},...Ce()?[{id:`copyOnSelect`,label:`Copy on select`,value:v.copyOnSelect??!0,type:`boolean`,onChange(e){I(t=>({...t,copyOnSelect:e})),y({...L(),copyOnSelect:e}),z(`tengu_config_changed`,{setting:`copyOnSelect`,value:String(e)})}}]:[],W?{id:`autoUpdatesChannel`,label:`Auto-update channel`,value:`disabled`,type:`managedEnum`,onChange(){}}:{id:`autoUpdatesChannel`,label:`Auto-update channel`,value:x?.autoUpdatesChannel??`latest`,type:`managedEnum`,onChange(){}},{id:`theme`,label:`Theme`,value:g,type:`managedEnum`,onChange:ce},{id:`notifChannel`,label:`Local notifications`,value:v.preferredNotifChannel,options:[`auto`,`iterm2`,`terminal_bell`,`iterm2_with_bell`,`kitty`,`ghostty`,`notifications_disabled`],type:`enum`,onChange(e){I(t=>({...t,preferredNotifChannel:e})),y({...L(),preferredNotifChannel:e})}},{id:`taskCompleteNotifEnabled`,label:`Push when idle`,value:v.taskCompleteNotifEnabled??!1,type:`boolean`,onChange(e){I(t=>({...t,taskCompleteNotifEnabled:e})),y({...L(),taskCompleteNotifEnabled:e})}},{id:`inputNeededNotifEnabled`,label:`Push when input needed`,value:v.inputNeededNotifEnabled??!1,type:`boolean`,onChange(e){I(t=>({...t,inputNeededNotifEnabled:e})),y({...L(),inputNeededNotifEnabled:e})}},{id:`agentPushNotifEnabled`,label:`Push when Claude decides`,value:v.agentPushNotifEnabled??!1,type:`boolean`,onChange(e){I(t=>({...t,agentPushNotifEnabled:e})),y({...L(),agentPushNotifEnabled:e})}},{id:`outputStyle`,label:`Output style`,value:C,type:`managedEnum`,onChange:()=>{}},...Be?[{id:`defaultView`,label:`What you see by default`,value:x?.defaultView===void 0?`default`:String(x.defaultView),options:[`transcript`,`chat`,`default`],type:`enum`,onChange(e){let t=e==="default"?void 0:e;F(`localSettings`,{defaultView:t}),S(e=>({...e,defaultView:t}));let n=t===`chat`;P(e=>e.isBriefOnly===n?e:{...e,isBriefOnly:n}),ue(n),R(t=>({...t,"Default view":e})),z(`tengu_default_view_setting_changed`,{value:t??`unset`})}}]:[],{id:`language`,label:`Language`,value:w??`Default (English)`,type:`managedEnum`,onChange:()=>{}},{id:`editorMode`,label:`Editor mode`,value:v.editorMode===`emacs`?`normal`:v.editorMode||`normal`,options:[`normal`,`vim`],type:`enum`,onChange(e){I(t=>({...t,editorMode:e})),y({...L(),editorMode:e}),z(`tengu_editor_mode_changed`,{mode:e,source:`config_panel`})}},{id:`prStatusFooterEnabled`,label:`Show PR status footer`,value:v.prStatusFooterEnabled??!0,type:`boolean`,onChange(e){I(t=>t.prStatusFooterEnabled===e?t:{...t,prStatusFooterEnabled:e}),y({...L(),prStatusFooterEnabled:e}),z(`tengu_pr_status_footer_setting_changed`,{enabled:e})}},{id:`model`,label:`Model`,value:M===null?`Default (recommended)`:M,type:`managedEnum`,onChange:Ot},...wt?[{id:`diffTool`,label:`Diff tool`,value:v.diffTool??`auto`,options:[`terminal`,`auto`],type:`enum`,onChange(e){I(t=>({...t,diffTool:e})),y({...L(),diffTool:e}),z(`tengu_diff_tool_changed`,{tool:e,source:`config_panel`})}}]:[],...Oe()?[]:[{id:`autoConnectIde`,label:`Auto-connect to IDE (external terminal)`,value:v.autoConnectIde??!1,type:`boolean`,onChange(e){I(t=>({...t,autoConnectIde:e})),y({...L(),autoConnectIde:e}),z(`tengu_auto_connect_ide_changed`,{enabled:e,source:`config_panel`})}}],...Oe()?[{id:`autoInstallIdeExtension`,label:`Auto-install IDE extension`,value:v.autoInstallIdeExtension??!0,type:`boolean`,onChange(e){I(t=>({...t,autoInstallIdeExtension:e})),y({...L(),autoInstallIdeExtension:e}),z(`tengu_auto_install_ide_extension_changed`,{enabled:e,source:`config_panel`})}}]:[],...yt()?[{id:`remoteControlAtStartup`,label:`Enable Remote Control for all sessions`,value:v.remoteControlAtStartup===void 0?`default`:String(v.remoteControlAtStartup),options:[`true`,`false`,`default`],type:`enum`,onChange(e){if(e==="default")I(e=>{if(e.remoteControlAtStartup===void 0)return e;let t={...e};return delete t.remoteControlAtStartup,t}),y({...L(),remoteControlAtStartup:void 0});else{let t=e===`true`;I(e=>e.remoteControlAtStartup===t?e:{...e,remoteControlAtStartup:t}),y({...L(),remoteControlAtStartup:t})}let t=Xe();P(e=>e.replBridgeEnabled===t&&!e.replBridgeOutboundOnly?e:{...e,replBridgeEnabled:t,replBridgeOutboundOnly:!1})}}]:[],...Dt?[{id:`showExternalIncludesDialog`,label:`External CLAUDE.md includes`,value:Ze().hasClaudeMdExternalIncludesApproved?`true`:`false`,type:`managedEnum`,onChange(){}}]:[],...process.env.ANTHROPIC_API_KEY&&!r()?[{id:`apiKey`,label:(0,Z.jsxs)(f,{children:[`Use custom API key: `,(0,Z.jsx)(f,{bold:!0,children:st(process.env.ANTHROPIC_API_KEY)})]}),searchText:`Use custom API key`,value:!!(process.env.ANTHROPIC_API_KEY&&v.customApiKeyResponses?.approved?.includes(st(process.env.ANTHROPIC_API_KEY))),type:`boolean`,onChange(e){I(t=>{let n={...t};if(n.customApiKeyResponses||(n.customApiKeyResponses={approved:[],rejected:[]}),n.customApiKeyResponses.approved||(n.customApiKeyResponses={...n.customApiKeyResponses,approved:[]}),n.customApiKeyResponses.rejected||(n.customApiKeyResponses={...n.customApiKeyResponses,rejected:[]}),process.env.ANTHROPIC_API_KEY){let t=st(process.env.ANTHROPIC_API_KEY);e?n.customApiKeyResponses={...n.customApiKeyResponses,approved:[...(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),t],rejected:(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t)}:n.customApiKeyResponses={...n.customApiKeyResponses,approved:(n.customApiKeyResponses.approved??[]).filter(e=>e!==t),rejected:[...(n.customApiKeyResponses.rejected??[]).filter(e=>e!==t),t]}}return n}),y(L())}}]:[]],G=Y.useMemo(()=>{if(!U)return At;let e=U.toLowerCase();return At.filter(t=>t.id.toLowerCase().includes(e)?!0:(`searchText`in t?t.searchText:t.label).toLowerCase().includes(e))},[At,U]);Y.useEffect(()=>{if(E>=G.length){let e=Math.max(0,G.length-1);Ee(e),O(Math.max(0,e-j+1));return}O(e=>E<e?E:E>=e+j?E-j+1:e)},[G.length,E,j]);let Mt=(0,X.useCallback)(e=>{O(t=>e<t?e:e>=t+j?e-j+1:t)},[j]),Pt=(0,X.useCallback)(()=>{if(V!==null)return;let e=Object.entries(Je).map(([e,t])=>(z(`tengu_config_changed`,{key:e,value:t}),`Set ${e} to ${_.bold(t)}`)),n=r()?void 0:process.env.ANTHROPIC_API_KEY,i=!!(n&&b.current.customApiKeyResponses?.approved?.includes(st(n))),a=!!(n&&v.customApiKeyResponses?.approved?.includes(st(n)));if(i!==a&&(e.push(`${a?`Enabled`:`Disabled`} custom API key`),z(`tengu_config_changed`,{key:`env.ANTHROPIC_API_KEY`,value:a})),v.theme!==b.current.theme&&e.push(`Set theme to ${_.bold(v.theme)}`),v.preferredNotifChannel!==b.current.preferredNotifChannel&&e.push(`Set notifications to ${_.bold(v.preferredNotifChannel)}`),C!==be.current&&e.push(`Set output style to ${_.bold(C)}`),w!==we.current&&e.push(`Set response language to ${_.bold(w??`Default (English)`)}`),v.editorMode!==b.current.editorMode&&e.push(`Set editor mode to ${_.bold(v.editorMode||`emacs`)}`),v.diffTool!==b.current.diffTool&&e.push(`Set diff tool to ${_.bold(v.diffTool)}`),v.autoConnectIde!==b.current.autoConnectIde&&e.push(`${v.autoConnectIde?`Enabled`:`Disabled`} auto-connect to IDE`),v.autoInstallIdeExtension!==b.current.autoInstallIdeExtension&&e.push(`${v.autoInstallIdeExtension?`Enabled`:`Disabled`} auto-install IDE extension`),v.autoCompactEnabled!==b.current.autoCompactEnabled&&e.push(`${v.autoCompactEnabled?`Enabled`:`Disabled`} auto-compact`),v.respectGitignore!==b.current.respectGitignore&&e.push(`${v.respectGitignore?`Enabled`:`Disabled`} respect .gitignore in file picker`),v.copyOnSelect!==b.current.copyOnSelect&&e.push(`${v.copyOnSelect?`Enabled`:`Disabled`} copy on select`),v.terminalProgressBarEnabled!==b.current.terminalProgressBarEnabled&&e.push(`${v.terminalProgressBarEnabled?`Enabled`:`Disabled`} terminal progress bar`),v.showStatusInTerminalTab!==b.current.showStatusInTerminalTab&&e.push(`${v.showStatusInTerminalTab?`Enabled`:`Disabled`} terminal tab status`),v.showTurnDuration!==b.current.showTurnDuration&&e.push(`${v.showTurnDuration?`Enabled`:`Disabled`} turn duration`),v.remoteControlAtStartup!==b.current.remoteControlAtStartup){let t=v.remoteControlAtStartup===void 0?`Reset Remote Control to default`:`${v.remoteControlAtStartup?`Enabled`:`Disabled`} Remote Control for all sessions`;e.push(t)}x?.autoUpdatesChannel!==pe.current?.autoUpdatesChannel&&e.push(`Set auto-update channel to ${_.bold(x?.autoUpdatesChannel??`latest`)}`),e.length>0?t(e.join(`
2
- `)):t(`Config dialog dismissed`,{display:`system`})},[V,Je,v,M,C,w,x?.autoUpdatesChannel,pt()?x?.fastMode:void 0,t]),Lt=(0,X.useCallback)(()=>{g!==rt.current&&ce(rt.current),I(()=>b.current);let e=et;F(`localSettings`,{spinnerTipsEnabled:e?.spinnerTipsEnabled,prefersReducedMotion:e?.prefersReducedMotion,defaultView:e?.defaultView,outputStyle:e?.outputStyle});let t=tt;F(`userSettings`,{alwaysThinkingEnabled:t?.alwaysThinkingEnabled,fastMode:t?.fastMode,promptSuggestionEnabled:t?.promptSuggestionEnabled,autoUpdatesChannel:t?.autoUpdatesChannel,minimumVersion:t?.minimumVersion,language:t?.language,useAutoModeDuringPlan:t?.useAutoModeDuringPlan,syntaxHighlightingDisabled:t?.syntaxHighlightingDisabled,permissions:t?.permissions===void 0?void 0:{...t.permissions,defaultMode:t.permissions.defaultMode}});let n=ct;P(e=>({...e,mainLoopModel:n.mainLoopModel,mainLoopModelForSession:n.mainLoopModelForSession,verbose:n.verbose,thinkingEnabled:n.thinkingEnabled,fastMode:n.fastMode,promptSuggestionEnabled:n.promptSuggestionEnabled,isBriefOnly:n.isBriefOnly,replBridgeEnabled:n.replBridgeEnabled,replBridgeOutboundOnly:n.replBridgeOutboundOnly,settings:n.settings,toolPermissionContext:he(e.toolPermissionContext)})),de()!==ut&&ue(ut)},[g,ce,et,tt,ct,ut,P]);te(`confirm:no`,(0,X.useCallback)(()=>{V===null&&(B.current&&Lt(),t(`Config dialog dismissed`,{display:`system`}))},[V,Lt,t]),{context:`Settings`,isActive:V===null&&!k&&!m}),te(`settings:close`,Pt,{context:`Settings`,isActive:V===null&&!k&&!m});let Rt=(0,X.useCallback)(()=>{let e=G[E];if(!(!e||!e.onChange)){if(e.type===`boolean`){B.current=!0,e.onChange(!e.value),e.id===`thinkingEnabled`&&(!e.value===$e.current?bt(!1):n.messages.some(e=>e.type===`assistant`)&&bt(!0));return}if(e.id===`theme`||e.id===`model`||e.id===`showExternalIncludesDialog`||e.id===`outputStyle`||e.id===`language`)switch(e.id){case`theme`:H(`Theme`),a(!0);return;case`model`:H(`Model`),a(!0);return;case`showExternalIncludesDialog`:H(`ExternalIncludes`),a(!0);return;case`outputStyle`:H(`OutputStyle`),a(!0);return;case`language`:H(`Language`),a(!0);return}if(e.id===`autoUpdatesChannel`){if(W){H(`EnableAutoUpdates`),a(!0);return}(x?.autoUpdatesChannel??`latest`)===`latest`?(H(`ChannelDowngrade`),a(!0)):(B.current=!0,F(`userSettings`,{autoUpdatesChannel:`latest`,minimumVersion:void 0}),S(e=>({...e,autoUpdatesChannel:`latest`,minimumVersion:void 0})),z(`tengu_autoupdate_channel_changed`,{channel:`latest`}));return}if(e.type===`enum`){B.current=!0;let t=(e.options.indexOf(e.value)+1)%e.options.length;e.onChange(e.options[t]);return}}},[W,G,E,x?.autoUpdatesChannel,a]),Bt=e=>{bt(!1);let t=Math.max(0,Math.min(G.length-1,E+e));Ee(t),Mt(t)};return l({"select:previous":()=>{E===0?(bt(!1),A(!0),O(0)):Bt(-1)},"select:next":()=>Bt(1),"scroll:lineUp":()=>Bt(-1),"scroll:lineDown":()=>Bt(1),"select:accept":Rt,"select:previousValue":()=>Rt(),"select:nextValue":()=>Rt(),"settings:search":()=>{A(!0),xt(``)}},{context:`Settings`,isActive:V===null&&!k&&!m}),(0,Z.jsx)(d,{flexDirection:`column`,width:`100%`,tabIndex:0,autoFocus:!0,onKeyDown:(0,X.useCallback)(e=>{if(V===null&&!m){if(k){if(e.key===`escape`){e.preventDefault(),U.length>0?xt(``):A(!1);return}(e.key===`return`||e.key===`down`||e.key===`wheeldown`)&&(e.preventDefault(),A(!1),Ee(0),O(0));return}if(e.key===`left`||e.key===`right`||e.key===`tab`){e.preventDefault(),Rt();return}e.ctrl||e.meta||e.key===`j`||e.key===`k`||e.key===`/`||e.key.length===1&&e.key!==` `&&(e.preventDefault(),A(!0),xt(e.key))}},[V,m,k,U,xt,Rt]),children:V===`Theme`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Nt,{onThemeSelect:e=>{B.current=!0,ce(e),H(null),a(!1)},onCancel:()=>{H(null),a(!1)},hideEscToCancel:!0,skipExitHandling:!0}),(0,Z.jsx)(d,{children:(0,Z.jsx)(f,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`Enter`,action:`select`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]}):V===`Model`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(It,{initial:M,onSelect:e=>{B.current=!0,Ot(e),H(null),a(!1)},onCancel:()=>{H(null),a(!1)},showFastModeNotice:pt()?Le&&dt(M)&&mt():!1}),(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]}):V===`ExternalIncludes`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zt,{onDone:()=>{H(null),a(!1)},externalIncludes:ye(Et)}),(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`disable external includes`})]})})]}):V===`OutputStyle`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(cn,{initialStyle:C,onComplete:e=>{B.current=!0,_e(e??`default`),H(null),a(!1),F(`localSettings`,{outputStyle:e}),z(`tengu_output_style_changed`,{style:e??`default`,source:`config_panel`,settings_source:`localSettings`})},onCancel:()=>{H(null),a(!1)}}),(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]}):V===`Language`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(pn,{initialLanguage:w,onComplete:e=>{B.current=!0,Se(e),H(null),a(!1),F(`userSettings`,{language:e}),z(`tengu_language_changed`,{language:e??`default`,source:`config_panel`})},onCancel:()=>{H(null),a(!1)}}),(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})]}):V===`EnableAutoUpdates`?(0,Z.jsx)(le,{title:`Enable Auto-Updates`,onCancel:()=>{H(null),a(!1)},hideBorder:!0,hideInputGuide:!0,children:W?.type===`config`?(0,Z.jsx)(Me,{options:[{label:`Enable with latest channel`,value:`latest`},{label:`Enable with stable channel`,value:`stable`}],onChange:e=>{B.current=!0,H(null),a(!1),I(e=>({...e,autoUpdates:!0})),y({...L(),autoUpdates:!0}),F(`userSettings`,{autoUpdatesChannel:e,minimumVersion:void 0}),S(t=>({...t,autoUpdatesChannel:e,minimumVersion:void 0})),z(`tengu_autoupdate_enabled`,{channel:e})}}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{children:W?.type===`env`?`Auto-updates are controlled by an environment variable and cannot be changed here.`:`Auto-updates are disabled in development builds.`}),W?.type===`env`&&(0,Z.jsxs)(f,{dimColor:!0,children:[`Unset `,W.envVar,` to re-enable auto-updates.`]})]})}):V===`ChannelDowngrade`?(0,Z.jsx)(rn,{currentVersion:`0.0.6`,onChoice:e=>{if(H(null),a(!1),e===`cancel`)return;B.current=!0;let t={autoUpdatesChannel:`stable`};e===`stay`&&(t.minimumVersion=`0.0.6`),F(`userSettings`,t),S(e=>({...e,...t})),z(`tengu_autoupdate_channel_changed`,{channel:`stable`,minimum_version_set:e===`stay`})}}):(0,Z.jsxs)(d,{flexDirection:`column`,gap:1,marginY:oe?void 0:1,children:[(0,Z.jsx)(ae,{query:U,isFocused:k&&!m,isTerminalFocused:ke,cursorOffset:St,placeholder:`Search settings…`}),(0,Z.jsx)(d,{flexDirection:`column`,children:G.length===0?(0,Z.jsxs)(f,{dimColor:!0,italic:!0,children:[`No settings match "`,U,`"`]}):(0,Z.jsxs)(Z.Fragment,{children:[D>0&&(0,Z.jsxs)(f,{dimColor:!0,children:[s.arrowUp,` `,D,` more above`]}),G.slice(D,D+j).map((e,t)=>{let n=D+t===E&&!m&&!k;return(0,Z.jsx)(Y.Fragment,{children:(0,Z.jsxs)(d,{width:`100%`,children:[(0,Z.jsx)(d,{width:44,children:(0,Z.jsxs)(f,{color:n?`suggestion`:void 0,children:[n?s.pointer:` `,` `,e.label]})}),(0,Z.jsx)(d,{flexGrow:1,children:e.type===`boolean`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:e.value.toString()}),vt&&e.id===`thinkingEnabled`&&(0,Z.jsxs)(f,{color:`warning`,children:[` `,`Changing thinking mode mid-conversation will increase latency and may reduce quality.`]})]}):e.id===`theme`?(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:vn[e.value.toString()]??e.value.toString()}):e.id===`notifChannel`?(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:(0,Z.jsx)(_n,{value:e.value.toString()})}):e.id===`defaultPermissionMode`?(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:Ke(e.value)}):e.id===`autoUpdatesChannel`&&W?(0,Z.jsxs)(d,{flexDirection:`column`,children:[(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:`disabled`}),(0,Z.jsxs)(f,{dimColor:!0,children:[`(`,Ye(W),`)`]})]}):(0,Z.jsx)(f,{color:n?`suggestion`:void 0,children:e.value.toString()})})]})},e.id)}),D+j<G.length&&(0,Z.jsxs)(f,{dimColor:!0,children:[s.arrowDown,` `,G.length-D-j,` more below`]})]})}),m?(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(c,{shortcut:`←/→ tab`,action:`switch`}),(0,Z.jsx)(c,{shortcut:`↓`,action:`return`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`close`})]})}):k?(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(f,{children:`Type to filter`}),(0,Z.jsx)(c,{shortcut:`Enter/↓`,action:`select`}),(0,Z.jsx)(c,{shortcut:`↑`,action:`tabs`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`clear`})]})}):(0,Z.jsx)(f,{dimColor:!0,children:(0,Z.jsxs)(p,{children:[(0,Z.jsx)(N,{action:`select:accept`,context:`Settings`,fallback:`Space`,description:`change`}),(0,Z.jsx)(N,{action:`settings:close`,context:`Settings`,fallback:`Enter`,description:`save`}),(0,Z.jsx)(N,{action:`settings:search`,context:`Settings`,fallback:`/`,description:`search`}),(0,Z.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})]})})}function _n({value:e}){switch(e){case`auto`:return`Auto`;case`iterm2`:return(0,Z.jsxs)(f,{children:[`iTerm2 `,(0,Z.jsx)(f,{dimColor:!0,children:`(OSC 9)`})]});case`terminal_bell`:return(0,Z.jsxs)(f,{children:[`Terminal Bell `,(0,Z.jsx)(f,{dimColor:!0,children:`(\\a)`})]});case`kitty`:return(0,Z.jsxs)(f,{children:[`Kitty `,(0,Z.jsx)(f,{dimColor:!0,children:`(OSC 99)`})]});case`ghostty`:return(0,Z.jsxs)(f,{children:[`Ghostty `,(0,Z.jsx)(f,{dimColor:!0,children:`(OSC 777)`})]});case`iterm2_with_bell`:return`iTerm2 w/ Bell`;case`notifications_disabled`:return`Disabled`;default:return e}}var Y,X,Z,vn,yn=t((()=>{g(),Y=n(h(),1),X=n(h(),1),vt(),o(),Je(),B(),m(),Be(),S(),R(),$e(),bt(),Mt(),Se(),Pt(),ct(),Lt(),Rt(),on(),O(),fn(),hn(),we(),w(),G(),Bt(),pe(),P(),b(),M(),a(),Ht(),E(),ut(),_e(),Z=y(),vn={auto:`Auto (match terminal)`,dark:`Dark mode`,light:`Light mode`,"dark-daltonized":`Dark mode (colorblind-friendly)`,"light-daltonized":`Light mode (colorblind-friendly)`,"dark-ansi":`Dark mode (ANSI colors only)`,"light-ansi":`Light mode (ANSI colors only)`}}));function bn({title:e,limit:t,maxWidth:n,showTimeInReset:r=!0,extraSubtext:i}){let{utilization:a,resets_at:o}=t;if(a===null)return null;let s=`${Math.floor(a)}% used`,c;return o&&(c=`Resets ${tt(o,!0,r)}`),i&&(c=c?`${i} · ${c}`:i),n>=62?(0,Q.jsxs)(d,{flexDirection:`column`,children:[(0,Q.jsx)(f,{bold:!0,children:e}),(0,Q.jsxs)(d,{flexDirection:`row`,gap:1,children:[(0,Q.jsx)(ie,{ratio:a/100,width:50,fillColor:`rate_limit_fill`,emptyColor:`rate_limit_empty`}),(0,Q.jsx)(f,{children:s})]}),c&&(0,Q.jsx)(f,{dimColor:!0,children:c})]}):(0,Q.jsxs)(d,{flexDirection:`column`,children:[(0,Q.jsxs)(f,{children:[(0,Q.jsx)(f,{bold:!0,children:e}),c&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(f,{children:` `}),(0,Q.jsxs)(f,{dimColor:!0,children:[`· `,c]})]})]}),(0,Q.jsx)(ie,{ratio:a/100,width:n,fillColor:`rate_limit_fill`,emptyColor:`rate_limit_empty`}),(0,Q.jsx)(f,{children:s})]})}function xn(){let[e,t]=(0,wn.useState)(null),[n,r]=(0,wn.useState)(null),[i,a]=(0,wn.useState)(!0),{columns:o}=se(),s=o-2,c=Math.min(s,80),l=Cn.useCallback(async()=>{a(!0),r(null);try{let e=await Wt();t(e)}catch(e){Qe(e);let t=e,n=t.response?.data?ze(t.response.data):void 0;r(n?`Failed to load usage data: ${n}`:`Failed to load usage data`)}finally{a(!1)}},[]);if((0,wn.useEffect)(()=>{l()},[l]),te(`settings:retry`,()=>{l()},{context:`Settings`,isActive:!!n&&!i}),n)return(0,Q.jsxs)(d,{flexDirection:`column`,gap:1,children:[(0,Q.jsxs)(f,{color:`error`,children:[`Error: `,n]}),(0,Q.jsx)(f,{dimColor:!0,children:(0,Q.jsxs)(p,{children:[(0,Q.jsx)(N,{action:`settings:retry`,context:`Settings`,fallback:`r`,description:`retry`}),(0,Q.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})]})})]});if(!e)return(0,Q.jsxs)(d,{flexDirection:`column`,gap:1,children:[(0,Q.jsx)(f,{dimColor:!0,children:`Loading usage data…`}),(0,Q.jsx)(f,{dimColor:!0,children:(0,Q.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})})]});let u=it(),ee=u===`max`||u===`team`||u===null,ne=[{title:`Current session`,limit:e.five_hour},{title:`Current week (all models)`,limit:e.seven_day},...ee?[{title:`Current week (Sonnet only)`,limit:e.seven_day_sonnet}]:[]];return(0,Q.jsxs)(d,{flexDirection:`column`,gap:1,width:`100%`,children:[ne.some(({limit:e})=>e)||(0,Q.jsx)(f,{dimColor:!0,children:`/usage is only available for subscription plans.`}),ne.map(({title:e,limit:t})=>t&&(0,Q.jsx)(bn,{title:e,limit:t,maxWidth:c},e)),e.extra_usage&&(0,Q.jsx)(Sn,{extraUsage:e.extra_usage,maxWidth:c}),Gt()&&(0,Q.jsx)(qt,{maxWidth:c}),(0,Q.jsx)(f,{dimColor:!0,children:(0,Q.jsx)(N,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`})})]})}function Sn({extraUsage:e,maxWidth:t}){let n=it();if(!(n===`pro`||n===`max`))return!1;if(!e.is_enabled)return Ee.isEnabled()?(0,Q.jsxs)(d,{flexDirection:`column`,children:[(0,Q.jsx)(f,{bold:!0,children:Tn}),(0,Q.jsx)(f,{dimColor:!0,children:`Extra usage not enabled · /extra-usage to enable`})]}):null;if(e.monthly_limit===null)return(0,Q.jsxs)(d,{flexDirection:`column`,children:[(0,Q.jsx)(f,{bold:!0,children:Tn}),(0,Q.jsx)(f,{dimColor:!0,children:`Unlimited`})]});if(typeof e.used_credits!=`number`||typeof e.utilization!=`number`)return null;let r=Ne(e.used_credits/100,2),i=Ne(e.monthly_limit/100,2),a=new Date,o=new Date(a.getFullYear(),a.getMonth()+1,1);return(0,Q.jsx)(bn,{title:Tn,limit:{utilization:e.utilization,resets_at:o.toISOString()},showTimeInReset:!1,extraSubtext:`${r} / ${i} spent`,maxWidth:t})}var Cn,wn,Q,Tn,En=t((()=>{Cn=n(h(),1),wn=n(h(),1),je(),j(),rt(),E(),g(),vt(),Ut(),et(),R(),Re(),w(),Kt(),Q=y(),Tn=`Extra usage`}));function Dn({onClose:e,context:t,defaultTab:n}){let[r,i]=(0,On.useState)(n),[a,o]=(0,On.useState)(!1),[s,c]=(0,On.useState)(!1),l=jt(),{rows:u}=At(se()),d=l?u+1:Math.max(15,Math.min(Math.floor(u*.8),30)),[f]=(0,On.useState)(()=>Xt().catch(()=>[]));return Ot(),te(`confirm:no`,()=>{a||e(`Status dialog dismissed`,{display:`system`})},{context:`Settings`,isActive:!a&&!(r===`Config`&&s)}),(0,$.jsx)(v,{color:`permission`,children:(0,$.jsx)(ce,{color:`permission`,selectedTab:r,onTabChange:i,hidden:a,initialHeaderFocused:n!==`Config`,contentHeight:a||l?void 0:d,children:[(0,$.jsx)(oe,{title:`Status`,children:(0,$.jsx)(Qt,{context:t,diagnosticsPromise:f})},`status`),(0,$.jsx)(oe,{title:`Config`,children:(0,$.jsx)(On.Suspense,{fallback:null,children:(0,$.jsx)(gn,{context:t,onClose:e,setTabsHidden:o,onIsSearchModeChange:c,contentHeight:d})})},`config`),(0,$.jsx)(oe,{title:`Usage`,children:(0,$.jsx)(xn,{})},`usage`)]})})}var On,$,kn=t((()=>{h(),On=n(h(),1),vt(),kt(),E(),G(),g(),nn(),yn(),En(),$=y()}));export{kn as n,Dn as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,Wt as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{en as s,ur as c}from"./state-ix0xIunV.js";import{Aw as l,V_ as u,ba as d,cC as f,fx as p,jw as m,px as h,sC as g,xa as _,z_ as v}from"./loadAgentsDir-D206qwP3.js";import{n as y,t as b}from"./cwd-CYmmnQVS.js";import{d as x,p as S}from"./debug-BrXObCdR.js";import{c as C,g as w}from"./settings-BovzmwMP.js";import{g as T,n as E,y as D}from"./config-DmomySWC.js";import{n as O,r as k}from"./analytics-BotDBGh0.js";import{bn as A}from"./prompt-BNHtszmZ.js";import{u as j}from"./referral-CUaIo_vT.js";import{n as M,t as N}from"./useExitOnCtrlCDWithKeybindings-DKIqRraH.js";import{n as P,t as F}from"./PermissionDialog-0ya1CU5k.js";import{homedir as I}from"os";var L=e(i(),1),R=o();a(),s(),y(),S(),O(),T(),f(),j(),p(),u(),N(),P(),w(),A(),_(),m();function z(e){if(e===null||e.disableAllHooks)return!1;if(e.statusLine||e.fileSuggestion)return!0;if(!e.hooks)return!1;for(let t of Object.values(e.hooks))if(t.length>0)return!0;return!1}function B(){let e=[];return z(C(`projectSettings`))&&e.push(`.claude/settings.json`),z(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function V(e){return e.some(e=>e.ruleBehavior===`allow`&&(e.ruleValue.toolName===`Bash`||e.ruleValue.toolName.startsWith(`Bash(`)))}function H(){let e=[];return V(l(`projectSettings`))&&e.push(`.claude/settings.json`),V(l(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function U(e){return!!e?.otelHeadersHelper}function W(){let e=[];return U(C(`projectSettings`))&&e.push(`.claude/settings.json`),U(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function G(e){return!!e?.apiKeyHelper}function K(){let e=[];return G(C(`projectSettings`))&&e.push(`.claude/settings.json`),G(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function q(e){return!!(e?.awsAuthRefresh||e?.awsCredentialExport)}function J(){let e=[];return q(C(`projectSettings`))&&e.push(`.claude/settings.json`),q(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function Y(e){return!!e?.gcpAuthRefresh}function X(){let e=[];return Y(C(`projectSettings`))&&e.push(`.claude/settings.json`),Y(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}function Z(e){return e?.env?Object.keys(e.env).some(e=>!d.has(e.toUpperCase())):!1}function Q(){let e=[];return Z(C(`projectSettings`))&&e.push(`.claude/settings.json`),Z(C(`localSettings`))&&e.push(`.claude/settings.local.json`),e}A();function $({onDone:e,commands:i}){let{servers:a}=v(`project`),o=Object.keys(a).length>0,s=B().length>0,l=H(),u=K().length>0,d=J().length>0,f=X().length>0,p=W().length>0,m=Q().length>0,_=i?.some(e=>e.type===`prompt`&&e.loadedFrom===`commands_DEPRECATED`&&(e.source===`projectSettings`||e.source===`localSettings`)&&e.allowedTools?.some(e=>e===`Bash`||e.startsWith(`Bash(`)))??!1,y=i?.some(e=>e.type===`prompt`&&(e.loadedFrom===`skills`||e.loadedFrom===`plugin`)&&(e.source===`projectSettings`||e.source===`localSettings`||e.source===`plugin`)&&e.allowedTools?.some(e=>e===`Bash`||e.startsWith(`Bash(`)))??!1,S=l.length>0||_||y,C=E(),[w,T]=L.useState(null);L.useEffect(()=>{if(w!==null){let e=w,t=setTimeout(()=>g(e));return()=>clearTimeout(t)}},[w]),L.useEffect(()=>{k(`tengu_trust_dialog_shown`,{isHomeDir:I()===b(),hasMcpServers:o,hasHooks:s,hasBashExecution:S,hasApiKeyHelper:u,hasAwsCommands:d,hasGcpCommands:f,hasOtelHeadersHelper:p,hasDangerousEnvVars:m})},[o,s,S,u,d,f,p,m]);function O(t){if(t===`exit`){T(1);return}let n=I()===b();k(`tengu_trust_dialog_accept`,{isHomeDir:n,hasMcpServers:o,hasHooks:s,hasBashExecution:S,hasApiKeyHelper:u,hasAwsCommands:d,hasGcpCommands:f,hasOtelHeadersHelper:p,hasDangerousEnvVars:m}),n?c(!0):D(e=>({...e,hasTrustDialogAccepted:!0})),e()}let A=M(()=>T(1));return r(`confirm:no`,()=>{T(0)},{context:`Confirmation`}),w===null?C?(setTimeout(e),null):(0,R.jsx)(F,{color:`warning`,titleColor:`warning`,title:`Accessing workspace:`,children:(0,R.jsxs)(t,{flexDirection:`column`,gap:1,paddingTop:1,children:[(0,R.jsx)(n,{bold:!0,children:x().cwd()}),(0,R.jsx)(n,{children:`Is this a project you trust? (Your own code, a well-known open source project, or work from your team).`}),(0,R.jsx)(n,{children:`Once trusted, Work Mate can read, edit, and run commands in this folder.`}),(0,R.jsx)(h,{options:[{label:`Yes, I trust this folder`,value:`enable_all`},{label:`No, exit`,value:`exit`}],onChange:e=>O(e),onCancel:()=>O(`exit`)}),(0,R.jsx)(n,{dimColor:!0,children:A.pending?(0,R.jsxs)(R.Fragment,{children:[`Press `,A.keyName,` again to exit`]}):(0,R.jsx)(R.Fragment,{children:`Enter to confirm · Esc to cancel`})})]})}):null}export{$ as TrustDialog};
@@ -1,103 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{n as i,t as a}from"./figures-5ThXQEtq.js";import{C as o,D as s,I as c,P as l,T as u,Wt as d,di as f,fi as p,t as m,ui as h,y as g}from"./src-CDCSSo0U2.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{$d as v,Af as y,Ah as b,Bc as x,Bg as S,Bh as ee,Cf as C,Ef as te,Fb as ne,Fx as re,Gw as ie,Hd as ae,Hn as oe,Jo as se,KS as ce,Kd as le,ME as ue,Mf as de,NE as fe,Nb as pe,Nf as me,O_ as he,Oh as ge,Px as _e,Qd as ve,So as ye,Sx as w,Tf as be,UD as xe,US as Se,Ud as Ce,Uh as we,Un as Te,Vc as Ee,Vg as De,Vh as Oe,WD as ke,WS as Ae,Wn as je,Ww as Me,Xd as Ne,Xu as Pe,Yu as Fe,ZT as Ie,Zd as Le,_C as Re,_u as ze,at as Be,bf as Ve,c as He,dv as Ue,ef as We,et as Ge,gC as Ke,jf as qe,k_ as Je,kh as Ye,l as Xe,lh as Ze,mx as Qe,nt as $e,o as et,of as tt,px as nt,qd as rt,r as it,s as at,sf as ot,sh as st,st as ct,t as lt,uv as ut,vu as dt,wf as ft,xx as T,yf as pt,zo as mt}from"./loadAgentsDir-D206qwP3.js";import{n as ht,t as gt}from"./cwd-CYmmnQVS.js";import{C as _t,G as vt,I as yt,Q as bt,S as xt,W as St,z as Ct}from"./debug-BrXObCdR.js";import{Q as wt,Qt as Tt,_n as Et,ct as Dt,dn as Ot,en as kt,gn as At,ln as jt,lt as Mt,nt as Nt}from"./settings-BovzmwMP.js";import{I as Pt,P as Ft}from"./config-DmomySWC.js";import{o as It,s as Lt}from"./log-BMCygSzM.js";import{n as Rt,r as zt}from"./analytics-BotDBGh0.js";import{T as Bt,b as Vt}from"./startupProfiler-xa3NmN7Z.js";import{l as Ht,n as Ut,o as Wt}from"./stringUtils-DGLPkqJ4.js";import{Tn as Gt,wn as Kt}from"./prompt-BNHtszmZ.js";import{st as qt}from"./rcDebugLog-CUy1_F23.js";import{u as E}from"./referral-CUaIo_vT.js";import{r as Jt,t as Yt}from"./TungstenTool-CxMQVCuF.js";import{a as Xt,i as Zt,n as Qt,o as $t,r as en,t as tn}from"./agentDisplay-XoDJhr03.js";import{n as nn,t as rn}from"./useExitOnCtrlCDWithKeybindings-DKIqRraH.js";import{n as an,t as on}from"./useMergedTools-CKvwz_Zt.js";import{n as sn,r as cn,t as ln}from"./promptEditor-DeMrXUir.js";import{n as un,t as dn}from"./useMainLoopModel-XetDUXd-.js";import{join as D}from"path";import{mkdir as fn,open as pn,unlink as mn}from"fs/promises";var O,hn=e((()=>{O={FOLDER_NAME:`.claude`,AGENTS_DIR:`agents`}}));function gn(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 _n(e){switch(e){case`flagSettings`:throw Error(`Cannot get directory path for ${e} agents`);case`userSettings`:return D(n(),O.AGENTS_DIR);case`projectSettings`:return D(gt(),O.FOLDER_NAME,O.AGENTS_DIR);case`policySettings`:return D(Tt(),O.FOLDER_NAME,O.AGENTS_DIR);case`localSettings`:return D(gt(),O.FOLDER_NAME,O.AGENTS_DIR)}}function vn(e){switch(e){case`projectSettings`:return D(`.`,O.FOLDER_NAME,O.AGENTS_DIR);default:return _n(e)}}function yn(e){return D(_n(e.source),`${e.agentType}.md`)}function bn(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return D(_n(e.source),`${e.filename||e.agentType}.md`)}function xn(e){return e.source===`built-in`?`Built-in`:D(vn(e.source),`${e.agentType}.md`)}function Sn(e){return at(e)?`Built-in`:Xe(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:D(vn(e.source),`${e.filename||e.agentType}.md`)}async function Cn(e){let t=_n(e);return await fn(t,{recursive:!0}),t}async function wn(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await Cn(e);let l=yn({source:e,agentType:t}),u=gn(t,n,r,i,o,s,c);try{await Dn(l,u,a?`wx`:`w`)}catch(e){throw yt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function Tn(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await Dn(bn(e),gn(e.agentType,t,n,r,i,a,o))}async function En(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=bn(e);try{await mn(t)}catch(e){if(yt(e)!==`ENOENT`)throw e}}async function Dn(e,t,n=`w`){let r=await pn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var On=e((()=>{kt(),et(),ht(),r(),Ct(),hn()}));function kn({agent:e,tools:t,onBack:n}){let r=b(e,t,!1),i=Sn(e),o=ve(e.agentType);d(`confirm:no`,n,{context:`Confirmation`});let s=e=>{e.key===`return`&&(e.preventDefault(),n())};function u(){return r.hasWildcard?(0,k.jsx)(l,{children:`All tools`}):!e.tools||e.tools.length===0?(0,k.jsx)(l,{children:`None`}):(0,k.jsxs)(k.Fragment,{children:[r.validTools.length>0&&(0,k.jsx)(l,{children:r.validTools.join(`, `)}),r.invalidTools.length>0&&(0,k.jsxs)(l,{color:`warning`,children:[a.warning,` Unrecognized: `,r.invalidTools.join(`, `)]})]})}return(0,k.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:s,children:[(0,k.jsx)(l,{dimColor:!0,children:i}),(0,k.jsxs)(c,{flexDirection:`column`,children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Description`}),` (tells Claude when to use this agent):`]}),(0,k.jsx)(c,{marginLeft:2,children:(0,k.jsx)(l,{children:e.whenToUse})})]}),(0,k.jsxs)(c,{children:[(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Tools`}),`:`,` `]}),u()]}),(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Model`}),`: `,ee(e.model)]}),e.permissionMode&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Permission mode`}),`: `,e.permissionMode]}),e.memory&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Memory`}),`: `,oe(e.memory)]}),e.hooks&&Object.keys(e.hooks).length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Hooks`}),`: `,Object.keys(e.hooks).join(`, `)]}),e.skills&&e.skills.length>0&&(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Skills`}),`:`,` `,e.skills.length>10?`${e.skills.length} skills`:e.skills.join(`, `)]}),o&&(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`Color`}),`:`,` `,(0,k.jsxs)(l,{backgroundColor:o,color:`inverseText`,children:[` `,e.agentType,` `]})]})}),!at(e)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{children:(0,k.jsxs)(l,{children:[(0,k.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,k.jsx)(c,{marginLeft:2,marginRight:2,children:(0,k.jsx)(st,{children:e.getSystemPrompt()})})]})]})}var k,An=e((()=>{i(),p(),m(),E(),v(),Te(),Ye(),et(),we(),Ze(),On(),k=_()}));function jn({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,Mn.useState)(Math.max(0,Nn.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:Nn.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<Nn.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=Nn[r];n(t===`automatic`?void 0:t)}},s=Nn[r];return(0,A.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,A.jsx)(c,{flexDirection:`column`,children:Nn.map((e,t)=>{let n=t===r;return(0,A.jsxs)(c,{flexDirection:`row`,gap:1,children:[(0,A.jsx)(l,{color:n?`suggestion`:void 0,children:n?a.pointer:` `}),e===`automatic`?(0,A.jsx)(l,{bold:n,children:`Automatic color`}):(0,A.jsxs)(c,{gap:1,children:[(0,A.jsx)(l,{backgroundColor:Le[e],color:`inverseText`,children:` `}),(0,A.jsx)(l,{bold:n,children:Ut(e)})]})]},e)})}),(0,A.jsxs)(c,{marginTop:1,children:[(0,A.jsx)(l,{children:`Preview: `}),s===void 0||s===`automatic`?(0,A.jsxs)(l,{inverse:!0,bold:!0,children:[` `,`@`,e,` `]}):(0,A.jsxs)(l,{backgroundColor:Le[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var Mn,A,Nn,Pn=e((()=>{i(),Mn=t(p(),1),m(),v(),Wt(),A=_(),Nn=[`automatic`,...Ne]}));function Fn({initialModel:e,onComplete:t,onCancel:n}){let r=In.useMemo(()=>{let t=Oe();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,Ln.jsxs)(c,{flexDirection:`column`,children:[(0,Ln.jsx)(c,{marginBottom:1,children:(0,Ln.jsx)(l,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,Ln.jsx)(nt,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var In,Ln,Rn=e((()=>{In=t(p(),1),m(),we(),Qe(),Ln=_()}));function zn(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([C.name,be.name,ae.name,x.name,Ke.name,tt.name,le.name,ut.name,S.name])},EDIT:{name:`Edit tools`,toolNames:new Set([de.name,y.name,pt.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([ze.name,process.env.USER_TYPE===`ant`?Yt.name:void 0].filter(e=>e!==void 0))},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function Bn(e){let t=new Map;return e.forEach(e=>{if(Je(e)){let n=Mt(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 Vn({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,j.useMemo)(()=>ge({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[s,u]=(0,j.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[f,p]=(0,j.useState)(0),[m,h]=(0,j.useState)(!1),g=(0,j.useMemo)(()=>{let e=new Set(i.map(e=>e.name));return s.filter(t=>e.has(t))},[s,i]),_=new Set(g),v=g.length===i.length&&i.length>0,y=e=>{e&&u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},b=(e,t)=>{u(n=>{if(t){let t=e.filter(e=>!n.includes(e));return[...n,...t]}else return n.filter(t=>!e.includes(t))})},x=()=>{let e=i.map(e=>e.name);n(g.length===e.length&&e.every(e=>g.includes(e))?void 0:g)},S=(0,j.useMemo)(()=>{let e=zn(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{Je(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]),ee=e=>{let t=At(e,e=>_.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);b(n,t)}},C=[];C.push({id:`continue`,label:`Continue`,action:x,isContinue:!0}),C.push({id:`bucket-all`,label:`${v?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);b(e,!v)}});let te=zn();[{id:`bucket-readonly`,name:te.READ_ONLY.name,tools:S.readOnly},{id:`bucket-edit`,name:te.EDIT.name,tools:S.edit},{id:`bucket-execution`,name:te.EXECUTION.name,tools:S.execution},{id:`bucket-mcp`,name:te.MCP.name,tools:S.mcp},{id:`bucket-other`,name:te.OTHER.name,tools:S.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=At(n,e=>_.has(e.name))===n.length;C.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:ee(n)})});let ne=C.length;C.push({id:`toggle-individual`,label:m?`Hide advanced options`:`Show advanced options`,action:()=>{h(!m),m&&f>ne&&p(ne)},isToggle:!0});let re=(0,j.useMemo)(()=>Bn(i),[i]);return m&&(re.length>0&&(C.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),re.forEach(({serverName:e,tools:t})=>{let n=At(t,e=>_.has(e.name))===t.length;C.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${Ht(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);b(e,!n)}})}),C.push({id:`tools-header`,label:`Individual Tools:`,action:()=>{},isHeader:!0})),i.forEach(e=>{let t=e.name;if(e.name.startsWith(`mcp__`)){let n=Mt(e.name);t=n?`${n.toolName} (${n.serverName})`:e.name}C.push({id:`tool-${e.name}`,label:`${_.has(e.name)?a.checkboxOn:a.checkboxOff} ${t}`,action:()=>y(e.name)})})),d(`confirm:no`,(0,j.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,M.jsxs)(c,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(e.key===`return`){e.preventDefault();let t=C[f];t&&!t.isHeader&&t.action()}else if(e.key===`up`){e.preventDefault();let t=f-1;for(;t>0&&C[t]?.isHeader;)t--;p(Math.max(0,t))}else if(e.key===`down`){e.preventDefault();let t=f+1;for(;t<C.length-1&&C[t]?.isHeader;)t++;p(Math.min(C.length-1,t))}},children:[(0,M.jsxs)(l,{color:f===0?`suggestion`:void 0,bold:f===0,children:[f===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,M.jsx)(o,{width:40}),C.slice(1).map((e,t)=>{let n=t+1===f,r=e.isToggle,i=e.isHeader;return(0,M.jsxs)(j.Fragment,{children:[r&&(0,M.jsx)(o,{width:40}),i&&t>0&&(0,M.jsx)(c,{marginTop:1}),(0,M.jsxs)(l,{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,M.jsx)(c,{marginTop:1,flexDirection:`column`,children:(0,M.jsx)(l,{dimColor:!0,children:v?`All tools selected`:`${_.size} of ${i.length} tools selected`})})]})}var j,M,Hn=e((()=>{i(),j=t(p(),1),Dt(),he(),Ye(),Nt(),dt(),Ce(),me(),Ee(),qe(),ft(),te(),Ue(),Ve(),De(),rt(),ot(),Re(),Jt(),m(),E(),Et(),Wt(),M=_()}));function Un(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:xe(jt(e))}var Wn=e((()=>{ke(),Ot()}));function Gn({agent:e,tools:t,onSaved:n,onBack:r}){let i=ce(),[o,s]=(0,N.useState)(`menu`),[u,f]=(0,N.useState)(0),[p,m]=(0,N.useState)(null),[g,_]=(0,N.useState)(e.color),v=(0,N.useCallback)(async()=>{let t=await ln(bn(e));t.error?m(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),y=(0,N.useCallback)(async(t={})=>{let{tools:r,color:a,model:o}=t,s=a??g,c=r!==void 0,l=o!==void 0,u=s!==e.color;if(!c&&!l&&!u)return!1;try{return!He(e)&&!Xe(e)?!1:(await Tn(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&We(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:it(n),allAgents:n}}}),n(`Updated agent: ${h.bold(e.agentType)}`),!0)}catch(e){return m(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,g,n,i]),b=(0,N.useMemo)(()=>[{label:`Open in editor`,action:v},{label:`Edit tools`,action:()=>s(`edit-tools`)},{label:`Edit model`,action:()=>s(`edit-model`)},{label:`Edit color`,action:()=>s(`edit-color`)}],[v]),x=(0,N.useCallback)(()=>{m(null),o===`menu`?r():s(`menu`)},[o,r]),S=(0,N.useCallback)(e=>{if(e.key===`up`)e.preventDefault(),f(e=>Math.max(0,e-1));else if(e.key===`down`)e.preventDefault(),f(e=>Math.min(b.length-1,e+1));else if(e.key===`return`){e.preventDefault();let t=b[u];t&&t.action()}},[b,u]);d(`confirm:no`,x,{context:`Confirmation`});let ee=()=>(0,P.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:S,children:[(0,P.jsxs)(l,{dimColor:!0,children:[`Source: `,Un(e.source)]}),(0,P.jsx)(c,{marginTop:1,flexDirection:`column`,children:b.map((e,t)=>(0,P.jsxs)(l,{color:t===u?`suggestion`:void 0,children:[t===u?`${a.pointer} `:` `,e.label]},e.label))}),p&&(0,P.jsx)(c,{marginTop:1,children:(0,P.jsx)(l,{color:`error`,children:p})})]});switch(o){case`menu`:return ee();case`edit-tools`:return(0,P.jsx)(Vn,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await y({tools:e})}});case`edit-color`:return(0,P.jsx)(jn,{agentName:e.agentType,currentColor:g||e.color||`automatic`,onConfirm:async e=>{_(e),s(`menu`),await y({color:e})}});case`edit-model`:return(0,P.jsx)(Fn,{initialModel:e.model,onComplete:async e=>{s(`menu`),await y({model:e})}});default:return null}}var N,P,Kn=e((()=>{f(),i(),p(),N=t(p(),1),Se(),m(),E(),v(),et(),cn(),On(),Pn(),Rn(),Hn(),Wn(),P=_()}));function qn({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=nn();return(0,Jn.jsx)(c,{marginLeft:2,children:(0,Jn.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Jn,Yn=e((()=>{p(),rn(),m(),Jn=_()}));function Xn({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:s}){let[u,d]=F.useState(null),[f,p]=F.useState(!0),m=F.useMemo(()=>[...t].sort(Qt),[t]),h=e=>({isOverridden:!!e.overriddenBy,overriddenBy:e.overriddenBy||null}),_=()=>(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:f?`${a.pointer} `:` `}),(0,I.jsx)(l,{color:f?`suggestion`:void 0,children:`Create new agent`})]}),v=e=>{let t=e.source===`built-in`,n=!t&&!f&&u?.agentType===e.agentType&&u?.source===e.source,{isOverridden:r,overriddenBy:i}=h(e),o=t||r,s=!t&&n?`suggestion`:void 0,d=Xt(e);return(0,I.jsxs)(c,{children:[(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:t?``:n?`${a.pointer} `:` `}),(0,I.jsx)(l,{dimColor:o&&!n,color:s,children:e.agentType}),d&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,d]}),e.memory&&(0,I.jsxs)(l,{dimColor:!0,color:s,children:[` · `,e.memory,` memory`]}),i&&(0,I.jsxs)(l,{dimColor:!n,color:n?`warning`:void 0,children:[` `,a.warning,` shadowed by `,en(i)]})]},`${e.agentType}-${e.source}`)},y=F.useMemo(()=>{let t=m.filter(e=>e.source!==`built-in`);return e===`all`?tn.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[m,e]);F.useEffect(()=>{!u&&!f&&y.length>0&&(i?p(!0):d(y[0]||null))},[y,u,f,i]);let b=e=>{if(e.key===`return`){e.preventDefault(),f&&i?i():u&&r(u);return}if(e.key!==`up`&&e.key!==`down`)return;e.preventDefault();let t=!!i,n=y.length+ +!!t;if(n===0)return;let a=0;if(!f&&u){let e=y.findIndex(e=>e.agentType===u.agentType&&e.source===u.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)p(!0),d(null);else{let e=t?o-1:o,n=y[e];n&&(p(!1),d(n))}},x=(e=`Built-in (always available):`)=>{let t=m.filter(e=>e.source===`built-in`);return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),t.map(v)]})},S=(e,t)=>{if(!t.length)return null;let n=t[0]?.baseDir;return(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,children:[(0,I.jsxs)(c,{paddingLeft:2,children:[(0,I.jsx)(l,{bold:!0,dimColor:!0,children:e}),n&&(0,I.jsxs)(l,{dimColor:!0,children:[` (`,n,`)`]})]}),t.map(e=>v(e))]})},ee=Un(e),C=m.filter(e=>e.source===`built-in`);return!m.length||e!==`built-in`&&!m.some(e=>e.source!==`built-in`)?(0,I.jsx)(g,{title:ee,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,I.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:b,children:[i&&(0,I.jsx)(c,{children:_()}),(0,I.jsx)(l,{dimColor:!0,children:`No agents found. Create specialized subagents that Claude can delegate to.`}),(0,I.jsx)(l,{dimColor:!0,children:`Each subagent has its own context window, custom system prompt, and specific tools.`}),(0,I.jsx)(l,{dimColor:!0,children:`Try creating: Code Reviewer, Code Simplifier, Security Reviewer, Tech Lead, or UX Reviewer.`}),e!==`built-in`&&m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),x()]})]})}):(0,I.jsxs)(g,{title:ee,subtitle:`${At(m,e=>!e.overriddenBy)} agents`,onCancel:n,hideInputGuide:!0,children:[s&&s.length>0&&(0,I.jsx)(c,{marginTop:1,children:(0,I.jsx)(l,{dimColor:!0,children:s[s.length-1]})}),(0,I.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:b,children:[i&&(0,I.jsx)(c,{marginBottom:1,children:_()}),e===`all`?(0,I.jsxs)(I.Fragment,{children:[tn.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,I.jsx)(F.Fragment,{children:S(e,m.filter(e=>e.source===t))},t)),C.length>0&&(0,I.jsxs)(c,{flexDirection:`column`,marginBottom:1,paddingLeft:2,children:[(0,I.jsxs)(l,{dimColor:!0,children:[(0,I.jsx)(l,{bold:!0,children:`Built-in agents`}),` (always available)`]}),C.map(v)]})]}):e===`built-in`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(l,{dimColor:!0,italic:!0,children:`Built-in agents are provided by default and cannot be modified.`}),(0,I.jsx)(c,{marginTop:1,flexDirection:`column`,children:m.map(e=>v(e))})]}):(0,I.jsxs)(I.Fragment,{children:[m.filter(e=>e.source!==`built-in`).map(e=>v(e)),m.some(e=>e.source===`built-in`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o,{}),x()]})]})]})]})}var F,I,Zn=e((()=>{i(),F=t(p(),1),m(),Zt(),Et(),Wn(),I=_()}));function Qn({steps:e,initialData:t={},onComplete:n,onCancel:r,children:i,title:a,showStepCounter:o=!0}){let[s,c]=(0,L.useState)(0),[l,u]=(0,L.useState)(t),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)([]);nn(),(0,L.useEffect)(()=>{d&&(m([]),n(l))},[d,l,n]);let h=(0,L.useCallback)(()=>{s<e.length-1?(p.length>0&&m(e=>[...e,s]),c(e=>e+1)):f(!0)},[s,e.length,p]),g=(0,L.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]),_=(0,L.useCallback)(t=>{t>=0&&t<e.length&&(m(e=>[...e,s]),c(t))},[s,e.length]),v=(0,L.useCallback)(()=>{m([]),r&&r()},[r]),y=(0,L.useCallback)(e=>{u(t=>({...t,...e}))},[]),b=(0,L.useMemo)(()=>({currentStepIndex:s,totalSteps:e.length,wizardData:l,setWizardData:u,updateWizardData:y,goNext:h,goBack:g,goToStep:_,cancel:v,title:a,showStepCounter:o}),[s,e.length,l,y,h,g,_,v,a,o]),x=e[s];return!x||d?null:(0,$n.jsx)(er.Provider,{value:b,children:i||(0,$n.jsx)(x,{})})}var L,$n,er,tr=e((()=>{L=t(p(),1),rn(),$n=_(),er=(0,L.createContext)(null)}));function R(){let e=(0,nr.useContext)(er);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var nr,rr=e((()=>{nr=t(p(),1),tr()}));function ir({instructions:e=(0,z.jsxs)(u,{children:[(0,z.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,z.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})}){let t=nn();return(0,z.jsx)(c,{marginLeft:3,marginTop:1,children:(0,z.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var z,ar=e((()=>{rn(),m(),w(),z=_()}));function B({title:e,color:t=`suggestion`,children:n,subtitle:r,footerText:i}){let{currentStepIndex:a,totalSteps:o,title:s,showStepCounter:c,goBack:l}=R();return(0,or.jsxs)(or.Fragment,{children:[(0,or.jsx)(g,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,or.jsx)(ir,{instructions:i})]})}var or,V=e((()=>{m(),rr(),ar(),or=_()})),H=e((()=>{rr(),V(),ar(),tr()}));function sr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return d(`confirm:no`,t,{context:`Confirmation`}),(0,U.jsx)(B,{subtitle:`Choose background color`,footerText:(0,U.jsxs)(u,{children:[(0,U.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,U.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,U.jsx)(c,{children:(0,U.jsx)(jn,{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,cr=e((()=>{m(),E(),w(),H(),V(),Pn(),U=_()}));function lr(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 ur(e,t,n){let r=[],i=[];if(!e.agentType)r.push(`Agent type is required`);else{let t=lr(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 ${Un(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=b(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 dr=e((()=>{Ye(),Wn()}));function fr({tools:e,existingAgents:t,onSave:n,onSaveAndEdit:r,error:i}){let{goBack:a,wizardData:o}=R();d(`confirm:no`,a,{context:`Confirmation`});let f=e=>{e.key===`s`||e.key===`return`?(e.preventDefault(),n()):e.key===`e`&&(e.preventDefault(),r())},p=o.finalAgent,m=ur(p,e,t),h=Bt(p.getSystemPrompt(),240),g=Bt(p.whenToUse,240),_=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]}`,v=Pt()?(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Memory`}),`: `,oe(p.memory)]}):null;return(0,W.jsx)(B,{subtitle:`Confirm and save`,footerText:(0,W.jsxs)(u,{children:[(0,W.jsx)(s,{shortcut:`s/Enter`,action:`save`}),(0,W.jsx)(s,{shortcut:`e`,action:`edit in your editor`}),(0,W.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,W.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:f,children:[(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Name`}),`: `,p.agentType]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Location`}),`:`,` `,xn({source:o.location,agentType:p.agentType})]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Tools`}),`: `,_(p.tools)]}),(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Model`}),`: `,ee(p.model)]}),v,(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Description`}),` (tells Claude when to use this agent):`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:g})}),(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`System prompt`}),`:`]})}),(0,W.jsx)(c,{marginLeft:2,marginTop:1,children:(0,W.jsx)(l,{children:h})}),m.warnings.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`warning`,children:`Warnings:`}),m.warnings.map((e,t)=>(0,W.jsxs)(l,{dimColor:!0,children:[` `,`• `,e]},t))]}),m.errors.length>0&&(0,W.jsxs)(c,{marginTop:1,flexDirection:`column`,children:[(0,W.jsx)(l,{color:`error`,children:`Errors:`}),m.errors.map((e,t)=>(0,W.jsxs)(l,{color:`error`,children:[` `,`• `,e]},t))]}),i&&(0,W.jsx)(c,{marginTop:1,children:(0,W.jsx)(l,{color:`error`,children:i})}),(0,W.jsx)(c,{marginTop:2,children:(0,W.jsxs)(l,{color:`success`,children:[`Press `,(0,W.jsx)(l,{bold:!0,children:`s`}),` or `,(0,W.jsx)(l,{bold:!0,children:`Enter`}),` to save, `,(0,W.jsx)(l,{bold:!0,children:`e`}),` to save and edit`]})})]})})}var W,pr=e((()=>{m(),E(),Ft(),Te(),Vt(),we(),w(),H(),V(),On(),dr(),W=_()}));function mr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=R(),[i,a]=(0,hr.useState)(null),o=ce(),s=(0,hr.useCallback)(async e=>{if(r?.finalAgent)try{await wn(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:it(t),allAgents:t}}}),lt(),e&&await ln(yn({source:r.location,agentType:r.finalAgent.agentType})),zt(`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: ${h.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${h.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,gr.jsx)(fr,{tools:e,existingAgents:t,onSave:(0,hr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,hr.useCallback)(()=>s(!0),[s]),error:i})}var hr,gr,_r=e((()=>{f(),hr=t(p(),1),Rt(),Se(),et(),cn(),H(),On(),pr(),gr=_()}));function vr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,yr.useState)(r.whenToUse||``),[o,f]=(0,yr.useState)(i.length),[p,m]=(0,yr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,yr.useCallback)(async()=>{let e=await sn(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Claude when to use this agent)`,footerText:(0,G.jsxs)(u,{children:[(0,G.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,G.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,G.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,G.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,G.jsxs)(c,{flexDirection:`column`,children:[(0,G.jsx)(l,{children:`When should Claude use this agent?`}),(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(_e,{value:i,onChange:a,onSubmit:t=>{let r=t.trim();if(!r){m(`Description is required`);return}m(null),n({whenToUse:r}),e()},placeholder:`e.g., use this agent after you're done writing code...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(l,{color:`error`,children:p})})]})})}var yr,G,br=e((()=>{yr=t(p(),1),m(),E(),cn(),w(),re(),H(),V(),G=_()}));async function xr(e,t,n,r){let i=ye({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 ue(),o=ct([i],a),s=Pt()?Sr+Cr:Sr,c=await $e({messages:se(o),systemPrompt:qt([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>Kt(),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 zt(`tengu_agent_definition_generated`,{agent_identifier:u.identifier}),{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var Sr,Cr,wr=e((()=>{fe(),Ge(),Gt(),Nt(),Be(),mt(),Ft(),Rt(),xt(),Ie(),Sr=`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 ${wt} 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 ${wt} 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
- `,Cr=`
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 Tr(){let{updateWizardData:e,goBack:t,goToStep:n,wizardData:r}=R(),[i,a]=(0,K.useState)(r.generationPrompt||``),[o,s]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[m,h]=(0,K.useState)(i.length),g=un(),_=(0,K.useRef)(null);d(`confirm:no`,(0,K.useCallback)(()=>{_.current&&(_.current.abort(),_.current=null,s(!1),p(`Generation cancelled`))},[]),{context:`Settings`,isActive:o}),d(`chat:externalEditor`,(0,K.useCallback)(async()=>{let e=await sn(i);e.content!==null&&(a(e.content),h(e.content.length))},[i]),{context:`Chat`,isActive:!o}),d(`confirm:no`,(0,K.useCallback)(()=>{e({generationPrompt:``,agentType:``,systemPrompt:``,whenToUse:``,generatedAgent:void 0,wasGenerated:!1}),a(``),p(null),t()},[e,t]),{context:`Settings`,isActive:!o});let v=async()=>{let t=i.trim();if(!t){p(`Please describe what the agent should do`);return}p(null),s(!0),e({generationPrompt:t,isGenerating:!0});let r=Me();_.current=r;try{let i=await xr(t,g,[],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`)&&p(t.message||`Failed to generate agent`),e({isGenerating:!1})}finally{s(!1),_.current=null}},y=`Describe what this agent should do and when it should be used (be comprehensive for best results)`;return o?(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`cancel`}),children:(0,q.jsxs)(c,{flexDirection:`row`,alignItems:`center`,children:[(0,q.jsx)(pe,{}),(0,q.jsx)(l,{color:`suggestion`,children:` Generating agent from description...`})]})}):(0,q.jsx)(B,{subtitle:y,footerText:(0,q.jsxs)(u,{children:[(0,q.jsx)(T,{action:`confirm:yes`,context:`Confirmation`,fallback:`Enter`,description:`submit`}),(0,q.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,q.jsxs)(c,{flexDirection:`column`,children:[f&&(0,q.jsx)(c,{marginBottom:1,children:(0,q.jsx)(l,{color:`error`,children:f})}),(0,q.jsx)(_e,{value:i,onChange:a,onSubmit:v,placeholder:`e.g., Help me write unit tests for my code...`,columns:80,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})]})})}var K,q,Er=e((()=>{vt(),K=t(p(),1),dn(),m(),E(),ie(),cn(),w(),ne(),re(),H(),V(),wr(),q=_()}));function Dr(){let{goNext:e,updateWizardData:t,cancel:n}=R();return(0,J.jsx)(B,{subtitle:`Choose location`,footerText:(0,J.jsxs)(u,{children:[(0,J.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,J.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]}),children:(0,J.jsx)(c,{children:(0,J.jsx)(nt,{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,Or=e((()=>{m(),w(),Qe(),H(),V(),J=_()}));function kr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();d(`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)(u,{children:[(0,Y.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,Y.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,Y.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Y.jsx)(c,{children:(0,Y.jsx)(nt,{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:Pt()&&i&&a?()=>r.systemPrompt+`
101
-
102
- `+je(a,i):()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,Ar=e((()=>{m(),E(),Ft(),Te(),w(),Qe(),H(),V(),Y=_()}));function jr(){let{goNext:e,goBack:t,updateWizardData:n,goToStep:r}=R();return(0,X.jsx)(B,{subtitle:`Creation method`,footerText:(0,X.jsxs)(u,{children:[(0,X.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,X.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,X.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,X.jsx)(c,{children:(0,X.jsx)(nt,{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,Mr=e((()=>{m(),w(),Qe(),H(),V(),X=_()}));function Nr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return(0,Pr.jsx)(B,{subtitle:`Select model`,footerText:(0,Pr.jsxs)(u,{children:[(0,Pr.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,Pr.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,Pr.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Pr.jsx)(Fn,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var Pr,Fr=e((()=>{w(),m(),H(),V(),Rn(),Pr=_()}));function Ir(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,Lr.useState)(r.systemPrompt||``),[o,f]=(0,Lr.useState)(i.length),[p,m]=(0,Lr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,Lr.useCallback)(async()=>{let e=await sn(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,Z.jsx)(B,{subtitle:`System prompt`,footerText:(0,Z.jsxs)(u,{children:[(0,Z.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Z.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Z.jsx)(T,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`open in editor`}),(0,Z.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Z.jsxs)(c,{flexDirection:`column`,children:[(0,Z.jsx)(l,{children:`Enter the system prompt for your agent:`}),(0,Z.jsx)(l,{dimColor:!0,children:`Be comprehensive for best results`}),(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(_e,{value:i,onChange:a,onSubmit:()=>{let t=i.trim();if(!t){m(`System prompt is required`);return}m(null),n({systemPrompt:t}),e()},placeholder:`You are a helpful code reviewer who...`,columns:80,cursorOffset:o,onChangeCursorOffset:f,focus:!0,showCursor:!0})}),p&&(0,Z.jsx)(c,{marginTop:1,children:(0,Z.jsx)(l,{color:`error`,children:p})})]})})}var Lr,Z,Rr=e((()=>{Lr=t(p(),1),m(),E(),cn(),w(),re(),H(),V(),Z=_()}));function zr({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,Br.jsx)(B,{subtitle:`Select tools`,footerText:(0,Br.jsxs)(u,{children:[(0,Br.jsx)(s,{shortcut:`Enter`,action:`toggle selection`}),(0,Br.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,Br.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,Br.jsx)(Vn,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var Br,Vr=e((()=>{m(),w(),H(),V(),Hn(),Br=_()}));function Hr(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),[a,o]=(0,Ur.useState)(i.agentType||``),[f,p]=(0,Ur.useState)(null),[m,h]=(0,Ur.useState)(a.length);return d(`confirm:no`,n,{context:`Settings`}),(0,Q.jsx)(B,{subtitle:`Agent type (identifier)`,footerText:(0,Q.jsxs)(u,{children:[(0,Q.jsx)(s,{shortcut:`Type`,action:`enter text`}),(0,Q.jsx)(s,{shortcut:`Enter`,action:`continue`}),(0,Q.jsx)(T,{action:`confirm:no`,context:`Settings`,fallback:`Esc`,description:`go back`})]}),children:(0,Q.jsxs)(c,{flexDirection:`column`,children:[(0,Q.jsx)(l,{children:`Enter a unique identifier for your agent:`}),(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(_e,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=lr(n);if(i){p(i);return}p(null),r({agentType:n}),t()},placeholder:`e.g., test-runner, tech-lead, etc`,columns:60,cursorOffset:m,onChangeCursorOffset:h,focus:!0,showCursor:!0})}),f&&(0,Q.jsx)(c,{marginTop:1,children:(0,Q.jsx)(l,{color:`error`,children:f})})]})})}var Ur,Q,Wr=e((()=>{Ur=t(p(),1),m(),E(),w(),re(),H(),V(),dr(),Q=_()}));function Gr({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Kr.jsx)(Qn,{steps:[Dr,jr,Tr,()=>(0,Kr.jsx)(Hr,{existingAgents:t}),Ir,vr,()=>(0,Kr.jsx)(zr,{tools:e}),Nr,sr,...Pt()?[kr]:[],()=>(0,Kr.jsx)(mr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Kr,qr=e((()=>{Ft(),H(),cr(),_r(),br(),Er(),Or(),Ar(),Mr(),Fr(),Rr(),Vr(),Wr(),Kr=_()}));function Jr({tools:e,onExit:t}){let[n,r]=(0,Yr.useState)({mode:`list-agents`,source:`all`}),i=Ae(e=>e.agentDefinitions),a=Ae(e=>e.mcp.tools),o=Ae(e=>e.toolPermissionContext),s=ce(),{allAgents:u,activeAgents:d}=i,[f,p]=(0,Yr.useState)([]),m=an(e,a,o);nn();let _=(0,Yr.useMemo)(()=>({"built-in":u.filter(e=>e.source===`built-in`),userSettings:u.filter(e=>e.source===`userSettings`),projectSettings:u.filter(e=>e.source===`projectSettings`),policySettings:u.filter(e=>e.source===`policySettings`),localSettings:u.filter(e=>e.source===`localSettings`),flagSettings:u.filter(e=>e.source===`flagSettings`),plugin:u.filter(e=>e.source===`plugin`),all:u}),[u]),v=(0,Yr.useCallback)(e=>{p(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),y=(0,Yr.useCallback)(async e=>{try{await En(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:it(n)}}}),p(t=>[...t,`Deleted agent: ${h.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Lt(St(e))}},[s]);switch(n.mode){case`list-agents`:{let e=$t(n.source===`all`?[..._[`built-in`],..._.userSettings,..._.projectSettings,..._.localSettings,..._.policySettings,..._.flagSettings,..._.plugin]:_[n.source],d);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xn,{source:n.source,agents:e,onBack:()=>{t((f.length>0?`Agent changes:\n${f.join(`
103
- `)}`:void 0)??`Agents dialog dismissed`,{display:f.length===0?`system`:void 0})},onSelect:e=>r({mode:`agent-menu`,agent:e,previousMode:n}),onCreateNew:()=>r({mode:`create-agent`}),changes:f}),(0,$.jsx)(qn,{})]})}case`create-agent`:return(0,$.jsx)(Gr,{tools:m,existingAgents:d,onComplete:v,onCancel:()=>r({mode:`list-agents`,source:`all`})});case`agent-menu`:{let e=u.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)(g,{title:n.agent.agentType,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsxs)(c,{flexDirection:`column`,children:[(0,$.jsx)(nt,{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)}),f.length>0&&(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(l,{dimColor:!0,children:f[f.length-1]})})]})}),(0,$.jsx)(qn,{})]})}case`view-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:e.agentType,onCancel:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode}),hideInputGuide:!0,children:(0,$.jsx)(kn,{agent:e,tools:m,allAgents:u,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(qn,{instructions:`Press Enter or Esc to go back`})]})}case`delete-confirm`:return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(g,{title:`Delete agent`,onCancel:()=>{`previousMode`in n&&r(n.previousMode)},color:`error`,children:[(0,$.jsxs)(l,{children:[`Are you sure you want to delete the agent `,(0,$.jsx)(l,{bold:!0,children:n.agent.agentType}),`?`]}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsxs)(l,{dimColor:!0,children:[`Source: `,n.agent.source]})}),(0,$.jsx)(c,{marginTop:1,children:(0,$.jsx)(nt,{options:[{label:`Yes, delete`,value:`yes`},{label:`No, cancel`,value:`no`}],onChange:e=>{e===`yes`?y(n.agent):`previousMode`in n&&r(n.previousMode)},onCancel:()=>{`previousMode`in n&&r(n.previousMode)}})})]}),(0,$.jsx)(qn,{instructions:`Press ↑↓ to navigate, Enter to select, Esc to cancel`})]});case`edit-agent`:{let e=u.find(e=>e.agentType===n.agent.agentType&&e.source===n.agent.source)||n.agent;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{title:`Edit agent: ${e.agentType}`,onCancel:()=>r(n.previousMode),hideInputGuide:!0,children:(0,$.jsx)(Gn,{agent:e,tools:m,onSaved:e=>{v(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(qn,{})]})}default:return null}}var Yr,$,Xr=e((()=>{f(),p(),Yr=t(p(),1),rn(),on(),m(),Se(),Zt(),et(),Ct(),It(),Qe(),An(),Kn(),Yn(),Zn(),On(),qr(),$=_()}));async function Zr(e,t){let n=t.getAppState().toolPermissionContext;return(0,Qr.jsx)(Jr,{tools:Fe(n),onExit:e})}var Qr;e((()=>{p(),Xr(),Pe(),Qr=_()}))();export{Zr as call};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{V_ as t,z_ as n}from"./loadAgentsDir-D206qwP3.js";import{g as r,u as i}from"./settings-BovzmwMP.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 +0,0 @@
1
- import{a as e,n as t,o as n}from"./api-gqTA-D7n.js";n();export{t as fetchCodeSessionsFromSessionsAPI,e as getOAuthHeaders};
@@ -1 +0,0 @@
1
- import{n as e,t}from"./auth-BnSrKyJe.js";export{t as authLogin,e as authStatus};
@@ -1 +0,0 @@
1
- import{Bt as e,It as t,Ot as n,mt as r,yt as i}from"./model-CKkOnnnx.js";e();export{r as checkAndRefreshOAuthTokenIfNeeded,i as clearOAuthTokenCache,n as getClaudeAIOAuthTokens,t as handleOAuth401Error};
@@ -1,15 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ot as n}from"./state-ix0xIunV.js";import{C as r,CT as i,E as a,OT as ee,PT as o,ST as s,_T as te,bT as c,dT as l,dd as u,fT as d,fd as ne,gT as f,hT as p,mT as m,pT as h,ud as g,vT as _,x as re,xT as v,yT as y,zT as ie}from"./loadAgentsDir-D206qwP3.js";import{s as ae,u as oe}from"./types-C-MRCL8J.js";import{a as se,n as ce,o as le,t as ue}from"./bridgeConfig-BhxRF2vm.js";import{i as b,o as x}from"./bg-WnYN5ifx.js";import{n as S,t as C}from"./state-Cn_m2NOf.js";import{n as w,r as T}from"./pipeTransport-CqCnc-Ys.js";import{join as E}from"path";import"crypto";import{readFile as D,readdir as O}from"fs/promises";function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){return typeof e==`string`&&z.includes(e)}function j(e){return typeof e==`string`&&B.includes(e)}function M(e){return!k(e)||typeof e.name!=`string`||!j(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 N(e){if(!k(e)||typeof e.runId!=`string`||typeof e.workflow!=`string`||!A(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(M).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 P(e,t){try{return N(oe(await D(E(e,L,`${t}.json`),`utf-8`),!1))}catch{return null}}async function F(e=n()){let t;try{t=await O(E(e,L))}catch{return[]}let r=t.filter(e=>e.endsWith(`.json`));return(await Promise.all(r.slice(0,R).map(t=>P(e,t.slice(0,-5))))).filter(e=>e!==null).sort((e,t)=>t.updatedAt-e.updatedAt)}function I(e){if(e.length===0)return[`Workflow runs: 0`,` none`].join(`
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 L,R,z,B,V=e((()=>{t(),ae(),L=E(`.claude`,`workflow-runs`),R=200,z=[`running`,`completed`,`cancelled`],B=[`pending`,`running`,`completed`,`cancelled`]}));function H(){return E(w(),`registry.json`)}async function U(){try{let e=await D(H(),`utf8`),t=JSON.parse(e);return t.version===1?t:{...W}}catch{return{...W}}}var W,de=e((()=>{T(),W={version:1,mainMachineId:null,main:null,subs:[]}}));async function fe(){return pe(await U())}function pe(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
- `)}var me=e((()=>{de()}));function he(){try{let e=le(),t=ue();return[`Remote Control: ${e?`self-hosted`:`official`}`,` base_url=${ce()}`,` token=${t?`present`:`missing`}`,` entitlement=checked at remote-control startup`].join(`
5
- `)}catch(e){return[`Remote Control: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
6
- `)}}var ge=e((()=>{se()}));async function _e(){let e=S(),t=await x(),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 ve(){let e=!1,t=null;try{e=a(),t=re()}catch(e){return[`Auto mode: unknown`,` reason=${e instanceof Error?e.message:String(e)}`].join(`
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:ve()}),Promise.resolve({id:`runs`,title:`Runs`,content:d(e)}),Promise.resolve({id:`flows`,title:`Flows`,content:y(t)}),F().then(e=>({id:`workflow-runs`,title:`Workflow Runs`,content:I(e)})),fe().then(e=>({id:`pipes`,title:`Pipes`,content:e})),_e().then(e=>({id:`runtime`,title:`Runtime`,content:e})),Promise.resolve({id:`remote-control`,title:`Remote Control`,content:he()}),ne().then(e=>({id:`remote-trigger`,title:`RemoteTrigger`,content:g(e)}))])}async function ye(e){return(await G(e)).map((e,t)=>[t===0?`# Autonomy Deep Status`:`## ${e.title}`,e.content].join(`
10
- `)).join(`
11
-
12
- `)}var be=e((()=>{C(),b(),v(),h(),r(),u(),V(),me(),ge()}));function xe(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,Se=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([m(t),s(t)]);return e?.deep?ye({runs:n,flows:r}):[d(n),y(r)].join(`
13
- `)}async function Ce(e,t){let[n,r]=await Promise.all([m(t?.rootDir),s(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 we(e){process.stdout.write(`${await J(e)}\n`)}async function Y(e,t){return l(await m(t?.rootDir),q(e))}async function Te(e){process.stdout.write(`${await Y(e)}\n`)}async function X(e,t){return _(await s(t?.rootDir),q(e))}async function Ee(e){process.stdout.write(`${await X(e)}\n`)}async function Z(e,t){return te(await c(e,t?.rootDir))}async function De(e){process.stdout.write(`${await Z(e)}\n`)}async function Q(e,t){let n=await i({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=ie(t=>t.autonomy?.flowId===e);r=n.length;for(let e of n)e.autonomy?.runId&&await p(e.autonomy.runId,t?.rootDir)}else{for(let e of n.queuedRunIds)await p(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 Oe(e){process.stdout.write(`${await Q(e)}\n`)}async function $(e,t){let n=await f({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 ke(e){process.stdout.write(`${await $(e)}\n`)}async function Ae(e,t){let n=xe(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 je=e((()=>{v(),h(),be(),Se(),o()}));export{Te as a,Ae as c,X as d,Y as f,$ as g,q as h,Ee as i,Ce as l,je as m,De as n,we as o,J as p,ke as r,Q as s,Oe as t,Z as u};
@@ -1 +0,0 @@
1
- import{t as e}from"./backgroundHousekeeping-BVMf_Tjn.js";export{e as startBackgroundHousekeeping};
@@ -1,17 +0,0 @@
1
- import{a as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{K as i,R as a,en as o}from"./state-ix0xIunV.js";import{Dx as s,Et as c,Gw as l,Hg as u,So as d,To as f,Wg as ee,Ww as te,Xl as ne,Yl as p,Yw as m,ZT as h,br as g,et as _,hS as v,ht as y,jr as re,kx as ie,mS as ae,nt as oe,wo as se,zo as b}from"./loadAgentsDir-D206qwP3.js";import{n as ce,t as le}from"./cwd-CYmmnQVS.js";import{S as ue,W as de,a as fe,d as x,l as S,p as C,z as w}from"./debug-BrXObCdR.js";import{f as T,g as E,v as D}from"./settings-BovzmwMP.js";import{C as O,T as k,w as A}from"./config-DmomySWC.js";import{o as j,s as M,v as N,y as P}from"./log-BMCygSzM.js";import{n as F,r as I}from"./analytics-BotDBGh0.js";import{_ as L,h as R}from"./model-CKkOnnnx.js";import{Tn as z,wn as B}from"./prompt-BNHtszmZ.js";import{st as V}from"./rcDebugLog-CUy1_F23.js";import{i as H,t as U}from"./nativeInstaller-CA5d6_G7.js";import{n as pe,t as me}from"./allErrors-1896uQA1.js";import{n as he,r as ge}from"./magicDocs-DWjL2k7P.js";import{n as _e,t as ve}from"./pluginAutoupdate-reO2PgtQ.js";import{n as ye,r as be}from"./registerProtocol-B7Fzdofu.js";import{homedir as xe}from"os";import{join as W}from"path";import"crypto";import*as G from"fs/promises";r(),o(),ce(),ue(),C(),fe(),P(),E(),z(),L(),m(),ne(),re(),ge(),_(),j(),w(),b(),h(),_(),l(),w(),j(),b(),h();async function Se(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(le(),`.claude`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{M(Error(`Failed to read skill file for improvement: ${i}`));return}let o=t.map(e=>`- ${e.section}: ${e.change}`).join(`
2
- `),s=R(),c=await oe({messages:[d({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
- ${o}
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:V([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:te().signal,options:{getToolPermissionContext:async()=>B(),model:s,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),l=se(f(Array.isArray(c.message.content)?c.message.content:[]).trim(),`updated_file`);if(!l){M(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,l,`utf-8`)}catch(e){M(de(e))}}F(),ie(),O(),j(),U(),v(),pe(),ee(),c();var Ce=30;function K(){let e=((T()||{}).cleanupPeriodDays??Ce)*24*60*60*1e3;return new Date(Date.now()-e)}function we(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function Te(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 q(e,t,n){let r={messages:0,errors:0};try{let i=await x().readdir(e);for(let a of i)try{Te(a.name)<t&&(await x().unlink(W(e,a.name)),n?r.messages++:r.errors++)}catch(e){M(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&M(e)}return r}async function Ee(){let e=x(),t=K(),n=N.errors(),r=N.baseLogs(),i=await q(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=>W(r,e.name));for(let n of a)i=we(i,await q(n,t,!0)),await Y(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&M(e)}return i}async function J(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Y(e,t){try{await t.rmdir(e)}catch{}}async function De(){let e=K(),t={messages:0,errors:0},n=g(),r=x(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=W(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 J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=W(i,n.name),o=W(a,u),s;try{s=await r.readdir(o)}catch{await Y(a,r);continue}for(let n of s)if(n.isFile())try{await J(W(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=W(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Y(i,r)}await Y(o,r),await Y(a,r)}await Y(i,r)}return t}async function Oe(e,t,n=!0){let r=K(),i={messages:0,errors:0},a=x(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await J(W(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Y(e,a),i}function ke(){return Oe(W(n(),`plans`),`.md`)}async function Ae(){let e=K(),t={messages:0,errors:0},r=x();try{let i=W(n(),`file-history`),a;try{a=await r.readdir(i)}catch{return t}let o=a.filter(e=>e.isDirectory()).map(e=>W(i,e.name));await Promise.all(o.map(async n=>{try{(await r.stat(n)).mtime<e&&(await r.rm(n,{recursive:!0,force:!0}),t.messages++)}catch{t.errors++}})),await Y(i,r)}catch(e){M(e)}return t}async function X(){let e=K(),t={messages:0,errors:0},r=x();try{let i=W(n(),`session-env`),a;try{a=await r.readdir(i)}catch{return t}let o=a.filter(e=>e.isDirectory()).map(e=>W(i,e.name));for(let n of o)try{(await r.stat(n)).mtime<e&&(await r.rm(n,{recursive:!0,force:!0}),t.messages++)}catch{t.errors++}await Y(i,r)}catch(e){M(e)}return t}async function je(){let e=K(),t={messages:0,errors:0},r=x(),i=W(n(),`debug`),a;try{a=await r.readdir(i)}catch{return t}for(let n of a)if(!(!n.isFile()||!n.name.endsWith(`.txt`)||n.name===`latest`))try{await J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}return t}var Z=1440*60*1e3;async function Q(){let e=W(n(),`.npm-cache-cleanup`);try{let t=await G.stat(e);if(Date.now()-t.mtimeMs<Z){S(`npm cache cleanup: skipping, ran recently`);return}}catch{}try{await A(e,{retries:0,realpath:!1})}catch{S(`npm cache cleanup: skipping, lock held`);return}S(`npm cache cleanup: starting`);let r=W(xe(),`.npm`,`_cacache`),i=Date.now();try{let n=await import(`./lib-rQZENxQg.js`).then(e=>t(e.default,1)),a=i-Z,o=n.ls.stream(r),s=[];for await(let e of o)e.key.includes(`@anthropic-ai/claude-`)&&s.push({key:e.key,time:e.time});let c=new Map;for(let e of s){let t=e.key.lastIndexOf(`@`),n=t>0?e.key.slice(0,t):e.key,r=c.get(n)??[];r.push(e),c.set(n,r)}let l=[];for(let[,e]of c){e.sort((e,t)=>t.time-e.time);for(let t=0;t<e.length;t++){let n=e[t];(n.time<a||t>=5)&&l.push(n.key)}}await Promise.all(l.map(e=>n.rm.entry(r,e))),await G.writeFile(e,new Date().toISOString());let u=Date.now()-i;l.length>0?S(`npm cache cleanup: Removed ${l.length} old @anthropic-ai entries in ${u}ms`):S(`npm cache cleanup: completed in ${u}ms`),I(`tengu_npm_cache_cleanup`,{success:!0,durationMs:u,entriesRemoved:l.length})}catch(e){M(e),I(`tengu_npm_cache_cleanup`,{success:!1,durationMs:Date.now()-i})}finally{await k(e,{realpath:!1}).catch(()=>{})}}async function Me(){let e=W(n(),`.version-cleanup`);try{let t=await G.stat(e);if(Date.now()-t.mtimeMs<Z){S(`version cleanup: skipping, ran recently`);return}}catch{}try{await A(e,{retries:0,realpath:!1})}catch{S(`version cleanup: skipping, lock held`);return}S(`version cleanup: starting (throttled)`);try{await H(),await G.writeFile(e,new Date().toISOString())}catch(e){M(e)}finally{await k(e,{realpath:!1}).catch(()=>{})}}async function Ne(){let{errors:e}=me();if(e.length>0&&D(`cleanupPeriodDays`)){S(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await Ee(),await De(),await ke(),await Ae(),await X(),await je(),await s(),await ae(K());let t=await y(K());t>0&&I(`tengu_worktree_cleanup`,{removed:t}),process.env.USER_TYPE===`ant`&&await Q()}o(),U(),_e();var Pe=(ye(),e(be)),Fe=1440*60*1e3,$=600*1e3;function Ie(){he(),import(`./extractMemories-BcaklA33.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),p(),ve(),a()&&Pe.ensureDeepLinkProtocolRegistered();let e=!0;async function t(){if(a()&&i()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Ne()),a()&&i()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await H()}setTimeout(t,$).unref(),process.env.USER_TYPE===`ant`&&setInterval(()=>{Q(),Me()},Fe).unref()}export{Se as n,Ie as t};
@@ -1 +0,0 @@
1
- import{a as e,n as t,o as n,t as r}from"./bridgeConfig-BhxRF2vm.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
@@ -1 +0,0 @@
1
- import{n as e,r as t,t as n}from"./bridgeEnabled-SbB-6zdY.js";t();export{n as checkBridgeMinVersion,e as getBridgeDisabledReason};
@@ -1,68 +0,0 @@
1
- import{l as e,o as t,u as n}from"./envUtils-DSxRz_kt.js";import{Gr as r,di as i,t as a,ui as o}from"./src-CDCSSo0U2.js";import{Aa as s,Et as c,Fa as l,Ma as u,NC as d,Na as f,PC as p,Pa as m,ax as h,dx as g,ix as _,ja as v,jt as y,lx as b,nx as ee,ox as x,sx as S,ux as C,vt as w}from"./loadAgentsDir-D206qwP3.js";import{C as T,F as E,S as D,a as O,l as k,w as A,z as j}from"./debug-BrXObCdR.js";import{Gt as M,Kt as N,Wt as te}from"./settings-BovzmwMP.js";import{M as P,j as F}from"./git-Do0wJvux.js";import{o as I,s as L}from"./log-BMCygSzM.js";import{i as R,n as z,r as B}from"./analytics-BotDBGh0.js";import{T as V,b as H,u as U}from"./startupProfiler-xa3NmN7Z.js";import{_n as W,vn as G}from"./model-CKkOnnnx.js";import{n as K,t as q}from"./rcDebugLog-CUy1_F23.js";import{c as J,d as ne,f as re,n as Y,o as X,r as ie}from"./debugUtils-NO5KtXqi.js";import{n as ae,s as oe}from"./firstPartyEventLogger-CoSUd0a1.js";import{n as se,t as ce}from"./datadog-CpqEQbHa.js";import{a as le,t as ue}from"./types-Bh9S_JG5.js";import{i as de,n as Z,r as Q}from"./cliLaunch-BkPAatcs.js";import{t as $}from"./lib-BlVGipXx.js";import{t as fe}from"./capacityWake-CV_x9H8j.js";import{t as pe}from"./jwtUtils-DE2GPUcx.js";import{t as me}from"./pollConfig-DH2oCtFS.js";import{i as he}from"./trustedDevice-BTYoQCkC.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./workSecret-CNWiR2uQ.js";import{hostname as xe,tmpdir as Se}from"os";import{basename as Ce,dirname as we,join as Te,resolve as Ee}from"path";import{createWriteStream as De}from"fs";import{randomUUID as Oe}from"crypto";import{spawn as ke}from"child_process";import{createInterface as Ae}from"readline";t(),j(),D(),F(),I(),z(),H(),W(),p(),ce(),ae(),X(),q(),le(),u(),c(),de(),i();var je=$();N(),a(),O(),b();var Me={type:`utf8`,errorCorrectionLevel:`L`,small:!0};async function Ne(e){return(await(0,je.toString)(e,Me)).split(`
2
- `).filter(e=>e.length>0)}function Pe(e){let t=e.write??(e=>process.stdout.write(e)),n=e.verbose,i=0,a=`idle`,s=`Ready`,c=``,l=``,u=``,d=``,f=``,p=``,m=null,v=[],y=!1,b=null,w=0,T=0,E=1,D=null,O=`single-session`,A=new Map,j=null,N=0;function P(e){let t=process.stdout.columns||80,n=0;for(let i of e.split(`
3
- `)){if(i.length===0){n++;continue}let e=r(i);n+=Math.max(1,Math.ceil(e/t))}return e.endsWith(`
4
- `)&&n--,n}function F(e){t(e),i+=P(e)}function I(){i<=0||(k(`[bridge:ui] clearStatusLines count=${i}`),t(`\x1b[${i}A`),t(`\x1B[J`),i=0)}function L(e){I(),t(e)}function R(e){Ne(e).then(e=>{v=e,W()}).catch(e=>{k(`QR code generation failed: ${e}`,{level:`error`})})}function z(){I();let e=M[N%M.length],t=``;c&&(t+=o.dim(` · `)+o.dim(c)),l&&(t+=o.dim(` · `)+o.dim(l)),F(`${o.yellow(e)} ${o.yellow(`Connecting`)}${t}\n`)}function B(){H(),z(),j=setInterval(()=>{N++,z()},150)}function H(){j&&(clearInterval(j),j=null)}function W(){if(a===`reconnecting`||a===`failed`)return;I();let e=a===`idle`;if(y)for(let e of v)F(`${o.dim(e)}\n`);let t=te,n=e?o.green:o.cyan,r=(e?o.green:o.cyan)(s),i=``;if(c&&(i+=o.dim(` · `)+o.dim(c)),l&&O!==`worktree`&&(i+=o.dim(` · `)+o.dim(l)),process.env.USER_TYPE===`ant`&&u&&F(`${o.yellow(`[ANT-ONLY] Logs:`)} ${o.dim(u)}\n`),F(`${n(t)} ${r}${i}\n`),E>1){let e=O===`worktree`?`New sessions will be created in an isolated worktree`:`New sessions will be created in the current directory`;F(` ${o.dim(`Capacity: ${T}/${E} \u00b7 ${e}`)}\n`);for(let[,e]of A){let t=g(e.title?V(e.title,35):o.dim(`Attached`),e.url),n=e.activity;F(` ${t}${n&&n.type!==`result`&&n.type!==`error`?o.dim(` ${V(n.summary,40)}`):``}
5
- `)}}if(E===1){let e=O===`single-session`?`Single session · exits when complete`:O===`worktree`?`Capacity: ${T}/1 \u00b7 New sessions will be created in an isolated worktree`:`Capacity: ${T}/1 \u00b7 New sessions will be created in the current directory`;F(` ${o.dim(e)}\n`)}E===1&&!e&&b&&Date.now()-w<3e4&&F(` ${o.dim(V(b,60))}\n`);let f=m??d;if(f){F(`
6
- `);let t=e?S(f):_(f),n=y?o.dim.italic(`space to hide QR code`):o.dim.italic(`space to show QR code`),r=D?o.dim.italic(` · w to toggle spawn mode`):``;F(`${o.dim(t)}\n`),F(`${n}${r}\n`)}}return{printBanner(e,r){f=e.sessionIngressUrl,p=r,d=h(r,f),R(d),n&&t(o.dim(`Remote Control`)+` v0.0.6
7
- `),n&&(e.spawnMode!==`single-session`&&(t(o.dim(`Spawn mode: `)+`${e.spawnMode}\n`),t(o.dim(`Max concurrent sessions: `)+`${e.maxSessions}\n`)),t(o.dim(`Environment ID: `)+`${r}\n`)),e.sandbox&&t(o.dim(`Sandbox: `)+`${o.green(`Enabled`)}\n`),t(`
8
- `),B()},logSessionStart(e,t){if(n){let n=V(t,80);L(o.dim(`[${C()}]`)+` Session started: ${o.white(`"${n}"`)} (${o.dim(e)})\n`)}},logSessionComplete(e,t){L(o.dim(`[${C()}]`)+` Session ${o.green(`completed`)} (${U(t)}) ${o.dim(e)}\n`)},logSessionFailed(e,t){L(o.dim(`[${C()}]`)+` Session ${o.red(`failed`)}: ${t} ${o.dim(e)}\n`)},logStatus(e){L(o.dim(`[${C()}]`)+` ${e}\n`)},logVerbose(e){n&&L(o.dim(`[${C()}] ${e}`)+`
9
- `)},logError(e){L(o.red(`[${C()}] Error: ${e}`)+`
10
- `)},logReconnected(e){L(o.dim(`[${C()}]`)+` ${o.green(`Reconnected`)} after ${U(e)}\n`)},setRepoInfo(e,t){c=e,l=t},setDebugLogPath(e){u=e},updateIdleStatus(){H(),a=`idle`,s=`Ready`,b=null,w=0,m=null,R(d),W()},setAttached(e){H(),a=`attached`,s=`Connected`,b=null,w=0,E<=1&&(m=x(e,p,f),R(m)),W()},updateReconnectingStatus(e,t){if(H(),I(),a=`reconnecting`,y)for(let e of v)F(`${o.dim(e)}\n`);let n=M[N%M.length];N++,F(`${o.yellow(n)} ${o.yellow(`Reconnecting`)} ${o.dim(`·`)} ${o.dim(`retrying in ${e}`)} ${o.dim(`·`)} ${o.dim(`disconnected ${t}`)}\n`)},updateFailedStatus(e){H(),I(),a=`failed`;let t=``;c&&(t+=o.dim(` · `)+o.dim(c)),l&&(t+=o.dim(` · `)+o.dim(l)),F(`${o.red(`×`)} ${o.red(`Remote Control Failed`)}${t}\n`),F(`${o.dim(ee)}\n`),e&&F(`${o.red(e)}\n`)},updateSessionStatus(e,t,n,r){n.type===`tool_start`&&(b=n.summary,w=Date.now()),W()},clearStatus(){H(),I()},toggleQr(){y=!y,W()},updateSessionCount(e,t,n){T===e&&E===t&&O===n||(T=e,E=t,O=n)},setSpawnModeDisplay(e){D!==e&&(D=e,e&&(O=e))},addSession(e,t){A.set(e,{url:t})},updateSessionActivity(e,t){let n=A.get(e);n&&(n.activity=t)},setSessionTitle(e,t){let n=A.get(e);n&&(n.title=t,!(a===`reconnecting`||a===`failed`)&&(E===1&&(a=`titled`,s=V(t,40)),W()))},removeSession(e){A.delete(e)},refreshDisplay(){a===`reconnecting`||a===`failed`||W()}}}J();var Fe=10,Ie=10;function Le(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var Re={Read:`Reading`,Write:`Writing`,Edit:`Editing`,MultiEdit:`Editing`,Bash:`Running`,Glob:`Searching`,Grep:`Searching`,WebFetch:`Fetching`,WebSearch:`Searching`,Task:`Running task`,FileReadTool:`Reading`,FileWriteTool:`Writing`,FileEditTool:`Editing`,GlobTool:`Searching`,GrepTool:`Searching`,BashTool:`Running`,NotebookEditTool:`Editing notebook`,LSP:`LSP`};function ze(e,t){let n=Re[e]??e,r=t.file_path??t.filePath??t.pattern??t.command?.slice(0,60)??t.url??t.query??``;return r?`${n} ${r}`:n}function Be(e,t,n){let r;try{r=T(e)}catch{return[]}if(!r||typeof r!=`object`)return[];let i=r,a=[],o=Date.now();switch(i.type){case`assistant`:{let e=i.message;if(!e)break;let r=e.content;if(!Array.isArray(r))break;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e;if(r.type===`tool_use`){let e=r.name??`Tool`,i=r.input??{},s=ze(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${He(i)}`)}else if(r.type===`text`){let e=r.text??``;e.length>0&&(a.push({type:`text`,summary:e.slice(0,80),timestamp:o}),n(`[bridge:activity] sessionId=${t} text "${e.slice(0,100)}"`))}}break}case`result`:{let e=i.subtype;if(e===`success`)a.push({type:`result`,summary:`Session completed`,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=success`);else if(e){let r=i.errors?.[0]??`Error: ${e}`;a.push({type:`error`,summary:r,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=${e} error="${r}"`)}else n(`[bridge:activity] sessionId=${t} result subtype=undefined`);break}default:break}return a}function Ve(e){if(e.parent_tool_use_id!=null||e.isSynthetic||e.isReplay)return;let t=e.message?.content,n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`){n=e.text;break}}return n=n?.trim(),n||void 0}function He(e){let t=[];for(let[n,r]of Object.entries(e))if(typeof r==`string`&&t.push(`${n}="${r.slice(0,100)}"`),t.length>=3)break;return t.join(` `)}function Ue(e){return{spawn(t,n){let r=Le(t.sessionId),i;if(e.debugFile){let t=e.debugFile.lastIndexOf(`.`);i=t>0?`${e.debugFile.slice(0,t)}-${r}${e.debugFile.slice(t)}`:`${e.debugFile}-${r}`}else(e.verbose||process.env.USER_TYPE===`ant`)&&(i=Te(Se(),`claude`,`bridge-session-${r}.log`));let a=null,o;e.debugFile&&(o=Te(we(e.debugFile),`bridge-transcript-${r}.jsonl`),a=De(o,{flags:`a`}),a.on(`error`,t=>{e.onDebug(`[bridge:session] Transcript write error: ${t.message}`),a=null}),e.onDebug(`[bridge:session] Transcript log: ${o}`));let s=[...e.scriptArgs,`--print`,`--sdk-url`,t.sdkUrl,`--session-id`,t.sessionId,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--replay-user-messages`,...e.verbose?[`--verbose`]:[],...i?[`--debug-file`,i]:[],...e.permissionMode?[`--permission-mode`,e.permissionMode]:[]],c={...e.env,CLAUDE_CODE_OAUTH_TOKEN:void 0,CLAUDE_CODE_ENVIRONMENT_KIND:`bridge`,...e.sandbox&&{CLAUDE_CODE_FORCE_SANDBOX:`1`},CLAUDE_CODE_SESSION_ACCESS_TOKEN:t.accessToken,CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2:`1`,...t.useCcrV2&&{CLAUDE_CODE_USE_CCR_V2:`1`,CLAUDE_CODE_WORKER_EPOCH:String(t.workerEpoch)}};e.onDebug(`[bridge:session] Spawning sessionId=${t.sessionId} sdkUrl=${t.sdkUrl} accessToken=${t.accessToken?`present`:`MISSING`}`),e.onDebug(`[bridge:session] Child args: ${s.join(` `)}`),i&&e.onDebug(`[bridge:session] Debug log: ${i}`);let l=ke(e.execPath,s,{cwd:n,stdio:[`pipe`,`pipe`,`pipe`],env:c,windowsHide:!0});e.onDebug(`[bridge:session] sessionId=${t.sessionId} pid=${l.pid}`);let u=[],d=null,f=[],p=!1,m=!1;l.stderr&&Ae({input:l.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(t+`
11
- `),f.length>=Ie&&f.shift(),f.push(t)}),l.stdout&&Ae({input:l.stdout}).on(`line`,n=>{a&&a.write(n+`
12
- `),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${Y(n)}`),e.verbose&&process.stderr.write(n+`
13
- `);let r=Be(n,t.sessionId,e.onDebug);for(let n of r)u.length>=Fe&&u.shift(),u.push(n),d=n,e.onActivity?.(t.sessionId,n);{let r;try{r=T(n)}catch{}if(r&&typeof r==`object`){let n=r;if(n.type===`control_request`)n.request?.subtype===`can_use_tool`&&e.onPermissionRequest&&e.onPermissionRequest(t.sessionId,r,t.accessToken);else if(n.type===`user`&&!m&&t.onFirstUserMessage){let e=Ve(n);e&&(m=!0,t.onFirstUserMessage(e))}}}});let h=new Promise(n=>{l.on(`close`,(r,i)=>{a&&(a.end(),a=null),i===`SIGTERM`||i===`SIGINT`?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} interrupted signal=${i} pid=${l.pid}`),n(`interrupted`)):r===0?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} completed exit_code=0 pid=${l.pid}`),n(`completed`)):(e.onDebug(`[bridge:session] sessionId=${t.sessionId} failed exit_code=${r} pid=${l.pid}`),n(`failed`))}),l.on(`error`,r=>{e.onDebug(`[bridge:session] sessionId=${t.sessionId} spawn error: ${r.message}`),n(`failed`)})}),g={sessionId:t.sessionId,done:h,activities:u,accessToken:t.accessToken,lastStderr:f,get currentActivity(){return d},kill(){l.killed||(e.onDebug(`[bridge:session] Sending SIGTERM to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGTERM`))},forceKill(){!p&&l.pid&&(p=!0,e.onDebug(`[bridge:session] Sending SIGKILL to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGKILL`))},writeStdin(n){l.stdin&&!l.stdin.destroyed&&(e.onDebug(`[bridge:ws] sessionId=${t.sessionId} >>> ${Y(n)}`),l.stdin.write(n))},updateAccessToken(n){g.accessToken=n,g.writeStdin(A({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})+`
14
- `),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return g}}}O(),b(),X();var We={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Ge=1e3,Ke=32;async function qe(){return!1}function Je(e){return e.connCapMs*2}function Ye(){let e=[...Z()],t=Q();return t&&e.push(t),e}function Xe(e,t,n){try{return e.spawn(t,n)}catch(e){let t=E(e);return L(Error(`Session spawn failed: ${t}`)),t}}async function Ze(t,r,i,a,o,c,u,p=We,h,g){let _=new AbortController;u.aborted?_.abort():u.addEventListener(`abort`,()=>_.abort(),{once:!0});let v=_.signal,b=new Map,ee=new Map,x=new Map,S=new Map,C=new Map,T=new Map,D=new Set,O=new Map,A=new Set,j=new Set,M=fe(v);async function N(){K(`heartbeat: checking ${b.size} active session(s)`);let e=!1,t=!1,n=[];for(let[i]of b){let o=x.get(i),c=C.get(i);if(!(!o||!c))try{await a.heartbeatWork(r,o,c),e=!0}catch(e){k(`[bridge:heartbeat] Failed for sessionId=${i} workId=${o}: ${E(e)}`),e instanceof s&&(B(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),e.status===401||e.status===403?n.push(i):t=!0)}}for(let e of n){c.logVerbose(`Session ${e} token expired — re-queuing via bridge/reconnect`);try{await a.reconnectSession(r,e),k(`[bridge:heartbeat] Re-queued sessionId=${e} via bridge/reconnect`)}catch(t){c.logError(`Failed to refresh session ${e} token: ${E(t)}`),k(`[bridge:heartbeat] reconnectSession(${e}) failed: ${E(t)}`,{level:`error`})}}return t?`fatal`:n.length>0?`auth_failed`:e?`ok`:`failed`}let te=new Set,F=g?pe({getAccessToken:g,onRefresh:(e,t)=>{let n=b.get(e);n&&(te.has(e)?(c.logVerbose(`Refreshing session ${e} token via bridge/reconnect`),a.reconnectSession(r,e).catch(t=>{c.logError(`Failed to refresh session ${e} token: ${E(t)}`),k(`[bridge:token] reconnectSession(${e}) failed: ${E(t)}`,{level:`error`})})):n.updateAccessToken(t))},label:`bridge`}):null,I=Date.now(),R=new Set;function z(e){R.add(e),e.finally(()=>R.delete(e))}let V=0,H=0,W=null,q=null,J=null,re=null,Y=!1;if(k(`[bridge:work] Starting poll loop spawnMode=${t.spawnMode} maxSessions=${t.maxSessions} environmentId=${r}`),P(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),process.env.USER_TYPE===`ant`){let e;if(t.debugFile){let n=t.debugFile.lastIndexOf(`.`);e=n>0?`${t.debugFile.slice(0,n)}-*${t.debugFile.slice(n)}`:`${t.debugFile}-*`}else e=Te(Se(),`claude`,`bridge-session-*.log`);c.setDebugLogPath(e)}c.printBanner(t,r),c.updateSessionCount(0,t.maxSessions,t.spawnMode),h&&c.setAttached(h);function X(){c.updateSessionCount(b.size,t.maxSessions,t.spawnMode);for(let[e,t]of b){let n=t.currentActivity;n&&c.updateSessionActivity(S.get(e)??e,n)}if(b.size===0){c.updateIdleStatus();return}let[e,n]=[...b.entries()].pop(),r=ee.get(e);if(!r)return;let i=n.currentActivity;if(!i||i.type===`result`||i.type===`error`){t.maxSessions>1&&c.refreshDisplay();return}let a=U(Date.now()-r),o=n.activities.filter(e=>e.type===`tool_start`).slice(-5).map(e=>e.summary);c.updateSessionStatus(e,a,i,o)}function ae(){oe(),X(),re=setInterval(X,Ge)}function oe(){re&&(clearInterval(re),re=null)}function se(e,n,i){return o=>{let s=x.get(e);K(`session done: sessionId=${e} workId=${s??`none`} status=${o} wasTimedOut=${A.has(e)} duration=${Math.round((Date.now()-n)/1e3)}s stderr=${i.lastStderr.length>0?i.lastStderr.join(`\\n`).slice(0,500):`(none)`}`),b.delete(e),ee.delete(e),x.delete(e),C.delete(e);let l=S.get(e)??e;S.delete(e),c.removeSession(l),j.delete(l),te.delete(e);let u=T.get(e);u&&(clearTimeout(u),T.delete(e)),F?.cancel(e),M.wake();let d=A.delete(e),f=d&&o===`interrupted`?`failed`:o,m=Date.now()-n;k(`[bridge:session] sessionId=${e} workId=${s??`unknown`} exited status=${f} duration=${U(m)}`),B(`tengu_bridge_session_done`,{status:f,duration_ms:m}),P(`info`,`bridge_session_done`,{status:f,duration_ms:m}),c.clearStatus(),oe();let h=i.lastStderr.length>0?i.lastStderr.join(`
15
- `):void 0,g;switch(f){case`completed`:c.logSessionComplete(e,m);break;case`failed`:!d&&!v.aborted&&(g=h??`Process exited with error`,c.logSessionFailed(e,g),L(Error(`Bridge session failed: ${g}`)));break;case`interrupted`:c.logVerbose(`Session ${e} interrupted`);break}f!==`interrupted`&&s&&(z(rt(a,r,s,c,p.stopWorkBaseDelayMs)),D.add(s));let w=O.get(e);if(w&&(O.delete(e),z(y(w.worktreePath,w.worktreeBranch,w.gitRoot,w.hookBased).catch(e=>c.logVerbose(`Failed to remove worktree ${w.worktreePath}: ${E(e)}`)))),f!==`interrupted`&&!v.aborted)if(t.spawnMode!==`single-session`)z(a.archiveSession(l).catch(t=>c.logVerbose(`Failed to archive session ${e}: ${E(t)}`))),k(`[bridge:session] Session ${f}, returning to idle (multi-session mode)`);else{k(`[bridge:session] Session ${f}, aborting poll loop to tear down environment`),_.abort();return}v.aborted||ae()}}for(h||ae();!v.aborted;){let u=me();try{K(`poll: envId=${r} activeSessions=${b.size}`);let s=await a.pollForWork(r,i,v,u.reclaim_older_than_ms);if(W!==null||q!==null){let e=Date.now()-(W??q??Date.now());c.logReconnected(e),k(`[bridge:poll] Reconnected after ${U(e)}`),B(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(V=0,H=0,W=null,q=null,J=null,!s){if(b.size>=t.maxSessions){let e=u.multisession_poll_interval_ms_at_capacity;if(u.non_exclusive_heartbeat_interval_ms>0){B(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:b.size,heartbeat_interval_ms:u.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!v.aborted&&b.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=me();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=M.signal();if(r=await N(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await G(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:v.aborted?`shutdown`:b.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(B(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:b.size}),a===`poll_due`&&k(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=M.signal();await G(e>0?e:u.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=M.signal();await G(e,t.signal),t.cleanup()}}else await G(b.size>0?u.multisession_poll_interval_ms_partial_capacity:u.multisession_poll_interval_ms_not_at_capacity,v);continue}let f=b.size>=t.maxSessions;if(D.has(s.id)){if(k(`[bridge:work] Skipping already-completed workId=${s.id}`),f){let e=M.signal();u.non_exclusive_heartbeat_interval_ms>0?(await N(),await G(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await G(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await G(1e3,v);continue}let m;try{m=ye(s.secret)}catch(e){let t=E(e);if(c.logError(`Failed to decode work secret for workId=${s.id}: ${t}`),B(`tengu_bridge_work_secret_failed`,{}),D.add(s.id),z(rt(a,r,s.id,c,p.stopWorkBaseDelayMs)),f){let e=M.signal();u.non_exclusive_heartbeat_interval_ms>0?(await N(),await G(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await G(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let g=async()=>{k(`[bridge:work] Acknowledging workId=${s.id}`);try{await a.acknowledgeWork(r,s.id,m.session_ingress_token)}catch(e){k(`[bridge:work] Acknowledge failed workId=${s.id}: ${E(e)}`)}},_=s.data.type;switch(s.data.type){case`healthcheck`:await g(),k(`[bridge:work] Healthcheck received`),c.logVerbose(`Healthcheck received`);break;case`session`:{let i=s.data.id;K(`work received: type=session sessionId=${i} workId=${s.id}`);try{l(i,`session_id`)}catch{await g(),c.logError(`Invalid session_id received: ${i}`);break}let u=b.get(i);if(u){u.updateAccessToken(m.session_ingress_token),C.set(i,m.session_ingress_token),x.set(i,s.id),F?.schedule(i,m.session_ingress_token),k(`[bridge:work] Updated access token for existing sessionId=${i} workId=${s.id}`),await g();break}if(b.size>=t.maxSessions){k(`[bridge:work] At capacity (${b.size}/${t.maxSessions}), cannot spawn new session for workId=${s.id}`);break}await g();let f=Date.now(),_,M=!1,N;if(m.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){_=be(t.apiBaseUrl,i);for(let e=1;e<=2;e++)try{N=await _e(_,m.session_ingress_token),M=!0,k(`[bridge:session] CCR v2: registered worker sessionId=${i} epoch=${N} attempt=${e}`);break}catch(t){let n=E(t);if(e<2){if(k(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await G(2e3,v),v.aborted)break;continue}c.logError(`CCR v2 worker registration failed for session ${i}: ${n}`),L(Error(`registerWorker failed: ${n}`)),D.add(s.id),z(rt(a,r,s.id,c,p.stopWorkBaseDelayMs))}if(!M)break}else _=ve(t.sessionIngressUrl,i);let I=t.spawnMode,R=t.dir,V=0;if(I===`worktree`&&(h===void 0||!ge(i,h))){let e=Date.now();try{let t=await w(`bridge-${Le(i)}`);V=Date.now()-e,O.set(i,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),R=t.worktreePath,k(`[bridge:session] Created worktree for sessionId=${i} at ${t.worktreePath}`)}catch(e){let t=E(e);c.logError(`Failed to create worktree for session ${i}: ${t}`),L(Error(`Worktree creation failed: ${t}`)),D.add(s.id),z(rt(a,r,s.id,c,p.stopWorkBaseDelayMs));break}}k(`[bridge:session] Spawning sessionId=${i} sdkUrl=${_}`);let H=ne(i);K(`spawning session: sessionId=${i} sdkUrl=${_} useCcrV2=${M} workerEpoch=${N} dir=${R} accessToken=${m.session_ingress_token?m.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let U=Xe(o,{sessionId:i,sdkUrl:_,accessToken:m.session_ingress_token,useCcrV2:M,workerEpoch:N,onFirstUserMessage:e=>{if(j.has(H))return;j.add(H);let n=dt(e);c.setSessionTitle(H,n),k(`[bridge:title] derived title for ${H}: ${n}`),import(`./createSession-CoQtL5Rj.js`).then(({updateBridgeSessionTitle:e})=>e(H,n,{baseUrl:t.apiBaseUrl})).catch(e=>k(`[bridge:title] failed to update title for ${H}: ${e}`,{level:`error`}))}},R);if(typeof U==`string`){c.logError(`Failed to spawn session ${i}: ${U}`);let e=O.get(i);e&&(O.delete(i),z(y(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>c.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${E(t)}`)))),D.add(s.id),z(rt(a,r,s.id,c,p.stopWorkBaseDelayMs));break}let W=U,q=Date.now()-f;B(`tengu_bridge_session_started`,{active_sessions:b.size,spawn_mode:I,in_worktree:O.has(i),spawn_duration_ms:q,worktree_create_ms:V,inProtectedNamespace:n()}),P(`info`,`bridge_session_started`,{spawn_mode:I,in_worktree:O.has(i),spawn_duration_ms:q,worktree_create_ms:V}),b.set(i,W),x.set(i,s.id),C.set(i,m.session_ingress_token),S.set(i,H);let J=Date.now();ee.set(i,J),c.logSessionStart(i,`Session ${i}`);let re=Le(i),Y;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);Y=e>0?`${t.debugFile.slice(0,e)}-${re}${t.debugFile.slice(e)}`:`${t.debugFile}-${re}`}else(t.verbose||process.env.USER_TYPE===`ant`)&&(Y=Te(Se(),`claude`,`bridge-session-${re}.log`));Y&&c.logVerbose(`Debug log: ${Y}`),c.addSession(H,d(H,t.sessionIngressUrl)),ae(),c.setAttached(H),ft(H,t.apiBaseUrl).then(e=>{e&&b.has(i)&&(j.add(H),c.setSessionTitle(H,e),k(`[bridge:title] server title for ${H}: ${e}`))}).catch(e=>k(`[bridge:title] failed to fetch title for ${H}: ${e}`,{level:`error`}));let X=t.sessionTimeoutMs??864e5;if(X>0){let e=setTimeout(it,X,i,X,c,A,W);T.set(i,e)}M&&te.add(i),F?.schedule(i,m.session_ingress_token),W.done.then(se(i,J,W));break}default:await g(),k(`[bridge:work] Unknown work type: ${_}, skipping`);break}if(f){let e=M.signal();u.non_exclusive_heartbeat_interval_ms>0?(await N(),await G(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await G(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(v.aborted)break;if(e instanceof s){Y=!0,f(e.errorType)?c.logStatus(e.message):m(e)?k(`[bridge:work] Suppressed 403 error: ${e.message}`):(c.logError(e.message),L(e)),B(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),P(f(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=ie(e);if(K(`poll error: ${t} isConn=${$e(e)} isServer=${et(e)} activeSessions=${b.size}`),$e(e)||et(e)){let e=Date.now();J!==null&&e-J>Je(p)&&(k(`[bridge:work] Detected system sleep (${Math.round((e-J)/1e3)}s gap), resetting error budget`),P(`info`,`bridge_poll_sleep_detected`,{gapMs:e-J}),W=null,V=0,q=null,H=0),J=e,W||(W=e);let n=e-W;if(n>=p.connGiveUpMs){c.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),B(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),P(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),Y=!0;break}q=null,H=0,V=V?Math.min(V*2,p.connCapMs):p.connInitialMs;let r=tt(V);c.logVerbose(`Connection error, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),c.updateReconnectingStatus(nt(r),U(n)),me().non_exclusive_heartbeat_interval_ms>0&&await N(),await G(r,v)}else{let e=Date.now();J!==null&&e-J>Je(p)&&(k(`[bridge:work] Detected system sleep (${Math.round((e-J)/1e3)}s gap), resetting error budget`),P(`info`,`bridge_poll_sleep_detected`,{gapMs:e-J}),W=null,V=0,q=null,H=0),J=e,q||(q=e);let n=e-q;if(n>=p.generalGiveUpMs){c.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),B(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),P(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),Y=!0;break}W=null,V=0,H=H?Math.min(H*2,p.generalCapMs):p.generalInitialMs;let r=tt(H);c.logVerbose(`Poll failed, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),c.updateReconnectingStatus(nt(r),U(n)),me().non_exclusive_heartbeat_interval_ms>0&&await N(),await G(r,v)}}}oe(),c.clearStatus();let ce=Date.now()-I;B(`tengu_bridge_shutdown`,{active_sessions:b.size,loop_duration_ms:ce}),P(`info`,`bridge_shutdown`,{active_sessions:b.size,loop_duration_ms:ce});let le=new Set(b.keys());h&&le.add(h);let ue=new Map(S);if(b.size>0){k(`[bridge:shutdown] Shutting down ${b.size} active session(s)`),c.logStatus(`Shutting down ${b.size} active session(s)\u2026`);let e=new Map(x);for(let[e,t]of b.entries())k(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...b.values()].map(e=>e.done)),G(p.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of b.entries())k(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of T.values())clearTimeout(e);if(T.clear(),F?.cancelAll(),O.size>0){let e=[...O.values()];O.clear(),k(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>y(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>a.stopWork(r,t,!0).catch(n=>c.logVerbose(`Failed to stop work ${t} for session ${e}: ${E(n)}`))))}if(R.size>0&&await Promise.allSettled([...R]),t.spawnMode===`single-session`&&h&&!Y){c.logStatus("Resume this session by running `claude remote-control --continue`"),k(`[bridge:shutdown] Skipping archive+deregister to allow resume of session ${h}`);return}le.size>0&&(k(`[bridge:shutdown] Archiving ${le.size} session(s)`),await Promise.allSettled([...le].map(e=>a.archiveSession(ue.get(e)??ne(e)).catch(t=>c.logVerbose(`Failed to archive session ${e}: ${E(t)}`)))));try{await a.deregisterEnvironment(r),k(`[bridge:shutdown] Environment deregistered, bridge offline`),c.logVerbose(`Environment deregistered.`)}catch(e){c.logVerbose(`Failed to deregister environment: ${E(e)}`)}let{clearBridgePointer:de}=await import(`./bridgePointer-MqLe5Asm.js`);await de(t.dir),c.logVerbose(`Environment offline.`)}var Qe=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function $e(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&Qe.has(e.code))}function et(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function tt(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function nt(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function rt(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),k(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof s){m(e)?k(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),P(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=E(e);if(a<3){let e=tt(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${nt(e)}: ${t}`),await G(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),P(`error`,`bridge_stop_work_failed`,{attempts:3})}}function it(e,t,n,r,i){k(`[bridge:session] sessionId=${e} timed out after ${U(t)}`),B(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${U(t)}`),r.add(e),i.kill()}var at=[`session`,`same-dir`,`worktree`];function ot(e){return e===`session`?`single-session`:e===`same-dir`?`same-dir`:e===`worktree`?`worktree`:`--spawn requires one of: ${at.join(`, `)} (got: ${e??`<missing>`})`}function st(e){let t=e===void 0?NaN:parseInt(e,10);return isNaN(t)||t<1?`--capacity requires a positive integer (got: ${e??`<missing>`})`:t}function ct(e){let t=!1,n=!1,r,i,a,o,s=!1,c,l,u,d,f=!1;for(let m=0;m<e.length;m++){let h=e[m];if(h===`--help`||h===`-h`)s=!0;else if(h===`--verbose`||h===`-v`)t=!0;else if(h===`--sandbox`)n=!0;else if(h===`--no-sandbox`)n=!1;else if(h===`--debug-file`&&m+1<e.length)r=Ee(e[++m]);else if(h.startsWith(`--debug-file=`))r=Ee(h.slice(13));else if(h===`--session-timeout`&&m+1<e.length)i=parseInt(e[++m],10)*1e3;else if(h.startsWith(`--session-timeout=`))i=parseInt(h.slice(18),10)*1e3;else if(h===`--permission-mode`&&m+1<e.length)a=e[++m];else if(h.startsWith(`--permission-mode=`))a=h.slice(18);else if(h===`--name`&&m+1<e.length)o=e[++m];else if(h.startsWith(`--name=`))o=h.slice(7);else if(h===`--session-id`&&m+1<e.length){if(d=e[++m],!d)return p(`--session-id requires a value`)}else if(h.startsWith(`--session-id=`)){if(d=h.slice(13),!d)return p(`--session-id requires a value`)}else if(h===`--continue`||h===`-c`)f=!0;else if(h===`--spawn`||h.startsWith(`--spawn=`)){if(c!==void 0)return p(`--spawn may only be specified once`);let t=ot(h.startsWith(`--spawn=`)?h.slice(8):e[++m]);if(t===`single-session`||t===`same-dir`||t===`worktree`)c=t;else return p(t)}else if(h===`--capacity`||h.startsWith(`--capacity=`)){if(l!==void 0)return p(`--capacity may only be specified once`);let t=st(h.startsWith(`--capacity=`)?h.slice(11):e[++m]);if(typeof t==`number`)l=t;else return p(t)}else if(h===`--create-session-in-dir`)u=!0;else if(h===`--no-create-session-in-dir`)u=!1;else return p(`Unknown argument: ${h}\nRun 'claude remote-control --help' for usage.`)}if(c===`single-session`&&l!==void 0)return p(`--capacity cannot be used with --spawn=session (single-session mode has fixed capacity 1).`);if((d||f)&&(c!==void 0||l!==void 0||u!==void 0))return p(`--session-id and --continue cannot be used with --spawn, --capacity, or --create-session-in-dir.`);if(d&&f)return p(`--session-id and --continue cannot be used together.`);return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s};function p(e){return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s,error:e}}}async function lt(){let{EXTERNAL_PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e.join(`, `),n=await qe(),r=`
16
- Remote Control - Connect your local environment to claude.ai/code
17
-
18
- USAGE
19
- claude remote-control [options]
20
- OPTIONS
21
- --name <name> Name for the session (shown in claude.ai/code)
22
- -c, --continue Resume the last session in this directory
23
- --session-id <id> Resume a specific session by ID (cannot be
24
- used with spawn flags or --continue)
25
- --permission-mode <mode> Permission mode for spawned sessions
26
- (${t})
27
- --debug-file <path> Write debug logs to file
28
- -v, --verbose Enable verbose output
29
- -h, --help Show this help
30
- ${n?` --spawn <mode> Spawn mode: same-dir, worktree, session
31
- (default: same-dir)
32
- --capacity <N> Max concurrent sessions in worktree or
33
- same-dir mode (default: ${Ke})
34
- --[no-]create-session-in-dir Pre-create a session in the current
35
- directory; in worktree mode this session
36
- stays in cwd while on-demand sessions get
37
- isolated worktrees (default: on)
38
- `:``}
39
- DESCRIPTION
40
- Remote Control allows you to control sessions on your local device from
41
- claude.ai/code (https://claude.ai/code). Run this command in the
42
- directory you want to work in, then connect from the Claude app or web.
43
- ${n?`
44
- Remote Control runs as a persistent server that accepts multiple concurrent
45
- sessions in the current directory. One session is pre-created on start so
46
- you have somewhere to type immediately. Use --spawn=worktree to isolate
47
- each on-demand session in its own git worktree, or --spawn=session for
48
- the classic single-session mode (exits when that session ends). Press 'w'
49
- during runtime to toggle between same-dir and worktree.
50
- `:``}
51
- NOTES
52
- - You must be logged in with a Claude account that has a subscription
53
- - Run \`claude\` first in the directory to accept the workspace trust dialog
54
- ${n?` - Worktree mode requires a git repository or WorktreeCreate/WorktreeRemove hooks
55
- `:``}`;console.log(r)}var ut=80;function dt(e){return V(e.replace(/\s+/g,` `).trim(),ut)}async function ft(e,t){let{getBridgeSession:n}=await import(`./createSession-CoQtL5Rj.js`);return(await n(e,{baseUrl:t}))?.title||void 0}async function pt(e){let t=ct(e);if(t.help){await lt();return}t.error&&(console.error(`Error: ${t.error}`),process.exit(1));let{verbose:n,sandbox:r,debugFile:i,sessionTimeoutMs:a,permissionMode:o,name:c,spawnMode:u,capacity:d,createSessionInDir:f,sessionId:p,continueSession:m}=t,h=p,g,_=u!==void 0||d!==void 0||f!==void 0;if(o!==void 0){let{PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e;t.includes(o)||(console.error(`Error: Invalid permission mode '${o}'. Valid modes: ${t.join(`, `)}`),process.exit(1))}let y=Ee(`.`),{enableConfigs:b,checkHasTrustDialogAccepted:ee}=await import(`./config-DY5-_kk_.js`);b();let{initSinks:x}=await import(`./sinks-BpcRrN_T.js`);x();let S=await qe();_&&!S&&(await R(`tengu_bridge_multi_session_denied`,{used_spawn:u!==void 0,used_capacity:d!==void 0,used_create_session_in_dir:f!==void 0}),await Promise.race([Promise.all([oe(),se()]),G(500,void 0,{unref:!0})]).catch(()=>{}),console.error(`Error: Multi-session Remote Control is not enabled for your account yet.`),process.exit(1));let{setOriginalCwd:C,setCwdState:w}=await import(`./state-BOa-3Av3.js`);C(y),w(y),ee()||(console.error(`Error: Workspace not trusted. Please run \`claude\` in ${y} first to review and accept the workspace trust dialog.`),process.exit(1));let{clearOAuthTokenCache:T,checkAndRefreshOAuthTokenIfNeeded:D}=await import(`./auth-DRTjfnGy.js`),{getBridgeAccessToken:O,getBridgeBaseUrl:A}=await import(`./bridgeConfig-CqIQ_rvD.js`);O()||(console.error(ue),process.exit(1));let{getGlobalConfig:j,saveGlobalConfig:M,getCurrentProjectConfig:N,saveCurrentProjectConfig:te}=await import(`./config-DY5-_kk_.js`);if(!j().remoteDialogSeen){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
56
- Remote Control lets you access this CLI session from the web (claude.ai/code)
57
- or the Claude app, so you can pick up where you left off on any device.
58
-
59
- You can disconnect remote access anytime by running /remote-control again.
60
- `);let t=await new Promise(t=>{e.question(`Enable Remote Control? (y/n) `,t)});e.close(),M(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0}),t.toLowerCase()!==`y`&&t.toLowerCase()!==`yes`&&process.exit(0)}if(m){let{readBridgePointerAcrossWorktrees:e}=await import(`./bridgePointer-MqLe5Asm.js`),t=await e(y);t||(console.error("Error: No recent session found in this directory or its worktrees. Run `claude remote-control` to start a new one."),process.exit(1));let{pointer:n,dir:r}=t,i=Math.round(n.ageMs/6e4),a=i<60?`${i}m`:`${Math.round(i/60)}h`,o=r===y?``:` from worktree ${r}`;console.error(`Resuming session ${n.sessionId} (${a} ago)${o}\u2026`),h=n.sessionId,g=r}let F=A();F.startsWith(`http://`)&&!F.includes(`localhost`)&&!F.includes(`127.0.0.1`)&&(console.error(`Error: Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`),process.exit(1));let I=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||F,{getBranch:z,getRemoteUrl:V,findGitRoot:H}=await import(`./git-CbcnOf0E.js`),{hasWorktreeCreateHook:U}=await import(`./hooks-DPLIIpAD.js`),W=U()||H(y)!==null,K=S?N().remoteControlSpawnMode:void 0;if(K===`worktree`&&!W&&(console.error(`Warning: Saved spawn mode is worktree but this directory is not a git repository. Falling back to same-dir.`),K=void 0,te(e=>e.remoteControlSpawnMode===void 0?e:{...e,remoteControlSpawnMode:void 0})),S&&!K&&W&&u===void 0&&!h&&process.stdin.isTTY){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
61
- Claude Remote Control is launching in spawn mode which lets you create new sessions in this project from Work Mate on Web or your Mobile app. Learn more here: https://code.claude.com/docs/en/remote-control
62
-
63
- Spawn mode for this project:
64
- [1] same-dir — sessions share the current directory (default)
65
- [2] worktree — each session gets an isolated git worktree
66
-
67
- This can be changed later or explicitly set with --spawn=same-dir or --spawn=worktree.
68
- `);let t=await new Promise(t=>{e.question(`Choose [1/2] (default: 1): `,t)});e.close();let n=t.trim()===`2`?`worktree`:`same-dir`;K=n,B(`tengu_bridge_spawn_mode_chosen`,{spawn_mode:n}),te(e=>e.remoteControlSpawnMode===n?e:{...e,remoteControlSpawnMode:n})}let q,J;h?(J=`single-session`,q=`resume`):u===void 0?K===void 0?(J=S?`same-dir`:`single-session`,q=`gate_default`):(J=K,q=`saved`):(J=u,q=`flag`);let ne=J===`single-session`?1:d??Ke,Y=f??!0;if(!h){let{clearBridgePointer:e}=await import(`./bridgePointer-MqLe5Asm.js`);await e(y)}J===`worktree`&&!W&&(console.error(`Error: Worktree mode requires a git repository or WorktreeCreate hooks configured. Use --spawn=session for single-session mode.`),process.exit(1));let X=await z(),ie=await V(),ae=xe(),ce=Oe(),{handleOAuth401Error:le}=await import(`./auth-DRTjfnGy.js`),de=v({baseUrl:F,getAccessToken:O,runnerVersion:`0.0.6`,onDebug:k,onAuth401:le,getTrustedDeviceToken:he}),Z;if(h){try{l(h,`sessionId`)}catch{console.error(`Error: Invalid session ID "${h}". Session IDs must not contain unsafe characters.`),process.exit(1)}await D(),T();let{getBridgeSession:e}=await import(`./createSession-CoQtL5Rj.js`),t=await e(h,{baseUrl:F,getAccessToken:O});if(!t){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-MqLe5Asm.js`);await e(g)}console.error(`Error: Session ${h} not found. It may have been archived or expired.`),process.exit(1)}if(!t.environment_id){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-MqLe5Asm.js`);await e(g)}console.error(`Error: Session ${h} has no environment_id. It may never have been attached to a bridge.`),process.exit(1)}Z=t.environment_id,k(`[bridge:init] Resuming session ${h} on environment ${Z}`)}let Q={dir:y,machineName:ae,branch:X,gitRepoUrl:ie,maxSessions:ne,spawnMode:J,verbose:n,sandbox:r,bridgeId:ce,workerType:`claude_code`,environmentId:Oe(),reuseEnvironmentId:Z,apiBaseUrl:F,sessionIngressUrl:I,debugFile:i,sessionTimeoutMs:a};k(`[bridge:init] bridgeId=${ce}${Z?` reuseEnvironmentId=${Z}`:``} dir=${y} branch=${X} gitRepoUrl=${ie} machine=${ae}`),k(`[bridge:init] apiBaseUrl=${F} sessionIngressUrl=${I}`),k(`[bridge:init] sandbox=${r}${i?` debugFile=${i}`:``}`);let $,fe;try{let e=await de.registerBridgeEnvironment(Q);$=e.environment_id,fe=e.environment_secret}catch(e){B(`tengu_bridge_registration_failed`,{status:e instanceof s?e.status:void 0}),console.error(e instanceof s&&e.status===404?`Remote Control environments are not available for your account.`:`Error: ${E(e)}`),process.exit(1)}let pe;if(h)if(Z&&$!==Z)L(Error(`Bridge resume env mismatch: requested ${Z}, backend returned ${$}. Falling back to fresh session.`)),console.warn(`Warning: Could not resume session ${h} — its environment has expired. Creating a fresh session instead.`);else{let e=re(h),t=e===h?[h]:[h,e],n=!1,r;for(let e of t)try{await de.reconnectSession($,e),k(`[bridge:init] Session ${e} re-queued via bridge/reconnect`),pe=h,n=!0;break}catch(t){r=t,k(`[bridge:init] reconnectSession(${e}) failed: ${E(t)}`)}if(!n){let e=r,t=e instanceof s;if(g&&t){let{clearBridgePointer:e}=await import(`./bridgePointer-MqLe5Asm.js`);await e(g)}console.error(t?`Error: ${E(e)}`:`Error: Failed to reconnect session ${h}: ${E(e)}\nThe session may still be resumable — try running the same command again.`),process.exit(1)}}k(`[bridge:init] Registered, server environmentId=${$}`);let ge=me();B(`tengu_bridge_started`,{max_sessions:Q.maxSessions,has_debug_file:!!Q.debugFile,sandbox:Q.sandbox,verbose:Q.verbose,heartbeat_interval_ms:ge.non_exclusive_heartbeat_interval_ms,spawn_mode:Q.spawnMode,spawn_mode_source:q,multi_session_gate:S,pre_create_session:Y,worktree_available:W}),P(`info`,`bridge_started`,{max_sessions:Q.maxSessions,sandbox:Q.sandbox,spawn_mode:Q.spawnMode});let _e=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:n,sandbox:r,debugFile:i,permissionMode:o,onDebug:k,onActivity:(e,t)=>{k(`[bridge:activity] sessionId=${e} ${t.type} ${t.summary}`)},onPermissionRequest:(e,t,n)=>{k(`[bridge:perm] sessionId=${e} tool=${t.request.tool_name} request_id=${t.request_id} (not auto-approving)`)}}),ve=Pe({verbose:n}),{parseGitHubRepository:ye}=await import(`./detectRepository-BTPgN89l.js`),be=ie?ye(ie):null,Se=be?be.split(`/`).pop():Ce(y);ve.setRepoInfo(Se,X);let we=J!==`single-session`&&W;we&&ve.setSpawnModeDisplay(J);let Te=e=>{if(e[0]===3||e[0]===4){process.emit(`SIGINT`);return}if(e[0]===32){ve.toggleQr();return}if(e[0]===119){if(!we)return;let e=Q.spawnMode===`same-dir`?`worktree`:`same-dir`;Q.spawnMode=e,B(`tengu_bridge_spawn_mode_toggled`,{spawn_mode:e}),ve.logStatus(e===`worktree`?`Spawn mode: worktree (new sessions get isolated git worktrees)`:`Spawn mode: same-dir (new sessions share the current directory)`),ve.setSpawnModeDisplay(e),ve.refreshDisplay(),te(t=>t.remoteControlSpawnMode===e?t:{...t,remoteControlSpawnMode:e});return}};process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on(`data`,Te));let De=new AbortController,ke=()=>{k(`[bridge:shutdown] SIGINT received, shutting down`),De.abort()},Ae=()=>{k(`[bridge:shutdown] SIGTERM received, shutting down`),De.abort()};process.on(`SIGINT`,ke),process.on(`SIGTERM`,Ae);let je=pe||null;if(Y&&!pe){let{createBridgeSession:e}=await import(`./createSession-CoQtL5Rj.js`);try{je=await e({environmentId:$,title:c,events:[],gitRepoUrl:ie,branch:X,signal:De.signal,baseUrl:F,getAccessToken:O,permissionMode:o}),je&&k(`[bridge:init] Created initial session ${je}`)}catch(e){k(`[bridge:init] Session creation failed (non-fatal): ${E(e)}`)}}let Me=null;if(je&&J===`single-session`){let{writeBridgePointer:e}=await import(`./bridgePointer-MqLe5Asm.js`),t={sessionId:je,environmentId:$,source:`standalone`};await e(Q.dir,t),Me=setInterval(e,3600*1e3,Q.dir,t),Me.unref?.()}try{await Ze(Q,$,fe,de,_e,ve,De.signal,void 0,je??void 0,async()=>(T(),await D(),O()))}finally{Me!==null&&clearInterval(Me),process.off(`SIGINT`,ke),process.off(`SIGTERM`,Ae),process.stdin.off(`data`,Te),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()}process.exit(0)}var mt=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function ht(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-BOa-3Av3.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-DY5-_kk_.js`);o();let{initSinks:c}=await import(`./sinks-BpcRrN_T.js`);if(c(),!s())throw new mt(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(ue);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-CqIQ_rvD.js`),u=l();if(u.startsWith(`http://`)&&!u.includes(`localhost`)&&!u.includes(`127.0.0.1`))throw new mt(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let d=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||u,{getBranch:f,getRemoteUrl:p,findGitRoot:m}=await import(`./git-CbcnOf0E.js`),{hasWorktreeCreateHook:h}=await import(`./hooks-DPLIIpAD.js`);if(e.spawnMode===`worktree`&&!(h()||m(n)!==null))throw new mt(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let g=await f(),_=await p(),y=xe(),b=Oe(),ee={dir:n,machineName:y,branch:g,gitRepoUrl:_,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:b,workerType:`claude_code`,environmentId:Oe(),apiBaseUrl:u,sessionIngressUrl:d,sessionTimeoutMs:e.sessionTimeoutMs},x=v({baseUrl:u,getAccessToken:e.getAccessToken,runnerVersion:`0.0.6`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:he}),S,C;try{let e=await x.registerBridgeEnvironment(ee);S=e.environment_id,C=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${E(e)}`)}let w=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),T=gt(r);T.printBanner(ee,S);let D;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-CoQtL5Rj.js`);try{let i=await n({environmentId:S,title:e.name,events:[],gitRepoUrl:_,branch:g,signal:t,baseUrl:u,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(D=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${E(e)}`)}}await Ze(ee,S,C,x,w,T,t,void 0,D,async()=>e.getAccessToken())}function gt(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}export{ct as a,et as i,pt as n,ht as o,$e as r,Ze as s,mt as t};