@readmagic/workmate 0.0.28 → 0.0.30

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 (305) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Bmgh8VS3.js → AddWorkspaceDirectory-B03NZZuQ.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-45Ize2zR.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-BJfHqScU.js → AgentsMdExternalIncludesDialog-CIyefOzT.js} +1 -1
  4. package/dist/chunks/App-WBysAL0_.js +1 -0
  5. package/dist/chunks/{BackgroundTasksDialog-WkoL4g5Q.js → BackgroundTasksDialog-CvvrjBoq.js} +2 -2
  6. package/dist/chunks/{BypassPermissionsModeDialog-BT9yl0Qt.js → BypassPermissionsModeDialog-DdVbMyla.js} +1 -1
  7. package/dist/chunks/{CustomSelect-t4wXuXWH.js → CustomSelect-iSG1rbWU.js} +1 -1
  8. package/dist/chunks/{DiffDialog-CXZxnb7Y.js → DiffDialog-DSb46fzB.js} +5 -5
  9. package/dist/chunks/Doctor--yF3SBsD.js +1 -0
  10. package/dist/chunks/Doctor-dR71Dg_D.js +3 -0
  11. package/dist/chunks/ExitFlow-BiBi5Sqk.js +2 -0
  12. package/dist/chunks/{InvalidConfigDialog-riLYEaUP.js → InvalidConfigDialog-7MkDSXXj.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-BGXl3V1A.js → InvalidSettingsDialog-D8Ves3Th.js} +1 -1
  14. package/dist/chunks/{KeybindingProviderSetup-syiDgtpB.js → KeybindingProviderSetup-DJSFdVYv.js} +1 -1
  15. package/dist/chunks/MCPConnectionManager-BZxRMdGO.js +1 -0
  16. package/dist/chunks/MCPToolListView-H_Kvvelz.js +1 -0
  17. package/dist/chunks/{McpParsingWarnings-Czze2JPd.js → McpParsingWarnings-D2xvaog9.js} +1 -1
  18. package/dist/chunks/MessageSelector-DQgIgPij.js +3 -0
  19. package/dist/chunks/Messages-DyQCr-od.js +10 -0
  20. package/dist/chunks/{Onboarding-CD_Uv5h9.js → Onboarding-DFufTPIY.js} +1 -1
  21. package/dist/chunks/{PromptInputFooterSuggestions-CHXJsTtQ.js → PromptInputFooterSuggestions-B9JRcHHE.js} +1 -1
  22. package/dist/chunks/{PromptInputHelpMenu-BZIVCV7V.js → PromptInputHelpMenu-DcGXK5lt.js} +1 -1
  23. package/dist/chunks/{ProviderSetup-CwMvjmjh.js → ProviderSetup-DJ_Z1BSe.js} +1 -1
  24. package/dist/chunks/QueryEngine-BQ5PSqKV.js +1 -0
  25. package/dist/chunks/{REPL-CtFtb35A.js → REPL-CjoJCy0g.js} +24 -24
  26. package/dist/chunks/REPL-DGieTVDl.js +1 -0
  27. package/dist/chunks/ResumeConversation-exTLviBY.js +1 -0
  28. package/dist/chunks/SearchExtraToolsTool-BBhWAuoA.js +1 -0
  29. package/dist/chunks/Settings-nM6-cXh0.js +2 -0
  30. package/dist/chunks/Spinner-ChT4lOOg.js +1 -0
  31. package/dist/chunks/{SpinnerGlyph-BR_SiV9L.js → SpinnerGlyph-4aVLQdJf.js} +1 -1
  32. package/dist/chunks/{TextInput-ou7ZhpVY.js → TextInput-CanSwT9J.js} +5 -5
  33. package/dist/chunks/{ThemePicker-CVFWqSc7.js → ThemePicker-CXzPiSy0.js} +1 -1
  34. package/dist/chunks/{TrustDialog-CGXv_LF4.js → TrustDialog-D0fJ-YIw.js} +1 -1
  35. package/dist/chunks/{ValidationErrorsList-CKeHoN2Z.js → ValidationErrorsList-29bQ0l-Q.js} +1 -1
  36. package/dist/chunks/{_baseEach-BYhqv77g.js → _baseEach-DPcnudh_.js} +1 -1
  37. package/dist/chunks/{add-dir-BSizpuef.js → add-dir-DbNz1SeY.js} +1 -1
  38. package/dist/chunks/{agentDisplay-JKfYFD1m.js → agentDisplay-Bif3eE1e.js} +1 -1
  39. package/dist/chunks/{agents-BDTCH6YB.js → agents-CbsNbPbp.js} +1 -1
  40. package/dist/chunks/{agents-MEaV8P2G.js → agents-yvC-VikU.js} +6 -6
  41. package/dist/chunks/allErrors-Bv1e8fra.js +1 -0
  42. package/dist/chunks/{appleTerminalBackup-CN8kS74J.js → appleTerminalBackup-Ct9hf1QQ.js} +1 -1
  43. package/dist/chunks/{backgroundHousekeeping-CsXlkIg3.js → backgroundHousekeeping-C75FgxW1.js} +1 -1
  44. package/dist/chunks/backgroundHousekeeping-d0qpqWHe.js +1 -0
  45. package/dist/chunks/banner-D5m9LUjl.js +2 -0
  46. package/dist/chunks/{branch-BllXcYwS.js → branch-DOQ3yNds.js} +2 -2
  47. package/dist/chunks/bridgeControl-DMUu37uO.js +2 -0
  48. package/dist/chunks/{btw-DzaRBa6o.js → btw-DUjuwyMH.js} +1 -1
  49. package/dist/chunks/{bundledMode-D9omqD3L.js → bundledMode-Dqe4pz0a.js} +1 -1
  50. package/dist/chunks/caches-BKAPMXp9.js +1 -0
  51. package/dist/chunks/caches-he4NeZSK.js +1 -0
  52. package/dist/chunks/channel-C8JmEI06.js +2 -0
  53. package/dist/chunks/{channel-Gw6skpUh.js → channel-TEYwDITo.js} +1 -1
  54. package/dist/chunks/{clear-CDQs9_5P.js → clear-BFlTcvMt.js} +1 -1
  55. package/dist/chunks/{client-pA7fKk0-.js → client-D3QmHVeI.js} +1 -1
  56. package/dist/chunks/client-dTKhXxBT.js +1 -0
  57. package/dist/chunks/{client-2w-g5kMx.js → client-q_uGYC2E.js} +1 -1
  58. package/dist/chunks/client-y_U1O4mI.js +1 -0
  59. package/dist/chunks/commands-BoGtXPAA.js +1 -0
  60. package/dist/chunks/compact-CyR7Sbo1.js +2 -0
  61. package/dist/chunks/config-B-hDBSL8.js +1 -0
  62. package/dist/chunks/config-Bjwat4P6.js +3 -0
  63. package/dist/chunks/config-DubkVeOw.js +1 -0
  64. package/dist/chunks/{context-TkdzCK3Y.js → context-Cm_gyngQ.js} +1 -1
  65. package/dist/chunks/{context-noninteractive-BcBo64vo.js → context-noninteractive-BDmFfPRt.js} +2 -2
  66. package/dist/chunks/context-noninteractive-CmOFpwwP.js +1 -0
  67. package/dist/chunks/conversation-B7YCvyCD.js +1 -0
  68. package/dist/chunks/conversation-CYZKYlWc.js +1 -0
  69. package/dist/chunks/{conversationRecovery-_hWC7JBO.js → conversationRecovery-BUqpxLl-.js} +1 -1
  70. package/dist/chunks/crossProjectResume-BCa2l0KZ.js +40 -0
  71. package/dist/chunks/{debug-2pVES-2G.js → debug-NBJH_NxR.js} +2 -2
  72. package/dist/chunks/{detectRepository--luIRv5H.js → detectRepository-Bu0he_XM.js} +1 -1
  73. package/dist/chunks/{diff-BzVUPO4Z.js → diff-BEvpLh_b.js} +1 -1
  74. package/dist/chunks/{directoryCompletion-BC0qRmrz.js → directoryCompletion-CwKPuwrS.js} +1 -1
  75. package/dist/chunks/doctor-DYKr9Reu.js +1 -0
  76. package/dist/chunks/{entry-333L52Lo.js → entry-JGyBs1p5.js} +3 -3
  77. package/dist/chunks/{execFileNoThrow-DXSEj8ZO.js → execFileNoThrow-7Ys9mO27.js} +1 -1
  78. package/dist/chunks/exit-DU2KGyDk.js +1 -0
  79. package/dist/chunks/{extraUsage-CmgRR-zH.js → extraUsage-cZx2XLx4.js} +1 -1
  80. package/dist/chunks/extractMemories-4wbv-mTc.js +1 -0
  81. package/dist/chunks/fast-BALHWqpd.js +1 -0
  82. package/dist/chunks/{fast-D7oNjaZ3.js → fast-DUJq6-QE.js} +1 -1
  83. package/dist/chunks/{fetchModelList-Cv1vWIpC.js → fetchModelList-Dn8OahtV.js} +1 -1
  84. package/dist/chunks/fetchModelList-OZ2sLDEx.js +1 -0
  85. package/dist/chunks/{fileSuggestions-DF3HTRKr.js → fileSuggestions-XLnnVLwx.js} +3 -3
  86. package/dist/chunks/{gemini-ou7_YyXc.js → gemini-qzPNGqOX.js} +2 -2
  87. package/dist/chunks/{generateSessionName-CeN9EZNY.js → generateSessionName-CA-cc58H.js} +1 -1
  88. package/dist/chunks/{genericProcessUtils-GqURdVAv.js → genericProcessUtils-XwqvFxyn.js} +1 -1
  89. package/dist/chunks/{goal-CCxo4Wyf.js → goal-x9Pkx5nv.js} +3 -3
  90. package/dist/chunks/{grok-BMmUcNbI.js → grok-36CpLjsq.js} +1 -1
  91. package/dist/chunks/{help-CYtogTZk.js → help-DwfAEV0X.js} +1 -1
  92. package/dist/chunks/{history-CUrqO9rV.js → history-PZLMYab7.js} +1 -1
  93. package/dist/chunks/hooks-BofA8GeO.js +1 -0
  94. package/dist/chunks/{hooks-ByVkvodY.js → hooks-DBmA-DWx.js} +2 -2
  95. package/dist/chunks/{install-DIxyfdXG.js → install-DF4ep6nb.js} +1 -1
  96. package/dist/chunks/{instrumentation-BmHivmxs.js → instrumentation-BAbhrE3f.js} +3 -3
  97. package/dist/chunks/{job-D534P26R.js → job-CFWKIjNl.js} +1 -1
  98. package/dist/chunks/{keybindings-CxgQqQJe.js → keybindings-CkiE_uBG.js} +1 -1
  99. package/dist/chunks/{launchLocalMemory-CWXLb3KF.js → launchLocalMemory-Cf8l-1fz.js} +2 -2
  100. package/dist/chunks/{launchOnboarding-CocPmwzz.js → launchOnboarding-8CDef-v1.js} +1 -1
  101. package/dist/chunks/loadAgentsDir-C-qRJlXH.js +1 -0
  102. package/dist/chunks/{loadAgentsDir-bmpKLPdG.js → loadAgentsDir-DnHL_5cU.js} +358 -358
  103. package/dist/chunks/loadPluginHooks-BuunKr9m.js +1 -0
  104. package/dist/chunks/{loader-BMAtuwRa.js → loader-DsEdsMHv.js} +1 -1
  105. package/dist/chunks/localSearch-BulDBrBk.js +1 -0
  106. package/dist/chunks/{localSearch-Da8cVYoI.js → localSearch-LFCzV7VE.js} +1 -1
  107. package/dist/chunks/{log-L1kqxa_P.js → log-D98mO6yJ.js} +1 -1
  108. package/dist/chunks/{logoUtils-qNuBc2nI.js → logoUtils-B8MIA7c5.js} +1 -1
  109. package/dist/chunks/{magicDocs-BsEiBLQl.js → magicDocs-BoxJusTI.js} +2 -2
  110. package/dist/chunks/{main-B31aPMPP.js → main-B9ciFYnO.js} +22 -22
  111. package/dist/chunks/{managedEnv-EZ2IirNa.js → managedEnv-B0mj-wgE.js} +1 -1
  112. package/dist/chunks/managedEnv-BFpXdDI8.js +1 -0
  113. package/dist/chunks/mcp-B3Ewo-_h.js +1 -0
  114. package/dist/chunks/mcp-CHlAZvpV.js +2 -0
  115. package/dist/chunks/{mcp-Dd8TBfQQ.js → mcp-DVKuOqvY.js} +3 -3
  116. package/dist/chunks/memory-Cr0d-s7U.js +1 -0
  117. package/dist/chunks/{mode-SM8doWgC.js → mode-DBNBDbVP.js} +2 -2
  118. package/dist/chunks/model-B2r1Ms0g.js +1 -0
  119. package/dist/chunks/model-C9ANf1-R.js +1 -0
  120. package/dist/chunks/{modelOptions-BQL4gbNk.js → modelOptions-B4BWYms0.js} +1 -1
  121. package/dist/chunks/{nativeInstaller-DMkZdsof.js → nativeInstaller-BDJxBAPV.js} +1 -1
  122. package/dist/chunks/{notifications-BwS1XsnZ.js → notifications-BV-VeXyJ.js} +1 -1
  123. package/dist/chunks/{onChangeAppState-C9cYQJPF.js → onChangeAppState-BGWWkhBg.js} +1 -1
  124. package/dist/chunks/openai-BL_IWBTr.js +2 -0
  125. package/dist/chunks/{overlayContext-C5WPACKC.js → overlayContext-DGUFuee9.js} +1 -1
  126. package/dist/chunks/{parser-CTnaXFVJ.js → parser-D2kggQDp.js} +1 -1
  127. package/dist/chunks/parser-DZUcp40d.js +1 -0
  128. package/dist/chunks/{partition-CKgWl7p4.js → partition-B2VCm4vu.js} +1 -1
  129. package/dist/chunks/{pasteStore-njJCBMKr.js → pasteStore-2RafnH7M.js} +1 -1
  130. package/dist/chunks/permissions-Bkj1UB1h.js +3 -0
  131. package/dist/chunks/{pidLock-CqkC3-nD.js → pidLock-CawSx6hb.js} +2 -2
  132. package/dist/chunks/{plan-Ce6wfjjI.js → plan-D7Ki5ADu.js} +1 -1
  133. package/dist/chunks/plugin-D7I6VZjh.js +17 -0
  134. package/dist/chunks/{pluginAutoupdate-ByokIVEs.js → pluginAutoupdate-Cr3jw-ky.js} +1 -1
  135. package/dist/chunks/pluginBlocklist-JG_kJSSK.js +1 -0
  136. package/dist/chunks/pluginCliCommands-BWIBBFJf.js +1 -0
  137. package/dist/chunks/{pluginFlagging-B2ZX5_oB.js → pluginFlagging-yFcXMVin.js} +1 -1
  138. package/dist/chunks/pluginOperations-6QXjdPOb.js +2 -0
  139. package/dist/chunks/pluginStartupCheck-B-nYb61N.js +1 -0
  140. package/dist/chunks/{pluginStartupCheck-QG0d95dE.js → pluginStartupCheck-CkjyJ4RS.js} +1 -1
  141. package/dist/chunks/plugins-CMDfjFp-.js +4 -0
  142. package/dist/chunks/{poorMode-CG2JNTD0.js → poorMode-BvypUTur.js} +1 -1
  143. package/dist/chunks/poorMode-CP6359Sz.js +1 -0
  144. package/dist/chunks/print-B6x_8O9w.js +13 -0
  145. package/dist/chunks/process-CewWh77C.js +1 -0
  146. package/dist/chunks/process-De2crvt4.js +1 -0
  147. package/dist/chunks/processBashCommand-D0BBcBHY.js +1 -0
  148. package/dist/chunks/processSlashCommand-BvjNuNyP.js +5 -0
  149. package/dist/chunks/{projectOnboardingState-D-_ijZnG.js → projectOnboardingState-ofkjp9FJ.js} +1 -1
  150. package/dist/chunks/prompt-Cpu4meqR.js +1 -0
  151. package/dist/chunks/{prompt-BnDapYGL.js → prompt-DDlkyIzV.js} +3 -3
  152. package/dist/chunks/prompt-HO8Docca.js +1 -0
  153. package/dist/chunks/{promptEditor-14TB3MYt.js → promptEditor-CyMqa_av.js} +1 -1
  154. package/dist/chunks/{protocolHandler-CJO3CRYW.js → protocolHandler-Bjmx7OmF.js} +1 -1
  155. package/dist/chunks/{proxy--_NfbJhm.js → proxy-MzIsnPd7.js} +1 -1
  156. package/dist/chunks/{reconciler-C_HKsocm.js → reconciler-CHbint0C.js} +1 -1
  157. package/dist/chunks/refresh-yut9uEfd.js +1 -0
  158. package/dist/chunks/{reject-Tug1RmkE.js → reject-CrNfit3M.js} +1 -1
  159. package/dist/chunks/{reload-plugins-CL9LWzpq.js → reload-plugins-labKy5Eh.js} +1 -1
  160. package/dist/chunks/rename-c8tElppw.js +1 -0
  161. package/dist/chunks/{renderOptions-B0RFpjRI.js → renderOptions-B3DyIbF6.js} +1 -1
  162. package/dist/chunks/{resume-BZ42SpS2.js → resume-C8xif2lo.js} +2 -2
  163. package/dist/chunks/ripgrep-CIIzTaSI.js +1 -0
  164. package/dist/chunks/{ripgrep-67m14ImZ.js → ripgrep-CnK9qx1e.js} +1 -1
  165. package/dist/chunks/{runtimeObserver-DT5P2_XL.js → runtimeObserver-DuJ8mRfr.js} +4 -4
  166. package/dist/chunks/{runtimeObserver-BLq2guVy.js → runtimeObserver-vmPplAGH.js} +1 -1
  167. package/dist/chunks/sandbox-adapter-BKnsdtVj.js +1 -0
  168. package/dist/chunks/{sandbox-toggle-DghmaJhK.js → sandbox-toggle-USHaZHD7.js} +1 -1
  169. package/dist/chunks/searchExtraTools-DV5iZPdw.js +1 -0
  170. package/dist/chunks/{select-CaxQ-BVq.js → select-BpiKdirZ.js} +1 -1
  171. package/dist/chunks/sessionFileAccessHooks-nq8C34WL.js +1 -0
  172. package/dist/chunks/sessionObserver-CKp3uqPg.js +1 -0
  173. package/dist/chunks/{sessionObserver-DBoZUvWL.js → sessionObserver-sO6PF7mV.js} +1 -1
  174. package/dist/chunks/sessionStorage-CuQf4d1y.js +1 -0
  175. package/dist/chunks/{sessionTracing-5a7HDF4e.js → sessionTracing-Bz89tYh5.js} +1 -1
  176. package/dist/chunks/settings-B3WqnPDo.js +1 -0
  177. package/dist/chunks/{settings-D4M13toi.js → settings-CA-5Px85.js} +2 -2
  178. package/dist/chunks/setup-B-FejaeH.js +3 -0
  179. package/dist/chunks/{shadowedRuleDetection-L3tnySui.js → shadowedRuleDetection-BI6Xz0pY.js} +1 -1
  180. package/dist/chunks/{sideQuestion-BJTVma-5.js → sideQuestion-BEpCuv_7.js} +3 -3
  181. package/dist/chunks/{sinks-CV0SWuZW.js → sinks-BvOPODnl.js} +1 -1
  182. package/dist/chunks/sinks-DLALCllz.js +1 -0
  183. package/dist/chunks/skillChangeDetector-D-fxaAMH.js +1 -0
  184. package/dist/chunks/{skillGapStore-Cposc03e.js → skillGapStore-A1FCr8Mf.js} +2 -2
  185. package/dist/chunks/{skillLifecycle-RXQp0JU7.js → skillLifecycle-CTVa34xO.js} +2 -2
  186. package/dist/chunks/{skillSearchPanel-B2pjskqk.js → skillSearchPanel-CjekGkrw.js} +4 -4
  187. package/dist/chunks/{skills-D2ZjMtv4.js → skills-110JHHbj.js} +1 -1
  188. package/dist/chunks/{sleep-xKMbXTJe.js → sleep-BGewNhNx.js} +1 -1
  189. package/dist/chunks/{startupProfiler-B9Qv2QGH.js → startupProfiler-C_xcIvEA.js} +1 -1
  190. package/dist/chunks/startupProfiler-uueg2S43.js +1 -0
  191. package/dist/chunks/status-D_b3UMke.js +1 -0
  192. package/dist/chunks/statusNoticeHelpers-C5BRU3lw.js +1 -0
  193. package/dist/chunks/{stringUtils-Cs6E5f-B.js → stringUtils-CtJhTszO.js} +1 -1
  194. package/dist/chunks/switcher-BFzvv7KT.js +1 -0
  195. package/dist/chunks/{switcher-rep86o4_.js → switcher-nLHGsxLw.js} +1 -1
  196. package/dist/chunks/{tasks-B4coTfrq.js → tasks-CjYr59Ak.js} +1 -1
  197. package/dist/chunks/{templateJobs-C5ukh6H3.js → templateJobs-ECX0rRRp.js} +1 -1
  198. package/dist/chunks/{terminalSetup-CaGbEVjB.js → terminalSetup-AptBNs_i.js} +1 -1
  199. package/dist/chunks/{terminalSetup-xe_P98fY.js → terminalSetup-CKO6eWhS.js} +1 -1
  200. package/dist/chunks/{theme-7RmvErYJ.js → theme-BCSx9irC.js} +1 -1
  201. package/dist/chunks/tipRegistry-CnQB3TaA.js +2 -0
  202. package/dist/chunks/{toolEventObserver-Dzwzi5Vi.js → toolEventObserver-Bqtypnkk.js} +1 -1
  203. package/dist/chunks/toolPool-B1sXN7SK.js +1 -0
  204. package/dist/chunks/{udsClient-CWeoNrm3.js → udsClient-COYqIvvr.js} +1 -1
  205. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-BT0nexZw.js → useExitOnCtrlCDWithKeybindings-DegJrysj.js} +1 -1
  206. package/dist/chunks/useMainLoopModel-CPnigpM1.js +1 -0
  207. package/dist/chunks/useManagePlugins-BW2Zj_jf.js +1 -0
  208. package/dist/chunks/useMergedTools-CTm1AU9b.js +1 -0
  209. package/dist/chunks/{useSearchInput-j12K4wEo.js → useSearchInput-DrY4BZKy.js} +1 -1
  210. package/dist/chunks/useSettingsErrors-2uIAF6H8.js +1 -0
  211. package/dist/chunks/{util-CCEK8oze.js → util-BUgUtaUV.js} +1 -1
  212. package/dist/chunks/validatePlugin-BGB8T9Mb.js +1 -0
  213. package/dist/chunks/{vim-BlO9V5_5.js → vim-DdxGarvY.js} +1 -1
  214. package/dist/chunks/worktree-DBZ7f9Lk.js +1 -0
  215. package/dist/cli.js +1 -1
  216. package/package.json +1 -1
  217. package/dist/chunks/AgentsMdExternalIncludesDialog-BjbUilCE.js +0 -1
  218. package/dist/chunks/App-COdpsR2w.js +0 -1
  219. package/dist/chunks/Doctor-B6isid5K.js +0 -1
  220. package/dist/chunks/Doctor-COj-tZBc.js +0 -3
  221. package/dist/chunks/ExitFlow-CcMYH5iI.js +0 -2
  222. package/dist/chunks/MCPConnectionManager-C7RmKzJh.js +0 -1
  223. package/dist/chunks/MCPToolListView-CewNLJus.js +0 -1
  224. package/dist/chunks/MessageSelector-Kc6JlnDX.js +0 -3
  225. package/dist/chunks/Messages-BvFYO4Zn.js +0 -10
  226. package/dist/chunks/QueryEngine-DAwfp_ht.js +0 -1
  227. package/dist/chunks/REPL-tFT1FGQF.js +0 -1
  228. package/dist/chunks/ResumeConversation-CERzSBvg.js +0 -1
  229. package/dist/chunks/SearchExtraToolsTool-ndh4aEwQ.js +0 -1
  230. package/dist/chunks/Settings-CPaqWNdP.js +0 -2
  231. package/dist/chunks/Spinner-C0qHjfIY.js +0 -1
  232. package/dist/chunks/allErrors-Dhnf6rqg.js +0 -1
  233. package/dist/chunks/backgroundHousekeeping-Bu-zRFCx.js +0 -1
  234. package/dist/chunks/banner-BKOzHotb.js +0 -2
  235. package/dist/chunks/bridgeControl-aDnUrYZR.js +0 -2
  236. package/dist/chunks/caches-CMF-MmR-.js +0 -1
  237. package/dist/chunks/caches-CW5YnYNS.js +0 -1
  238. package/dist/chunks/channel-DVx21qde.js +0 -1
  239. package/dist/chunks/client-B0ngS4Uu.js +0 -1
  240. package/dist/chunks/client-BP4DOH3K.js +0 -1
  241. package/dist/chunks/commands-CfYMwgP7.js +0 -1
  242. package/dist/chunks/compact-6F2tuItE.js +0 -2
  243. package/dist/chunks/config-BDkzWBnL.js +0 -1
  244. package/dist/chunks/config-Bio2EjUK.js +0 -3
  245. package/dist/chunks/config-C_AEhZrn.js +0 -1
  246. package/dist/chunks/context-noninteractive-oFcnY1Er.js +0 -1
  247. package/dist/chunks/conversation-CYZyg1U1.js +0 -1
  248. package/dist/chunks/conversation-DXzlRhNw.js +0 -1
  249. package/dist/chunks/crossProjectResume-CCo3iZrB.js +0 -40
  250. package/dist/chunks/doctor-B4jQbGQr.js +0 -1
  251. package/dist/chunks/exit-D5DYnRvR.js +0 -1
  252. package/dist/chunks/extractMemories-CVUrBFMj.js +0 -1
  253. package/dist/chunks/fast-CRhW9zha.js +0 -1
  254. package/dist/chunks/fetchModelList-DIa1HwAJ.js +0 -1
  255. package/dist/chunks/hooks-CBGUcyCs.js +0 -1
  256. package/dist/chunks/loadAgentsDir-Zw648oQO.js +0 -1
  257. package/dist/chunks/loadPluginHooks-BIfM53-_.js +0 -1
  258. package/dist/chunks/localSearch-Dbj8cXyO.js +0 -1
  259. package/dist/chunks/managedEnv-DCGLDTP_.js +0 -1
  260. package/dist/chunks/mcp-BMeWtYCx.js +0 -2
  261. package/dist/chunks/mcp-CYbesbfl.js +0 -1
  262. package/dist/chunks/memory-DtQQGyPS.js +0 -1
  263. package/dist/chunks/model-C2r-PaR4.js +0 -1
  264. package/dist/chunks/model-Dd3x121y.js +0 -1
  265. package/dist/chunks/openai-Bea4I2Od.js +0 -2
  266. package/dist/chunks/parser-Diihup2V.js +0 -1
  267. package/dist/chunks/permissions-Dv_PCfY0.js +0 -3
  268. package/dist/chunks/plugin-aK4tDrVg.js +0 -17
  269. package/dist/chunks/pluginBlocklist-ByRQaVPu.js +0 -1
  270. package/dist/chunks/pluginCliCommands-Dyk4HYHs.js +0 -1
  271. package/dist/chunks/pluginOperations-BCvJvfOC.js +0 -2
  272. package/dist/chunks/pluginStartupCheck-o_TC7wIt.js +0 -1
  273. package/dist/chunks/plugins-DzsTDNWJ.js +0 -4
  274. package/dist/chunks/poorMode-eMIFCAC_.js +0 -1
  275. package/dist/chunks/print-dUT7E1g9.js +0 -13
  276. package/dist/chunks/process-CNfq37LF.js +0 -1
  277. package/dist/chunks/process-gEbdy6uY.js +0 -1
  278. package/dist/chunks/processBashCommand-DtGCgTkF.js +0 -1
  279. package/dist/chunks/processSlashCommand-wXblpK2C.js +0 -5
  280. package/dist/chunks/prompt-BdH2zk0S.js +0 -1
  281. package/dist/chunks/prompt-D0TFER0A.js +0 -1
  282. package/dist/chunks/refresh-Cm4jZzLa.js +0 -1
  283. package/dist/chunks/rename-OfKJSazJ.js +0 -1
  284. package/dist/chunks/ripgrep-DB7KB8RZ.js +0 -1
  285. package/dist/chunks/sandbox-adapter-982rx2cm.js +0 -1
  286. package/dist/chunks/searchExtraTools-B4N1bpy0.js +0 -1
  287. package/dist/chunks/sessionFileAccessHooks-BqQ58T7e.js +0 -1
  288. package/dist/chunks/sessionObserver-qYpA90El.js +0 -1
  289. package/dist/chunks/sessionStorage-CC0v4zMs.js +0 -1
  290. package/dist/chunks/settings-Dfit5gGT.js +0 -1
  291. package/dist/chunks/setup-DVLnIlse.js +0 -3
  292. package/dist/chunks/sinks-C9NdbjLo.js +0 -1
  293. package/dist/chunks/skillChangeDetector-DlodgOyC.js +0 -1
  294. package/dist/chunks/startupProfiler-DWcM4QBl.js +0 -1
  295. package/dist/chunks/status-BcSkj9nE.js +0 -1
  296. package/dist/chunks/statusNoticeHelpers-DsrqBOQt.js +0 -1
  297. package/dist/chunks/switcher-BietN6il.js +0 -1
  298. package/dist/chunks/tipRegistry-BYpJZIjR.js +0 -2
  299. package/dist/chunks/toolPool-BGfiNj6h.js +0 -1
  300. package/dist/chunks/useMainLoopModel-QuE7VkgX.js +0 -1
  301. package/dist/chunks/useManagePlugins-pGaGzsEg.js +0 -1
  302. package/dist/chunks/useMergedTools-BLsIT3R_.js +0 -1
  303. package/dist/chunks/useSettingsErrors-C8VIzdws.js +0 -1
  304. package/dist/chunks/validatePlugin-CTVnWx9H.js +0 -1
  305. package/dist/chunks/worktree-BWL0vR4o.js +0 -1
@@ -1,12 +1,12 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.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,ai as f,di as p,fi as m,t as h,y as g}from"./src-BX54x08P.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as v,K as y,Qn as b,X as x,fn as ee,mn as S,nt as te,rn as C,rt as ne,tn as re}from"./settings-D4M13toi.js";import{hr as ie,mr as ae}from"./state-CXY-q5gr.js";import{$d as oe,$x as se,Ap as ce,Au as le,Bh as ue,Bv as de,By as fe,Cf as pe,Cp as me,Dc as he,Dl as ge,Dp as _e,Ec as ve,Ef as ye,El as be,Em as xe,F_ as Se,GS as Ce,Hh as we,I_ as Te,Ji as Ee,Mm as De,Mu as Oe,Nm as ke,Nu as Ae,Op as je,Pm as Me,Q as Ne,Rl as Pe,Rm as Fe,Sp as Ie,Tf as Le,Tl as Re,Tm as ze,X as Be,_m as Ve,_p as He,bp as Ue,c as We,dd as Ge,ef as Ke,et as qe,fw as Je,gm as Ye,gp as Xe,hd as w,jm as Ze,ju as Qe,l as $e,ld as et,md as T,mw as tt,nt,o as rt,pw as it,r as at,s as ot,t as st,tb as E,ty as ct,ua as lt,vp as ut,wf as dt,wl as ft,xp as pt,yp as mt,zh as ht,zl as gt,zm as _t,zv as vt,zy as yt}from"./loadAgentsDir-bmpKLPdG.js";import{n as bt,t as xt}from"./cwd-DrEEb4f5.js";import{H as St,I as Ct,N as wt,S as Tt,V as Et,Y as Dt,x as Ot}from"./debug-2pVES-2G.js";import{C as kt,T as At}from"./config-Bio2EjUK.js";import{o as jt,s as Mt}from"./log-L1kqxa_P.js";import{n as Nt}from"./analytics-COpjZpvd.js";import{S as Pt,_ as Ft}from"./startupProfiler-B9Qv2QGH.js";import{l as It,n as Lt,o as Rt}from"./stringUtils-Cs6E5f-B.js";import{_n as zt,vn as Bt}from"./prompt-BnDapYGL.js";import{n as Vt,t as Ht}from"./_baseSlice-D67_NpZ1.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,t as Jt}from"./agentDisplay-JKfYFD1m.js";import{n as Yt,t as Xt}from"./useExitOnCtrlCDWithKeybindings-BT0nexZw.js";import{n as Zt,t as Qt}from"./TextInput-ou7ZhpVY.js";import{n as $t,t as en}from"./select-CaxQ-BVq.js";import{r as tn,t as nn}from"./Spinner-C0qHjfIY.js";import{n as rn,t as an}from"./useMergedTools-BLsIT3R_.js";import{n as on,r as sn,t as cn}from"./promptEditor-14TB3MYt.js";import{n as ln,t as un}from"./useMainLoopModel-QuE7VkgX.js";import{join as D}from"path";import{mkdir as dn,open as fn,unlink as pn}from"fs/promises";function mn(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:Ht(e,t,n)}var hn=e((()=>{Vt()}));function gn(e){return _n.test(e)}var _n,vn=e((()=>{_n=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`)}));function yn(e){return e.split(``)}var bn=e((()=>{}));function xn(e){return e.match(Rn)||[]}var Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=e((()=>{Sn=`\\ud800-\\udfff`,Cn=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,wn=`\\ufe0e\\ufe0f`,Tn=`[`+Sn+`]`,En=`[`+Cn+`]`,Dn=`\\ud83c[\\udffb-\\udfff]`,On=`(?:`+En+`|`+Dn+`)`,kn=`[^`+Sn+`]`,An=`(?:\\ud83c[\\udde6-\\uddff]){2}`,jn=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Mn=`\\u200d`,Nn=On+`?`,Pn=`[`+wn+`]?`,Fn=`(?:`+Mn+`(?:`+[kn,An,jn].join(`|`)+`)`+Pn+Nn+`)*`,In=Pn+Nn+Fn,Ln=`(?:`+[kn+En+`?`,En,An,jn,Tn].join(`|`)+`)`,Rn=RegExp(Dn+`(?=`+Dn+`)|`+Ln+In,`g`)}));function Bn(e){return gn(e)?xn(e):yn(e)}var Vn=e((()=>{bn(),vn(),zn()}));function Hn(e){return function(t){t=ie(t);var n=gn(t)?Bn(t):void 0,r=n?n[0]:t.charAt(0),i=n?mn(n,1).join(``):t.slice(1);return r[e]()+i}}var Un=e((()=>{hn(),vn(),Vn(),ae()})),Wn,Gn=e((()=>{Un(),Wn=Hn(`toUpperCase`)}));function Kn(e){return Wn(ie(e).toLowerCase())}var qn=e((()=>{ae(),Gn()})),O,Jn=e((()=>{O={FOLDER_NAME:`.workmate`,AGENTS_DIR:`agents`}}));function Yn(e,t,n,r,i,a,o){return`---
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.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,ai as f,di as p,fi as m,t as h,y as g}from"./src-BX54x08P.js";import{t as _}from"./jsx-runtime-Bb4Xn-E0.js";import{$n as v,K as y,Qn as b,X as x,fn as ee,mn as S,nt as te,rn as C,rt as ne,tn as re}from"./settings-CA-5Px85.js";import{hr as ie,mr as ae}from"./state-CXY-q5gr.js";import{Ap as oe,Bl as se,Bm as ce,Cp as le,Df as ue,Dl as de,Dm as fe,Ef as pe,El as me,Fm as he,Fu as ge,Hh as _e,Hv as ve,Hy as ye,Im as be,L_ as xe,Mp as Se,Mu as Ce,Nm as we,Nu as Te,Oc as Ee,Of as De,Ol as Oe,Om as ke,Pm as Ae,Pu as je,Q as Me,R_ as Ne,Sp as Pe,Tf as Fe,Tp as Ie,Vh as Le,Vl as Re,Vm as ze,Vv as Be,Vy as Ve,Wh as He,Xi as Ue,_d as w,bp as We,c as Ge,dd as Ke,et as qe,fa as Je,gd as T,gw as Ye,hw as Xe,it as Ze,kc as Qe,kl as $e,kp as et,l as tt,mw as nt,nf as rt,nt as it,o as at,pd as ot,qS as st,r as ct,rb as E,ry as lt,s as ut,t as dt,tS as ft,tf as pt,vm as mt,vp as ht,wp as gt,xp as _t,ym as vt,yp as yt}from"./loadAgentsDir-DnHL_5cU.js";import{n as bt,t as xt}from"./cwd-DrEEb4f5.js";import{H as St,I as Ct,N as wt,S as Tt,V as Et,Y as Dt,x as Ot}from"./debug-NBJH_NxR.js";import{C as kt,T as At}from"./config-Bjwat4P6.js";import{o as jt,s as Mt}from"./log-D98mO6yJ.js";import{n as Nt}from"./analytics-COpjZpvd.js";import{S as Pt,_ as Ft}from"./startupProfiler-C_xcIvEA.js";import{l as It,n as Lt,o as Rt}from"./stringUtils-CtJhTszO.js";import{_n as zt,vn as Bt}from"./prompt-DDlkyIzV.js";import{n as Vt,t as Ht}from"./_baseSlice-D67_NpZ1.js";import{a as Ut,i as Wt,n as Gt,o as Kt,r as qt,t as Jt}from"./agentDisplay-Bif3eE1e.js";import{n as Yt,t as Xt}from"./useExitOnCtrlCDWithKeybindings-DegJrysj.js";import{n as Zt,t as Qt}from"./TextInput-CanSwT9J.js";import{n as $t,t as en}from"./select-BpiKdirZ.js";import{r as tn,t as nn}from"./Spinner-ChT4lOOg.js";import{n as rn,t as an}from"./useMergedTools-CTm1AU9b.js";import{n as on,r as sn,t as cn}from"./promptEditor-CyMqa_av.js";import{n as ln,t as un}from"./useMainLoopModel-CPnigpM1.js";import{join as D}from"path";import{mkdir as dn,open as fn,unlink as pn}from"fs/promises";function mn(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:Ht(e,t,n)}var hn=e((()=>{Vt()}));function gn(e){return _n.test(e)}var _n,vn=e((()=>{_n=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`)}));function yn(e){return e.split(``)}var bn=e((()=>{}));function xn(e){return e.match(Rn)||[]}var Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=e((()=>{Sn=`\\ud800-\\udfff`,Cn=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,wn=`\\ufe0e\\ufe0f`,Tn=`[`+Sn+`]`,En=`[`+Cn+`]`,Dn=`\\ud83c[\\udffb-\\udfff]`,On=`(?:`+En+`|`+Dn+`)`,kn=`[^`+Sn+`]`,An=`(?:\\ud83c[\\udde6-\\uddff]){2}`,jn=`[\\ud800-\\udbff][\\udc00-\\udfff]`,Mn=`\\u200d`,Nn=On+`?`,Pn=`[`+wn+`]?`,Fn=`(?:`+Mn+`(?:`+[kn,An,jn].join(`|`)+`)`+Pn+Nn+`)*`,In=Pn+Nn+Fn,Ln=`(?:`+[kn+En+`?`,En,An,jn,Tn].join(`|`)+`)`,Rn=RegExp(Dn+`(?=`+Dn+`)|`+Ln+In,`g`)}));function Bn(e){return gn(e)?xn(e):yn(e)}var Vn=e((()=>{bn(),vn(),zn()}));function Hn(e){return function(t){t=ie(t);var n=gn(t)?Bn(t):void 0,r=n?n[0]:t.charAt(0),i=n?mn(n,1).join(``):t.slice(1);return r[e]()+i}}var Un=e((()=>{hn(),vn(),Vn(),ae()})),Wn,Gn=e((()=>{Un(),Wn=Hn(`toUpperCase`)}));function Kn(e){return Wn(ie(e).toLowerCase())}var qn=e((()=>{ae(),Gn()})),O,Jn=e((()=>{O={FOLDER_NAME:`.workmate`,AGENTS_DIR:`agents`}}));function Yn(e,t,n,r,i,a,o){return`---
2
2
  name: ${e}
3
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
4
  ---
5
5
 
6
6
  ${r}
7
- `}function Xn(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(xt(),O.FOLDER_NAME,O.AGENTS_DIR);case`policySettings`:return D(re(),O.FOLDER_NAME,O.AGENTS_DIR);case`localSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR)}}function Zn(e){switch(e){case`projectSettings`:return D(`.`,O.FOLDER_NAME,O.AGENTS_DIR);default:return Xn(e)}}function Qn(e){return D(Xn(e.source),`${e.agentType}.md`)}function $n(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return D(Xn(e.source),`${e.filename||e.agentType}.md`)}function er(e){return e.source===`built-in`?`Built-in`:D(Zn(e.source),`${e.agentType}.md`)}function tr(e){return ot(e)?`Built-in`:$e(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:D(Zn(e.source),`${e.filename||e.agentType}.md`)}async function nr(e){let t=Xn(e);return await dn(t,{recursive:!0}),t}async function rr(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await nr(e);let l=Qn({source:e,agentType:t}),u=Yn(t,n,r,i,o,s,c);try{await or(l,u,a?`wx`:`w`)}catch(e){throw wt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function ir(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await or($n(e),Yn(e.agentType,t,n,r,i,a,o))}async function ar(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=$n(e);try{await pn(t)}catch(e){if(wt(e)!==`ENOENT`)throw e}}async function or(e,t,n=`w`){let r=await fn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var sr=e((()=>{C(),rt(),bt(),r(),Ct(),Jn()}));function cr({agent:e,tools:t,onBack:n}){let r=ut(e,t,!1),i=tr(e),o=pt(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 Work Mate 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`}),`: `,_e(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`}),`: `,Je(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,` `]})]})}),!ot(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)(et,{children:e.getSystemPrompt()})})]})]})}var k,lr=e((()=>{i(),h(),E(),Ie(),it(),He(),rt(),ce(),Ge(),sr(),k=_()}));function ur({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,dr.useState)(Math.max(0,j.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:j.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<j.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=j[r];n(t===`automatic`?void 0:t)}},s=j[r];return(0,A.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,A.jsx)(c,{flexDirection:`column`,children:j.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:Ue[e],color:`inverseText`,children:` `}),(0,A.jsx)(l,{bold:n,children:Lt(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:Ue[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var dr,A,j,fr=e((()=>{i(),dr=t(f(),1),h(),Ie(),Rt(),A=_(),j=[`automatic`,...mt]}));function pr({initialModel:e,onComplete:t,onCancel:n}){let r=mr.useMemo(()=>{let t=je();return e&&!t.some(t=>t.value===e)?[{value:e,label:e,description:`Current model (custom ID)`},...t]:t},[e]);return(0,hr.jsxs)(c,{flexDirection:`column`,children:[(0,hr.jsx)(c,{marginBottom:1,children:(0,hr.jsx)(l,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,hr.jsx)(en,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var mr,hr,gr=e((()=>{mr=t(f(),1),h(),ce(),$t(),hr=_()}));function _r(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([Ze.name,ke.name,ft.name,yt.name,ze.name,Pe.name,be.name,Le.name,pe.name])},EDIT:{name:`Edit tools`,toolNames:new Set([Oe.name,Fe.name,le.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([Ye.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function vr(e){let t=new Map;return e.forEach(e=>{if(Ke(e)){let n=ne(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 yr({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,M.useMemo)(()=>Xe({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[s,u]=(0,M.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(!1),g=(0,M.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])},x=(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))})},ee=()=>{let e=i.map(e=>e.name);n(g.length===e.length&&e.every(e=>g.includes(e))?void 0:g)},S=(0,M.useMemo)(()=>{let e=_r(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{Ke(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]),te=e=>{let t=b(e,e=>_.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);x(n,t)}},C=[];C.push({id:`continue`,label:`Continue`,action:ee,isContinue:!0}),C.push({id:`bucket-all`,label:`${v?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);x(e,!v)}});let re=_r();[{id:`bucket-readonly`,name:re.READ_ONLY.name,tools:S.readOnly},{id:`bucket-edit`,name:re.EDIT.name,tools:S.edit},{id:`bucket-execution`,name:re.EXECUTION.name,tools:S.execution},{id:`bucket-mcp`,name:re.MCP.name,tools:S.mcp},{id:`bucket-other`,name:re.OTHER.name,tools:S.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=b(n,e=>_.has(e.name))===n.length;C.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:te(n)})});let ie=C.length;C.push({id:`toggle-individual`,label:m?`Hide advanced options`:`Show advanced options`,action:()=>{h(!m),m&&f>ie&&p(ie)},isToggle:!0});let ae=(0,M.useMemo)(()=>vr(i),[i]);return m&&(ae.length>0&&(C.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),ae.forEach(({serverName:e,tools:t})=>{let n=b(t,e=>_.has(e.name))===t.length;C.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${It(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);x(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=ne(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,M.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,N.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,N.jsxs)(l,{color:f===0?`suggestion`:void 0,bold:f===0,children:[f===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,N.jsx)(o,{width:40}),C.slice(1).map((e,t)=>{let n=t+1===f,r=e.isToggle,i=e.isHeader;return(0,N.jsxs)(M.Fragment,{children:[r&&(0,N.jsx)(o,{width:40}),i&&t>0&&(0,N.jsx)(c,{marginTop:1}),(0,N.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,N.jsx)(c,{marginTop:1,flexDirection:`column`,children:(0,N.jsx)(l,{dimColor:!0,children:v?`All tools selected`:`${_.size} of ${i.length} tools selected`})})]})}var M,N,br=e((()=>{i(),M=t(f(),1),te(),oe(),He(),x(),Ve(),Re(),Ae(),fe(),_t(),De(),Me(),ye(),Qe(),dt(),ge(),gt(),xe(),h(),E(),v(),Rt(),N=_()}));function xr(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:Kn(ee(e))}var Sr=e((()=>{qn(),S()}));function Cr({agent:e,tools:t,onSaved:n,onBack:r}){let i=we(),[o,s]=(0,P.useState)(`menu`),[u,f]=(0,P.useState)(0),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(e.color),v=(0,P.useCallback)(async()=>{let t=await cn($n(e));t.error?h(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),y=(0,P.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!We(e)&&!$e(e)?!1:(await ir(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&me(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:at(n),allAgents:n}}}),n(`Updated agent: ${p.bold(e.agentType)}`),!0)}catch(e){return h(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,g,n,i]),b=(0,P.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,P.useCallback)(()=>{h(null),o===`menu`?r():s(`menu`)},[o,r]),ee=(0,P.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 S=()=>(0,F.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,F.jsxs)(l,{dimColor:!0,children:[`Source: `,xr(e.source)]}),(0,F.jsx)(c,{marginTop:1,flexDirection:`column`,children:b.map((e,t)=>(0,F.jsxs)(l,{color:t===u?`suggestion`:void 0,children:[t===u?`${a.pointer} `:` `,e.label]},e.label))}),m&&(0,F.jsx)(c,{marginTop:1,children:(0,F.jsx)(l,{color:`error`,children:m})})]});switch(o){case`menu`:return S();case`edit-tools`:return(0,F.jsx)(yr,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await y({tools:e})}});case`edit-color`:return(0,F.jsx)(ur,{agentName:e.agentType,currentColor:g||e.color||`automatic`,onConfirm:async e=>{_(e),s(`menu`),await y({color:e})}});case`edit-model`:return(0,F.jsx)(pr,{initialModel:e.model,onComplete:async e=>{s(`menu`),await y({model:e})}});default:return null}}var P,F,wr=e((()=>{m(),i(),P=t(f(),1),ht(),h(),E(),Ie(),rt(),sn(),sr(),fr(),gr(),br(),Sr(),F=_()}));function Tr({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Yt();return(0,Er.jsx)(c,{marginLeft:2,children:(0,Er.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Er,Dr=e((()=>{Xt(),h(),Er=_()}));function Or({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:s}){let[u,d]=kr.useState(null),[f,p]=kr.useState(!0),m=kr.useMemo(()=>[...t].sort(Gt),[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=Ut(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 `,qt(i)]})]},`${e.agentType}-${e.source}`)},y=kr.useMemo(()=>{let t=m.filter(e=>e.source!==`built-in`);return e===`all`?Jt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[m,e]);kr.useEffect(()=>{!u&&!f&&y.length>0&&(i?p(!0):d(y[0]||null))},[y,u,f,i]);let x=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))}},ee=(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))]})},te=xr(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:te,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,I.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{children:_()}),(0,I.jsx)(l,{dimColor:!0,children:`No agents found. Create specialized subagents that Work Mate 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,{}),ee()]})]})}):(0,I.jsxs)(g,{title:te,subtitle:`${b(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:x,children:[i&&(0,I.jsx)(c,{marginBottom:1,children:_()}),e===`all`?(0,I.jsxs)(I.Fragment,{children:[Jt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,I.jsx)(kr.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,{}),ee()]})]})]})]})}var kr,I,Ar=e((()=>{i(),kr=t(f(),1),h(),Wt(),v(),Sr(),I=_()}));function jr({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)([]);Yt(),(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,Mr.jsx)(Nr.Provider,{value:b,children:i||(0,Mr.jsx)(x,{})})}var L,Mr,Nr,Pr=e((()=>{L=t(f(),1),Xt(),Mr=_(),Nr=(0,L.createContext)(null)}));function R(){let e=(0,Fr.useContext)(Nr);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var Fr,Ir=e((()=>{Fr=t(f(),1),Pr()}));function Lr({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=Yt();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,Rr=e((()=>{Xt(),h(),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,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(g,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,zr.jsx)(Lr,{instructions:i})]})}var zr,V=e((()=>{h(),Ir(),Rr(),zr=_()})),H=e((()=>{Ir(),V(),Rr(),Pr()}));function Br(){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)(ur,{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,Vr=e((()=>{h(),E(),w(),H(),V(),fr(),U=_()}));function Hr(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=Hr(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 ${xr(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=ut(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 Wr=e((()=>{He(),Sr()}));function Gr({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=Pt(p.getSystemPrompt(),240),g=Pt(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=At()?(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Memory`}),`: `,Je(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`}),`:`,` `,er({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`}),`: `,_e(p.model)]}),v,(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate 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,Kr=e((()=>{h(),E(),kt(),it(),Ft(),ce(),w(),H(),V(),sr(),Wr(),W=_()}));function qr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=R(),[i,a]=(0,Jr.useState)(null),o=we(),s=(0,Jr.useCallback)(async e=>{if(r?.finalAgent)try{await rr(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:at(t),allAgents:t}}}),st(),e&&await cn(Qn({source:r.location,agentType:r.finalAgent.agentType})),r.finalAgent.agentType,r.wasGenerated,r.location,r.finalAgent.tools?.length,r.finalAgent.model,r.finalAgent.color,r.finalAgent.memory,r.finalAgent.memory,{...e?{opened_in_editor:!0}:{}},n(e?`Created agent: ${p.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${p.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,Yr.jsx)(Gr,{tools:e,existingAgents:t,onSave:(0,Jr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,Jr.useCallback)(()=>s(!0),[s]),error:i})}var Jr,Yr,Xr=e((()=>{m(),Jr=t(f(),1),Nt(),ht(),rt(),sn(),H(),sr(),Kr(),Yr=_()}));function Zr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,Qr.useState)(r.whenToUse||``),[o,f]=(0,Qr.useState)(i.length),[p,m]=(0,Qr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,Qr.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Work Mate 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 Work Mate use this agent?`}),(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(Qt,{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 Qr,G,$r=e((()=>{Qr=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),G=_()}));async function ei(e,t,n,r){let i=se({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 Se(),o=nt([i],a),s=At()?ti+ni:ti,c=await Ne({messages:lt(o),systemPrompt:Ce([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>zt(),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=Tt(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=Tt(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return u.identifier,{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var ti,ni,ri=e((()=>{Te(),Be(),Bt(),x(),qe(),Ee(),kt(),Nt(),Ot(),ct(),ti=`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.
7
+ `}function Xn(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(xt(),O.FOLDER_NAME,O.AGENTS_DIR);case`policySettings`:return D(re(),O.FOLDER_NAME,O.AGENTS_DIR);case`localSettings`:return D(xt(),O.FOLDER_NAME,O.AGENTS_DIR)}}function Zn(e){switch(e){case`projectSettings`:return D(`.`,O.FOLDER_NAME,O.AGENTS_DIR);default:return Xn(e)}}function Qn(e){return D(Xn(e.source),`${e.agentType}.md`)}function $n(e){if(e.source===`built-in`)return`Built-in`;if(e.source===`plugin`)throw Error(`Cannot get file path for plugin agents`);return D(Xn(e.source),`${e.filename||e.agentType}.md`)}function er(e){return e.source===`built-in`?`Built-in`:D(Zn(e.source),`${e.agentType}.md`)}function tr(e){return ut(e)?`Built-in`:tt(e)?`Plugin: ${e.plugin||`Unknown`}`:e.source===`flagSettings`?`CLI argument`:D(Zn(e.source),`${e.filename||e.agentType}.md`)}async function nr(e){let t=Xn(e);return await dn(t,{recursive:!0}),t}async function rr(e,t,n,r,i,a=!0,o,s,c){if(e===`built-in`)throw Error(`Cannot save built-in agents`);await nr(e);let l=Qn({source:e,agentType:t}),u=Yn(t,n,r,i,o,s,c);try{await or(l,u,a?`wx`:`w`)}catch(e){throw wt(e)===`EEXIST`?Error(`Agent file already exists: ${l}`):e}}async function ir(e,t,n,r,i,a,o){if(e.source===`built-in`)throw Error(`Cannot update built-in agents`);await or($n(e),Yn(e.agentType,t,n,r,i,a,o))}async function ar(e){if(e.source===`built-in`)throw Error(`Cannot delete built-in agents`);let t=$n(e);try{await pn(t)}catch(e){if(wt(e)!==`ENOENT`)throw e}}async function or(e,t,n=`w`){let r=await fn(e,n);try{await r.writeFile(t,{encoding:`utf-8`}),await r.datasync()}finally{await r.close()}}var sr=e((()=>{C(),at(),bt(),r(),Ct(),Jn()}));function cr({agent:e,tools:t,onBack:n}){let r=We(e,t,!1),i=tr(e),o=le(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 Work Mate 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`}),`: `,et(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`}),`: `,nt(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,` `]})]})}),!ut(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)(Ke,{children:e.getSystemPrompt()})})]})]})}var k,lr=e((()=>{i(),h(),E(),gt(),Xe(),yt(),at(),Se(),ot(),sr(),k=_()}));function ur({agentName:e,currentColor:t=`automatic`,onConfirm:n}){let[r,i]=(0,dr.useState)(Math.max(0,j.indexOf(t))),o=e=>{if(e.key===`up`)e.preventDefault(),i(e=>e>0?e-1:j.length-1);else if(e.key===`down`)e.preventDefault(),i(e=>e<j.length-1?e+1:0);else if(e.key===`return`){e.preventDefault();let t=j[r];n(t===`automatic`?void 0:t)}},s=j[r];return(0,A.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:o,children:[(0,A.jsx)(c,{flexDirection:`column`,children:j.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:Pe[e],color:`inverseText`,children:` `}),(0,A.jsx)(l,{bold:n,children:Lt(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:Pe[s],color:`inverseText`,bold:!0,children:[` `,`@`,e,` `]})]})]})}var dr,A,j,fr=e((()=>{i(),dr=t(f(),1),h(),gt(),Rt(),A=_(),j=[`automatic`,..._t]}));function pr({initialModel:e,onComplete:t,onCancel:n}){let r=mr.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,hr.jsxs)(c,{flexDirection:`column`,children:[(0,hr.jsx)(c,{marginBottom:1,children:(0,hr.jsx)(l,{dimColor:!0,children:`Model determines the agent's reasoning capabilities and speed.`})}),(0,hr.jsx)(en,{options:r,defaultValue:e??`sonnet`,onChange:t,onCancel:()=>n?n():t(void 0)})]})}var mr,hr,gr=e((()=>{mr=t(f(),1),h(),Se(),$t(),hr=_()}));function _r(){return{READ_ONLY:{name:`Read-only tools`,toolNames:new Set([we.name,he.name,me.name,Ve.name,fe.name,se.name,Oe.name,ue.name,Fe.name])},EDIT:{name:`Edit tools`,toolNames:new Set([je.name,ce.name,Ce.name])},EXECUTION:{name:`Execution tools`,toolNames:new Set([mt.name])},MCP:{name:`MCP tools`,toolNames:new Set,isMcp:!0},OTHER:{name:`Other tools`,toolNames:new Set}}}function vr(e){let t=new Map;return e.forEach(e=>{if(rt(e)){let n=ne(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 yr({tools:e,initialTools:t,onComplete:n,onCancel:r}){let i=(0,M.useMemo)(()=>ht({tools:e,isBuiltIn:!1,isAsync:!1}),[e]),[s,u]=(0,M.useState)(!t||t.includes(`*`)?i.map(e=>e.name):t),[f,p]=(0,M.useState)(0),[m,h]=(0,M.useState)(!1),g=(0,M.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])},x=(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))})},ee=()=>{let e=i.map(e=>e.name);n(g.length===e.length&&e.every(e=>g.includes(e))?void 0:g)},S=(0,M.useMemo)(()=>{let e=_r(),t={readOnly:[],edit:[],execution:[],mcp:[],other:[]};return i.forEach(n=>{rt(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]),te=e=>{let t=b(e,e=>_.has(e.name))<e.length;return()=>{let n=e.map(e=>e.name);x(n,t)}},C=[];C.push({id:`continue`,label:`Continue`,action:ee,isContinue:!0}),C.push({id:`bucket-all`,label:`${v?a.checkboxOn:a.checkboxOff} All tools`,action:()=>{let e=i.map(e=>e.name);x(e,!v)}});let re=_r();[{id:`bucket-readonly`,name:re.READ_ONLY.name,tools:S.readOnly},{id:`bucket-edit`,name:re.EDIT.name,tools:S.edit},{id:`bucket-execution`,name:re.EXECUTION.name,tools:S.execution},{id:`bucket-mcp`,name:re.MCP.name,tools:S.mcp},{id:`bucket-other`,name:re.OTHER.name,tools:S.other}].forEach(({id:e,name:t,tools:n})=>{if(n.length===0)return;let r=b(n,e=>_.has(e.name))===n.length;C.push({id:e,label:`${r?a.checkboxOn:a.checkboxOff} ${t}`,action:te(n)})});let ie=C.length;C.push({id:`toggle-individual`,label:m?`Hide advanced options`:`Show advanced options`,action:()=>{h(!m),m&&f>ie&&p(ie)},isToggle:!0});let ae=(0,M.useMemo)(()=>vr(i),[i]);return m&&(ae.length>0&&(C.push({id:`mcp-servers-header`,label:`MCP Servers:`,action:()=>{},isHeader:!0}),ae.forEach(({serverName:e,tools:t})=>{let n=b(t,e=>_.has(e.name))===t.length;C.push({id:`mcp-server-${e}`,label:`${n?a.checkboxOn:a.checkboxOff} ${e} (${t.length} ${It(t.length,`tool`)})`,action:()=>{let e=t.map(e=>e.name);x(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=ne(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,M.useCallback)(()=>{r?r():n(t)},[r,n,t]),{context:`Confirmation`}),(0,N.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,N.jsxs)(l,{color:f===0?`suggestion`:void 0,bold:f===0,children:[f===0?`${a.pointer} `:` `,`[ Continue ]`]}),(0,N.jsx)(o,{width:40}),C.slice(1).map((e,t)=>{let n=t+1===f,r=e.isToggle,i=e.isHeader;return(0,N.jsxs)(M.Fragment,{children:[r&&(0,N.jsx)(o,{width:40}),i&&t>0&&(0,N.jsx)(c,{marginTop:1}),(0,N.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,N.jsx)(c,{marginTop:1,flexDirection:`column`,children:(0,N.jsx)(l,{dimColor:!0,children:v?`All tools selected`:`${_.size} of ${i.length} tools selected`})})]})}var M,N,br=e((()=>{i(),M=t(f(),1),te(),pt(),yt(),x(),vt(),de(),ge(),ye(),ze(),Ae(),be(),De(),Te(),pe(),$e(),Re(),ke(),h(),E(),v(),Rt(),N=_()}));function xr(e){return e===`all`?`Agents`:e===`built-in`?`Built-in agents`:e===`plugin`?`Plugin agents`:Kn(ee(e))}var Sr=e((()=>{qn(),S()}));function Cr({agent:e,tools:t,onSaved:n,onBack:r}){let i=He(),[o,s]=(0,P.useState)(`menu`),[u,f]=(0,P.useState)(0),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(e.color),v=(0,P.useCallback)(async()=>{let t=await cn($n(e));t.error?h(t.error):n(`Opened ${e.agentType} in editor. If you made edits, restart to load the latest version.`)},[e,n]),y=(0,P.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!Ge(e)&&!tt(e)?!1:(await ir(e,e.whenToUse,r??e.tools,e.getSystemPrompt(),s,o??e.model),u&&s&&Ie(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:ct(n),allAgents:n}}}),n(`Updated agent: ${p.bold(e.agentType)}`),!0)}catch(e){return h(e instanceof Error?e.message:`Failed to save agent`),!1}},[e,g,n,i]),b=(0,P.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,P.useCallback)(()=>{h(null),o===`menu`?r():s(`menu`)},[o,r]),ee=(0,P.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 S=()=>(0,F.jsxs)(c,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,F.jsxs)(l,{dimColor:!0,children:[`Source: `,xr(e.source)]}),(0,F.jsx)(c,{marginTop:1,flexDirection:`column`,children:b.map((e,t)=>(0,F.jsxs)(l,{color:t===u?`suggestion`:void 0,children:[t===u?`${a.pointer} `:` `,e.label]},e.label))}),m&&(0,F.jsx)(c,{marginTop:1,children:(0,F.jsx)(l,{color:`error`,children:m})})]});switch(o){case`menu`:return S();case`edit-tools`:return(0,F.jsx)(yr,{tools:t,initialTools:e.tools,onComplete:async e=>{s(`menu`),await y({tools:e})}});case`edit-color`:return(0,F.jsx)(ur,{agentName:e.agentType,currentColor:g||e.color||`automatic`,onConfirm:async e=>{_(e),s(`menu`),await y({color:e})}});case`edit-model`:return(0,F.jsx)(pr,{initialModel:e.model,onComplete:async e=>{s(`menu`),await y({model:e})}});default:return null}}var P,F,wr=e((()=>{m(),i(),P=t(f(),1),Le(),h(),E(),gt(),at(),sn(),sr(),fr(),gr(),br(),Sr(),F=_()}));function Tr({instructions:e=`Press ↑↓ to navigate · Enter to select · Esc to go back`}){let t=Yt();return(0,Er.jsx)(c,{marginLeft:2,children:(0,Er.jsx)(l,{dimColor:!0,children:t.pending?`Press ${t.keyName} again to exit`:e})})}var Er,Dr=e((()=>{Xt(),h(),Er=_()}));function Or({source:e,agents:t,onBack:n,onSelect:r,onCreateNew:i,changes:s}){let[u,d]=kr.useState(null),[f,p]=kr.useState(!0),m=kr.useMemo(()=>[...t].sort(Gt),[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=Ut(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 `,qt(i)]})]},`${e.agentType}-${e.source}`)},y=kr.useMemo(()=>{let t=m.filter(e=>e.source!==`built-in`);return e===`all`?Jt.filter(e=>e.source!==`built-in`).flatMap(({source:e})=>t.filter(t=>t.source===e)):t},[m,e]);kr.useEffect(()=>{!u&&!f&&y.length>0&&(i?p(!0):d(y[0]||null))},[y,u,f,i]);let x=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))}},ee=(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))]})},te=xr(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:te,subtitle:`No agents found`,onCancel:n,hideInputGuide:!0,children:(0,I.jsxs)(c,{flexDirection:`column`,gap:1,tabIndex:0,autoFocus:!0,onKeyDown:x,children:[i&&(0,I.jsx)(c,{children:_()}),(0,I.jsx)(l,{dimColor:!0,children:`No agents found. Create specialized subagents that Work Mate 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,{}),ee()]})]})}):(0,I.jsxs)(g,{title:te,subtitle:`${b(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:x,children:[i&&(0,I.jsx)(c,{marginBottom:1,children:_()}),e===`all`?(0,I.jsxs)(I.Fragment,{children:[Jt.filter(e=>e.source!==`built-in`).map(({label:e,source:t})=>(0,I.jsx)(kr.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,{}),ee()]})]})]})]})}var kr,I,Ar=e((()=>{i(),kr=t(f(),1),h(),Wt(),v(),Sr(),I=_()}));function jr({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)([]);Yt(),(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,Mr.jsx)(Nr.Provider,{value:b,children:i||(0,Mr.jsx)(x,{})})}var L,Mr,Nr,Pr=e((()=>{L=t(f(),1),Xt(),Mr=_(),Nr=(0,L.createContext)(null)}));function R(){let e=(0,Fr.useContext)(Nr);if(!e)throw Error(`useWizard must be used within a WizardProvider`);return e}var Fr,Ir=e((()=>{Fr=t(f(),1),Pr()}));function Lr({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=Yt();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,Rr=e((()=>{Xt(),h(),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,zr.jsxs)(zr.Fragment,{children:[(0,zr.jsx)(g,{title:`${e||s||`Wizard`}${c===!1?``:` (${a+1}/${o})`}`,subtitle:r,onCancel:l,color:t,hideInputGuide:!0,isCancelActive:!1,children:n}),(0,zr.jsx)(Lr,{instructions:i})]})}var zr,V=e((()=>{h(),Ir(),Rr(),zr=_()})),H=e((()=>{Ir(),V(),Rr(),Pr()}));function Br(){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)(ur,{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,Vr=e((()=>{h(),E(),w(),H(),V(),fr(),U=_()}));function Hr(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=Hr(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 ${xr(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=We(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 Wr=e((()=>{yt(),Sr()}));function Gr({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=Pt(p.getSystemPrompt(),240),g=Pt(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=At()?(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Memory`}),`: `,nt(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`}),`:`,` `,er({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`}),`: `,et(p.model)]}),v,(0,W.jsx)(c,{marginTop:1,children:(0,W.jsxs)(l,{children:[(0,W.jsx)(l,{bold:!0,children:`Description`}),` (tells Work Mate 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,Kr=e((()=>{h(),E(),kt(),Xe(),Ft(),Se(),w(),H(),V(),sr(),Wr(),W=_()}));function qr({tools:e,existingAgents:t,onComplete:n}){let{wizardData:r}=R(),[i,a]=(0,Jr.useState)(null),o=He(),s=(0,Jr.useCallback)(async e=>{if(r?.finalAgent)try{await rr(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:ct(t),allAgents:t}}}),dt(),e&&await cn(Qn({source:r.location,agentType:r.finalAgent.agentType})),r.finalAgent.agentType,r.wasGenerated,r.location,r.finalAgent.tools?.length,r.finalAgent.model,r.finalAgent.color,r.finalAgent.memory,r.finalAgent.memory,{...e?{opened_in_editor:!0}:{}},n(e?`Created agent: ${p.bold(r.finalAgent.agentType)} and opened in editor. If you made edits, restart to load the latest version.`:`Created agent: ${p.bold(r.finalAgent.agentType)}`)}catch(e){a(e instanceof Error?e.message:`Failed to save agent`)}},[r,n,o]);return(0,Yr.jsx)(Gr,{tools:e,existingAgents:t,onSave:(0,Jr.useCallback)(()=>s(!1),[s]),onSaveAndEdit:(0,Jr.useCallback)(()=>s(!0),[s]),error:i})}var Jr,Yr,Xr=e((()=>{m(),Jr=t(f(),1),Nt(),Le(),at(),sn(),H(),sr(),Kr(),Yr=_()}));function Zr(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,Qr.useState)(r.whenToUse||``),[o,f]=(0,Qr.useState)(i.length),[p,m]=(0,Qr.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,Qr.useCallback)(async()=>{let e=await on(i);e.content!==null&&(a(e.content),f(e.content.length))},[i]),{context:`Chat`}),(0,G.jsx)(B,{subtitle:`Description (tell Work Mate 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 Work Mate use this agent?`}),(0,G.jsx)(c,{marginTop:1,children:(0,G.jsx)(Qt,{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 Qr,G,$r=e((()=>{Qr=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),G=_()}));async function ei(e,t,n,r){let i=ft({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 xe(),o=Ze([i],a),s=At()?ti+ni:ti,c=await qe({messages:Je(o),systemPrompt:st([s]),thinkingConfig:{type:`disabled`},tools:[],signal:r,options:{getToolPermissionContext:async()=>zt(),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=Tt(l.trim())}catch{let e=l.match(/\{[\s\S]*\}/);if(!e)throw Error(`No JSON object found in response`);u=Tt(e[0])}if(!u.identifier||!u.whenToUse||!u.systemPrompt)throw Error(`Invalid agent configuration generated`);return u.identifier,{identifier:u.identifier,whenToUse:u.whenToUse,systemPrompt:u.systemPrompt}}var ti,ni,ri=e((()=>{Ne(),Me(),Bt(),x(),it(),Ue(),kt(),Nt(),Ot(),lt(),ti=`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
10
 
11
11
  **Important Context**: You may have access to project-specific instructions from AGENTS.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
12
 
@@ -97,5 +97,5 @@ Remember: The agents you create should be autonomous experts capable of handling
97
97
  - For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
98
98
 
99
99
  The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
100
- `}));function ii(){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=ln(),_=(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 on(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=vt();_.current=r;try{let i=await ei(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 Dt||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)(nn,{}),(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)(Qt,{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,ai=e((()=>{St(),K=t(f(),1),un(),h(),E(),de(),sn(),w(),tn(),Zt(),H(),V(),ri(),q=_()}));function oi(){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)(en,{options:[{label:`Project (.workmate/agents/)`,value:`projectSettings`},{label:`Personal (~/.workmate/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var J,si=e((()=>{h(),w(),$t(),H(),V(),J=_()}));function ci(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();d(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.workmate/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.workmate/agent-memory/)`,value:`project`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.workmate/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.workmate/agent-memory/)`,value:`user`},{label:`Local scope (.workmate/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)(en,{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:At()&&i&&a?()=>`${r.systemPrompt}\n\n${tt(a,i)}`:()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,li=e((()=>{h(),E(),kt(),it(),w(),$t(),H(),V(),Y=_()}));function ui(){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)(en,{options:[{label:`Generate with Work Mate (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,di=e((()=>{h(),w(),$t(),H(),V(),X=_()}));function fi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return(0,pi.jsx)(B,{subtitle:`Select model`,footerText:(0,pi.jsxs)(u,{children:[(0,pi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,pi.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,pi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,pi.jsx)(pr,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var pi,mi=e((()=>{w(),h(),H(),V(),gr(),pi=_()}));function hi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,gi.useState)(r.systemPrompt||``),[o,f]=(0,gi.useState)(i.length),[p,m]=(0,gi.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,gi.useCallback)(async()=>{let e=await on(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)(Qt,{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 gi,Z,_i=e((()=>{gi=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),Z=_()}));function vi({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,yi.jsx)(B,{subtitle:`Select tools`,footerText:(0,yi.jsxs)(u,{children:[(0,yi.jsx)(s,{shortcut:`Enter`,action:`toggle selection`}),(0,yi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,yi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,yi.jsx)(yr,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var yi,bi=e((()=>{h(),w(),H(),V(),br(),yi=_()}));function xi(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),[a,o]=(0,Si.useState)(i.agentType||``),[f,p]=(0,Si.useState)(null),[m,h]=(0,Si.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)(Qt,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=Hr(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 Si,Q,Ci=e((()=>{Si=t(f(),1),h(),E(),w(),Zt(),H(),V(),Wr(),Q=_()}));function wi({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Ti.jsx)(jr,{steps:[oi,ui,ii,()=>(0,Ti.jsx)(xi,{existingAgents:t}),hi,Zr,()=>(0,Ti.jsx)(vi,{tools:e}),fi,Br,...At()?[ci]:[],()=>(0,Ti.jsx)(qr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Ti,Ei=e((()=>{kt(),H(),Vr(),Xr(),$r(),ai(),si(),li(),di(),mi(),_i(),bi(),Ci(),Ti=_()}));function Di({tools:e,onExit:t}){let[n,r]=(0,Oi.useState)({mode:`list-agents`,source:`all`}),i=ue(e=>e.agentDefinitions),a=ue(e=>e.mcp.tools),o=ue(e=>e.toolPermissionContext),s=we(),{allAgents:u,activeAgents:d}=i,[f,m]=(0,Oi.useState)([]),h=rn(e,a,o);Yt();let _=(0,Oi.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,Oi.useCallback)(e=>{m(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),y=(0,Oi.useCallback)(async e=>{try{await ar(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:at(n)}}}),m(t=>[...t,`Deleted agent: ${p.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Mt(Et(e))}},[s]);switch(n.mode){case`list-agents`:{let e=Kt(n.source===`all`?[..._[`built-in`],..._.userSettings,..._.projectSettings,..._.localSettings,..._.policySettings,..._.flagSettings,..._.plugin]:_[n.source],d);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Or,{source:n.source,agents:e,onBack:()=>{t((f.length>0?`Agent changes:\n${f.join(`
101
- `)}`: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)(Tr,{})]})}case`create-agent`:return(0,$.jsx)(wi,{tools:h,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)(en,{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)(Tr,{})]})}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)(cr,{agent:e,tools:h,allAgents:u,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Tr,{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)(en,{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)(Tr,{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)(Cr,{agent:e,tools:h,onSaved:e=>{v(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Tr,{})]})}default:return null}}var Oi,$,ki=e((()=>{m(),Oi=t(f(),1),Xt(),an(),h(),ht(),Wt(),rt(),Ct(),jt(),$t(),lr(),wr(),Dr(),Ar(),sr(),Ei(),$=_()}));async function Ai(e,t){let n=t.getAppState().toolPermissionContext;return(0,ji.jsx)(Di,{tools:ve(n),onExit:e})}var ji;e((()=>{ki(),he(),ji=_()}))();export{Ai as call};
100
+ `}));function ii(){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=ln(),_=(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 on(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=Be();_.current=r;try{let i=await ei(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 Dt||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)(nn,{}),(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)(Qt,{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,ai=e((()=>{St(),K=t(f(),1),un(),h(),E(),ve(),sn(),w(),tn(),Zt(),H(),V(),ri(),q=_()}));function oi(){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)(en,{options:[{label:`Project (.workmate/agents/)`,value:`projectSettings`},{label:`Personal (~/.workmate/agents/)`,value:`userSettings`}],onChange:n=>{t({location:n}),e()},onCancel:()=>n()},`location-select`)})})}var J,si=e((()=>{h(),w(),$t(),H(),V(),J=_()}));function ci(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();d(`confirm:no`,t,{context:`Confirmation`});let i=r.location===`userSettings`?[{label:`User scope (~/.workmate/agent-memory/) (Recommended)`,value:`user`},{label:`None (no persistent memory)`,value:`none`},{label:`Project scope (.workmate/agent-memory/)`,value:`project`},{label:`Local scope (.workmate/agent-memory-local/)`,value:`local`}]:[{label:`Project scope (.workmate/agent-memory/) (Recommended)`,value:`project`},{label:`None (no persistent memory)`,value:`none`},{label:`User scope (~/.workmate/agent-memory/)`,value:`user`},{label:`Local scope (.workmate/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)(en,{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:At()&&i&&a?()=>`${r.systemPrompt}\n\n${Ye(a,i)}`:()=>r.systemPrompt}:void 0}),e()},onCancel:t},`memory-select`)})})}var Y,li=e((()=>{h(),E(),kt(),Xe(),w(),$t(),H(),V(),Y=_()}));function ui(){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)(en,{options:[{label:`Generate with Work Mate (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,di=e((()=>{h(),w(),$t(),H(),V(),X=_()}));function fi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R();return(0,pi.jsx)(B,{subtitle:`Select model`,footerText:(0,pi.jsxs)(u,{children:[(0,pi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,pi.jsx)(s,{shortcut:`Enter`,action:`select`}),(0,pi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,pi.jsx)(pr,{initialModel:r.selectedModel,onComplete:t=>{n({selectedModel:t}),e()},onCancel:t})})}var pi,mi=e((()=>{w(),h(),H(),V(),gr(),pi=_()}));function hi(){let{goNext:e,goBack:t,updateWizardData:n,wizardData:r}=R(),[i,a]=(0,gi.useState)(r.systemPrompt||``),[o,f]=(0,gi.useState)(i.length),[p,m]=(0,gi.useState)(null);return d(`confirm:no`,t,{context:`Settings`}),d(`chat:externalEditor`,(0,gi.useCallback)(async()=>{let e=await on(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)(Qt,{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 gi,Z,_i=e((()=>{gi=t(f(),1),h(),E(),sn(),w(),Zt(),H(),V(),Z=_()}));function vi({tools:e}){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),a=e=>{r({selectedTools:e}),t()},o=i.selectedTools;return(0,yi.jsx)(B,{subtitle:`Select tools`,footerText:(0,yi.jsxs)(u,{children:[(0,yi.jsx)(s,{shortcut:`Enter`,action:`toggle selection`}),(0,yi.jsx)(s,{shortcut:`↑↓`,action:`navigate`}),(0,yi.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:(0,yi.jsx)(yr,{tools:e,initialTools:o,onComplete:a,onCancel:n})})}var yi,bi=e((()=>{h(),w(),H(),V(),br(),yi=_()}));function xi(e){let{goNext:t,goBack:n,updateWizardData:r,wizardData:i}=R(),[a,o]=(0,Si.useState)(i.agentType||``),[f,p]=(0,Si.useState)(null),[m,h]=(0,Si.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)(Qt,{value:a,onChange:o,onSubmit:e=>{let n=e.trim(),i=Hr(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 Si,Q,Ci=e((()=>{Si=t(f(),1),h(),E(),w(),Zt(),H(),V(),Wr(),Q=_()}));function wi({tools:e,existingAgents:t,onComplete:n,onCancel:r}){return(0,Ti.jsx)(jr,{steps:[oi,ui,ii,()=>(0,Ti.jsx)(xi,{existingAgents:t}),hi,Zr,()=>(0,Ti.jsx)(vi,{tools:e}),fi,Br,...At()?[ci]:[],()=>(0,Ti.jsx)(qr,{tools:e,existingAgents:t,onComplete:n})],initialData:{},onComplete:()=>{},onCancel:r,title:`Create new agent`,showStepCounter:!1})}var Ti,Ei=e((()=>{kt(),H(),Vr(),Xr(),$r(),ai(),si(),li(),di(),mi(),_i(),bi(),Ci(),Ti=_()}));function Di({tools:e,onExit:t}){let[n,r]=(0,Oi.useState)({mode:`list-agents`,source:`all`}),i=_e(e=>e.agentDefinitions),a=_e(e=>e.mcp.tools),o=_e(e=>e.toolPermissionContext),s=He(),{allAgents:u,activeAgents:d}=i,[f,m]=(0,Oi.useState)([]),h=rn(e,a,o);Yt();let _=(0,Oi.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,Oi.useCallback)(e=>{m(t=>[...t,e]),r({mode:`list-agents`,source:`all`})},[]),y=(0,Oi.useCallback)(async e=>{try{await ar(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:ct(n)}}}),m(t=>[...t,`Deleted agent: ${p.bold(e.agentType)}`]),r({mode:`list-agents`,source:`all`})}catch(e){Mt(Et(e))}},[s]);switch(n.mode){case`list-agents`:{let e=Kt(n.source===`all`?[..._[`built-in`],..._.userSettings,..._.projectSettings,..._.localSettings,..._.policySettings,..._.flagSettings,..._.plugin]:_[n.source],d);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Or,{source:n.source,agents:e,onBack:()=>{t((f.length>0?`Agent changes:\n${f.join(`
101
+ `)}`: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)(Tr,{})]})}case`create-agent`:return(0,$.jsx)(wi,{tools:h,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)(en,{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)(Tr,{})]})}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)(cr,{agent:e,tools:h,allAgents:u,onBack:()=>r({mode:`agent-menu`,agent:e,previousMode:n.previousMode})})}),(0,$.jsx)(Tr,{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)(en,{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)(Tr,{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)(Cr,{agent:e,tools:h,onSaved:e=>{v(e),r(n.previousMode)},onBack:()=>r(n.previousMode)})}),(0,$.jsx)(Tr,{})]})}default:return null}}var Oi,$,ki=e((()=>{m(),Oi=t(f(),1),Xt(),an(),h(),Le(),Wt(),at(),Ct(),jt(),$t(),lr(),wr(),Dr(),Ar(),sr(),Ei(),$=_()}));async function Ai(e,t){let n=t.getAppState().toolPermissionContext;return(0,ji.jsx)(Di,{tools:Ee(n),onExit:e})}var ji;e((()=>{ki(),Qe(),ji=_()}))();export{Ai as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,m as n}from"./settings-CA-5Px85.js";import{ff as r,uf as i}from"./loadAgentsDir-DnHL_5cU.js";function a(){let e=t(),n=[`user`,`project`,`local`].flatMap(e=>i(e).errors);return{settings:e.settings,errors:[...e.errors,...n]}}var o=e((()=>{r(),n()}));export{o as n,a as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{d as t,h as n,o as r}from"./config-Bio2EjUK.js";import{o as i,s as a}from"./log-L1kqxa_P.js";import{i as o,t as s}from"./execFileNoThrow-DXSEj8ZO.js";import{homedir as c}from"os";import{join as l}from"path";import{stat as u}from"fs/promises";function d(e){n(t=>({...t,appleTerminalSetupInProgress:!0,appleTerminalBackupPath:e}))}function f(){n(e=>({...e,appleTerminalSetupInProgress:!1}))}function p(){let e=r();return{inProgress:e.appleTerminalSetupInProgress??!1,backupPath:e.appleTerminalBackupPath||null}}function m(){return l(c(),`Library`,`Preferences`,`com.apple.Terminal.plist`)}async function h(){let e=m(),t=`${e}.bak`;try{let{code:n}=await s(`defaults`,[`export`,`com.apple.Terminal`,e]);if(n!==0)return null;try{await u(e)}catch{return null}return await s(`defaults`,[`export`,`com.apple.Terminal`,t]),d(t),t}catch(e){return a(e),null}}async function g(){let{inProgress:e,backupPath:t}=p();if(!e)return{status:`no_backup`};if(!t)return f(),{status:`no_backup`};try{await u(t)}catch{return f(),{status:`no_backup`}}try{let{code:e}=await s(`defaults`,[`import`,`com.apple.Terminal`,t]);return e===0?(await s(`killall`,[`cfprefsd`]),f(),{status:`restored`}):{status:`failed`,backupPath:t}}catch(e){return a(Error(`Failed to restore Terminal.app settings with: ${e}`)),f(),{status:`failed`,backupPath:t}}}var _=e((()=>{t(),o(),i()}));export{f as a,_ as i,g as n,m as r,h as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{d as t,h as n,o as r}from"./config-Bjwat4P6.js";import{o as i,s as a}from"./log-D98mO6yJ.js";import{i as o,t as s}from"./execFileNoThrow-7Ys9mO27.js";import{homedir as c}from"os";import{join as l}from"path";import{stat as u}from"fs/promises";function d(e){n(t=>({...t,appleTerminalSetupInProgress:!0,appleTerminalBackupPath:e}))}function f(){n(e=>({...e,appleTerminalSetupInProgress:!1}))}function p(){let e=r();return{inProgress:e.appleTerminalSetupInProgress??!1,backupPath:e.appleTerminalBackupPath||null}}function m(){return l(c(),`Library`,`Preferences`,`com.apple.Terminal.plist`)}async function h(){let e=m(),t=`${e}.bak`;try{let{code:n}=await s(`defaults`,[`export`,`com.apple.Terminal`,e]);if(n!==0)return null;try{await u(e)}catch{return null}return await s(`defaults`,[`export`,`com.apple.Terminal`,t]),d(t),t}catch(e){return a(e),null}}async function g(){let{inProgress:e,backupPath:t}=p();if(!e)return{status:`no_backup`};if(!t)return f(),{status:`no_backup`};try{await u(t)}catch{return f(),{status:`no_backup`}}try{let{code:e}=await s(`defaults`,[`import`,`com.apple.Terminal`,t]);return e===0?(await s(`killall`,[`cfprefsd`]),f(),{status:`restored`}):{status:`failed`,backupPath:t}}catch(e){return a(Error(`Failed to restore Terminal.app settings with: ${e}`)),f(),{status:`failed`,backupPath:t}}}var _=e((()=>{t(),o(),i()}));export{f as a,_ as i,g as n,m as r,h as t};
@@ -1 +1 @@
1
- import{i as e,o as t}from"./envUtils-QyzA_cFM.js";import{_ as n,d as r,m as i}from"./settings-D4M13toi.js";import{P as a,Pt as o,z as s}from"./state-CXY-q5gr.js";import{Fu as c,Ru as l,St as u,db as d,ft as f,gr as p,ic as m,or as h,pb as g,rc as _}from"./loadAgentsDir-bmpKLPdG.js";import{c as v,f as y,i as b,u as x}from"./debug-2pVES-2G.js";import{_ as S,o as C,s as w,v as T}from"./log-L1kqxa_P.js";import{n as E}from"./analytics-COpjZpvd.js";import{r as D,t as O}from"./pasteStore-njJCBMKr.js";import{r as k}from"./magicDocs-BsEiBLQl.js";import{i as A,t as j}from"./nativeInstaller-DMkZdsof.js";import{n as M,t as N}from"./allErrors-Dhnf6rqg.js";import{n as P,t as F}from"./pluginAutoupdate-ByokIVEs.js";import{join as I}from"path";o(),m(),k(),E(),T(),b(),t(),y(),l(),C(),D(),p(),M(),i(),g(),u();var L=30;function R(){let e=((r()||{}).cleanupPeriodDays??L)*24*60*60*1e3;return new Date(Date.now()-e)}function z(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function B(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 V(e,t,n){let r={messages:0,errors:0};try{let i=await x().readdir(e);for(let a of i)try{B(a.name)<t&&(await x().unlink(I(e,a.name)),n?r.messages++:r.errors++)}catch(e){w(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return r}async function H(){let e=x(),t=R(),n=S.errors(),r=S.baseLogs(),i=await V(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=>I(r,e.name));for(let n of a)i=z(i,await V(n,t,!0)),await W(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return i}async function U(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function W(e,t){try{await t.rmdir(e)}catch{}}async function G(){let e=R(),t={messages:0,errors:0},n=h(),r=x(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=I(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 U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=I(i,n.name),o=I(a,d),s;try{s=await r.readdir(o)}catch{await W(a,r);continue}for(let n of s)if(n.isFile())try{await U(I(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=I(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}await W(i,r)}await W(o,r),await W(a,r)}await W(i,r)}return t}async function K(e,t,n=!0){let r=R(),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 U(I(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await W(e,a),i}function q(){return K(I(e(),`plans`),`.md`)}async function J(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));await Promise.all(o.map(async e=>{try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await W(i,r)}catch(e){w(e)}return n}async function Y(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));for(let e of o)try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await W(i,r)}catch(e){w(e)}return n}async function X(){let t=R(),n={messages:0,errors:0},r=x(),i=I(e(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let e of a)if(!(!e.isFile()||!e.name.endsWith(`.txt`)||e.name===`latest`))try{await U(I(i,e.name),t,r)&&n.messages++}catch{n.errors++}return n}async function Z(){let{errors:e}=N();if(e.length>0&&n(`cleanupPeriodDays`)){v(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await H(),await G(),await q(),await J(),await Y(),await X(),await c(),await O(R()),await f(R())}j(),P();var Q=600*1e3;function $(){import(`./extractMemories-CVUrBFMj.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),_(),F();let e=!0;async function t(){if(a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}if(e&&(e=!1,await Z()),a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}await A()}setTimeout(t,Q).unref()}export{$ as t};
1
+ import{i as e,o as t}from"./envUtils-QyzA_cFM.js";import{_ as n,d as r,m as i}from"./settings-CA-5Px85.js";import{P as a,Pt as o,z as s}from"./state-CXY-q5gr.js";import{Bu as c,Lu as l,ac as u,cr as d,hb as f,mt as p,oc as m,pb as h,vr as g,wt as _}from"./loadAgentsDir-DnHL_5cU.js";import{c as v,f as y,i as b,u as x}from"./debug-NBJH_NxR.js";import{_ as S,o as C,s as w,v as T}from"./log-D98mO6yJ.js";import{n as E}from"./analytics-COpjZpvd.js";import{r as D,t as O}from"./pasteStore-2RafnH7M.js";import{r as k}from"./magicDocs-BoxJusTI.js";import{i as A,t as j}from"./nativeInstaller-BDJxBAPV.js";import{n as M,t as N}from"./allErrors-Bv1e8fra.js";import{n as P,t as F}from"./pluginAutoupdate-Cr3jw-ky.js";import{join as I}from"path";o(),m(),k(),E(),T(),b(),t(),y(),c(),C(),D(),g(),M(),i(),f(),_();var L=30;function R(){let e=((r()||{}).cleanupPeriodDays??L)*24*60*60*1e3;return new Date(Date.now()-e)}function z(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function B(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 V(e,t,n){let r={messages:0,errors:0};try{let i=await x().readdir(e);for(let a of i)try{B(a.name)<t&&(await x().unlink(I(e,a.name)),n?r.messages++:r.errors++)}catch(e){w(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return r}async function H(){let e=x(),t=R(),n=S.errors(),r=S.baseLogs(),i=await V(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=>I(r,e.name));for(let n of a)i=z(i,await V(n,t,!0)),await W(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&w(e)}return i}async function U(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function W(e,t){try{await t.rmdir(e)}catch{}}async function G(){let e=R(),t={messages:0,errors:0},n=d(),r=x(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=I(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 U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=I(i,n.name),o=I(a,h),s;try{s=await r.readdir(o)}catch{await W(a,r);continue}for(let n of s)if(n.isFile())try{await U(I(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=I(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await U(I(i,n.name),e,r)&&t.messages++}catch{t.errors++}await W(i,r)}await W(o,r),await W(a,r)}await W(i,r)}return t}async function K(e,t,n=!0){let r=R(),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 U(I(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await W(e,a),i}function q(){return K(I(e(),`plans`),`.md`)}async function J(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`file-history`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));await Promise.all(o.map(async e=>{try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}})),await W(i,r)}catch(e){w(e)}return n}async function Y(){let t=R(),n={messages:0,errors:0},r=x();try{let i=I(e(),`session-env`),a;try{a=await r.readdir(i)}catch{return n}let o=a.filter(e=>e.isDirectory()).map(e=>I(i,e.name));for(let e of o)try{(await r.stat(e)).mtime<t&&(await r.rm(e,{recursive:!0,force:!0}),n.messages++)}catch{n.errors++}await W(i,r)}catch(e){w(e)}return n}async function X(){let t=R(),n={messages:0,errors:0},r=x(),i=I(e(),`debug`),a;try{a=await r.readdir(i)}catch{return n}for(let e of a)if(!(!e.isFile()||!e.name.endsWith(`.txt`)||e.name===`latest`))try{await U(I(i,e.name),t,r)&&n.messages++}catch{n.errors++}return n}async function Z(){let{errors:e}=N();if(e.length>0&&n(`cleanupPeriodDays`)){v(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await H(),await G(),await q(),await J(),await Y(),await X(),await l(),await O(R()),await p(R())}j(),P();var Q=600*1e3;function $(){import(`./extractMemories-4wbv-mTc.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),u(),F();let e=!0;async function t(){if(a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}if(e&&(e=!1,await Z()),a()&&s()>Date.now()-1e3*60){setTimeout(t,Q).unref();return}await A()}setTimeout(t,Q).unref()}export{$ as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./backgroundHousekeeping-C75FgxW1.js";export{e as startBackgroundHousekeeping};
@@ -0,0 +1,2 @@
1
+ import{Br as e,In as t,Jr as n,Ur as r,Vn as i,ai as a,ni as o}from"./settings-CA-5Px85.js";import{Pt as s,q as c}from"./state-CXY-q5gr.js";import{c as l,i as u}from"./debug-NBJH_NxR.js";import{d,h as f,o as p}from"./config-Bjwat4P6.js";import{_ as m,f as h,p as g}from"./startupProfiler-C_xcIvEA.js";import{n as _,r as v}from"./detectRepository-Bu0he_XM.js";import{homedir as y}from"os";import{join as b,sep as x}from"path";import{realpath as S,stat as C}from"fs/promises";s(),d(),u(),v(),t(),a(),n();async function w(){try{let t=await _();if(!t){l(`Not in a GitHub repository, skipping path mapping update`);return}let n=c(),r=e(n)??n,i;try{i=(await S(r)).normalize(`NFC`)}catch{i=r}let a=t.toLowerCase(),o=p().githubRepoPaths?.[a]??[];if(o[0]===i){l(`Path ${i} already tracked for repo ${a}`);return}let s=o.filter(e=>e!==i),u=[i,...s];f(e=>({...e,githubRepoPaths:{...e.githubRepoPaths,[a]:u}})),l(`Added ${i} to tracked paths for repo ${a}`)}catch(e){l(`Error updating repo path mapping: ${e}`)}}function T(e){let t=p(),n=e.toLowerCase();return t.githubRepoPaths?.[n]??[]}async function E(e){let t=await Promise.all(e.map(i));return e.filter((e,n)=>t[n])}m(),a(),n();var D=10080*60*1e3,O=1e3;function k(e){let t=[`This session was opened by an external deep link in ${M(e.cwd)}`];if(e.repo){let n=e.lastFetch?g(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>D;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — AGENTS.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>O?`The prompt below (${h(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
2
+ `)}async function A(e){let t=await r(e);if(!t)return;let n=await o(t),[i,a]=await Promise.all([j(b(t,`FETCH_HEAD`)),n?j(b(n,`FETCH_HEAD`)):Promise.resolve(void 0)]);return i&&a?i>a?i:a:i??a}async function j(e){try{let{mtime:t}=await C(e);return t}catch{return}}function M(e){let t=y();return e===t?`~`:e.startsWith(t+x)?`~${e.slice(t.length)}`:e}export{w as a,T as i,A as n,E as r,k as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{vn as t,yn as n}from"./settings-D4M13toi.js";import{Pt as r,at as i,q as a}from"./state-CXY-q5gr.js";import{Sr as o,ar as s,ei as c,fr as l,gr as u,oi as d,pr as f}from"./loadAgentsDir-bmpKLPdG.js";import{C as p,x as m}from"./debug-2pVES-2G.js";import{n as h}from"./analytics-COpjZpvd.js";import{i as g,o as _}from"./stringUtils-Cs6E5f-B.js";import{randomUUID as v}from"crypto";import{mkdir as y,readFile as b,writeFile as x}from"fs/promises";function S(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function C(e){let t=v(),r=i(),c=s(a()),u=f(t),d=l();await y(c,{recursive:!0,mode:448});let m;try{m=await b(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=n(m),g=h.filter(e=>o(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let S=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:S,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(p(n)),e.type!==`progress`&&(S=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(p(e))}return await x(u,`${C.join(`
2
- `)}\n`,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:u,serializedMessages:w,contentReplacementRecords:_}}async function w(e){let t=`${e} (Branch)`;if((await d(t,{exact:!0})).length===0)return t;let n=await d(`${e} (Branch`),r=new Set([1]),i=RegExp(`^${g(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(i);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let a=2;for(;r.has(a);)a++;return`${e} (Branch ${a})`}async function T(e,t,n){let r=n?.trim()||void 0,a=i();try{let{sessionId:n,title:i,forkPath:o,serializedMessages:s,contentReplacementRecords:l}=await C(r),u=new Date,d=S(s.find(e=>e.type===`user`)),f=await w(i??d);await c(n,f,o),s.length;let p={date:u.toISOString().split(`T`)[0],messages:s,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:s.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=i?` "${i}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${a}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{r(),h(),t(),u(),m(),_()}))();export{T as call,S as deriveFirstPrompt};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{vn as t,yn as n}from"./settings-CA-5Px85.js";import{Pt as r,at as i,q as a}from"./state-CXY-q5gr.js";import{ci as o,hr as s,mr as c,ni as l,sr as u,vr as d,wr as f}from"./loadAgentsDir-DnHL_5cU.js";import{C as p,x as m}from"./debug-NBJH_NxR.js";import{n as h}from"./analytics-COpjZpvd.js";import{i as g,o as _}from"./stringUtils-CtJhTszO.js";import{randomUUID as v}from"crypto";import{mkdir as y,readFile as b,writeFile as x}from"fs/promises";function S(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function C(e){let t=v(),r=i(),o=u(a()),l=s(t),d=c();await y(o,{recursive:!0,mode:448});let m;try{m=await b(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=n(m),g=h.filter(e=>f(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===r).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let S=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:S,isSidechain:!1,forkedFrom:{sessionId:r,messageUuid:e.uuid}},i={...e,sessionId:t};w.push(i),C.push(p(n)),e.type!==`progress`&&(S=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(p(e))}return await x(l,`${C.join(`
2
+ `)}\n`,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:l,serializedMessages:w,contentReplacementRecords:_}}async function w(e){let t=`${e} (Branch)`;if((await o(t,{exact:!0})).length===0)return t;let n=await o(`${e} (Branch`),r=new Set([1]),i=RegExp(`^${g(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(i);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let a=2;for(;r.has(a);)a++;return`${e} (Branch ${a})`}async function T(e,t,n){let r=n?.trim()||void 0,a=i();try{let{sessionId:n,title:i,forkPath:o,serializedMessages:s,contentReplacementRecords:c}=await C(r),u=new Date,d=S(s.find(e=>e.type===`user`)),f=await w(i??d);await l(n,f,o),s.length;let p={date:u.toISOString().split(`T`)[0],messages:s,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:s.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:c},m=i?` "${i}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${a}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{r(),h(),t(),d(),m(),_()}))();export{T as call,S as deriveFirstPrompt};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-QyzA_cFM.js";import{Gi as r,Hi as i,Ki as a,Pi as o,aa as s,na as c,sa as l,ta as u}from"./settings-CA-5Px85.js";import{c as d,i as f}from"./debug-NBJH_NxR.js";import{n as p,r as m}from"./process-CewWh77C.js";import{o as h,s as g}from"./log-D98mO6yJ.js";import{join as _}from"node:path";import{spawn as v,spawnSync as y}from"node:child_process";import{chmodSync as b,existsSync as x,mkdirSync as S,readFileSync as C,renameSync as w,writeFileSync as T}from"node:fs";function E(){return _(t(),`channel`)}function D(){return _(E(),`dingtalk.json`)}function O(){return P.parse({})}function k(){let e=D();try{if(!x(e))return O();let t=C(e,`utf8`),n=JSON.parse(t);return P.parse(n)}catch(e){return g(e),O()}}function A(e){let t=D(),n=e(k());S(E(),{recursive:!0});let r=`${t}.${process.pid}.tmp`;T(r,`${JSON.stringify(n,null,2)}\n`,{mode:384}),w(r,t);try{b(t,384)}catch{}return n}function j(e){return e.channel?.enabled===!0&&e.channel?.activePlugin===`dingtalk`}function M(e){return e.permissionMode}var N,P,F=e((()=>{o(),n(),h(),N=c({workmateSessionId:l(),transcriptPath:l().optional(),lastActiveAt:u(),senderId:l().optional()}),P=c({corpid:l().default(``),appKey:l().default(``),appSecret:l().default(``),robotName:l().default(`workmate`),cardTemplateId:l().default(``),permissionMode:i([`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`]).default(`default`),sessionStrategy:i([`perConversation`,`perUser`,`shared`]).default(`perConversation`),confirmDangerous:a().default(!0),confirmTimeoutMs:u().default(300*1e3),admins:r(l()).default([]),sessions:s(l(),N).default({})})}));function I(){let e=B();if(e)return d(`[channel] bridge 已在运行,pid=${e}`,{level:`debug`}),{pid:e,started:!1};let t=m()?[process.argv[1],`channel`,`start`]:[`channel`,`start`],n=v(process.execPath,t,{detached:!0,stdio:`ignore`,cwd:process.cwd()});n.unref();let r=n.pid;return r?(d(`[channel] bridge 已启动,pid=${r}`,{level:`debug`}),{pid:r,started:!0}):{pid:0,started:!1}}function L(){let e=B();if(!e)return!1;try{return process.kill(e,`SIGTERM`),d(`[channel] 已发 SIGTERM 给 bridge pid=${e}`,{level:`debug`}),!0}catch(e){return g(e),!1}}function R(){return B()!==null}function z(){return B()}function B(){let e=y(`pgrep`,[`-f`,V],{encoding:`utf8`});if(e.status!==0||!e.stdout.trim())return null;let t=e.stdout.trim().split(`
2
+ `).map(Number).filter(e=>e&&e!==process.pid);return t.length?t[t.length-1]:null}var V,H=e((()=>{f(),h(),p(),V=`channel start$`}));export{L as a,F as c,I as i,j as l,H as n,k as o,R as r,M as s,z as t,A as u};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,bn as a,ot as o,t as s,vn as c,xt as l}from"./src-BX54x08P.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Gt as d}from"./settings-D4M13toi.js";import{Bv as f,F_ as p,GS as m,I_ as h,Ji as g,P_ as _,Rx as v,Us as y,Ws as b,dd as x,ld as S,ot as C,sb as w,st as T,ty as E,zv as D}from"./loadAgentsDir-bmpKLPdG.js";import{I as O,M as k}from"./debug-2pVES-2G.js";import{d as A,h as j}from"./config-Bio2EjUK.js";import{n as M,t as N}from"./SpinnerGlyph-BR_SiV9L.js";import{n as P,r as F}from"./sideQuestion-BJTVma-5.js";import{i as I,n as L}from"./modalContext-sU2lfR08.js";function R({question:e,context:t,onDone:i}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:h}=I(o());a(()=>p(e=>e+1),s||u?null:80);function g(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),i(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=D();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(k(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let _=Math.max(5,h-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:_,children:(0,U.jsx)(l,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(S,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(N,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=v(z(e.messages)),n=y();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([C(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),p(),_()]);return{systemPrompt:m(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(i(),1),c(),x(),M(),d(),T(),L(),h(),w(),s(),f(),A(),O(),b(),g(),P(),E(),U=u(),W=5,G=6,K=3}))();export{V as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,bn as a,ot as o,t as s,vn as c,xt as l}from"./src-BX54x08P.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Gt as d}from"./settings-CA-5Px85.js";import{Bx as f,Gs as p,Hv as m,I_ as h,Ks as g,L_ as _,R_ as v,Vv as y,Xi as b,ct as x,dd as S,lb as C,lt as w,pd as T,qS as E,ry as D}from"./loadAgentsDir-DnHL_5cU.js";import{I as O,M as k}from"./debug-NBJH_NxR.js";import{d as A,h as j}from"./config-Bjwat4P6.js";import{n as M,t as N}from"./SpinnerGlyph-4aVLQdJf.js";import{n as P,r as F}from"./sideQuestion-BEpCuv_7.js";import{i as I,n as L}from"./modalContext-sU2lfR08.js";function R({question:e,context:t,onDone:i}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:h}=I(o());a(()=>p(e=>e+1),s||u?null:80);function g(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),i(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=y();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(k(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let _=Math.max(5,h-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:_,children:(0,U.jsx)(l,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(S,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(N,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=p();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([x(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),_(),h()]);return{systemPrompt:E(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{H=t(i(),1),c(),T(),M(),d(),w(),L(),v(),C(),s(),m(),A(),O(),g(),b(),P(),D(),U=u(),W=5,G=6,K=3}))();export{V as call};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i,w as a,x as o}from"./debug-2pVES-2G.js";import{r as s,t as c}from"./execa-CBhG1doD.js";import{o as l,s as u}from"./log-L1kqxa_P.js";import{release as d}from"os";import{readFile as f}from"fs/promises";import{execSync as p}from"child_process";function m(e,t){return a`execSync: ${e.slice(0,100)}`,p(e,t)}var h=e((()=>{o()}));async function g(e){if(process.platform===`win32`){let t=await c(`where.exe ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim().split(/\r?\n/)[0]||null}let t=await c(`which ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim()}function _(e){if(process.platform===`win32`)try{return m(`where.exe ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim().split(/\r?\n/)[0]||null}catch{return null}try{return m(`which ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()||null}catch{return null}}var v,y,b,x=e((()=>{s(),h(),v=typeof Bun<`u`&&typeof Bun.which==`function`?Bun.which:null,y=v?async e=>v(e):g,b=v??_})),S,C,w=e((()=>{n(),r(),l(),S=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){u(e)}return`linux`}return`unknown`}catch(e){return u(e),`unknown`}}),C=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){u(e);return}}),t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:d()};try{let t=await f(`/etc/os-release`,`utf8`);for(let n of t.split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i,w as a,x as o}from"./debug-NBJH_NxR.js";import{r as s,t as c}from"./execa-CBhG1doD.js";import{o as l,s as u}from"./log-D98mO6yJ.js";import{release as d}from"os";import{readFile as f}from"fs/promises";import{execSync as p}from"child_process";function m(e,t){return a`execSync: ${e.slice(0,100)}`,p(e,t)}var h=e((()=>{o()}));async function g(e){if(process.platform===`win32`){let t=await c(`where.exe ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim().split(/\r?\n/)[0]||null}let t=await c(`which ${e}`,{shell:!0,stderr:`ignore`,reject:!1});return t.exitCode!==0||!t.stdout?null:t.stdout.trim()}function _(e){if(process.platform===`win32`)try{return m(`where.exe ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim().split(/\r?\n/)[0]||null}catch{return null}try{return m(`which ${e}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()||null}catch{return null}}var v,y,b,x=e((()=>{s(),h(),v=typeof Bun<`u`&&typeof Bun.which==`function`?Bun.which:null,y=v?async e=>v(e):g,b=v??_})),S,C,w=e((()=>{n(),r(),l(),S=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){u(e)}return`linux`}return`unknown`}catch(e){return u(e),`unknown`}}),C=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){u(e);return}}),t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:d()};try{let t=await f(`/etc/os-release`,`utf8`);for(let n of t.split(`
2
2
  `)){let t=n.match(/^(ID|VERSION_ID)=(.*)$/);if(t?.[1]&&t[2]){let n=t[2].replace(/^"|"$/g,``);t[1]===`ID`?e.linuxDistroId=n:e.linuxDistroVersion=n}}}catch{}return e})}));function T(){return process.versions.bun!==void 0}function E(){return typeof Bun<`u`&&Array.isArray(Bun.embeddedFiles)&&Bun.embeddedFiles.length>0}var D=e((()=>{}));export{C as a,y as c,h as d,S as i,b as l,E as n,w as o,T as r,x as s,D as t,m as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t,ti as n}from"./settings-CA-5Px85.js";import{Pt as r,l as i,mn as a}from"./state-CXY-q5gr.js";import{B_ as o,Bu as s,F_ as c,Hi as l,I_ as u,Ki as d,L_ as f,My as p,Pi as m,Pp as h,R_ as g,Ru as _,Tb as v,Ti as y,V_ as b,Y as x,_p as S,dh as C,dm as w,fh as T,hp as E,is as D,jy as O,lm as k,q as A,rs as j,wb as M,z_ as N}from"./loadAgentsDir-DnHL_5cU.js";import{a as P,n as F}from"./fileSuggestions-XLnnVLwx.js";import{r as I,t as L}from"./magicDocs-BoxJusTI.js";import{r as R,t as z}from"./detectRepository-Bu0he_XM.js";function B(e=new Set){let t=e.size>0;f.cache.clear?.(),u.cache.clear?.(),c.cache.clear?.(),o.cache.clear?.(),F(),y(),t||S(),N(null),a(null),w(),D(),p(`session_start`),_(),z(),A(),i(e),n(),l(),T(),L(),M(),import(`./SearchExtraToolsTool-BBhWAuoA.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-C-qRJlXH.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-Cpu4meqR.js`).then(({clearPromptCache:e})=>e())}var V=e((()=>{r(),m(),b(),g(),P(),h(),E(),k(),C(),I(),d(),j(),x(),O(),R(),t(),s(),v()}));export{V as n,B as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-BKAPMXp9.js";e();export{t as clearSessionCaches};
@@ -0,0 +1,2 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{n,t as r}from"./axios-DaWTGg7G.js";import{n as i,r as a}from"./wrapper-DVKxC5fR.js";import{Cr as o,Pt as s,Tr as c,Vt as l,wr as u}from"./settings-CA-5Px85.js";import{U as d,W as f}from"./loadAgentsDir-DnHL_5cU.js";import{c as p,i as m}from"./debug-NBJH_NxR.js";import{d as h,o as g}from"./config-Bjwat4P6.js";import{n as _,r as v}from"./process-CewWh77C.js";import{o as y,s as b}from"./log-D98mO6yJ.js";import{a as x,c as S,l as C,n as w,o as T,r as E,s as D,t as O,u as k}from"./bridgeControl-DMUu37uO.js";import{createInterface as A}from"node:readline";import{join as j}from"node:path";import{spawn as M}from"node:child_process";import{existsSync as N,readdirSync as P}from"node:fs";import{randomUUID as F}from"node:crypto";import{EventEmitter as I}from"node:events";import L from"events";_(),y(),d(),S(),w(),m(),e();var R=`https://api.dingtalk.com`,z=`https://oapi.dingtalk.com`,ee=`/gettoken`,B=`/v1.0/card/instances/createAndDeliver`,V=`/v1.0/card/streaming`,H=300*1e3,U=class{constructor(e){t(this,`opts`,void 0),t(this,`tokenCache`,null),this.opts=e}async getAccessToken(){if(this.tokenCache&&Date.now()<this.tokenCache.expiresAt-H)return this.tokenCache.token;let e=`${z}${ee}?appkey=${encodeURIComponent(this.opts.appKey)}&appsecret=${encodeURIComponent(this.opts.appSecret)}`,t=await(await fetch(e)).json();if(t.errcode!==0||!t.access_token)throw Error(`gettoken 失败: errcode=${t.errcode} errmsg=${t.errmsg}`);return this.tokenCache={token:t.access_token,expiresAt:Date.now()+(t.expires_in??7200)*1e3},t.access_token}async createAndDeliverCard(e){let t=F(),n=e.conversationType===`2`,r=await this.getAccessToken(),i=n?`IM_GROUP`:`IM_ROBOT`,a=n?e.conversationId:e.senderStaffId,o={cardTemplateId:e.cardTemplateId,outTrackId:t,cardData:{cardParamMap:{content:e.initialMarkdown}},openSpaceId:`dtv1.card//${i}.${a}`};n?(o.imGroupOpenSpaceModel={supportForward:!0},o.imGroupOpenDeliverModel={robotCode:this.opts.robotCode}):(o.imRobotOpenSpaceModel={supportForward:!0},o.imRobotOpenDeliverModel={robotCode:this.opts.robotCode});let s=await fetch(`${R}${B}`,{method:`POST`,headers:{"Content-Type":`application/json`,"x-acs-dingtalk-access-token":r},body:JSON.stringify(o)});if(!s.ok){let e=await s.text();throw Error(`createAndDeliver 失败: ${s.status} ${e}`)}return p(`[channel] 卡片已创建 outTrackId=${t} ${n?`群聊`:`单聊`}`,{level:`debug`}),t}async streamingUpdate(e,t,n={}){let r=await this.getAccessToken(),i={outTrackId:e,guid:F(),key:`content`,content:t,isFull:!0,isFinalize:n.finalize??!1,isError:n.error??!1},a=await fetch(`${R}${V}`,{method:`PUT`,headers:{"Content-Type":`application/json`,"x-acs-dingtalk-access-token":r},body:JSON.stringify(i)});if(!a.ok){let e=await a.text();throw Error(`streaming 失败: ${a.status} ${e}`)}p(`[channel] streaming 推送 finalize=${n.finalize??!1} len=${t.length}`,{level:`debug`})}},W=`https://api.dingtalk.com/v1.0/gateway/connections/open`,G=`https://oapi.dingtalk.com/gettoken`,K=`/v1.0/im/bot/messages/get`;i(),r(),e();var q={autoReconnect:!0,keepAlive:!1,ua:``,subscriptions:[{type:`EVENT`,topic:`*`}]},J=class extends L{constructor(e){if(super(),t(this,`debug`,!1),t(this,`connected`,!1),t(this,`registered`,!1),t(this,`reconnecting`,!1),t(this,`userDisconnect`,!1),t(this,`reconnectBaseInterval`,1e3),t(this,`reconnectMaxInterval`,6e4),t(this,`reconnectAttempts`,0),t(this,`heartbeat_interval`,8e3),t(this,`heartbeatIntervallId`,void 0),t(this,`reconnectTimerId`,void 0),t(this,`isConnecting`,!1),t(this,`sslopts`,{rejectUnauthorized:!0}),t(this,`config`,void 0),t(this,`socket`,void 0),t(this,`dw_url`,void 0),t(this,`isAlive`,!1),t(this,`onEventReceived`,e=>({status:`SUCCESS`})),this.config={...q,...e},!this.config.clientId||!this.config.clientSecret)throw console.error(`clientId or clientSecret is null`),Error(`clientId or clientSecret is null`);this.config.debug!==void 0&&(this.debug=this.config.debug)}getConfig(){return{...this.config}}printDebug(e){if(this.debug){let t=`[`+new Date().toISOString()+`]`;console.info(t,e)}}registerAllEventListener(e){return this.onEventReceived=e,this}registerCallbackListener(e,t){if(!e||!t)throw console.error(`registerCallbackListener: eventId and callback must be defined`),Error(`registerCallbackListener: eventId and callback must be defined`);return this.config.subscriptions.find(t=>t.topic===e&&t.type===`CALLBACK`)||this.config.subscriptions.push({type:`CALLBACK`,topic:e}),this.on(e,t),this}async getAccessToken(){let e=await n.get(`${G}?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`);if(e.status===200&&e.data.access_token)return this.config.access_token=e.data.access_token,e.data.access_token;throw Error(`getAccessToken: get access_token failed`)}async getEndpoint(){this.printDebug(`get connect endpoint by config`),this.printDebug(this.config);let e=await n({url:W,method:`POST`,responseType:`json`,data:{clientId:this.config.clientId,clientSecret:this.config.clientSecret,ua:this.config.ua,subscriptions:this.config.subscriptions},headers:{Accept:`application/json`}});if(this.printDebug(`res.data `+JSON.stringify(e.data)),e.data){this.config.endpoint=e.data;let{endpoint:t,ticket:n}=e.data;if(!t||!n)throw this.printDebug(`endpoint or ticket is null`),Error(`endpoint or ticket is null`);return this.dw_url=`${t}?ticket=${n}`,this}else throw Error(`build: get endpoint failed`)}cleanup(){this.heartbeatIntervallId!==void 0&&(clearInterval(this.heartbeatIntervallId),this.heartbeatIntervallId=void 0),this.socket&&(this.socket.removeAllListeners(),(this.socket.readyState===a.OPEN||this.socket.readyState===a.CONNECTING)&&this.socket.terminate(),this.socket=void 0)}scheduleReconnect(){if(!this.config.autoReconnect||this.userDisconnect||this.isConnecting)return;let e=Math.min(this.reconnectBaseInterval*2**this.reconnectAttempts+Math.random()*1e3,this.reconnectMaxInterval);this.reconnecting=!0,this.printDebug(`Reconnecting in `+(e/1e3).toFixed(1)+` seconds... (attempt `+(this.reconnectAttempts+1)+`)`),this.reconnectTimerId&&clearTimeout(this.reconnectTimerId),this.reconnectTimerId=setTimeout(()=>{this.reconnectTimerId=void 0,this.connect()},e)}_connect(){return new Promise((e,t)=>{this.printDebug(`Connecting to dingtalk websocket @ `+this.dw_url);try{this.socket=new a(this.dw_url,this.sslopts)}catch(e){this.printDebug(`WebSocket constructor error`),console.warn(`ERROR`,e),t(e);return}let n=!1;this.socket.on(`open`,()=>{this.connected=!0,this.reconnectAttempts=0,console.info(`[`+new Date().toISOString()+`] connect success`),this.config.keepAlive&&(this.isAlive=!0,this.heartbeatIntervallId=setInterval(()=>{var e;if(this.isAlive===!1)return console.error(`TERMINATE SOCKET: Ping Pong does not transfer heartbeat within heartbeat intervall`),this.socket?.terminate();this.isAlive=!1,(e=this.socket)==null||e.ping(``,!0)},this.heartbeat_interval)),n=!0,e()}),this.socket.on(`pong`,()=>{this.heartbeat()}),this.socket.on(`message`,e=>{this.onDownStream(e)}),this.socket.on(`close`,()=>{this.printDebug(`Socket closed`),this.connected=!1,this.registered=!1,this.heartbeatIntervallId!==void 0&&(clearInterval(this.heartbeatIntervallId),this.heartbeatIntervallId=void 0),n&&this.scheduleReconnect()}),this.socket.on(`error`,e=>{var r;this.printDebug(`SOCKET ERROR`),console.warn(`ERROR`,e),(r=this.socket)==null||r.terminate(),n||(n=!0,t(e))})})}async connect(){if(this.isConnecting){this.printDebug(`connect() already in progress, skipping`);return}this.userDisconnect=!1,this.isConnecting=!0;try{if(this.cleanup(),await this.getEndpoint(),this.userDisconnect)return;await this._connect()}catch(e){this.printDebug(`Connect failed: `+(e instanceof Error?e.message:String(e))),this.userDisconnect||(this.reconnectAttempts++,this.isConnecting=!1,this.scheduleReconnect());return}finally{this.isConnecting=!1}}disconnect(){console.info(`Disconnecting.`),this.userDisconnect=!0,this.reconnectTimerId&&(clearTimeout(this.reconnectTimerId),this.reconnectTimerId=void 0),this.reconnecting=!1,this.reconnectAttempts=0,this.cleanup(),this.connected=!1,this.registered=!1}heartbeat(){this.isAlive=!0,this.printDebug(`CLIENT-SIDE HEARTBEAT`)}onDownStream(e){this.printDebug(`Received message from dingtalk websocket server`);let t=JSON.parse(e);switch(this.printDebug(t),t.type){case`SYSTEM`:this.onSystem(t);break;case`EVENT`:this.onEvent(t);break;case`CALLBACK`:this.onCallback(t);break}}onSystem(e){var t;switch(e.headers.topic){case`CONNECTED`:this.printDebug(`CONNECTED`);break;case`REGISTERED`:this.registered=!0,this.reconnecting=!1;break;case`disconnect`:this.connected=!1,this.registered=!1;break;case`KEEPALIVE`:this.heartbeat();break;case`ping`:this.printDebug(`PING`),(t=this.socket)==null||t.send(JSON.stringify({code:200,headers:e.headers,message:`OK`,data:e.data}));break}}onEvent(e){var t;this.printDebug(`received event, message=`+JSON.stringify(e));let n=this.onEventReceived(e);(t=this.socket)==null||t.send(JSON.stringify({code:200,headers:{contentType:`application/json`,messageId:e.headers.messageId},message:`OK`,data:JSON.stringify(n)}))}onCallback(e){this.emit(e.headers.topic,e)}send(e,t){var n;if(!e)throw console.error(`send: messageId must be defined`),Error(`send: messageId must be defined`);let r={code:200,headers:{contentType:`application/json`,messageId:e},message:`OK`,data:JSON.stringify(t)};(n=this.socket)==null||n.send(JSON.stringify(r))}socketCallBackResponse(e,t){this.send(e,{response:t})}sendGraphAPIResponse(e,t){var n;if(!e)throw console.error(`send: messageId must be defined`),Error(`send: messageId must be defined`);let r={code:200,headers:{contentType:`application/json`,messageId:e},message:`OK`,data:JSON.stringify(t)};(n=this.socket)==null||n.send(JSON.stringify(r))}};i(),m(),e();var Y=class{constructor(e){t(this,`opts`,void 0),t(this,`client`,void 0),t(this,`messageHandler`,void 0),this.opts=e,this.client=new J({clientId:e.appKey,clientSecret:e.appSecret,debug:!1,keepAlive:!0})}onMessage(e){this.messageHandler=e,this.client.registerCallbackListener(K,e=>{this.handleDownstream(e)})}handleDownstream(e){try{let t=JSON.parse(e.data);if(p(`[channel] downstream 到达: msgtype=${t.msgtype} sender=${t.senderNick} conv=${t.conversationId}`,{level:`debug`}),t.msgtype!==`text`||!t.text?.content){p(`[channel] 丢弃: msgtype=${t.msgtype} 非文本或空 content`,{level:`debug`});return}let n=t.text.content.trim(),r=this.stripMention(n);if(!r){p(`[channel] 丢弃: 纯 @ 无正文`,{level:`debug`});return}p(`[channel] 派发消息: text="${r.slice(0,50)}" sender=${t.senderNick}`,{level:`debug`}),this.messageHandler?.({conversationId:t.conversationId,senderStaffId:t.senderStaffId,senderNick:t.senderNick,conversationType:t.conversationType,text:r,msgId:t.msgId,sessionWebhook:t.sessionWebhook,sessionWebhookExpiredTime:t.sessionWebhookExpiredTime,isAdmin:t.isAdmin})}catch(e){b(e)}try{this.client.socketCallBackResponse(e.headers.messageId,{status:`SUCCESS`,message:`OK`})}catch{}}stripMention(e){if(!this.opts.robotName)return e;let t=this.opts.robotName.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return e.replace(RegExp(`^@${t}\\s*`),``).trim()}async connect(){await this.client.connect(),p(`[channel] dingtalk stream 已连接`,{level:`debug`})}disconnect(){this.client.disconnect()}async sendText(e,t){if(e)try{await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({msgtype:`text`,text:{content:t}})})}catch(e){b(e)}}async sendMarkdown(e,t,n){if(e)try{await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({msgtype:`markdown`,markdown:{title:t,text:n}})})}catch(e){b(e)}}};c();function X(e,t){if(t&&N(t))return t;try{let t=u();for(let n of P(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=j(t,n.name,`${e}.jsonl`);if(N(r))return r}}catch{}return null}m(),y(),c(),s(),e();var Z=1800*1e3;function Q(e){return v()?{execPath:process.execPath,args:[process.argv[1],...e]}:{execPath:process.execPath,args:e}}var $=class{constructor(e){t(this,`opts`,void 0),t(this,`proc`,null),t(this,`rl`,null),t(this,`emitter`,new I),t(this,`lastActiveAt`,Date.now()),t(this,`idleTimer`,null),t(this,`closed`,!1),t(this,`spawnCwd`,process.cwd()),this.opts=e}onEvent(e){this.emitter.on(`event`,e)}async start(){let e=[`--print`,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--verbose`,`--permission-mode`,l(this.opts.permissionMode)];this.opts.transcriptPath?e.splice(1,0,`--resume`,this.opts.transcriptPath):this.opts.sessionId&&e.splice(1,0,`--resume`,this.opts.sessionId);let{execPath:t,args:n}=Q(e);this.proc=M(t,n,{stdio:[`pipe`,`pipe`,`pipe`],env:{...process.env,WORKMATE_INCLUDE_PARTIAL_MESSAGES:`true`,WORKMATE_STREAMLINED_OUTPUT:`true`}}),this.proc.on(`exit`,e=>{this.closed=!0,this.emit({type:`exit`,code:e}),this.cleanup()}),this.proc.on(`error`,e=>{b(e),this.emit({type:`stderr`,data:String(e)})}),this.proc.stderr&&this.proc.stderr.on(`data`,e=>{let t=e.toString();p(`[channel] workmate stderr: ${t}`,{level:`debug`}),this.emit({type:`stderr`,data:t})}),this.proc.stdout&&(this.rl=A({input:this.proc.stdout,crlfDelay:1/0}),this.rl.on(`line`,e=>this.handleLine(e))),this.idleTimer=setInterval(()=>this.checkIdle(),6e4)}checkIdle(){this.closed||Date.now()-this.lastActiveAt>Z&&(p(`[channel] workmate 子进程 idle 超时,回收`,{level:`debug`}),this.kill())}sendUserMessage(e){this.write({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,priority:`now`}),this.lastActiveAt=Date.now()}respondPermission(e,t){this.write({type:`control_response`,response:{subtype:`success`,request_id:e,response:t}}),this.lastActiveAt=Date.now()}autoAllow(e){this.respondPermission(e,{behavior:`allow`})}interrupt(){this.write({type:`control_request`,request_id:F(),request:{subtype:`interrupt`}})}handleLine(e){let t=e.trim();if(!t)return;this.lastActiveAt=Date.now();let n;try{n=JSON.parse(t)}catch{return}switch(n.type){case`stream_event`:{let e=n.event;e?.type===`content_block_delta`&&e.delta?.type===`text_delta`&&typeof e.delta.text==`string`?this.emit({type:`text`,text:e.delta.text}):e?.type===`message_stop`&&this.emit({type:`message_end`});break}case`streamlined_text`:this.emit({type:`text`,text:String(n.text)}),this.emit({type:`message_end`});break;case`streamlined_tool_use_summary`:this.emit({type:`tool_summary`,summary:String(n.tool_summary)});break;case`control_request`:{let e=n.request;e?.subtype===`can_use_tool`&&this.emit({type:`permission_request`,requestId:String(n.request_id),toolName:String(e.tool_name??``),input:e.input??{},toolUseId:String(e.tool_use_id??``)});break}case`result`:{let e=typeof n.session_id==`string`?n.session_id:void 0,t=e&&!this.opts.transcriptPath?j(o(this.spawnCwd),`${e}.jsonl`):void 0;this.emit({type:`turn_end`,subtype:n.subtype===`success`?`success`:`error`,resultText:typeof n.result==`string`?n.result:void 0,errors:Array.isArray(n.errors)?n.errors.map(String):void 0,durationMs:typeof n.duration_ms==`number`?n.duration_ms:void 0,sessionId:e,transcriptPath:t});break}case`keep_alive`:break}}emit(e){this.emitter.emit(`event`,e)}write(e){!this.proc?.stdin?.writable||this.closed||this.proc.stdin.write(`${JSON.stringify(e)}\n`)}isAlive(){return!!this.proc&&!this.closed}kill(){if(!(this.closed||!this.proc)){try{this.proc.stdin?.end()}catch{}try{this.proc.kill(`SIGTERM`)}catch{}setTimeout(()=>{try{this.proc?.kill(`SIGKILL`)}catch{}},3e3)}}cleanup(){this.idleTimer&&(clearInterval(this.idleTimer),this.idleTimer=null),this.rl?.close(),this.rl=null,this.closed=!0}async stop(){this.kill(),this.proc&&await new Promise(e=>{if(this.closed)return e();this.proc.once(`exit`,()=>e()),setTimeout(e,5e3)}),this.cleanup()}};m(),y(),e();var te=400;function ne(e,t){switch(t){case`perUser`:return`user:${e.senderStaffId}`;case`shared`:return`shared`;default:return`conv:${e.conversationId}`}}var re=class{constructor(e){t(this,`stream`,void 0),t(this,`sessions`,new Map),t(this,`config`,void 0),t(this,`running`,!1),t(this,`cardClient`,void 0),this.config=e??T(),this.stream=new Y({appKey:this.config.appKey,appSecret:this.config.appSecret,robotName:this.config.robotName}),this.cardClient=this.config.cardTemplateId?new U({appKey:this.config.appKey,appSecret:this.config.appSecret,robotCode:this.config.appKey}):null}async start(){if(!this.config.appKey||!this.config.appSecret)throw Error(`钉钉 appKey/appSecret 未配置,请在 /channel 里填好`);this.stream.onMessage(e=>{this.handleMessage(e)}),await this.stream.connect(),this.running=!0;let e=!1,t=()=>{if(e)return;e=!0;let t=setTimeout(()=>{process.exit(0)},6e3);this.stop().finally(()=>{clearTimeout(t),process.exit(0)})};process.on(`SIGTERM`,t),process.on(`SIGINT`,t),p(`[channel] bridge 已启动,等待钉钉消息`,{level:`debug`})}async stop(){if(this.running){this.running=!1,this.stream.disconnect();for(let e of this.sessions.values())e.streamTimer&&clearTimeout(e.streamTimer),await e.driver.stop();this.sessions.clear(),p(`[channel] bridge 已停止`,{level:`debug`})}}async handleMessage(e){let t=ne(e,this.config.sessionStrategy);p(`[channel] handleMessage: sender=${e.senderNick} conv=${e.conversationId} text="${e.text.slice(0,50)}"`,{level:`debug`});let n=this.sessions.get(t);if(n||(n=await this.createSession(t,e),this.sessions.set(t,n)),n.sessionWebhook=e.sessionWebhook,n.currentSenderStaffId=e.senderStaffId,n.pendingConfirm){let t=ie(e.text);if(t!==null){let r=n.pendingConfirm;if(n.pendingConfirm=null,!this.canConfirm(e.senderStaffId,r.senderStaffId)){await this.stream.sendText(e.sessionWebhook,`⚠️ 只有任务发起人或管理员能确认`);return}t.behavior===`terminate`?(n.driver.respondPermission(r.requestId,{behavior:`deny`,message:`用户在钉钉终止任务`}),n.driver.interrupt(),await this.stream.sendText(e.sessionWebhook,`🛑 已终止整个任务`)):(n.driver.respondPermission(r.requestId,t),await this.stream.sendText(e.sessionWebhook,t.behavior===`allow`?`✅ 已同意,继续执行`:`❌ 已拒绝此工具,继续下一步`));return}n.pendingConfirm=null}n.textBuffer=``,n.turnInProgress=!0,n.cardOutTrackId=null,n.conversationType=e.conversationType,n.conversationId=e.conversationId,n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),n.driver.sendUserMessage(e.text),p(`[channel] 已发 driver.sendUserMessage`,{level:`debug`})}async createSession(e,t){let n=this.config.sessions[e],r=n?.workmateSessionId??``,i=r?X(r,n?.transcriptPath):null;i&&i!==n?.transcriptPath&&(k(t=>{let n=t.sessions[e];return n?{...t,sessions:{...t.sessions,[e]:{...n,transcriptPath:i}}}:t}),this.config=T()),p(`[channel] ${r?`复用`:`新建`}会话: ${e} sid=${r||`(待 workmate 分配)`} tp=${i??`(待分配)`}`,{level:`debug`});let a=new $({sessionId:r||null,transcriptPath:i,permissionMode:D(this.config)});return await a.start(),a.onEvent(t=>{this.handleDriverEvent(e,t)}),{driver:a,workmateSessionId:r,transcriptPath:i,sessionWebhook:t.sessionWebhook,currentSenderStaffId:t.senderStaffId,conversationType:t.conversationType,conversationId:t.conversationId,textBuffer:``,turnInProgress:!1,pendingConfirm:null,cardOutTrackId:null,streamTimer:null,eventQueue:Promise.resolve()}}handleDriverEvent(e,t){let n=this.sessions.get(e);n&&(n.eventQueue=n.eventQueue.then(()=>this.processDriverEvent(e,t)).catch(e=>{b(e)}))}async processDriverEvent(e,t){let n=this.sessions.get(e);if(n)switch(t.type){case`text`:if(!n.cardOutTrackId&&this.cardClient&&n.turnInProgress)try{n.cardOutTrackId=await this.cardClient.createAndDeliverCard({conversationType:n.conversationType,conversationId:n.conversationId,senderStaffId:n.currentSenderStaffId,cardTemplateId:this.config.cardTemplateId,initialMarkdown:` `})}catch(e){b(e),p(`[channel] 卡片创建失败,回退整段 sendText`,{level:`debug`}),n.cardOutTrackId=null}n.textBuffer+=t.text,n.cardOutTrackId&&this.cardClient&&this.scheduleStreamPush(n);break;case`message_end`:if(n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),n.cardOutTrackId&&this.cardClient){let e=n.cardOutTrackId;n.cardOutTrackId=null;try{await this.cardClient.streamingUpdate(e,n.textBuffer,{finalize:!0})}catch(e){b(e),n.textBuffer.trim()&&await this.stream.sendText(n.sessionWebhook,n.textBuffer)}}else n.textBuffer.trim()&&await this.stream.sendText(n.sessionWebhook,n.textBuffer);n.textBuffer=``;break;case`tool_summary`:break;case`turn_end`:{n.turnInProgress=!1;let r=t.sessionId,i=t.transcriptPath;if(t.subtype===`success`&&r&&r!==n.workmateSessionId&&(n.workmateSessionId=r,n.transcriptPath=i??n.transcriptPath,k(t=>{let a=t.sessions[e];return{...t,sessions:{...t.sessions,[e]:{workmateSessionId:r,transcriptPath:i??a?.transcriptPath,lastActiveAt:Date.now(),senderId:n.currentSenderStaffId}}}}),this.config=T()),n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),t.subtype===`error`){if(n.cardOutTrackId&&this.cardClient){let e=n.cardOutTrackId;n.cardOutTrackId=null;let t=n.textBuffer;if(n.textBuffer=``,t.trim())try{await this.cardClient.streamingUpdate(e,t,{finalize:!0})}catch(e){b(e)}}else n.textBuffer=``;let e=t.errors?.length?t.errors:[`任务执行出错`];await this.stream.sendText(n.sessionWebhook,`⚠️ ${e.join(`
2
+ `)}`),p(`[channel] turn_end error: ${e.join(` | `)}`,{level:`debug`});break}if(n.cardOutTrackId&&this.cardClient){let e=n.cardOutTrackId;n.cardOutTrackId=null;let r=n.textBuffer||t.resultText||``;n.textBuffer=``;try{await this.cardClient.streamingUpdate(e,r,{finalize:!0})}catch(e){b(e),r.trim()&&await this.stream.sendText(n.sessionWebhook,r)}}else if(n.textBuffer.trim()){let e=n.textBuffer;n.textBuffer=``,await this.stream.sendText(n.sessionWebhook,e)}else t.subtype===`success`&&t.resultText?.trim()&&!this.cardClient&&await this.stream.sendText(n.sessionWebhook,t.resultText);p(`[channel] turn_end: subtype=${t.subtype} sid=${t.sessionId??`-`} resultText=${t.resultText?`"${t.resultText.slice(0,50)}"`:`(空)`}`,{level:`debug`});break}case`permission_request`:await this.handlePermissionRequest(n,t);break;case`stderr`:break;case`exit`:p(`[channel] workmate 子进程退出 code=${t.code},清会话 ${e}`,{level:`debug`}),n.streamTimer&&(clearTimeout(n.streamTimer),n.streamTimer=null),this.sessions.delete(e);break}}async handlePermissionRequest(e,t){if(f(t.toolName)){e.driver.autoAllow(t.requestId),p(`[channel] 只读工具 autoAllow: ${t.toolName}`,{level:`debug`});return}if(!this.config.confirmDangerous){e.driver.autoAllow(t.requestId);return}e.pendingConfirm={requestId:t.requestId,webhook:e.sessionWebhook,senderStaffId:e.currentSenderStaffId,toolName:t.toolName},p(`[channel] permission_request: tool=${t.toolName}`,{level:`debug`});let n=JSON.stringify(t.input,null,2).slice(0,500),r=Math.round(this.config.confirmTimeoutMs/6e4);await this.stream.sendMarkdown(e.sessionWebhook,`需要确认`,`### ⚠️ 需要确认:${t.toolName}\n\n**参数预览:**\n\`\`\`json\n${n}\n\`\`\`\n\n**选项:**\n- 回复「**同意**」→ 执行此工具\n- 回复「**拒绝**」→ 跳过此工具,继续下一步\n- 回复「**终止**」→ 终止整个任务\n\n⏰ ${r} 分钟无回复自动拒绝`),setTimeout(()=>{if(e.pendingConfirm?.requestId===t.requestId){e.pendingConfirm=null;try{e.driver.respondPermission(t.requestId,{behavior:`deny`,message:`确认超时`})}catch(e){b(e)}this.stream.sendText(e.sessionWebhook,`⏰ 确认超时,已拒绝执行`)}},this.config.confirmTimeoutMs)}scheduleStreamPush(e){e.streamTimer||(e.streamTimer=setTimeout(()=>{e.streamTimer=null,!(!e.cardOutTrackId||!this.cardClient)&&this.cardClient.streamingUpdate(e.cardOutTrackId,e.textBuffer).catch(e=>b(e))},te))}canConfirm(e,t){return!!(this.config.admins.includes(e)||t&&e===t||!t)}};function ie(e){let t=e.trim().toLowerCase();return[`同意`,`yes`,`y`,`确认`,`ok`,`allow`,`同意了`].includes(t)?{behavior:`allow`}:[`拒绝`,`no`,`n`,`cancel`,`deny`,`不同意`,`拒绝执行`].includes(t)?{behavior:`deny`,message:`用户在钉钉拒绝`}:[`终止`,`stop`,`abort`,`中止`,`终止任务`,`终止整个任务`].includes(t)?{behavior:`terminate`}:null}S(),h(),y();async function ae(e){let t=e[0]??`start`;switch(t){case`start`:await oe();break;case`status`:ce();break;case`stop`:se();break;default:console.error(`未知子命令: ${t}。可用: start | stop | status`),process.exit(1)}}async function oe(){C(g())||(console.error(`channel 未启用。请在交互会话里运行 /channel,开启 channel 并选择 activePlugin=dingtalk`),process.exit(1));let e=new re;try{await e.start(),console.log(`[channel] bridge 已启动,Ctrl+C 退出`),await new Promise(()=>{})}catch(e){b(e),console.error(`bridge 启动失败: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}function se(){let e=O();if(!e){console.log(`bridge 未运行`);return}x()?console.log(`已发停止信号给 bridge pid=${e}`):(console.error(`停止失败:pid=${e} 信号发送异常`),process.exit(1))}function ce(){let e=E(),t=O(),n=T(),r=C(g());console.log(`channel.enabled: ${r}`),console.log(`bridge.running: ${e}`),t&&console.log(`bridge.pid: ${t}`),console.log(`dingtalk.appKey: ${n.appKey?`已配置`:`未配置`}`),console.log(`dingtalk.robotName: ${n.robotName}`),console.log(`dingtalk.permissionMode: ${n.permissionMode}`),console.log(`dingtalk.sessionStrategy: ${n.sessionStrategy}`),console.log(`dingtalk.confirmDangerous: ${n.confirmDangerous}`),console.log(`sessions: ${Object.keys(n.sessions).length} 个`)}export{ae as channelMain};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{d as s,h as c,o as l}from"./config-Bio2EjUK.js";import{n as u,t as d}from"./select-CaxQ-BVq.js";import{a as f,c as p,i as m,n as h,o as g,r as _,t as v,u as y}from"./bridgeControl-aDnUrYZR.js";function b({onClose:e}){let[t,i]=(0,x.useState)(0),[a,o]=(0,x.useState)(``),s=l(),u=g(),p=s.channel?.enabled===!0,h=s.channel?.activePlugin??null,b=_(),T=v();function E(){i(e=>e+1)}function D(e,t){c(n=>({...n,channel:{enabled:e,activePlugin:t}})),E()}function O(e,t,n){let r=t[(t.indexOf(e)+1)%t.length];n(r),E()}let k=[{label:(0,S.jsxs)(r,{children:[`Channel 开关:`,(0,S.jsx)(r,{bold:!0,children:p?`on`:`off`})]}),value:`toggle-enabled`},{label:(0,S.jsxs)(r,{children:[`激活渠道:`,(0,S.jsx)(r,{bold:!0,children:h??`(无)`})]}),value:`set-plugin`},{label:(0,S.jsxs)(r,{children:[`钉钉 corpid:`,(0,S.jsx)(r,{dimColor:!0,children:u.corpid||`(空) 编辑 dingtalk.json`})]}),value:`noop:corpid`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppKey:`,(0,S.jsx)(r,{dimColor:!0,children:u.appKey?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appKey`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppSecret:`,(0,S.jsx)(r,{dimColor:!0,children:u.appSecret?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appSecret`},{label:(0,S.jsxs)(r,{children:[`机器人名:`,(0,S.jsx)(r,{bold:!0,children:u.robotName})]}),value:`noop:robotName`},{label:(0,S.jsxs)(r,{children:[`AI 卡片模板:`,(0,S.jsx)(r,{dimColor:!0,children:u.cardTemplateId?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:cardTemplateId`},{label:(0,S.jsxs)(r,{children:[`权限模式:`,(0,S.jsx)(r,{bold:!0,children:u.permissionMode})]}),value:`cycle-permissionMode`},{label:(0,S.jsxs)(r,{children:[`会话策略:`,(0,S.jsx)(r,{bold:!0,children:u.sessionStrategy}),(0,S.jsx)(r,{dimColor:!0,children:` (perConversation=每群一会话 / perUser=每人一会话 / shared=共用)`})]}),value:`cycle-sessionStrategy`},{label:(0,S.jsxs)(r,{children:[`危险操作钉钉确认:`,(0,S.jsx)(r,{bold:!0,children:u.confirmDangerous?`on`:`off`})]}),value:`toggle-confirmDangerous`},{label:(0,S.jsxs)(r,{bold:b,children:[b?`▶ bridge 运行中`:`▶ 启动 bridge`,T?` (pid=${T})`:``]}),value:`action:start`},{label:(0,S.jsx)(r,{bold:b,children:`■ 停止 bridge`}),value:`action:stop`}];function A(e){switch(o(``),e){case`toggle-enabled`:D(!p,h??`dingtalk`);break;case`set-plugin`:D(!0,`dingtalk`);break;case`cycle-permissionMode`:O(u.permissionMode,C,e=>y(t=>({...t,permissionMode:e})));break;case`cycle-sessionStrategy`:O(u.sessionStrategy,w,e=>y(t=>({...t,sessionStrategy:e})));break;case`toggle-confirmDangerous`:y(e=>({...e,confirmDangerous:!e.confirmDangerous})),E();break;case`action:start`:{let e=m();o(e.started?`bridge 已启动 (pid=${e.pid})`:`bridge 已在运行 (pid=${e.pid})`),E();break}case`action:stop`:{let e=f();o(e?`已发停止信号`:`bridge 未运行`),E();break}default:e.startsWith(`noop:`)&&o(`请编辑 ~/.workmate/channel/dingtalk.json 填入该字段`)}}return(0,S.jsxs)(n,{flexDirection:`column`,padding:1,children:[(0,S.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,S.jsx)(r,{bold:!0,children:`远程对话渠道(钉钉)`}),(0,S.jsx)(r,{dimColor:!0,children:`↑↓ 导航 · Enter 切换/执行 · Esc 退出`}),(0,S.jsx)(r,{dimColor:!0,children:`corpid/AppKey/AppSecret 请直接编辑 ~/.workmate/channel/dingtalk.json`})]}),(0,S.jsx)(d,{options:k,onChange:A,onCancel:e,visibleOptionCount:k.length},t),a&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(r,{bold:!0,children:a})})]})}var x,S,C,w,T=e((()=>{a(),x=t(i(),1),u(),s(),p(),h(),S=o(),C=[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],w=[`perConversation`,`perUser`,`shared`]})),E,D;e((()=>{T(),E=o(),D=async e=>(0,E.jsx)(b,{onClose:()=>e()})}))();export{D as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-BX54x08P.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{d as s,h as c,o as l}from"./config-Bjwat4P6.js";import{n as u,t as d}from"./select-BpiKdirZ.js";import{a as f,c as p,i as m,n as h,o as g,r as _,t as v,u as y}from"./bridgeControl-DMUu37uO.js";function b({onClose:e}){let[t,i]=(0,x.useState)(0),[a,o]=(0,x.useState)(``),s=l(),u=g(),p=s.channel?.enabled===!0,h=s.channel?.activePlugin??null,b=_(),T=v();function E(){i(e=>e+1)}function D(e,t){c(n=>({...n,channel:{enabled:e,activePlugin:t}})),E()}function O(e,t,n){let r=t[(t.indexOf(e)+1)%t.length];n(r),E()}let k=[{label:(0,S.jsxs)(r,{children:[`Channel 开关:`,(0,S.jsx)(r,{bold:!0,children:p?`on`:`off`})]}),value:`toggle-enabled`},{label:(0,S.jsxs)(r,{children:[`激活渠道:`,(0,S.jsx)(r,{bold:!0,children:h??`(无)`})]}),value:`set-plugin`},{label:(0,S.jsxs)(r,{children:[`钉钉 corpid:`,(0,S.jsx)(r,{dimColor:!0,children:u.corpid||`(空) 编辑 dingtalk.json`})]}),value:`noop:corpid`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppKey:`,(0,S.jsx)(r,{dimColor:!0,children:u.appKey?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appKey`},{label:(0,S.jsxs)(r,{children:[`钉钉 AppSecret:`,(0,S.jsx)(r,{dimColor:!0,children:u.appSecret?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:appSecret`},{label:(0,S.jsxs)(r,{children:[`机器人名:`,(0,S.jsx)(r,{bold:!0,children:u.robotName})]}),value:`noop:robotName`},{label:(0,S.jsxs)(r,{children:[`AI 卡片模板:`,(0,S.jsx)(r,{dimColor:!0,children:u.cardTemplateId?`已配置`:`(空) 编辑 dingtalk.json`})]}),value:`noop:cardTemplateId`},{label:(0,S.jsxs)(r,{children:[`权限模式:`,(0,S.jsx)(r,{bold:!0,children:u.permissionMode})]}),value:`cycle-permissionMode`},{label:(0,S.jsxs)(r,{children:[`会话策略:`,(0,S.jsx)(r,{bold:!0,children:u.sessionStrategy}),(0,S.jsx)(r,{dimColor:!0,children:` (perConversation=每群一会话 / perUser=每人一会话 / shared=共用)`})]}),value:`cycle-sessionStrategy`},{label:(0,S.jsxs)(r,{children:[`危险操作钉钉确认:`,(0,S.jsx)(r,{bold:!0,children:u.confirmDangerous?`on`:`off`})]}),value:`toggle-confirmDangerous`},{label:(0,S.jsxs)(r,{bold:b,children:[b?`▶ bridge 运行中`:`▶ 启动 bridge`,T?` (pid=${T})`:``]}),value:`action:start`},{label:(0,S.jsx)(r,{bold:b,children:`■ 停止 bridge`}),value:`action:stop`}];function A(e){switch(o(``),e){case`toggle-enabled`:D(!p,h??`dingtalk`);break;case`set-plugin`:D(!0,`dingtalk`);break;case`cycle-permissionMode`:O(u.permissionMode,C,e=>y(t=>({...t,permissionMode:e})));break;case`cycle-sessionStrategy`:O(u.sessionStrategy,w,e=>y(t=>({...t,sessionStrategy:e})));break;case`toggle-confirmDangerous`:y(e=>({...e,confirmDangerous:!e.confirmDangerous})),E();break;case`action:start`:{let e=m();o(e.started?`bridge 已启动 (pid=${e.pid})`:`bridge 已在运行 (pid=${e.pid})`),E();break}case`action:stop`:{let e=f();o(e?`已发停止信号`:`bridge 未运行`),E();break}default:e.startsWith(`noop:`)&&o(`请编辑 ~/.workmate/channel/dingtalk.json 填入该字段`)}}return(0,S.jsxs)(n,{flexDirection:`column`,padding:1,children:[(0,S.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,S.jsx)(r,{bold:!0,children:`远程对话渠道(钉钉)`}),(0,S.jsx)(r,{dimColor:!0,children:`↑↓ 导航 · Enter 切换/执行 · Esc 退出`}),(0,S.jsx)(r,{dimColor:!0,children:`corpid/AppKey/AppSecret 请直接编辑 ~/.workmate/channel/dingtalk.json`})]}),(0,S.jsx)(d,{options:k,onChange:A,onCancel:e,visibleOptionCount:k.length},t),a&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(r,{bold:!0,children:a})})]})}var x,S,C,w,T=e((()=>{a(),x=t(i(),1),u(),s(),p(),h(),S=o(),C=[`default`,`acceptEdits`,`bypassPermissions`,`plan`,`dontAsk`,`auto`],w=[`perConversation`,`perUser`,`shared`]})),E,D;e((()=>{T(),E=o(),D=async e=>(0,E.jsx)(b,{onClose:()=>e()})}))();export{D as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-CYZyg1U1.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./conversation-CYZKYlWc.js";var r;e((()=>{t(),r=async(e,t)=>(await n(t),{type:`text`,value:``})}))();export{r as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n}from"./proxy--_NfbJhm.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";function a(e){if(s)return s;let t=new r({apiKey:process.env.GROK_API_KEY||process.env.XAI_API_KEY||``,baseURL:process.env.GROK_BASE_URL||o,maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:n({forAnthropicAPI:!1}),...e?.fetchOverride&&{fetch:e.fetchOverride}});return e?.fetchOverride||(s=t),t}var o,s,c=e((()=>{i(),t(),o=`https://api.x.ai/v1`,s=null}));export{c as n,a as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n}from"./proxy-MzIsnPd7.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";function a(e){if(s)return s;let t=new r({apiKey:process.env.GROK_API_KEY||process.env.XAI_API_KEY||``,baseURL:process.env.GROK_BASE_URL||o,maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:n({forAnthropicAPI:!1}),...e?.fetchOverride&&{fetch:e.fetchOverride}});return e?.fetchOverride||(s=t),t}var o,s,c=e((()=>{i(),t(),o=`https://api.x.ai/v1`,s=null}));export{c as n,a as t};
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./client-q_uGYC2E.js";e();export{t as clearOpenAIClientCache};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n}from"./proxy--_NfbJhm.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";import{r as a,t as o}from"./store-Z8rTjDHe.js";function s(e){if(!e)return 0;let t=0,n=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,r;for(;(r=n.exec(e))!==null;){let e=Number(r[1]);switch(r[2]){case`ms`:t+=e/1e3;break;case`s`:t+=e;break;case`m`:t+=e*60;break;case`h`:t+=e*3600;break;case`d`:t+=e*86400;break}}if(t===0){let n=Number(e);Number.isFinite(n)&&(t=n)}return t<=0?0:Math.floor(Date.now()/1e3)+t}function c(e,t){if(e===null||t===null)return null;let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return null;let i=Math.max(0,r-n);return Math.min(1,Math.max(0,i/r))}var l,u=e((()=>{l={providerId:`openai`,parseHeaders(e){let t=[],n=c(e.get(`x-ratelimit-remaining-requests`),e.get(`x-ratelimit-limit-requests`));n!==null&&t.push({kind:`requests`,label:`RPM`,utilization:n,resetsAt:s(e.get(`x-ratelimit-reset-requests`))||void 0});let r=c(e.get(`x-ratelimit-remaining-tokens`),e.get(`x-ratelimit-limit-tokens`));return r!==null&&t.push({kind:`tokens`,label:`TPM`,utilization:r,resetsAt:s(e.get(`x-ratelimit-reset-tokens`))||void 0}),t}}}));function d(e){return async(...t)=>{let n=await e(...t);try{a(`openai`,l.parseHeaders(n.headers))}catch{}return n}}function f(e){if(m)return m;let t=process.env.OPENAI_API_KEY||``,i=process.env.OPENAI_BASE_URL,a=d(e?.fetchOverride??globalThis.fetch),o=new r({apiKey:t,...i&&{baseURL:i},maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,...process.env.OPENAI_ORG_ID&&{organization:process.env.OPENAI_ORG_ID},...process.env.OPENAI_PROJECT_ID&&{project:process.env.OPENAI_PROJECT_ID},fetchOptions:n({forAnthropicAPI:!1}),fetch:a});return e?.fetchOverride||(m=o),o}function p(){m=null}var m,h=e((()=>{i(),u(),o(),t(),m=null}));export{f as n,h as r,p as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n}from"./proxy-MzIsnPd7.js";import{n as r,t as i}from"./openai-CR3CcjCE.js";import{r as a,t as o}from"./store-Z8rTjDHe.js";function s(e){if(!e)return 0;let t=0,n=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,r;for(;(r=n.exec(e))!==null;){let e=Number(r[1]);switch(r[2]){case`ms`:t+=e/1e3;break;case`s`:t+=e;break;case`m`:t+=e*60;break;case`h`:t+=e*3600;break;case`d`:t+=e*86400;break}}if(t===0){let n=Number(e);Number.isFinite(n)&&(t=n)}return t<=0?0:Math.floor(Date.now()/1e3)+t}function c(e,t){if(e===null||t===null)return null;let n=Number(e),r=Number(t);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=0)return null;let i=Math.max(0,r-n);return Math.min(1,Math.max(0,i/r))}var l,u=e((()=>{l={providerId:`openai`,parseHeaders(e){let t=[],n=c(e.get(`x-ratelimit-remaining-requests`),e.get(`x-ratelimit-limit-requests`));n!==null&&t.push({kind:`requests`,label:`RPM`,utilization:n,resetsAt:s(e.get(`x-ratelimit-reset-requests`))||void 0});let r=c(e.get(`x-ratelimit-remaining-tokens`),e.get(`x-ratelimit-limit-tokens`));return r!==null&&t.push({kind:`tokens`,label:`TPM`,utilization:r,resetsAt:s(e.get(`x-ratelimit-reset-tokens`))||void 0}),t}}}));function d(e){return async(...t)=>{let n=await e(...t);try{a(`openai`,l.parseHeaders(n.headers))}catch{}return n}}function f(e){if(m)return m;let t=process.env.OPENAI_API_KEY||``,i=process.env.OPENAI_BASE_URL,a=d(e?.fetchOverride??globalThis.fetch),o=new r({apiKey:t,...i&&{baseURL:i},maxRetries:e?.maxRetries??0,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,...process.env.OPENAI_ORG_ID&&{organization:process.env.OPENAI_ORG_ID},...process.env.OPENAI_PROJECT_ID&&{project:process.env.OPENAI_PROJECT_ID},fetchOptions:n({forAnthropicAPI:!1}),fetch:a});return e?.fetchOverride||(m=o),o}function p(){m=null}var m,h=e((()=>{i(),u(),o(),t(),m=null}));export{f as n,h as r,p as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./client-D3QmHVeI.js";e();export{t as getGrokClient};
@@ -0,0 +1 @@
1
+ import{Pi as e,Ti as t,ki as n}from"./loadAgentsDir-DnHL_5cU.js";e();export{t as clearCommandsCache,n as getCommands};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{di as t,fi as n}from"./src-BX54x08P.js";import{It as r,Pt as i}from"./state-CXY-q5gr.js";import{$g as a,Bx as o,H_ as s,I_ as c,K_ as l,L_ as u,N_ as d,P_ as f,Qg as p,R_ as m,U_ as h,Xg as g,Xi as _,Yg as v,am as y,cb as b,ct as x,dm as S,gn as C,gp as w,hp as T,id as E,im as D,lm as O,lt as k,q_ as A,rd as j,sb as M,sv as N,tv as P}from"./loadAgentsDir-DnHL_5cU.js";import{F,I}from"./debug-NBJH_NxR.js";import{o as L,s as R}from"./log-D98mO6yJ.js";function z(e,n){let r=j(`tip`),i=M(`app:toggleTranscript`,`Global`,`ctrl+o`),a=[...e.options.verbose?[]:[`(${i} to see full summary)`],...n?[n]:[],...r?[r]:[]];return t.dim(`Compacted ${a.join(`
2
+ `)}`)}async function B(e,t){let n=e.getAppState(),r=await x(e.options.tools,e.options.mainLoopModel,Array.from(n.toolPermissionContext.additionalWorkingDirectories.keys()),e.options.mcpClients),i=d({mainThreadAgentDefinition:void 0,toolUseContext:e,customSystemPrompt:e.options.customSystemPrompt,defaultSystemPrompt:r,appendSystemPrompt:e.options.appendSystemPrompt}),[a,o]=await Promise.all([u(),c()]);return{systemPrompt:i,userContext:a,systemContext:o,toolUseContext:e,forkContextMessages:t}}var V;e((()=>{n(),i(),k(),m(),b(),T(),a(),l(),s(),O(),D(),P(),I(),C(),L(),_(),E(),f(),V=async(e,t)=>{let{abortController:n}=t,{messages:i}=t;if(i=o(i),i.length===0)throw Error(`No messages to compact`);let a=e.trim();try{if(!a){let e=await y(i,t.agentId);if(e)return u.cache.clear?.(),S(),w(t.options.querySource??`compact`,t.agentId),r(),A(),{type:`compact`,compactionResult:e,displayText:z(t)}}let e=(await h(i,t)).messages,n=await p(e,t,await B(t,e),!1,a,!1);return N(void 0),A(),u.cache.clear?.(),S(),{type:`compact`,compactionResult:n,displayText:z(t,n.userDisplayMessage)}}catch(e){throw n.signal.aborted?Error(`Compaction canceled.`):F(e,`Not enough messages to compact. Send a few more messages first, then try again.`)?Error(g):F(e,`Compaction interrupted · This may be due to network issues — please try again.`)?Error(v):(R(e),Error(`Error during compaction: ${e}`))}}}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{d as e,n as t}from"./config-Bjwat4P6.js";e();export{t as enableConfigs};
@@ -0,0 +1,3 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./isObject-C6qM3WEW.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{c as a,i as o,l as s,o as c}from"./envUtils-QyzA_cFM.js";import{Ai as l,Ar as u,Cn as d,Di as f,Ei as ee,In as te,Jr as p,Kn as ne,Sn as re,Xt as ie,Yt as m,bi as ae,bn as oe,di as se,fi as ce,ji as le,m as ue,mr as h,pr as de,rn as fe,s as g,t as pe,tn as me,vn as he,xi as ge,zr as _e}from"./settings-CA-5Px85.js";import{Hr as ve,Jr as ye,Pt as be,Ur as xe,X as _,Xr as Se,Yr as Ce,Zr as we,_r as Te,ai as Ee,ar as De,cr as Oe,dr as ke,ei as Ae,fr as je,gr as Me,ii as Ne,ir as Pe,lr as Fe,pr as Ie,q as Le,st as Re,ti as ze,ur as Be}from"./state-CXY-q5gr.js";import{n as Ve,t as He}from"./cwd-DrEEb4f5.js";import{$ as Ue,C as v,I as We,N as y,O as b,S as Ge,c as x,et as S,f as Ke,i as qe,u as C,x as Je}from"./debug-NBJH_NxR.js";import{d as Ye,o as Xe,s as Ze,u as Qe}from"./log-D98mO6yJ.js";import{n as $e}from"./analytics-COpjZpvd.js";import{i as et,n as tt}from"./lockfile-D_9vif6E.js";import{homedir as nt}from"os";import{basename as w,dirname as T,isAbsolute as rt,join as E,normalize as D,resolve as it,sep as at}from"path";import{unwatchFile as ot,watchFile as st}from"fs";import{randomBytes as ct}from"crypto";var O,lt=e((()=>{Ee(),ge(),Ce(),Se(),O=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Ne(t,ye(e)),e=ae(e);return t}:we}));function ut(e){return Ae(e,f,O)}var dt=e((()=>{ze(),lt(),ee()}));function ft(){let e=process.env.WORKMATE_DISABLE_AUTO_MEMORY;if(s(e))return!1;if(a(e))return!0;if(s(process.env.WORKMATE_SIMPLE)||s(process.env.WORKMATE_REMOTE)&&!process.env.WORKMATE_REMOTE_MEMORY_DIR)return!1;let t=pe();return t.autoMemoryEnabled===void 0||t.autoMemoryEnabled}function pt(){return!1}function mt(){return process.env.WORKMATE_REMOTE_MEMORY_DIR?process.env.WORKMATE_REMOTE_MEMORY_DIR:o()}function ht(e,t){if(!e)return;let n=e;if(t&&(n.startsWith(`~/`)||n.startsWith(`~\\`))){let e=n.slice(2),t=D(e||`.`);if(t===`.`||t===`..`)return;n=E(nt(),e)}let r=D(n).replace(/[/\\]+$/,``);if(!(!rt(r)||r.length<3||/^[A-Za-z]:$/.test(r)||r.startsWith(`\\\\`)||r.startsWith(`//`)||r.includes(`\0`)))return(r+at).normalize(`NFC`)}function gt(){return ht(process.env.WORKMATE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function _t(){return ht(g(`policySettings`)?.autoMemoryDirectory??g(`flagSettings`)?.autoMemoryDirectory??g(`localSettings`)?.autoMemoryDirectory??g(`userSettings`)?.autoMemoryDirectory,!0)}function vt(){return gt()!==void 0}function yt(){return _e(_())??_()}function bt(){return E(k(),Ct)}function xt(e){return D(e).startsWith(k())}var St,Ct,k,A=e((()=>{i(),be(),c(),p(),de(),ue(),St=`memory`,Ct=`MEMORY.md`,k=r(()=>(gt()??_t())||(E(E(mt(),`projects`),u(yt()),St)+at).normalize(`NFC`),()=>_())}));function j(e,n,r,i){if(!t(e))return e;n=je(n,e);for(var a=-1,o=n.length,s=o-1,c=e;c!=null&&++a<o;){var u=ke(n[a]),d=r;if(u===`__proto__`||u===`constructor`||u===`prototype`)return e;if(a!=s){var f=c[u];d=i?i(f,u,c):void 0,d===void 0&&(d=t(f)?f:xe(n[a+1])?[]:{})}l(c,u,d),c=c[u]}return e}var M=e((()=>{le(),Ie(),ve(),n(),Be()}));function wt(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Oe(e,o);n(s,o)&&j(a,je(o,e),s)}return a}var Tt=e((()=>{Fe(),M(),Ie()}));function N(e,t){if(e==null)return{};var n=Me(ut(e),function(e){return[e]});return t=Pe(t),wt(e,n,function(e,n){return t(e,n[0])})}var Et=e((()=>{Te(),De(),Tt(),dt()}));function P(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:`dark`,preferredNotifChannel:`auto`,verbose:!1,editorMode:`normal`,autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:`auto`,env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:6e4,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},respectGitignore:!0,channel:{enabled:!1,activePlugin:null}}}function Dt(){return G||(G=Ot())}function Ot(){if(Re())return!0;let e=z(),t=$();if(e.projects?.[t]?.hasTrustDialogAccepted)return!0;let n=h(He());for(;;){if(e.projects?.[n]?.hasTrustDialogAccepted)return!0;let t=h(it(n,`..`));if(t===n)break;n=t}return!1}function F(e){let t=K.config;return t?t.hasCompletedOnboarding===!0&&e.hasCompletedOnboarding!==!0:!1}function I(e){let t=null;try{Nt(m(),P,n=>{let r=e(n);return r===n?n:(t={...r,projects:At(n.projects)},t)})&&t&&R(t)}catch(n){x(`Failed to save config with lock: ${n}`,{level:`error`});let r=V(m(),P);if(F(r)){x(`saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`});return}let i=e(r);if(i===r)return;t={...i,projects:At(r.projects)},Mt(m(),t,W),R(t)}}function kt(){let e=J+Y;e>0&&J/e,J=0,Y=0}function L(e){if(e.installMethod!==void 0)return e;let t=e,n=`unknown`,r=e.autoUpdates??!0;switch(t.autoUpdaterStatus){case`migrated`:n=`local`;break;case`installed`:n=`native`;break;case`disabled`:r=!1;break;case`enabled`:case`no_permissions`:case`not_configured`:n=`global`;break;case void 0:break}return{...e,installMethod:n,autoUpdates:r}}function At(e){if(!e)return e;let t={},n=!1;for(let[r,i]of Object.entries(e)){let e=i;if(e.history!==void 0){n=!0;let{history:i,...a}=e;t[r]=a}else t[r]=i}return n?t:e}function jt(){if(Z)return;Z=!0;let e=m();st(e,{interval:qt,persistent:!1},t=>{t.mtimeMs<=K.mtime||C().readFile(e,{encoding:`utf-8`}).then(e=>{if(t.mtimeMs<=K.mtime)return;let n=oe(d(e));typeof n!=`object`||!n||(K={config:L({...P(),...n}),mtime:t.mtimeMs},q={mtime:t.mtimeMs,size:t.size})}).catch(()=>{})}),S(async()=>{ot(e),Z=!1})}function R(e){K={config:e,mtime:Date.now()},q=null}function z(){if(K.config)return J++,K.config;Y++;try{let e=null;try{e=C().statSync(m())}catch{}let t=L(V(m(),P));return K={config:t,mtime:e?.mtimeMs??Date.now()},q=e?{mtime:e.mtimeMs,size:e.size}:null,jt(),t}catch{return L(V(m(),P))}}function Mt(e,t,n){let r=T(e);C().mkdirSync(r),ne(e,v(N(t,(e,t)=>v(e)!==v(n[t])),null,2),{encoding:`utf-8`,mode:384}),e===m()&&X++}function Nt(e,t,n){let r=t(),i=T(e),a=C();a.mkdirSync(i);let o;try{let i=`${e}.lock`,s=Date.now();if(o=et(e,{lockfilePath:i,onCompromised:e=>{x(`Config lock compromised: ${e}`,{level:`error`})}}),Date.now()-s>100&&x(`Lock acquisition took longer than expected - another Work Mate instance may be running`),q&&e===m())try{let t=a.statSync(e);(t.mtimeMs!==q.mtime||t.size!==q.size)&&(q.mtime,t.mtimeMs,q.size,t.size)}catch(e){if(y(e)!==`ENOENT`)throw e}let c=V(e,t);if(e===m()&&F(c))return x(`saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.workmate.json. See GH #3117.`,{level:`error`}),!1;let l=n(c);if(l===c)return!1;let u=N(l,(e,t)=>v(e)!==v(r[t]));try{let t=w(e),n=B();try{a.mkdirSync(n)}catch(e){if(y(e)!==`EEXIST`)throw e}let r=a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse(),i=r[0],o=i?Number(i.split(`.backup.`).pop()):0,s=Number.isNaN(o)||Date.now()-o>=6e4;if(s){let r=E(n,`${t}.backup.${Date.now()}`);a.copyFileSync(e,r)}let c=s?a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse():r;for(let e of c.slice(5))try{a.unlinkSync(E(n,e))}catch{}}catch(e){y(e)!==`ENOENT`&&x(`Failed to backup config: ${e}`,{level:`error`})}return ne(e,v(u,null,2),{encoding:`utf-8`,mode:384}),e===m()&&X++,!0}finally{o&&o()}}function Pt(){if(Q)return;let e=Date.now();ce(`info`,`enable_configs_started`),Q=!0,V(m(),P,!0),ce(`info`,`enable_configs_completed`,{duration_ms:Date.now()-e})}function B(){return E(o(),`backups`)}function Ft(e){let t=C(),n=w(e),r=B();try{let e=t.readdirStringSync(r).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(e)return E(r,e)}catch{}let i=T(e);try{let r=t.readdirStringSync(i).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(r)return E(i,r);let a=`${e}.backup`;try{return t.statSync(a),a}catch{}}catch{}return null}function V(e,t,n){if(!Q)throw Error(`Config accessed before allowed.`);let r=C();try{let n=r.readFileSync(e,{encoding:`utf-8`});try{let e=Ge(d(n));return{...t(),...e}}catch(n){throw new b(n instanceof Error?n.message:String(n),e,t())}}catch(i){if(y(i)===`ENOENT`){let n=Ft(e);return n&&process.stderr.write(`\nWork Mate configuration file not found at: ${e}\nA backup file exists at: ${n}\nYou can manually restore it by running: cp "${n}" "${e}"\n\n`),t()}if(i instanceof b&&n)throw i;if(i instanceof b){if(x(`Config file corrupted, resetting to defaults: ${i.message}`,{level:`error`}),!H){H=!0;try{Ze(i);try{r.statSync(`${e}.backup`)}catch{}}finally{H=!1}}process.stderr.write(`\nWork Mate configuration file at ${e} is corrupted: ${i.message}\n`);let t=w(e),n=B();try{r.mkdirSync(n)}catch(e){if(y(e)!==`EEXIST`)throw e}let a=r.readdirStringSync(n).filter(e=>e.startsWith(`${t}.corrupted.`)),o,s=!1,c=r.readFileSync(e,{encoding:`utf-8`});for(let e of a)try{if(c===r.readFileSync(E(n,e),{encoding:`utf-8`})){s=!0;break}}catch{}if(!s){o=E(n,`${t}.corrupted.${Date.now()}`);try{r.copyFileSync(e,o),x(`Corrupted config backed up to: ${o}`,{level:`error`})}catch{}}let l=Ft(e);o?process.stderr.write(`The corrupted file has been backed up to: ${o}\n`):s&&process.stderr.write(`The corrupted file has already been backed up.
2
+ `),l?process.stderr.write(`A backup file exists at: ${l}\nYou can manually restore it by running: cp "${l}" "${e}"\n\n`):process.stderr.write(`
3
+ `)}return t()}}function It(){let e=$(),t=z();if(!t.projects)return U;let n=t.projects[e]??U;return typeof n.allowedTools==`string`&&(n.allowedTools=oe(n.allowedTools)??[]),n}function Lt(e){let t=$(),n=null;try{Nt(m(),P,r=>{let i=r.projects?.[t]??U,a=e(i);return a===i?r:(n={...r,projects:{...r.projects,[t]:a}},n)})&&n&&R(n)}catch(r){x(`Failed to save config with lock: ${r}`,{level:`error`});let i=V(m(),P);if(F(i)){x(`saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`});return}let a=i.projects?.[t]??U,o=e(a);if(o===a)return;n={...i,projects:{...i.projects,[t]:o}},Mt(m(),n,W),R(n)}}function Rt(){return Vt()!==null}function zt(){return Rt()&&!s(process.env.FORCE_AUTOUPDATE_PLUGINS)}function Bt(e){switch(e.type){case`development`:return`development build`;case`env`:return`${e.envVar} set`;case`config`:return`config`}}function Vt(){if(!s(process.env.ENABLE_AUTOUPDATER))return{type:`config`};if(s(process.env.DISABLE_AUTOUPDATER))return{type:`env`,envVar:`DISABLE_AUTOUPDATER`};let e=Qe();if(e)return{type:`env`,envVar:e};let t=z();return t.autoUpdates===!1&&(t.installMethod!==`native`||t.autoUpdatesProtectedForNative!==!0)?{type:`config`}:null}function Ht(){let e=z();if(e.userID)return e.userID;let t=ct(32).toString(`hex`);return I(e=>({...e,userID:t})),t}function Ut(){if(!z().firstStartTime){let e=new Date().toISOString();I(t=>({...t,firstStartTime:t.firstStartTime??e}))}}function Wt(e){let t=Le();switch(e){case`User`:return E(o(),`AGENTS.md`);case`Local`:return E(t,`AGENTS.local.md`);case`Project`:return E(t,`AGENTS.md`);case`Managed`:return E(me(),`AGENTS.md`);case`AutoMem`:return bt();default:return E(o(),`AGENTS.md`)}}function Gt(){return E(me(),`.workmate`,`rules`)}function Kt(){return E(o(),`rules`)}var H,U,W,G,K,q,J,Y,X,qt,Z,Q,$,Jt=e((()=>{i(),Et(),be(),A(),$e(),Ve(),Ue(),qe(),se(),ie(),c(),We(),te(),Ke(),p(),he(),re(),tt(),Xe(),de(),Ye(),fe(),Je(),H=!1,U={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasAgentsMdExternalIncludesApproved:!1,hasAgentsMdExternalIncludesWarningShown:!1},W=P(),G=!1,{...W},{...U},K={config:null,mtime:0},q=null,J=0,Y=0,X=0,S(async()=>{kt()}),qt=1e3,Z=!1,Q=!1,$=r(()=>{let e=Le();return h(_e(e)||it(e))})}));export{lt as A,A as C,ut as D,pt as E,dt as O,vt as S,ft as T,j as _,It as a,k as b,Wt as c,Jt as d,Rt as f,zt as g,I as h,Vt as i,O as k,Ht as l,Lt as m,Pt as n,z as o,Ut as p,Bt as r,Gt as s,Dt as t,Kt as u,M as v,xt as w,mt as x,bt as y};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-nM6-cXh0.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};