agentstudio 0.1.18 → 0.1.21

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 (664) hide show
  1. package/README.md +26 -505
  2. package/bin/agentstudio.js +305 -0
  3. package/bin/agentstudio.js.map +1 -0
  4. package/bin/serviceManager.d.ts +16 -0
  5. package/bin/serviceManager.d.ts.map +1 -0
  6. package/bin/serviceManager.js +434 -0
  7. package/bin/serviceManager.js.map +1 -0
  8. package/config/index.d.ts +74 -0
  9. package/config/index.d.ts.map +1 -0
  10. package/config/index.js +166 -0
  11. package/config/index.js.map +1 -0
  12. package/config/paths.d.ts +81 -0
  13. package/config/paths.d.ts.map +1 -0
  14. package/config/paths.js +98 -0
  15. package/config/paths.js.map +1 -0
  16. package/index.d.ts +4 -0
  17. package/index.d.ts.map +1 -0
  18. package/index.js +369 -0
  19. package/index.js.map +1 -0
  20. package/jobs/taskTimeoutMonitor.d.ts +25 -0
  21. package/jobs/taskTimeoutMonitor.d.ts.map +1 -0
  22. package/jobs/taskTimeoutMonitor.js +94 -0
  23. package/jobs/taskTimeoutMonitor.js.map +1 -0
  24. package/middleware/a2aAuth.d.ts +38 -0
  25. package/middleware/a2aAuth.d.ts.map +1 -0
  26. package/middleware/a2aAuth.js +134 -0
  27. package/middleware/a2aAuth.js.map +1 -0
  28. package/{backend/dist/middleware → middleware}/auth.d.ts +3 -1
  29. package/middleware/auth.d.ts.map +1 -0
  30. package/middleware/auth.js +35 -0
  31. package/middleware/auth.js.map +1 -0
  32. package/middleware/httpsOnly.d.ts +38 -0
  33. package/middleware/httpsOnly.d.ts.map +1 -0
  34. package/middleware/httpsOnly.js +105 -0
  35. package/middleware/httpsOnly.js.map +1 -0
  36. package/middleware/rateLimiting.d.ts +37 -0
  37. package/middleware/rateLimiting.d.ts.map +1 -0
  38. package/middleware/rateLimiting.js +118 -0
  39. package/middleware/rateLimiting.js.map +1 -0
  40. package/package.json +43 -38
  41. package/public/assets/AgentsPage-Nvg2xu6K.js +10 -0
  42. package/public/assets/Button-Co56C389.js +1 -0
  43. package/public/assets/ChatPage-D6sol0ad.js +442 -0
  44. package/public/assets/CommandForm-Bk7F_HU8.js +7 -0
  45. package/public/assets/CommandsPage-DZHyOdKd.js +1 -0
  46. package/public/assets/DashboardPage-29qC7Ev1.js +15 -0
  47. package/public/assets/FileBrowser-BYweUPH4.js +6 -0
  48. package/public/assets/FileExplorer-DNYj6Tsx.js +1 -0
  49. package/public/assets/GeneralSettingsPage-D9Xa7Nd8.js +1 -0
  50. package/public/assets/LandingPage-CjnT-cvO.js +1 -0
  51. package/public/assets/LoginPage-DcaGNCXH.js +16 -0
  52. package/public/assets/McpAdminSettingsPage-DgR3E2Bd.js +7 -0
  53. package/public/assets/McpPage-CtWf1CoL.js +40 -0
  54. package/public/assets/MemorySettingsPage-JTry4Ccp.js +1 -0
  55. package/public/assets/PluginsPage-D-BHjQ3P.js +1 -0
  56. package/public/assets/ProjectSelector-DSXOjMQC.js +1 -0
  57. package/public/assets/ProjectsPage-lLUk4-Xa.js +21 -0
  58. package/public/assets/ScheduledTasksPage-5hPbd9Vs.js +1 -0
  59. package/public/assets/SettingsLayout-DGJspXLp.js +1 -0
  60. package/public/assets/SkillsPage-DBw0m7D2.js +18 -0
  61. package/{backend/dist/frontend/assets/SubagentForm-DXtTTIKg.js → public/assets/SubagentForm-BdUK1U4y.js} +2 -2
  62. package/public/assets/SubagentsPage-Dnq70IFd.js +1 -0
  63. package/{backend/dist/frontend/assets/ToastTestPage-DT4wuN5C.js → public/assets/ToastTestPage-BfJQRFIm.js} +1 -1
  64. package/public/assets/ToolsList-Dl5F2fWk.js +1 -0
  65. package/public/assets/UnifiedToolSelector-CNbPsiuq.js +1 -0
  66. package/public/assets/VersionSettingsPage-BfoCcham.js +5 -0
  67. package/public/assets/_basePickBy-7C_e0Xv1.js +1 -0
  68. package/public/assets/_baseUniq-eGJNLBzx.js +1 -0
  69. package/public/assets/agents-ChrA1R0y.js +1 -0
  70. package/public/assets/arc-CuA752eE.js +1 -0
  71. package/public/assets/architectureDiagram-VXUJARFQ-BnPYh1OW.js +36 -0
  72. package/public/assets/blockDiagram-VD42YOAC-72nsMt_i.js +122 -0
  73. package/public/assets/c4Diagram-YG6GDRKO-BNJSAXcg.js +10 -0
  74. package/public/assets/channel-CIunGC5m.js +1 -0
  75. package/public/assets/chunk-4BX2VUAB-RPxkCWhH.js +1 -0
  76. package/public/assets/chunk-55IACEB6-3ePDt0kp.js +1 -0
  77. package/public/assets/chunk-B4BG7PRW-CBg_BBfl.js +165 -0
  78. package/public/assets/chunk-DI55MBZ5-DIh69TUJ.js +220 -0
  79. package/public/assets/chunk-FMBD7UC4-BbjwhyTe.js +15 -0
  80. package/public/assets/chunk-QN33PNHL-BpH-o_YR.js +1 -0
  81. package/public/assets/chunk-QZHKN3VN-DYB7rh5Q.js +1 -0
  82. package/public/assets/chunk-TZMSLE5B-DPCYEVb3.js +1 -0
  83. package/public/assets/classDiagram-2ON5EDUG-aUQHFsTA.js +1 -0
  84. package/public/assets/classDiagram-v2-WZHVMYZB-aUQHFsTA.js +1 -0
  85. package/public/assets/clone-Ckf7tA1V.js +1 -0
  86. package/public/assets/cose-bilkent-S5V4N54A-CnpfmL-Y.js +1 -0
  87. package/public/assets/cytoscape.esm-DtBltrT8.js +331 -0
  88. package/public/assets/dagre-6UL2VRFP-DR9x77Xf.js +4 -0
  89. package/{backend/dist/frontend/assets/data-structures-DLJedtzx.js → public/assets/data-structures-C0h9Oap1.js} +1 -1
  90. package/public/assets/defaultLocale-C4B-KCzX.js +1 -0
  91. package/public/assets/diagram-PSM6KHXK-SONPsQNx.js +24 -0
  92. package/public/assets/diagram-QEK2KX5R-BKYFSfC1.js +43 -0
  93. package/public/assets/diagram-S2PKOQOG-CkM0APZj.js +24 -0
  94. package/public/assets/erDiagram-Q2GNP2WA-BX1DpOGx.js +60 -0
  95. package/public/assets/flowDiagram-NV44I4VS-HAAlzNbq.js +162 -0
  96. package/public/assets/ganttDiagram-LVOFAZNH-BqzWexqa.js +267 -0
  97. package/public/assets/gitGraphDiagram-NY62KEGX-CIPmSp43.js +65 -0
  98. package/public/assets/graph-m515btDj.js +1 -0
  99. package/public/assets/index-Bn3v3S9-.js +293 -0
  100. package/public/assets/index-DWieeYj4.css +1 -0
  101. package/public/assets/infoDiagram-F6ZHWCRC-Pn4yNWrF.js +2 -0
  102. package/public/assets/init-Gi6I4Gst.js +1 -0
  103. package/public/assets/journeyDiagram-XKPGCS4Q-BfzTomS0.js +139 -0
  104. package/public/assets/kanban-definition-3W4ZIXB7-Cgju7b-L.js +89 -0
  105. package/public/assets/katex-qrhCpa0F.js +261 -0
  106. package/public/assets/layout-BKQfQSxJ.js +1 -0
  107. package/public/assets/linear-DigtLz3B.js +1 -0
  108. package/public/assets/mindmap-definition-VGOIOE7T-qopraVFy.js +68 -0
  109. package/public/assets/monaco-editor-DHKm5-VF.js +19 -0
  110. package/public/assets/ordinal-Cboi1Yqb.js +1 -0
  111. package/public/assets/pieDiagram-ADFJNKIX-BcoaAI-L.js +30 -0
  112. package/public/assets/quadrantDiagram-AYHSOK5B-D-DwcoSd.js +7 -0
  113. package/public/assets/requirementDiagram-UZGBJVZJ-DbQCpx77.js +64 -0
  114. package/public/assets/sankeyDiagram-TZEHDZUN-BVk8387S.js +10 -0
  115. package/public/assets/sequenceDiagram-WL72ISMW-BdzICjxO.js +145 -0
  116. package/public/assets/stateDiagram-FKZM4ZOC-CYY-uUvJ.js +1 -0
  117. package/public/assets/stateDiagram-v2-4FDKWEC3-Dh2Kvomq.js +1 -0
  118. package/{backend/dist/frontend/assets/syntax-highlighting-YWvMU4Hm.js → public/assets/syntax-highlighting-CnREyncB.js} +5 -5
  119. package/public/assets/tabManager-B2LQO_Ll.js +30 -0
  120. package/{backend/dist/frontend/assets/table-D6q1rytw.js → public/assets/table-D0L2RL5i.js} +1 -1
  121. package/public/assets/timeline-definition-IT6M3QCI-BAvjPYvX.js +61 -0
  122. package/public/assets/tools-IcPNZlPj.js +1 -0
  123. package/public/assets/treemap-KMMF4GRG-DtkpVA56.js +128 -0
  124. package/{backend/dist/frontend/assets/ui-components-Cw21Epuw.js → public/assets/ui-components-D1St49qC.js} +231 -96
  125. package/public/assets/useAgents-BnDTkOG8.js +2 -0
  126. package/public/assets/useClaudeVersions-CD59tFWM.js +1 -0
  127. package/public/assets/useCommands-mvMu3mMD.js +1 -0
  128. package/public/assets/useProjects-YXOjaOwL.js +1 -0
  129. package/public/assets/xychartDiagram-PRI3JC2R-ByBTDWE2.js +7 -0
  130. package/{backend/dist/frontend → public}/index.html +8 -8
  131. package/routes/__tests__/a2a.integration.test.d.ts +11 -0
  132. package/routes/__tests__/a2a.integration.test.d.ts.map +1 -0
  133. package/routes/__tests__/a2a.integration.test.js +314 -0
  134. package/routes/__tests__/a2a.integration.test.js.map +1 -0
  135. package/routes/__tests__/a2a.test.d.ts +6 -0
  136. package/routes/__tests__/a2a.test.d.ts.map +1 -0
  137. package/routes/__tests__/a2a.test.js +622 -0
  138. package/routes/__tests__/a2a.test.js.map +1 -0
  139. package/routes/__tests__/agents.test.d.ts +6 -0
  140. package/routes/__tests__/agents.test.d.ts.map +1 -0
  141. package/routes/__tests__/agents.test.js +315 -0
  142. package/routes/__tests__/agents.test.js.map +1 -0
  143. package/routes/__tests__/sessions.test.d.ts +7 -0
  144. package/routes/__tests__/sessions.test.d.ts.map +1 -0
  145. package/routes/__tests__/sessions.test.js +330 -0
  146. package/routes/__tests__/sessions.test.js.map +1 -0
  147. package/routes/a2a.d.ts +18 -0
  148. package/routes/a2a.d.ts.map +1 -0
  149. package/routes/a2a.js +649 -0
  150. package/routes/a2a.js.map +1 -0
  151. package/routes/a2a.streaming.test.d.ts +2 -0
  152. package/routes/a2a.streaming.test.d.ts.map +1 -0
  153. package/routes/a2a.streaming.test.js +167 -0
  154. package/routes/a2a.streaming.test.js.map +1 -0
  155. package/routes/a2aManagement.d.ts +21 -0
  156. package/routes/a2aManagement.d.ts.map +1 -0
  157. package/routes/a2aManagement.js +466 -0
  158. package/routes/a2aManagement.js.map +1 -0
  159. package/{backend/dist/routes → routes}/agents.d.ts.map +1 -1
  160. package/routes/agents.js +997 -0
  161. package/routes/agents.js.map +1 -0
  162. package/{backend/dist/routes → routes}/auth.d.ts.map +1 -1
  163. package/routes/auth.js +135 -0
  164. package/routes/auth.js.map +1 -0
  165. package/{backend/dist/routes → routes}/commands.d.ts.map +1 -1
  166. package/{backend/dist/routes → routes}/commands.js +115 -31
  167. package/routes/commands.js.map +1 -0
  168. package/routes/config.d.ts +4 -0
  169. package/routes/config.d.ts.map +1 -0
  170. package/routes/config.js +211 -0
  171. package/routes/config.js.map +1 -0
  172. package/{backend/dist/routes → routes}/files.d.ts.map +1 -1
  173. package/{backend/dist/routes → routes}/files.js +103 -43
  174. package/routes/files.js.map +1 -0
  175. package/routes/mcp.d.ts +27 -0
  176. package/routes/mcp.d.ts.map +1 -0
  177. package/{backend/dist/routes → routes}/mcp.js +195 -105
  178. package/routes/mcp.js.map +1 -0
  179. package/routes/mcpAdmin.d.ts +16 -0
  180. package/routes/mcpAdmin.d.ts.map +1 -0
  181. package/routes/mcpAdmin.js +308 -0
  182. package/routes/mcpAdmin.js.map +1 -0
  183. package/routes/mcpAdminManagement.d.ts +17 -0
  184. package/routes/mcpAdminManagement.d.ts.map +1 -0
  185. package/routes/mcpAdminManagement.js +345 -0
  186. package/routes/mcpAdminManagement.js.map +1 -0
  187. package/routes/media.d.ts.map +1 -0
  188. package/{backend/dist/routes → routes}/media.js +52 -42
  189. package/routes/media.js.map +1 -0
  190. package/routes/mediaAuth.d.ts +8 -0
  191. package/routes/mediaAuth.d.ts.map +1 -0
  192. package/routes/mediaAuth.js +136 -0
  193. package/routes/mediaAuth.js.map +1 -0
  194. package/routes/plugins.d.ts +4 -0
  195. package/routes/plugins.d.ts.map +1 -0
  196. package/routes/plugins.js +339 -0
  197. package/routes/plugins.js.map +1 -0
  198. package/{backend/dist/routes → routes}/projects.d.ts.map +1 -1
  199. package/routes/projects.js +884 -0
  200. package/routes/projects.js.map +1 -0
  201. package/routes/scheduledTasks.d.ts +9 -0
  202. package/routes/scheduledTasks.d.ts.map +1 -0
  203. package/routes/scheduledTasks.js +320 -0
  204. package/routes/scheduledTasks.js.map +1 -0
  205. package/{backend/dist/routes → routes}/sessions.d.ts.map +1 -1
  206. package/{backend/dist/routes → routes}/sessions.js +258 -39
  207. package/routes/sessions.js.map +1 -0
  208. package/{backend/dist/routes → routes}/settings.d.ts.map +1 -1
  209. package/{backend/dist/routes → routes}/settings.js +82 -241
  210. package/routes/settings.js.map +1 -0
  211. package/{backend/dist/routes/mcp.d.ts → routes/skills.d.ts} +1 -1
  212. package/routes/skills.d.ts.map +1 -0
  213. package/routes/skills.js +272 -0
  214. package/routes/skills.js.map +1 -0
  215. package/routes/slack.d.ts +10 -0
  216. package/routes/slack.d.ts.map +1 -0
  217. package/routes/slack.js +189 -0
  218. package/routes/slack.js.map +1 -0
  219. package/{backend/dist/routes → routes}/slides.d.ts.map +1 -1
  220. package/{backend/dist/routes → routes}/slides.js +29 -27
  221. package/routes/slides.js.map +1 -0
  222. package/{backend/dist/routes → routes}/subagents.js +27 -22
  223. package/routes/subagents.js.map +1 -0
  224. package/schemas/a2a.d.ts +858 -0
  225. package/schemas/a2a.d.ts.map +1 -0
  226. package/schemas/a2a.js +300 -0
  227. package/schemas/a2a.js.map +1 -0
  228. package/scripts/postinstall.js +10 -0
  229. package/services/__tests__/pluginInstaller.test.d.ts +5 -0
  230. package/services/__tests__/pluginInstaller.test.d.ts.map +1 -0
  231. package/services/__tests__/pluginInstaller.test.js +290 -0
  232. package/services/__tests__/pluginInstaller.test.js.map +1 -0
  233. package/services/__tests__/pluginParser.test.d.ts +5 -0
  234. package/services/__tests__/pluginParser.test.d.ts.map +1 -0
  235. package/services/__tests__/pluginParser.test.js +272 -0
  236. package/services/__tests__/pluginParser.test.js.map +1 -0
  237. package/services/__tests__/pluginPaths.test.d.ts +5 -0
  238. package/services/__tests__/pluginPaths.test.d.ts.map +1 -0
  239. package/services/__tests__/pluginPaths.test.js +221 -0
  240. package/services/__tests__/pluginPaths.test.js.map +1 -0
  241. package/services/__tests__/pluginScanner.test.d.ts +5 -0
  242. package/services/__tests__/pluginScanner.test.d.ts.map +1 -0
  243. package/services/__tests__/pluginScanner.test.js +272 -0
  244. package/services/__tests__/pluginScanner.test.js.map +1 -0
  245. package/services/__tests__/pluginSymlink.test.d.ts +5 -0
  246. package/services/__tests__/pluginSymlink.test.d.ts.map +1 -0
  247. package/services/__tests__/pluginSymlink.test.js +318 -0
  248. package/services/__tests__/pluginSymlink.test.js.map +1 -0
  249. package/services/__tests__/slackAIService.test.d.ts +5 -0
  250. package/services/__tests__/slackAIService.test.d.ts.map +1 -0
  251. package/services/__tests__/slackAIService.test.js +477 -0
  252. package/services/__tests__/slackAIService.test.js.map +1 -0
  253. package/services/__tests__/slackThreadMapper.test.d.ts +5 -0
  254. package/services/__tests__/slackThreadMapper.test.d.ts.map +1 -0
  255. package/services/__tests__/slackThreadMapper.test.js +194 -0
  256. package/services/__tests__/slackThreadMapper.test.js.map +1 -0
  257. package/services/a2a/__tests__/a2aClientTool.integration.test.d.ts +6 -0
  258. package/services/a2a/__tests__/a2aClientTool.integration.test.d.ts.map +1 -0
  259. package/services/a2a/__tests__/a2aClientTool.integration.test.js +264 -0
  260. package/services/a2a/__tests__/a2aClientTool.integration.test.js.map +1 -0
  261. package/services/a2a/__tests__/a2aClientTool.test.d.ts +6 -0
  262. package/services/a2a/__tests__/a2aClientTool.test.d.ts.map +1 -0
  263. package/services/a2a/__tests__/a2aClientTool.test.js +418 -0
  264. package/services/a2a/__tests__/a2aClientTool.test.js.map +1 -0
  265. package/services/a2a/__tests__/a2aConfigService.test.d.ts +6 -0
  266. package/services/a2a/__tests__/a2aConfigService.test.d.ts.map +1 -0
  267. package/services/a2a/__tests__/a2aConfigService.test.js +431 -0
  268. package/services/a2a/__tests__/a2aConfigService.test.js.map +1 -0
  269. package/services/a2a/__tests__/a2aConfigServicePath.test.d.ts +2 -0
  270. package/services/a2a/__tests__/a2aConfigServicePath.test.d.ts.map +1 -0
  271. package/services/a2a/__tests__/a2aConfigServicePath.test.js +49 -0
  272. package/services/a2a/__tests__/a2aConfigServicePath.test.js.map +1 -0
  273. package/services/a2a/__tests__/a2aSdkMcp.test.d.ts +10 -0
  274. package/services/a2a/__tests__/a2aSdkMcp.test.d.ts.map +1 -0
  275. package/services/a2a/__tests__/a2aSdkMcp.test.js +239 -0
  276. package/services/a2a/__tests__/a2aSdkMcp.test.js.map +1 -0
  277. package/services/a2a/__tests__/agentCardService.test.d.ts +6 -0
  278. package/services/a2a/__tests__/agentCardService.test.d.ts.map +1 -0
  279. package/services/a2a/__tests__/agentCardService.test.js +292 -0
  280. package/services/a2a/__tests__/agentCardService.test.js.map +1 -0
  281. package/services/a2a/__tests__/apiKeyService.test.d.ts +6 -0
  282. package/services/a2a/__tests__/apiKeyService.test.d.ts.map +1 -0
  283. package/services/a2a/__tests__/apiKeyService.test.js +284 -0
  284. package/services/a2a/__tests__/apiKeyService.test.js.map +1 -0
  285. package/services/a2a/__tests__/buildQueryOptionsIntegration.test.d.ts +2 -0
  286. package/services/a2a/__tests__/buildQueryOptionsIntegration.test.d.ts.map +1 -0
  287. package/services/a2a/__tests__/buildQueryOptionsIntegration.test.js +70 -0
  288. package/services/a2a/__tests__/buildQueryOptionsIntegration.test.js.map +1 -0
  289. package/services/a2a/__tests__/dynamic_config_verification.test.d.ts +2 -0
  290. package/services/a2a/__tests__/dynamic_config_verification.test.d.ts.map +1 -0
  291. package/services/a2a/__tests__/dynamic_config_verification.test.js +67 -0
  292. package/services/a2a/__tests__/dynamic_config_verification.test.js.map +1 -0
  293. package/services/a2a/__tests__/integrateA2AMcpServer.test.d.ts +2 -0
  294. package/services/a2a/__tests__/integrateA2AMcpServer.test.d.ts.map +1 -0
  295. package/services/a2a/__tests__/integrateA2AMcpServer.test.js +112 -0
  296. package/services/a2a/__tests__/integrateA2AMcpServer.test.js.map +1 -0
  297. package/services/a2a/__tests__/taskManager.integration.test.d.ts +7 -0
  298. package/services/a2a/__tests__/taskManager.integration.test.d.ts.map +1 -0
  299. package/services/a2a/__tests__/taskManager.integration.test.js +346 -0
  300. package/services/a2a/__tests__/taskManager.integration.test.js.map +1 -0
  301. package/services/a2a/__tests__/taskManager.test.d.ts +7 -0
  302. package/services/a2a/__tests__/taskManager.test.d.ts.map +1 -0
  303. package/services/a2a/__tests__/taskManager.test.js +423 -0
  304. package/services/a2a/__tests__/taskManager.test.js.map +1 -0
  305. package/services/a2a/a2aClientTool.d.ts +73 -0
  306. package/services/a2a/a2aClientTool.d.ts.map +1 -0
  307. package/services/a2a/a2aClientTool.js +572 -0
  308. package/services/a2a/a2aClientTool.js.map +1 -0
  309. package/services/a2a/a2aConfigService.d.ts +50 -0
  310. package/services/a2a/a2aConfigService.d.ts.map +1 -0
  311. package/services/a2a/a2aConfigService.js +186 -0
  312. package/services/a2a/a2aConfigService.js.map +1 -0
  313. package/services/a2a/a2aHistoryService.d.ts +32 -0
  314. package/services/a2a/a2aHistoryService.d.ts.map +1 -0
  315. package/services/a2a/a2aHistoryService.js +108 -0
  316. package/services/a2a/a2aHistoryService.js.map +1 -0
  317. package/services/a2a/a2aIntegration.d.ts +9 -0
  318. package/services/a2a/a2aIntegration.d.ts.map +1 -0
  319. package/services/a2a/a2aIntegration.js +41 -0
  320. package/services/a2a/a2aIntegration.js.map +1 -0
  321. package/services/a2a/a2aQueryService.d.ts +71 -0
  322. package/services/a2a/a2aQueryService.d.ts.map +1 -0
  323. package/services/a2a/a2aQueryService.js +166 -0
  324. package/services/a2a/a2aQueryService.js.map +1 -0
  325. package/services/a2a/a2aSdkMcp.d.ts +51 -0
  326. package/services/a2a/a2aSdkMcp.d.ts.map +1 -0
  327. package/services/a2a/a2aSdkMcp.js +185 -0
  328. package/services/a2a/a2aSdkMcp.js.map +1 -0
  329. package/services/a2a/a2aStreamEvents.d.ts +94 -0
  330. package/services/a2a/a2aStreamEvents.d.ts.map +1 -0
  331. package/services/a2a/a2aStreamEvents.js +92 -0
  332. package/services/a2a/a2aStreamEvents.js.map +1 -0
  333. package/services/a2a/agentCardService.d.ts +34 -0
  334. package/services/a2a/agentCardService.d.ts.map +1 -0
  335. package/services/a2a/agentCardService.js +228 -0
  336. package/services/a2a/agentCardService.js.map +1 -0
  337. package/services/a2a/agentMappingService.d.ts +53 -0
  338. package/services/a2a/agentMappingService.d.ts.map +1 -0
  339. package/services/a2a/agentMappingService.js +185 -0
  340. package/services/a2a/agentMappingService.js.map +1 -0
  341. package/services/a2a/apiKeyService.d.ts +101 -0
  342. package/services/a2a/apiKeyService.d.ts.map +1 -0
  343. package/services/a2a/apiKeyService.js +314 -0
  344. package/services/a2a/apiKeyService.js.map +1 -0
  345. package/services/a2a/taskCleanup.d.ts +30 -0
  346. package/services/a2a/taskCleanup.d.ts.map +1 -0
  347. package/services/a2a/taskCleanup.js +184 -0
  348. package/services/a2a/taskCleanup.js.map +1 -0
  349. package/services/a2a/taskManager.d.ts +86 -0
  350. package/services/a2a/taskManager.d.ts.map +1 -0
  351. package/services/a2a/taskManager.js +263 -0
  352. package/services/a2a/taskManager.js.map +1 -0
  353. package/services/agentStorage.d.ts +27 -0
  354. package/services/agentStorage.d.ts.map +1 -0
  355. package/services/agentStorage.js +487 -0
  356. package/services/agentStorage.js.map +1 -0
  357. package/services/askUserQuestion/askUserQuestionIntegration.d.ts +24 -0
  358. package/services/askUserQuestion/askUserQuestionIntegration.d.ts.map +1 -0
  359. package/services/askUserQuestion/askUserQuestionIntegration.js +52 -0
  360. package/services/askUserQuestion/askUserQuestionIntegration.js.map +1 -0
  361. package/services/askUserQuestion/askUserQuestionMcp.d.ts +103 -0
  362. package/services/askUserQuestion/askUserQuestionMcp.d.ts.map +1 -0
  363. package/services/askUserQuestion/askUserQuestionMcp.js +129 -0
  364. package/services/askUserQuestion/askUserQuestionMcp.js.map +1 -0
  365. package/services/askUserQuestion/index.d.ts +13 -0
  366. package/services/askUserQuestion/index.d.ts.map +1 -0
  367. package/services/askUserQuestion/index.js +35 -0
  368. package/services/askUserQuestion/index.js.map +1 -0
  369. package/services/askUserQuestion/init.d.ts +17 -0
  370. package/services/askUserQuestion/init.d.ts.map +1 -0
  371. package/services/askUserQuestion/init.js +47 -0
  372. package/services/askUserQuestion/init.js.map +1 -0
  373. package/services/askUserQuestion/notificationChannel.d.ts +97 -0
  374. package/services/askUserQuestion/notificationChannel.d.ts.map +1 -0
  375. package/services/askUserQuestion/notificationChannel.js +147 -0
  376. package/services/askUserQuestion/notificationChannel.js.map +1 -0
  377. package/services/askUserQuestion/slackNotificationChannel.d.ts +35 -0
  378. package/services/askUserQuestion/slackNotificationChannel.d.ts.map +1 -0
  379. package/services/askUserQuestion/slackNotificationChannel.js +129 -0
  380. package/services/askUserQuestion/slackNotificationChannel.js.map +1 -0
  381. package/services/askUserQuestion/sseNotificationChannel.d.ts +36 -0
  382. package/services/askUserQuestion/sseNotificationChannel.d.ts.map +1 -0
  383. package/services/askUserQuestion/sseNotificationChannel.js +88 -0
  384. package/services/askUserQuestion/sseNotificationChannel.js.map +1 -0
  385. package/services/askUserQuestion/userInputRegistry.d.ts +107 -0
  386. package/services/askUserQuestion/userInputRegistry.d.ts.map +1 -0
  387. package/services/askUserQuestion/userInputRegistry.js +253 -0
  388. package/services/askUserQuestion/userInputRegistry.js.map +1 -0
  389. package/{backend/dist/services → services}/claudeSession.d.ts +20 -5
  390. package/services/claudeSession.d.ts.map +1 -0
  391. package/{backend/dist/services → services}/claudeSession.js +123 -41
  392. package/services/claudeSession.js.map +1 -0
  393. package/services/claudeVersionStorage.d.ts +20 -0
  394. package/services/claudeVersionStorage.d.ts.map +1 -0
  395. package/services/claudeVersionStorage.js +331 -0
  396. package/services/claudeVersionStorage.js.map +1 -0
  397. package/services/mcpAdmin/__tests__/adminApiKeyService.test.d.ts +5 -0
  398. package/services/mcpAdmin/__tests__/adminApiKeyService.test.d.ts.map +1 -0
  399. package/services/mcpAdmin/__tests__/adminApiKeyService.test.js +289 -0
  400. package/services/mcpAdmin/__tests__/adminApiKeyService.test.js.map +1 -0
  401. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.d.ts +5 -0
  402. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.d.ts.map +1 -0
  403. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.js +345 -0
  404. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.js.map +1 -0
  405. package/services/mcpAdmin/__tests__/mcpAdminServer.test.d.ts +5 -0
  406. package/services/mcpAdmin/__tests__/mcpAdminServer.test.d.ts.map +1 -0
  407. package/services/mcpAdmin/__tests__/mcpAdminServer.test.js +453 -0
  408. package/services/mcpAdmin/__tests__/mcpAdminServer.test.js.map +1 -0
  409. package/services/mcpAdmin/__tests__/tools.test.d.ts +5 -0
  410. package/services/mcpAdmin/__tests__/tools.test.d.ts.map +1 -0
  411. package/services/mcpAdmin/__tests__/tools.test.js +371 -0
  412. package/services/mcpAdmin/__tests__/tools.test.js.map +1 -0
  413. package/services/mcpAdmin/adminApiKeyService.d.ts +61 -0
  414. package/services/mcpAdmin/adminApiKeyService.d.ts.map +1 -0
  415. package/services/mcpAdmin/adminApiKeyService.js +270 -0
  416. package/services/mcpAdmin/adminApiKeyService.js.map +1 -0
  417. package/services/mcpAdmin/index.d.ts +10 -0
  418. package/services/mcpAdmin/index.d.ts.map +1 -0
  419. package/services/mcpAdmin/index.js +43 -0
  420. package/services/mcpAdmin/index.js.map +1 -0
  421. package/services/mcpAdmin/mcpAdminServer.d.ts +76 -0
  422. package/services/mcpAdmin/mcpAdminServer.d.ts.map +1 -0
  423. package/services/mcpAdmin/mcpAdminServer.js +243 -0
  424. package/services/mcpAdmin/mcpAdminServer.js.map +1 -0
  425. package/services/mcpAdmin/tools/agentTools.d.ts +27 -0
  426. package/services/mcpAdmin/tools/agentTools.d.ts.map +1 -0
  427. package/services/mcpAdmin/tools/agentTools.js +359 -0
  428. package/services/mcpAdmin/tools/agentTools.js.map +1 -0
  429. package/services/mcpAdmin/tools/index.d.ts +15 -0
  430. package/services/mcpAdmin/tools/index.d.ts.map +1 -0
  431. package/services/mcpAdmin/tools/index.js +30 -0
  432. package/services/mcpAdmin/tools/index.js.map +1 -0
  433. package/services/mcpAdmin/tools/mcpServerTools.d.ts +27 -0
  434. package/services/mcpAdmin/tools/mcpServerTools.d.ts.map +1 -0
  435. package/services/mcpAdmin/tools/mcpServerTools.js +334 -0
  436. package/services/mcpAdmin/tools/mcpServerTools.js.map +1 -0
  437. package/services/mcpAdmin/tools/projectTools.d.ts +27 -0
  438. package/services/mcpAdmin/tools/projectTools.d.ts.map +1 -0
  439. package/services/mcpAdmin/tools/projectTools.js +353 -0
  440. package/services/mcpAdmin/tools/projectTools.js.map +1 -0
  441. package/services/mcpAdmin/tools/systemTools.d.ts +23 -0
  442. package/services/mcpAdmin/tools/systemTools.d.ts.map +1 -0
  443. package/services/mcpAdmin/tools/systemTools.js +241 -0
  444. package/services/mcpAdmin/tools/systemTools.js.map +1 -0
  445. package/services/mcpAdmin/types.d.ts +124 -0
  446. package/services/mcpAdmin/types.d.ts.map +1 -0
  447. package/services/mcpAdmin/types.js +18 -0
  448. package/services/mcpAdmin/types.js.map +1 -0
  449. package/{backend/dist/services → services}/messageQueue.d.ts.map +1 -1
  450. package/{backend/dist/services → services}/messageQueue.js +16 -3
  451. package/services/messageQueue.js.map +1 -0
  452. package/services/pluginInstaller.d.ts +58 -0
  453. package/services/pluginInstaller.d.ts.map +1 -0
  454. package/services/pluginInstaller.js +321 -0
  455. package/services/pluginInstaller.js.map +1 -0
  456. package/services/pluginParser.d.ts +45 -0
  457. package/services/pluginParser.d.ts.map +1 -0
  458. package/services/pluginParser.js +437 -0
  459. package/services/pluginParser.js.map +1 -0
  460. package/services/pluginPaths.d.ts +80 -0
  461. package/services/pluginPaths.d.ts.map +1 -0
  462. package/services/pluginPaths.js +274 -0
  463. package/services/pluginPaths.js.map +1 -0
  464. package/services/pluginScanner.d.ts +36 -0
  465. package/services/pluginScanner.d.ts.map +1 -0
  466. package/services/pluginScanner.js +251 -0
  467. package/services/pluginScanner.js.map +1 -0
  468. package/services/pluginSymlink.d.ts +54 -0
  469. package/services/pluginSymlink.d.ts.map +1 -0
  470. package/services/pluginSymlink.js +223 -0
  471. package/services/pluginSymlink.js.map +1 -0
  472. package/services/projectMetadataStorage.d.ts +114 -0
  473. package/services/projectMetadataStorage.d.ts.map +1 -0
  474. package/services/projectMetadataStorage.js +711 -0
  475. package/services/projectMetadataStorage.js.map +1 -0
  476. package/services/scheduledTaskStorage.d.ts +52 -0
  477. package/services/scheduledTaskStorage.d.ts.map +1 -0
  478. package/services/scheduledTaskStorage.js +285 -0
  479. package/services/scheduledTaskStorage.js.map +1 -0
  480. package/services/schedulerService.d.ts +81 -0
  481. package/services/schedulerService.d.ts.map +1 -0
  482. package/services/schedulerService.js +743 -0
  483. package/services/schedulerService.js.map +1 -0
  484. package/{backend/dist/services → services}/sessionManager.d.ts +6 -4
  485. package/services/sessionManager.d.ts.map +1 -0
  486. package/{backend/dist/services → services}/sessionManager.js +77 -16
  487. package/services/sessionManager.js.map +1 -0
  488. package/services/skillStorage.d.ts +60 -0
  489. package/services/skillStorage.d.ts.map +1 -0
  490. package/services/skillStorage.js +398 -0
  491. package/services/skillStorage.js.map +1 -0
  492. package/services/slackAIService.d.ts +81 -0
  493. package/services/slackAIService.d.ts.map +1 -0
  494. package/services/slackAIService.js +1091 -0
  495. package/services/slackAIService.js.map +1 -0
  496. package/services/slackClient.d.ts +46 -0
  497. package/services/slackClient.d.ts.map +1 -0
  498. package/services/slackClient.js +85 -0
  499. package/services/slackClient.js.map +1 -0
  500. package/services/slackSessionLock.d.ts +79 -0
  501. package/services/slackSessionLock.d.ts.map +1 -0
  502. package/services/slackSessionLock.js +353 -0
  503. package/services/slackSessionLock.js.map +1 -0
  504. package/services/slackThreadMapper.d.ts +57 -0
  505. package/services/slackThreadMapper.d.ts.map +1 -0
  506. package/services/slackThreadMapper.js +140 -0
  507. package/services/slackThreadMapper.js.map +1 -0
  508. package/types/a2a.d.ts +275 -0
  509. package/types/a2a.d.ts.map +1 -0
  510. package/types/a2a.js +23 -0
  511. package/types/a2a.js.map +1 -0
  512. package/types/agents.d.ts +95 -0
  513. package/types/agents.d.ts.map +1 -0
  514. package/types/agents.js +46 -0
  515. package/types/agents.js.map +1 -0
  516. package/types/claude-history.d.ts +62 -0
  517. package/types/claude-history.d.ts.map +1 -0
  518. package/types/claude-history.js +4 -0
  519. package/types/claude-history.js.map +1 -0
  520. package/types/claude-versions.d.ts +36 -0
  521. package/types/claude-versions.d.ts.map +1 -0
  522. package/types/claude-versions.js +3 -0
  523. package/types/claude-versions.js.map +1 -0
  524. package/types/commands.d.ts +50 -0
  525. package/types/commands.d.ts.map +1 -0
  526. package/types/commands.js +23 -0
  527. package/types/commands.js.map +1 -0
  528. package/types/plugins.d.ts +144 -0
  529. package/types/plugins.d.ts.map +1 -0
  530. package/types/plugins.js +8 -0
  531. package/types/plugins.js.map +1 -0
  532. package/types/projects.d.ts +42 -0
  533. package/types/projects.d.ts.map +1 -0
  534. package/types/projects.js +4 -0
  535. package/types/projects.js.map +1 -0
  536. package/types/scheduledTasks.d.ts +164 -0
  537. package/types/scheduledTasks.d.ts.map +1 -0
  538. package/types/scheduledTasks.js +17 -0
  539. package/types/scheduledTasks.js.map +1 -0
  540. package/types/skills.d.ts +91 -0
  541. package/types/skills.d.ts.map +1 -0
  542. package/types/skills.js +6 -0
  543. package/types/skills.js.map +1 -0
  544. package/types/slack.d.ts +97 -0
  545. package/types/slack.d.ts.map +1 -0
  546. package/types/slack.js +8 -0
  547. package/types/slack.js.map +1 -0
  548. package/types/streaming.d.ts +12 -0
  549. package/types/streaming.d.ts.map +1 -0
  550. package/types/streaming.js +8 -0
  551. package/types/streaming.js.map +1 -0
  552. package/types/subagents.d.ts +26 -0
  553. package/types/subagents.d.ts.map +1 -0
  554. package/types/subagents.js +3 -0
  555. package/types/subagents.js.map +1 -0
  556. package/utils/__tests__/claudeUtils.test.d.ts +5 -0
  557. package/utils/__tests__/claudeUtils.test.d.ts.map +1 -0
  558. package/utils/__tests__/claudeUtils.test.js +282 -0
  559. package/utils/__tests__/claudeUtils.test.js.map +1 -0
  560. package/utils/__tests__/sessionUtils.test.d.ts +5 -0
  561. package/utils/__tests__/sessionUtils.test.d.ts.map +1 -0
  562. package/utils/__tests__/sessionUtils.test.js +295 -0
  563. package/utils/__tests__/sessionUtils.test.js.map +1 -0
  564. package/utils/agentCardCache.d.ts +93 -0
  565. package/utils/agentCardCache.d.ts.map +1 -0
  566. package/utils/agentCardCache.js +212 -0
  567. package/utils/agentCardCache.js.map +1 -0
  568. package/utils/claudeUtils.d.ts +54 -0
  569. package/utils/claudeUtils.d.ts.map +1 -0
  570. package/utils/claudeUtils.js +387 -0
  571. package/utils/claudeUtils.js.map +1 -0
  572. package/utils/fileUtils.d.ts +2 -0
  573. package/utils/fileUtils.d.ts.map +1 -0
  574. package/utils/fileUtils.js +11 -0
  575. package/utils/fileUtils.js.map +1 -0
  576. package/utils/jwt.d.ts +30 -0
  577. package/utils/jwt.d.ts.map +1 -0
  578. package/utils/jwt.js +95 -0
  579. package/utils/jwt.js.map +1 -0
  580. package/utils/sessionUtils.d.ts +64 -0
  581. package/utils/sessionUtils.d.ts.map +1 -0
  582. package/utils/sessionUtils.js +266 -0
  583. package/utils/sessionUtils.js.map +1 -0
  584. package/README.zh-CN.md +0 -525
  585. package/backend/dist/bin/agentstudio.js +0 -120
  586. package/backend/dist/bin/agentstudio.js.map +0 -1
  587. package/backend/dist/frontend/assets/AgentsPage-Dqb_aqAA.js +0 -1
  588. package/backend/dist/frontend/assets/ChatPage-L8Paywyc.js +0 -91
  589. package/backend/dist/frontend/assets/CommandForm-DLl7EIMS.js +0 -7
  590. package/backend/dist/frontend/assets/CommandsPage-Bzavq0Ec.js +0 -1
  591. package/backend/dist/frontend/assets/DashboardPage-B3o4AYFT.js +0 -15
  592. package/backend/dist/frontend/assets/FileBrowser-DL3ayaqb.js +0 -1
  593. package/backend/dist/frontend/assets/GeneralSettingsPage-CBN_de-V.js +0 -1
  594. package/backend/dist/frontend/assets/LandingPage-Dl4ioKos.js +0 -1
  595. package/backend/dist/frontend/assets/LoginPage-4QqRdiSi.js +0 -12
  596. package/backend/dist/frontend/assets/McpPage-CY3tYiqj.js +0 -39
  597. package/backend/dist/frontend/assets/MemorySettingsPage-DGxrok5K.js +0 -1
  598. package/backend/dist/frontend/assets/ProjectSelector-hgmGYVFh.js +0 -1
  599. package/backend/dist/frontend/assets/ProjectsPage-D399IM0c.js +0 -14
  600. package/backend/dist/frontend/assets/SettingsLayout-CL_K-lzJ.js +0 -1
  601. package/backend/dist/frontend/assets/SubagentsPage-Chbhj8p2.js +0 -1
  602. package/backend/dist/frontend/assets/UnifiedToolSelector-CsM9qBvs.js +0 -1
  603. package/backend/dist/frontend/assets/VersionSettingsPage-74Q-LVgA.js +0 -5
  604. package/backend/dist/frontend/assets/agents-ClAzIJTw.js +0 -1
  605. package/backend/dist/frontend/assets/authFetch-BATQyPG5.js +0 -1
  606. package/backend/dist/frontend/assets/index-B9YHa7XT.css +0 -1
  607. package/backend/dist/frontend/assets/index-B_CTNvca.js +0 -268
  608. package/backend/dist/frontend/assets/monaco-editor-C7Z4sOhS.js +0 -19
  609. package/backend/dist/frontend/assets/tabManager-DV8urRBM.js +0 -30
  610. package/backend/dist/frontend/assets/tools-C4EPanYi.js +0 -1
  611. package/backend/dist/frontend/assets/useAgents-DwnOE1_k.js +0 -2
  612. package/backend/dist/frontend/assets/useClaudeVersions-CQdGnCqv.js +0 -1
  613. package/backend/dist/frontend/assets/useCommands-CCVaurbt.js +0 -1
  614. package/backend/dist/index.d.ts +0 -3
  615. package/backend/dist/index.d.ts.map +0 -1
  616. package/backend/dist/index.js +0 -157
  617. package/backend/dist/index.js.map +0 -1
  618. package/backend/dist/middleware/auth.d.ts.map +0 -1
  619. package/backend/dist/middleware/auth.js +0 -21
  620. package/backend/dist/middleware/auth.js.map +0 -1
  621. package/backend/dist/routes/agents.js +0 -803
  622. package/backend/dist/routes/agents.js.map +0 -1
  623. package/backend/dist/routes/auth.js +0 -60
  624. package/backend/dist/routes/auth.js.map +0 -1
  625. package/backend/dist/routes/commands.js.map +0 -1
  626. package/backend/dist/routes/files.js.map +0 -1
  627. package/backend/dist/routes/mcp.d.ts.map +0 -1
  628. package/backend/dist/routes/mcp.js.map +0 -1
  629. package/backend/dist/routes/media.d.ts.map +0 -1
  630. package/backend/dist/routes/media.js.map +0 -1
  631. package/backend/dist/routes/projects.js +0 -528
  632. package/backend/dist/routes/projects.js.map +0 -1
  633. package/backend/dist/routes/sessions.js.map +0 -1
  634. package/backend/dist/routes/settings.js.map +0 -1
  635. package/backend/dist/routes/slides.js.map +0 -1
  636. package/backend/dist/routes/subagents.js.map +0 -1
  637. package/backend/dist/services/claudeSession.d.ts.map +0 -1
  638. package/backend/dist/services/claudeSession.js.map +0 -1
  639. package/backend/dist/services/messageQueue.js.map +0 -1
  640. package/backend/dist/services/sessionManager.d.ts.map +0 -1
  641. package/backend/dist/services/sessionManager.js.map +0 -1
  642. package/backend/dist/utils/jwt.d.ts +0 -15
  643. package/backend/dist/utils/jwt.d.ts.map +0 -1
  644. package/backend/dist/utils/jwt.js +0 -28
  645. package/backend/dist/utils/jwt.js.map +0 -1
  646. /package/{backend/dist/bin → bin}/agentstudio.d.ts +0 -0
  647. /package/{backend/dist/bin → bin}/agentstudio.d.ts.map +0 -0
  648. /package/{backend/dist/frontend → public}/assets/ChatPage-BvQmXfcP.css +0 -0
  649. /package/{backend/dist/frontend → public}/assets/agents-DwCY2K8p.css +0 -0
  650. /package/{backend/dist/frontend → public}/assets/dateFormat-CXa8VnEC.js +0 -0
  651. /package/{backend/dist/frontend → public}/cc-studio.png +0 -0
  652. /package/{backend/dist/frontend → public}/vite.svg +0 -0
  653. /package/{backend/dist/routes → routes}/agents.d.ts +0 -0
  654. /package/{backend/dist/routes → routes}/auth.d.ts +0 -0
  655. /package/{backend/dist/routes → routes}/commands.d.ts +0 -0
  656. /package/{backend/dist/routes → routes}/files.d.ts +0 -0
  657. /package/{backend/dist/routes → routes}/media.d.ts +0 -0
  658. /package/{backend/dist/routes → routes}/projects.d.ts +0 -0
  659. /package/{backend/dist/routes → routes}/sessions.d.ts +0 -0
  660. /package/{backend/dist/routes → routes}/settings.d.ts +0 -0
  661. /package/{backend/dist/routes → routes}/slides.d.ts +0 -0
  662. /package/{backend/dist/routes → routes}/subagents.d.ts +0 -0
  663. /package/{backend/dist/routes → routes}/subagents.d.ts.map +0 -0
  664. /package/{backend/dist/services → services}/messageQueue.d.ts +0 -0
@@ -0,0 +1,40 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as m,W as Q}from"./monaco-editor-DHKm5-VF.js";import{a as g,A as u}from"./agents-ChrA1R0y.js";import{u as ce,s as U,a as V,b}from"./index-Bn3v3S9-.js";import{T as me,a as xe,b as B,c as v,d as pe,e as C}from"./table-D0L2RL5i.js";import{u as ge}from"./tools-IcPNZlPj.js";import{g as ue,L as N,p as he,C as M,n as be,q as fe,r as W,s as z,k as X,t as G,u as K,v as Y,E as ye}from"./ui-components-D1St49qC.js";import"./syntax-highlighting-CnREyncB.js";const Te=()=>{const{t:s}=ge("pages"),{isMobile:l}=ce(),[x,c]=m.useState([]),[Z,q]=m.useState(!0),[$,ee]=m.useState(""),[w,te]=m.useState(""),[se,f]=m.useState(!1),[p,D]=m.useState(null),[o,y]=m.useState({name:"",type:"stdio",config:""}),[S,O]=m.useState(!1),[T,L]=m.useState(!1),[h,I]=m.useState({}),ae=async()=>{try{q(!0);const t=await g(`${u}/mcp`);if(t.ok){const r=await t.json();c(r.servers||[])}else console.error("Failed to load MCP configs:",t.status),c([])}catch(t){console.error("Failed to load MCP configs:",t),c([])}finally{q(!1)}};Q.useEffect(()=>{ae()},[]),Q.useEffect(()=>{const t=setTimeout(()=>{te($)},300);return()=>clearTimeout(t)},[$]);const k=async t=>{try{console.log("Validating MCP server:",t),c(a=>a.map(n=>n.name===t?{...n,status:"validating"}:n));const r=await g(`${u}/mcp/${t}/validate`,{method:"POST"});if(console.log("Validation response status:",r.status),r.ok){const a=await r.json();c(n=>n.map(i=>i.name===t?{...i,status:"active",tools:a.tools||[],error:void 0}:i))}else{const a=await r.json();let n=a.error||s("mcp.errors.validationFailed");a.details&&(n+=`
2
+ ${a.details}`),c(i=>i.map(d=>d.name===t?{...d,status:"error",error:n,tools:void 0}:d))}}catch(r){console.error("MCP server validation failed:",r),c(a=>a.map(n=>n.name===t?{...n,status:"error",error:s("mcp.errors.networkError"),tools:void 0}:n))}},re=async()=>{for(const t of x)await k(t.name)},F=x.filter(t=>{const r=w.toLowerCase(),a=t.name.toLowerCase().includes(r),n=t.command?.toLowerCase().includes(r)||!1,i=t.args?.join(" ").toLowerCase().includes(r)||!1,d=t.url?.toLowerCase().includes(r)||!1;return a||n||i||d}),E=t=>{D(t);const{name:r,status:a,error:n,tools:i,lastValidated:d,...j}=t;y({name:t.name,type:t.type,config:JSON.stringify(j,null,2)}),f(!0)},H=t=>{let r="";t.type==="stdio"?r=`${t.command} ${t.args?.join(" ")||""}`.trim():r=t.url||"",navigator.clipboard.writeText(r).then(()=>{V(s("mcp.commandCopied"))}).catch(()=>{b(s("mcp.errors.copyFailed"))})},J=async t=>{if(window.confirm(s("mcp.confirmDelete",{name:t})))try{const r=await g(`${u}/mcp/${t}`,{method:"DELETE"});if(r.ok)c(a=>a.filter(n=>n.name!==t));else{const a=await r.json();throw new Error(a.error||s("mcp.errors.deleteFailed"))}}catch(r){console.error("Delete config failed:",r),b(s("mcp.errors.deleteFailed"),r instanceof Error?r.message:s("errors:common.unknownError"))}},R=()=>{y({name:"",type:"stdio",config:""}),D(null)},le=async()=>{try{L(!0);const t=await g(`${u}/mcp/claude-code`);if(t.ok){const a=(await t.json()).servers||[];if(a.length===0){U(s("mcp.import.noConfigFound"));return}let n=0,i=0;for(const d of a){if(x.find(P=>P.name===d.name)){i++;continue}const ie={...d},_=await g(`${u}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(_.ok){const P=await _.json();c(de=>[P.server,...de]),n++}}n>0?V(s("mcp.import.success",{imported:n,skipped:i})):U(s("mcp.import.allExist"))}else{const r=await t.json();throw new Error(r.error||s("mcp.errors.importFailed"))}}catch(t){console.error("Failed to import from Claude Code:",t),b(s("mcp.errors.importFailed"),t instanceof Error?t.message:s("errors:common.unknownError"))}finally{L(!1)}},A=(t,r)=>{if(!t.trim())return!1;try{const a=JSON.parse(t);if(!a.type||a.type!==r)return!1;if(r==="stdio"){if(!a.command||!Array.isArray(a.args))return!1}else if(r==="http"&&(!a.url||typeof a.url!="string"))return!1;return!(a.timeout&&typeof a.timeout!="number"||a.autoApprove&&!Array.isArray(a.autoApprove))}catch{return!1}},ne=async t=>{if(t.preventDefault(),!o.name.trim()){b(s("mcp.form.nameRequired"));return}if(!A(o.config,o.type)){b(s("mcp.form.configInvalid",{fields:o.type==="stdio"?s("mcp.form.requiredFieldsStdio"):s("mcp.form.requiredFieldsHttp")}));return}O(!0);try{const r=JSON.parse(o.config);let a;if(p)console.log("Updating existing MCP server:",p.name,"with config:",r),a=await g(`${u}/mcp/${p.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});else{const n={name:o.name,...r};a=await g(`${u}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}if(a.ok){const n=await a.json();c(p?d=>d.map(j=>j.name===p.name?n.server:j):d=>[n.server,...d]),R(),f(!1);const i=n.server.name;await k(i)}else{const n=await a.json();throw new Error(n.error||s("mcp.errors.saveFailed"))}}catch(r){console.error("Failed to save MCP config:",r),b(s("mcp.errors.saveFailed"),r instanceof Error?r.message:s("errors:common.unknownError"))}finally{O(!1)}},oe=()=>{f(!1),R()};return Z?e.jsx("div",{className:`${l?"p-4":"p-8"} flex items-center justify-center min-h-[60vh]`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:s("mcp.loading")})]})}):e.jsxs("div",{className:`${l?"p-4":"p-8"}`,children:[e.jsxs("div",{className:`${l?"mb-6":"mb-8"}`,children:[e.jsx("div",{className:`flex items-center ${l?"mb-4":"justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${l?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("mcp.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${l?"mt-1":"mt-2"}`,children:s("mcp.subtitle")})]})}),e.jsx("div",{className:"mb-6 bg-white dark:bg-gray-800 rounded-lg shadow p-4 md:p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-gray-900 dark:text-gray-100",children:x.length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:s("mcp.stats.total")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-green-600 dark:text-green-400",children:x.filter(t=>t.status==="active").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:s("mcp.stats.active")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-red-600 dark:text-red-400",children:x.filter(t=>t.status==="error").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:s("mcp.stats.error")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-blue-600 dark:text-blue-400",children:x.filter(t=>t.status==="validating").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:s("mcp.stats.validating")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-purple-600 dark:text-purple-400",children:x.reduce((t,r)=>t+(r.tools?.length||0),0)}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:s("mcp.stats.tools")})]})]})}),e.jsxs("div",{className:`${l?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${l?"":"flex-1"} relative`,children:[e.jsx(ue,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:s("mcp.searchPlaceholder"),value:$,onChange:t=>ee(t.target.value),className:`pl-10 pr-4 ${l?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${l?"text-sm":""}`})]}),e.jsxs("div",{className:`${l?"flex space-x-2":"flex items-center space-x-3"}`,children:[e.jsxs("button",{onClick:re,disabled:x.length===0,className:`${l?"flex-1 px-3 py-2 text-sm":"px-5 py-3"} bg-gray-600 text-white rounded-lg hover:bg-gray-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap font-medium flex items-center ${l?"justify-center":"space-x-2"} disabled:opacity-50 disabled:cursor-not-allowed`,title:s("mcp.validateAll"),children:[e.jsx(N,{className:`${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:s("mcp.validateAll")})]}),e.jsxs("button",{onClick:le,disabled:T,className:`${l?"flex-1 px-3 py-2 text-sm":"px-5 py-3"} bg-green-600 text-white rounded-lg hover:bg-green-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap font-medium flex items-center ${l?"justify-center":"space-x-2"} disabled:opacity-50 disabled:cursor-not-allowed`,children:[T&&e.jsx(N,{className:`${l?"w-4 h-4":"w-5 h-5"} animate-spin`}),e.jsx("span",{children:s(T?"mcp.import.importing":"mcp.import.button")})]}),e.jsxs("button",{onClick:()=>f(!0),className:`${l?"flex-1 px-3 py-2 text-sm":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap flex items-center ${l?"justify-center":"space-x-2"} font-medium`,children:[e.jsx(he,{className:`${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:s("mcp.addServer")})]})]})]})]}),F.length===0?e.jsxs("div",{className:`text-center ${l?"py-8":"py-16"} bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:[e.jsx("div",{className:`${l?"text-4xl":"text-6xl"} mb-4`,children:"🖥️"}),e.jsx("h3",{className:`${l?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:s(w?"mcp.noResults":"mcp.noServers")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${l?"mb-4":"mb-6"}`,children:s(w?"mcp.adjustSearch":"mcp.addFirstServer")}),!w&&e.jsx("button",{onClick:()=>f(!0),className:`${l?"px-4 py-2 text-sm":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("mcp.addServer")})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"md:hidden space-y-4",children:F.map((t,r)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow overflow-hidden",children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start space-x-3 mb-3",children:[e.jsx("div",{className:"text-2xl",children:t.type==="http"?"🌐":"🖥️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base font-medium text-gray-900 dark:text-white truncate",children:t.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:t.type==="stdio"?`${t.command} ${t.args?.join(" ")||""}`.trim():t.url})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm mb-3",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 block mb-1",children:[s("mcp.table.type"),":"]}),e.jsx("span",{className:`inline-flex items-center px-2 py-1 text-xs font-medium rounded-full ${t.type==="http"?"bg-blue-100 text-blue-800":"bg-purple-100 text-purple-800"}`,children:t.type==="http"?"HTTP":"Stdio"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 block mb-1",children:[s("mcp.table.status"),":"]}),t.status==="active"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800",children:[e.jsx(M,{className:"w-3 h-3 mr-1"}),s("mcp.status.active")]}),t.status==="error"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-red-100 text-red-800",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),s("mcp.status.error")]}),t.status==="validating"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800",children:[e.jsx(N,{className:"w-3 h-3 mr-1 animate-spin"}),s("mcp.status.validating")]}),!t.status&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-gray-100 text-gray-800",children:[e.jsx(fe,{className:"w-3 h-3 mr-1"}),s("mcp.status.unvalidated")]})]})]}),t.status==="active"&&t.tools&&t.tools.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("button",{onClick:()=>I(a=>({...a,[t.name]:!a[t.name]})),className:"flex items-center space-x-2 text-sm text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors mb-2 w-full",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[t.tools.length," ",s("mcp.table.tools")]}),h[t.name]?e.jsx(z,{className:"w-4 h-4 ml-auto text-gray-400"}):e.jsx(X,{className:"w-4 h-4 ml-auto text-gray-400"})]}),h[t.name]&&e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-40 overflow-y-auto",children:t.tools.map((a,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-1 rounded text-xs font-mono border border-green-200 dark:border-green-800",title:a,children:a},n))}),!h[t.name]&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.tools.slice(0,3).map((a,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-0.5 rounded text-xs font-mono",title:a,children:a},n)),t.tools.length>3&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:["+",t.tools.length-3]})]})]}),t.status==="error"&&t.error&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 mb-3 p-2 bg-red-50 dark:bg-red-900/20 rounded border border-red-200 dark:border-red-800",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-xs",children:t.error})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:s("mcp.table.actions")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>k(t.name),disabled:t.status==="validating",className:"p-2 text-green-600 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/50 rounded-md transition-colors disabled:opacity-50",title:s("mcp.actions.validate"),children:t.status==="validating"?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(M,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>H(t),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-900/50 rounded-md transition-colors",title:s("mcp.actions.copyCommand"),children:e.jsx(G,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E(t),className:"p-2 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:s("mcp.actions.edit"),children:e.jsx(K,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(t.name),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:s("mcp.actions.delete"),children:e.jsx(Y,{className:"w-4 h-4"})})]})]})})]},t.name+"-"+r))}),e.jsx("div",{className:"hidden md:block bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(me,{children:[e.jsx(xe,{children:e.jsxs(B,{children:[e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("mcp.table.server")}),e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("mcp.table.type")}),e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("mcp.table.tools")}),e.jsx(v,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("mcp.table.actions")})]})}),e.jsx(pe,{children:F.map((t,r)=>e.jsxs(B,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(C,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:t.type==="http"?"🌐":"🖥️"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:t.source==="plugin"?s("mcp.source.plugin"):s("mcp.source.local")})]}),t.status==="error"&&t.error&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 mt-1 max-w-md",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans",children:t.error})})]})]})}),e.jsx(C,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 text-xs font-medium rounded-full ${t.type==="http"?"bg-blue-100 text-blue-800":"bg-purple-100 text-purple-800"}`,children:t.type==="http"?"HTTP":"Stdio"})}),e.jsx(C,{className:"px-6 py-4",children:t.status==="active"&&t.tools&&t.tools.length>0?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>I(a=>({...a,[t.name]:!a[t.name]})),className:"flex items-center space-x-2 text-sm text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors mb-2 group",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[t.tools.length," ",s("mcp.table.tools")]}),h[t.name]?e.jsx(z,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"}):e.jsx(X,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"})]}),h[t.name]&&e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-48 overflow-y-auto pr-2",children:t.tools.map((a,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-1 rounded text-xs font-mono border border-green-200 dark:border-green-800 hover:bg-green-100 dark:hover:bg-green-900/50 transition-colors",title:a,children:a},n))}),!h[t.name]&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.tools.slice(0,5).map((a,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-0.5 rounded text-xs font-mono",title:a,children:a},n)),t.tools.length>5&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:["+",t.tools.length-5]})]})]}):e.jsx("span",{className:"text-sm text-gray-400",children:t.status==="active"?s("mcp.table.noTools"):"-"})}),e.jsx(C,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx("button",{onClick:()=>k(t.name),disabled:t.status==="validating",className:"inline-flex items-center px-2 py-1 text-xs font-medium text-green-600 bg-green-50 dark:bg-green-900/50 rounded-md hover:bg-green-100 dark:hover:bg-green-900/70 transition-colors disabled:opacity-50",title:s("mcp.actions.validate"),children:t.status==="validating"?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(M,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>H(t),className:"inline-flex items-center px-2 py-1 text-xs font-medium text-gray-600 bg-gray-50 dark:bg-gray-900/50 rounded-md hover:bg-gray-100 dark:hover:bg-gray-900/70 transition-colors",title:s("mcp.actions.copyCommand"),children:e.jsx(G,{className:"w-3 h-3"})}),t.source==="plugin"?e.jsxs("button",{onClick:()=>E(t),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("mcp.actions.view"),children:[e.jsx(ye,{className:"w-3 h-3 mr-1"}),s("mcp.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>E(t),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("mcp.actions.edit"),children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),s("mcp.actions.edit")]}),e.jsx("button",{onClick:()=>J(t.name),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("mcp.actions.delete"),children:e.jsx(Y,{className:"w-4 h-4"})})]})]})})]},t.name+"-"+r))})]})})]}),se&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${l?"max-w-full":"max-w-2xl"} mx-4 max-h-[90vh] overflow-y-auto`,children:e.jsxs("div",{className:`${l?"p-4":"p-6"}`,children:[e.jsxs("div",{className:`flex items-center ${l?"flex-col space-y-3":"justify-between"} mb-4`,children:[e.jsx("h2",{className:`${l?"text-lg":"text-xl"} font-semibold text-gray-900 dark:text-white`,children:s(p?"mcp.modal.editTitle":"mcp.modal.addTitle")}),e.jsxs("div",{className:`flex ${l?"w-full space-x-2":"space-x-3"}`,children:[e.jsx("button",{type:"button",onClick:oe,disabled:S,className:`${l?"flex-1 px-3 py-2 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50`,children:s("common:actions.cancel")}),e.jsx("button",{type:"submit",form:"mcp-config-form",disabled:S||!o.name.trim()||!A(o.config,o.type),className:`${l?"flex-1 px-3 py-2 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:s(S?"mcp.modal.saving":p?"mcp.modal.saveConfig":"mcp.modal.addConfig")})]})]}),e.jsx("form",{id:"mcp-config-form",onSubmit:ne,children:e.jsxs("div",{className:`${l?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("mcp.form.serverName")}),e.jsx("input",{type:"text",value:o.name,onChange:t=>y({...o,name:t.target.value}),placeholder:s("mcp.form.serverNamePlaceholder"),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${l?"text-sm":""}`,required:!0,disabled:!!p}),p&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:s("mcp.form.nameNotEditable")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("mcp.form.mcpType")}),e.jsxs("select",{value:o.type,onChange:t=>{const r=t.target.value;y({...o,type:r,config:r==="stdio"?`{
3
+ "type": "stdio",
4
+ "command": "npx",
5
+ "args": [
6
+ "-y",
7
+ "@playwright/mcp@latest",
8
+ "--extension"
9
+ ],
10
+ "timeout": 6000,
11
+ "autoApprove": [
12
+ "interactive_feedback"
13
+ ]
14
+ }`:`{
15
+ "type": "http",
16
+ "url": "http://127.0.0.1:3845/mcp",
17
+ "timeout": 6000,
18
+ "autoApprove": [
19
+ "interactive_feedback"
20
+ ]
21
+ }`})},className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${l?"text-sm":""}`,required:!0,children:[e.jsx("option",{value:"stdio",children:s("mcp.form.stdioOption")}),e.jsx("option",{value:"http",children:s("mcp.form.httpOption")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:s("mcp.form.selectConnectionType")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("mcp.form.configuration")}),e.jsx("textarea",{value:o.config,onChange:t=>y({...o,config:t.target.value}),placeholder:o.type==="stdio"?`{
22
+ "type": "stdio",
23
+ "command": "npx",
24
+ "args": [
25
+ "-y",
26
+ "@playwright/mcp@latest",
27
+ "--extension"
28
+ ],
29
+ "timeout": 6000,
30
+ "autoApprove": [
31
+ "interactive_feedback"
32
+ ]
33
+ }`:`{
34
+ "type": "http",
35
+ "url": "http://127.0.0.1:3845/mcp",
36
+ "timeout": 6000,
37
+ "autoApprove": [
38
+ "interactive_feedback"
39
+ ]
40
+ }`,rows:l?10:15,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm dark:bg-gray-700 dark:text-white ${l?"text-xs":""}`,required:!0}),o.config&&!A(o.config,o.type)&&e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:s("mcp.form.configFormatError",{fields:o.type==="stdio"?s("mcp.form.requiredFieldsStdio"):s("mcp.form.requiredFieldsHttp")})}),e.jsxs("div",{className:`mt-2 text-xs text-gray-500 dark:text-gray-400 ${l?"text-xs":""}`,children:[e.jsx("p",{children:e.jsx("strong",{children:s("mcp.form.requiredFields")})}),e.jsxs("ul",{className:"list-disc ml-4 mt-1",children:[e.jsxs("li",{children:[e.jsx("code",{children:"type"}),": ",s("mcp.form.typeField")]}),o.type==="stdio"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:[e.jsx("code",{children:"command"}),": ",s("mcp.form.commandField")]}),e.jsxs("li",{children:[e.jsx("code",{children:"args"}),": ",s("mcp.form.argsField")]})]}):e.jsxs("li",{children:[e.jsx("code",{children:"url"}),": ",s("mcp.form.urlField")]})]}),e.jsx("p",{className:"mt-2",children:e.jsx("strong",{children:s("mcp.form.optionalFields")})}),e.jsxs("ul",{className:"list-disc ml-4 mt-1",children:[e.jsxs("li",{children:[e.jsx("code",{children:"timeout"}),": ",s("mcp.form.timeoutField")]}),e.jsxs("li",{children:[e.jsx("code",{children:"autoApprove"}),": ",s("mcp.form.autoApproveField")]})]})]})]})]})})]})})})]})};export{Te as McpPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as a}from"./monaco-editor-DHKm5-VF.js";import{a as m,A as g}from"./agents-ChrA1R0y.js";import{a as h,b as p}from"./index-Bn3v3S9-.js";import{u as b}from"./tools-IcPNZlPj.js";import{u as f,e as j,y as u,z as k}from"./ui-components-D1St49qC.js";import"./syntax-highlighting-CnREyncB.js";const F=()=>{const{t:s}=b("pages"),[r,l]=a.useState(""),[o,i]=a.useState(!1),[n,d]=a.useState(!1);a.useEffect(()=>{c()},[]);const c=async()=>{d(!0);try{const t=await m(`${g}/settings/global-memory`);if(t.ok){const y=await t.text();l(y)}}catch(t){console.error("Failed to load global memory:",t)}finally{d(!1)}},x=async()=>{try{if((await m(`${g}/settings/global-memory`,{method:"POST",headers:{"Content-Type":"text/plain"},body:r})).ok)i(!1),h(s("settings.memorySettings.saveSuccess"));else throw new Error("Failed to save")}catch(t){console.error("Failed to save global memory:",t),p(s("settings.memorySettings.saveFailed"))}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:s("settings.memorySettings.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.memorySettings.description")})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("settings.memorySettings.fileSourceInfo")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"block font-medium text-gray-900 dark:text-white",children:s("settings.memorySettings.memoryContent")}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs("button",{onClick:()=>i(!o),className:"flex items-center space-x-1 px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsx(f,{className:"w-4 h-4"}),e.jsx("span",{children:s(o?"settings.memorySettings.cancelEdit":"settings.memorySettings.edit")})]}),e.jsxs("button",{onClick:c,disabled:n,className:"flex items-center space-x-1 px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 disabled:opacity-50",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsx("span",{children:s(n?"settings.memorySettings.refreshing":"settings.memorySettings.refresh")})]})]})]}),o?e.jsxs("div",{className:"space-y-3",children:[e.jsx("textarea",{value:r,onChange:t=>l(t.target.value),rows:20,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm",placeholder:s("settings.memorySettings.placeholder")}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx("button",{onClick:()=>i(!1),className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-300",children:s("settings.memorySettings.cancel")}),e.jsxs("button",{onClick:x,className:"flex items-center space-x-1 px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(u,{className:"w-4 h-4"}),e.jsx("span",{children:s("settings.memorySettings.saveMemory")})]})]})]}):e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 bg-gray-50 dark:bg-gray-700/50 min-h-[300px]",children:n?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:s("settings.memorySettings.loading")})}):r?e.jsx("pre",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap font-mono",children:r}):e.jsx("div",{className:"flex items-center justify-center h-64 text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-12 h-12 mx-auto mb-3 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:s("settings.memorySettings.noMemory")}),e.jsx("p",{className:"text-xs mt-1",children:s("settings.memorySettings.clickEditToStart")})]})})}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 space-y-1",children:[e.jsxs("p",{children:["• ",s("settings.memorySettings.infoAutoLoad")]}),e.jsxs("p",{children:["• ",s("settings.memorySettings.infoSuggestions")]}),e.jsxs("p",{children:["• ",s("settings.memorySettings.infoFileLocation")]})]})]})]})})]})};export{F as MemorySettingsPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o,W as A}from"./monaco-editor-DHKm5-VF.js";import{u as Z,b as D,c as E,a as w,A as N}from"./agents-ChrA1R0y.js";import{b as P,a as T,s as H,u as z}from"./index-Bn3v3S9-.js";import{u as F}from"./tools-IcPNZlPj.js";import{c as de,B as v}from"./Button-Co56C389.js";import{aD as I,aE as K,f as q,g as X,p as J,R as oe,v as _,X as ue,E as Y,e as me,I as xe,aF as ge,Z as pe,$ as he,o as ye,aG as be,C as fe,ab as je}from"./ui-components-D1St49qC.js";import{F as ve}from"./FileExplorer-DNYj6Tsx.js";import"./syntax-highlighting-CnREyncB.js";const ee=o.createContext(void 0),se=()=>{const s=o.useContext(ee);if(!s)throw new Error("Tabs compound components must be used within Tabs");return s},ae=o.forwardRef(({value:s,onValueChange:a,defaultValue:l,className:i,children:n},r)=>{const[p,m]=o.useState(s||l||"");o.useEffect(()=>{s!==void 0&&m(s)},[s]);const y=o.useCallback(t=>{m(t),a?.(t)},[a]);return e.jsx(ee.Provider,{value:{value:p,onValueChange:y},children:e.jsx("div",{ref:r,className:i,children:n})})});ae.displayName="Tabs";const te=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`inline-flex h-10 items-center justify-center rounded-md bg-gray-100 dark:bg-gray-800 p-1 text-gray-500 dark:text-gray-400 ${s||""}`,...l,children:a}));te.displayName="TabsList";const Q=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r,onValueChange:p}=se(),m=r===a;return e.jsx("button",{ref:n,type:"button",role:"tab","aria-selected":m,onClick:()=>p?.(a),className:`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${m?"bg-white dark:bg-gray-950 text-gray-950 dark:text-gray-50 shadow-sm":"hover:bg-gray-200/50 dark:hover:bg-gray-700/50"} ${s||""}`,...i,children:l})});Q.displayName="TabsTrigger";const V=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r}=se();return r!==a?null:e.jsx("div",{ref:n,role:"tabpanel",className:`mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 ${s||""}`,...i,children:l})});V.displayName="TabsContent";const ke=()=>{const s=Z(),{t:a}=F("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugin-marketplaces"],queryFn:async()=>{const t=await w(`${N}/plugins/marketplaces`);if(!t.ok)throw new Error("Failed to fetch marketplaces");return(await t.json()).marketplaces}}),p=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to add marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceAddSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceAddError"),t.message)}}),m=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}/sync`,{method:"POST"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to sync marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceSyncSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceSyncError"),t.message)}}),y=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}`,{method:"DELETE"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to remove marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.marketplaceRemoveSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceRemoveError"),t.message)}});return{marketplaces:l,isLoading:i,error:n,refetch:r,addMarketplace:p.mutate,isAddingMarketplace:p.isPending,syncMarketplace:m.mutate,isSyncingMarketplace:m.isPending,removeMarketplace:y.mutate,isRemovingMarketplace:y.isPending}},we=()=>{const s=Z(),{t:a}=F("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugins-available"],queryFn:async()=>{const g=await w(`${N}/plugins/available`);if(!g.ok)throw new Error("Failed to fetch available plugins");return(await g.json()).plugins}}),{data:p=[],isLoading:m,error:y,refetch:t}=D({queryKey:["plugins-installed"],queryFn:async()=>{const g=await w(`${N}/plugins/installed`);if(!g.ok)throw new Error("Failed to fetch installed plugins");return(await g.json()).plugins}}),u=E({mutationFn:async g=>{const f=await w(`${N}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!f.ok){const b=await f.json();throw new Error(b.error||"Failed to install plugin")}return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.installSuccess"))},onError:g=>{P(a("plugins.messages.installError"),g.message)}}),h=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/enable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to enable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.enableSuccess"))},onError:g=>{P(a("plugins.messages.enableError"),g.message)}}),S=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/disable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to disable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.disableSuccess"))},onError:g=>{P(a("plugins.messages.disableError"),g.message)}}),j=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}`,{method:"DELETE"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to uninstall plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.uninstallSuccess"))},onError:g=>{P(a("plugins.messages.uninstallError"),g.message)}});return{availablePlugins:l,isLoadingAvailable:i,availableError:n,refetchAvailable:r,installedPlugins:p,isLoadingInstalled:m,installedError:y,refetchInstalled:t,installPlugin:u.mutate,isInstallingPlugin:u.isPending,enablePlugin:h.mutate,isEnablingPlugin:h.isPending,disablePlugin:S.mutate,isDisablingPlugin:S.isPending,uninstallPlugin:j.mutate,isUninstallingPlugin:j.isPending}},Ne=(s,a)=>D({queryKey:["plugin-detail",s,a],queryFn:async()=>{if(!s||!a)return null;const l=await w(`${N}/plugins/${s}/${a}`);if(!l.ok)throw new Error("Failed to fetch plugin details");return await l.json()},enabled:!!s&&!!a}),Se=(s,a,l)=>D({queryKey:["plugin-file-content",s,a,l],queryFn:async()=>{if(!s||!a||!l)return null;const i=await w(`${N}/plugins/${s}/${a}/files/${l}`);if(!i.ok)throw new Error("Failed to fetch file content");return await i.json()},enabled:!!s&&!!a&&!!l}),M=A.forwardRef(({className:s,type:a,...l},i)=>e.jsx("input",{type:a,className:de("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:i,...l}));M.displayName="Input";const $=o.forwardRef(({className:s,...a},l)=>e.jsx("label",{ref:l,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${s||""}`,...a}));$.displayName="Label";const re=({open:s,onOpenChange:a,children:l})=>(o.useEffect(()=>{const i=n=>{n.key==="Escape"&&s&&a&&a(!1)};return s&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[s,a]),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>a&&a(!1)}),e.jsx("div",{className:"relative z-50 w-full flex items-center justify-center",children:l})]}):null),O=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 ${s||""}`,...l,children:a}));O.displayName="DialogContent";const le=({className:s,children:a,...l})=>e.jsx("div",{className:`mb-4 ${s||""}`,...l,children:a}),B=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("h2",{ref:i,className:`text-lg font-semibold text-gray-900 dark:text-white ${s||""}`,...l,children:a}));B.displayName="DialogTitle";const Ce=({className:s,children:a,...l})=>e.jsx("div",{className:`flex justify-end space-x-2 ${s||""}`,...l,children:a}),G=o.forwardRef(({children:s,value:a,onValueChange:l,...i},n)=>{const[r,p]=o.useState(!1),[m,y]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&y(a)},[a]);const t=u=>{y(u),l&&l(u),p(!1)};return e.jsx("div",{ref:n,className:"relative",...i,children:o.Children.map(s,u=>o.isValidElement(u)?o.cloneElement(u,{selectedValue:m,isOpen:r,setIsOpen:p,onSelect:t}):u)})});G.displayName="Select";const U=o.forwardRef(({children:s,selectedValue:a,isOpen:l,setIsOpen:i,className:n,...r},p)=>e.jsxs("button",{ref:p,type:"button",onClick:()=>i&&i(!l),className:`flex h-10 w-full items-center justify-between rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 ${n||""}`,...r,children:[e.jsx("div",{className:"flex-1 text-left flex items-center",children:s}),e.jsx("svg",{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}));U.displayName="SelectTrigger";const ne=o.forwardRef(({placeholder:s,selectedValue:a,children:l},i)=>l?e.jsx("span",{ref:i,children:l}):e.jsx("span",{ref:i,children:a||s}));ne.displayName="SelectValue";const W=o.forwardRef(({children:s,isOpen:a,onSelect:l,...i},n)=>a?e.jsx("div",{ref:n,className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-lg",...i,children:o.Children.map(s,r=>o.isValidElement(r)?o.cloneElement(r,{onSelect:l}):r)}):null);W.displayName="SelectContent";const L=o.forwardRef(({value:s,children:a,onSelect:l,...i},n)=>e.jsx("div",{ref:n,onClick:()=>l&&l(s),className:"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100",...i,children:a}));L.displayName="SelectItem";const Ee=({isOpen:s,onClose:a,onAdd:l,isAdding:i})=>{const{t:n}=F("pages"),[r,p]=o.useState({name:"",type:"github",source:"",description:"",branch:"main"}),m=t=>{t.preventDefault(),l(r),y()},y=()=>{p({name:"",type:"github",source:"",description:"",branch:"main"}),a()};return e.jsx(re,{open:s,onOpenChange:y,children:e.jsxs(O,{className:"max-w-[600px] w-full max-h-[90vh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(B,{children:n("plugins.marketplaces.addModal.title")})}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx($,{htmlFor:"name",children:n("plugins.marketplaces.addModal.name")}),e.jsx(M,{id:"name",value:r.name,onChange:t=>p({...r,name:t.target.value}),placeholder:n("plugins.marketplaces.addModal.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"type",children:n("plugins.marketplaces.addModal.type")}),e.jsxs(G,{value:r.type,onValueChange:t=>p({...r,type:t}),children:[e.jsx(U,{children:e.jsxs("div",{className:"flex items-center space-x-2",children:[r.type==="github"&&e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]}),r.type==="git"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]}),r.type==="local"&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})]})}),e.jsxs(W,{children:[e.jsx(L,{value:"github",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]})}),e.jsx(L,{value:"git",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]})}),e.jsx(L,{value:"local",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})})]})]})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"source",children:n("plugins.marketplaces.addModal.source")}),e.jsx(M,{id:"source",value:r.source,onChange:t=>p({...r,source:t.target.value}),placeholder:r.type==="local"?n("plugins.marketplaces.addModal.sourcePlaceholderLocal"):r.type==="github"?n("plugins.marketplaces.addModal.sourcePlaceholderGithub"):n("plugins.marketplaces.addModal.sourcePlaceholderGit"),required:!0})]}),(r.type==="git"||r.type==="github")&&e.jsxs("div",{children:[e.jsx($,{htmlFor:"branch",children:n("plugins.marketplaces.addModal.branch")}),e.jsx(M,{id:"branch",value:r.branch,onChange:t=>p({...r,branch:t.target.value}),placeholder:n("plugins.marketplaces.addModal.branchPlaceholder")})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"description",children:n("plugins.marketplaces.addModal.description")}),e.jsx(M,{id:"description",value:r.description,onChange:t=>p({...r,description:t.target.value}),placeholder:n("plugins.marketplaces.addModal.descriptionPlaceholder")})]})]}),e.jsxs(Ce,{className:"mt-6",children:[e.jsx(v,{type:"button",variant:"outline",onClick:y,disabled:i,children:n("plugins.marketplaces.addModal.cancel")}),e.jsx(v,{type:"submit",disabled:i,children:n(i?"plugins.marketplaces.addModal.adding":"plugins.marketplaces.addModal.add")})]})]})]})})},Pe=({marketplaces:s,isLoading:a,onAddMarketplace:l,isAdding:i,onSyncMarketplace:n,isSyncing:r,onRemoveMarketplace:p,isRemoving:m,onMarketplaceClick:y})=>{const{t}=F("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(!1),f=s.filter(x=>x.displayName.toLowerCase().includes(h.toLowerCase())||x.source.toLowerCase().includes(h.toLowerCase())),b=(x,C)=>{window.confirm(t("plugins.marketplaces.confirmDelete",{name:C}))&&p(x)};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center justify-between"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(X,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.marketplaces.searchPlaceholder"),value:h,onChange:x=>S(x.target.value),className:"pl-10"})]}),e.jsxs(v,{onClick:()=>g(!0),className:u?"w-full":"",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}),f.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t(h?"plugins.marketplaces.noResults":"plugins.marketplaces.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t("plugins.marketplaces.addFirst")}),!h&&e.jsxs(v,{onClick:()=>g(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}):e.jsx("div",{className:"space-y-4",children:f.map(x=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>y?.(x.id),children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400",children:x.displayName}),e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 flex items-center space-x-1",children:[x.type==="github"&&e.jsx(I,{className:"w-3 h-3"}),x.type==="git"&&e.jsx(K,{className:"w-3 h-3"}),x.type==="local"&&e.jsx(q,{className:"w-3 h-3"}),e.jsx("span",{children:t(`plugins.marketplaces.types.${x.type}`)})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:x.source}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[x.pluginCount," plugins"]}),x.lastSync&&e.jsxs("span",{children:["Last sync: ",new Date(x.lastSync).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>n(x.id),disabled:r,className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",title:t("plugins.marketplaces.actions.sync"),children:e.jsx(oe,{className:`w-4 h-4 text-green-600 dark:text-green-400 ${r?"animate-spin":""}`})}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>b(x.id,x.displayName),disabled:m,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",title:t("plugins.marketplaces.actions.delete"),children:e.jsx(_,{className:"w-4 h-4 text-red-600 dark:text-red-400"})})]})]})},x.id))}),e.jsx(Ee,{isOpen:j,onClose:()=>g(!1),onAdd:l,isAdding:i})]})},Me=({isOpen:s,onClose:a,marketplaceName:l,pluginName:i})=>{const{t:n}=F("pages"),{data:r,isLoading:p}=Ne(s?l:null,s?i:null),[m,y]=o.useState("overview");A.useEffect(()=>{r&&console.log("Plugin Detail Data:",r)},[r]);const[t,u]=o.useState(null),[h,S]=o.useState(null),{data:j}=Se(t?l:null,t?i:null,t),g=d=>{u(d.relativePath),y("file")},f=d=>{const c=d.relativePath.includes("/")?d.relativePath.substring(0,d.relativePath.lastIndexOf("/")):"";S(c),y("directory")},b=()=>{y("overview"),u(null),S(null)},x=d=>{switch(d){case"command":return e.jsx(ye,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"});case"agent":return e.jsx(he,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"});case"skill":return e.jsx(pe,{className:"w-4 h-4 text-green-600 dark:text-green-400"});case"hook":return e.jsx(ge,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"});case"mcp":return e.jsx(xe,{className:"w-4 h-4 text-red-600 dark:text-red-400"});default:return e.jsx(me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}},C=d=>{const c=`plugins.detail.componentTypes.${d}`;return n(c,{defaultValue:d})};if(!s)return null;const k=[];return r?.components&&(r.components.commands?.forEach(d=>k.push({...d,typeLabel:"command"})),r.components.agents?.forEach(d=>k.push({...d,typeLabel:"agent"})),r.components.skills?.forEach(d=>k.push({...d,typeLabel:"skill"})),r.components.hooks?.forEach(d=>k.push({...d,typeLabel:"hook"})),r.components.mcpServers?.forEach(d=>k.push({...d,typeLabel:"mcp"}))),e.jsx(re,{open:s,onOpenChange:a,children:e.jsxs(O,{className:"max-w-[1200px] w-full h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{children:[m==="overview"&&(r?.manifest?.name||i),m==="file"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:t})]}),m==="directory"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:h||n("plugins.detail.root")})]})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:a,children:e.jsx(ue,{className:"w-4 h-4"})})]})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})}):r?e.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[m==="overview"&&e.jsxs("div",{className:"h-full overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:r?.manifest?.name||i}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r?.manifest?.description||r?.plugin?.manifest?.description||n("plugins.detail.noDescription")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.version")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.version||r?.plugin?.manifest?.version||"-"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.author")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:(()=>{const d=r?.manifest?.author||r?.plugin?.manifest?.author;return d?typeof d=="string"?d:d.name:"-"})()})]}),(r?.manifest?.license||r?.plugin?.manifest?.license)&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.license")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.license||r?.plugin?.manifest?.license})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:[n("plugins.detail.components")," (",k.length,")"]}),k.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.type")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.name")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.description")}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:k.map((d,c)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[x(d.type),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:C(d.type)})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-white",children:d.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.description||"-"})}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>g(d),title:n("plugins.detail.viewEntryFile"),className:"text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:e.jsx(Y,{className:"w-4 h-4"})}),d.type==="skill"&&e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>f(d),title:n("plugins.detail.browseDirectory"),className:"text-purple-600 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/30",children:e.jsx(q,{className:"w-4 h-4"})})]})]},c))})]})}):e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("plugins.detail.noComponents")})]})]}),m==="file"&&e.jsx("div",{className:"h-full overflow-y-auto p-6",children:j?e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 p-4 rounded-lg font-mono",children:j.content}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})}),m==="directory"&&r?.plugin?.installPath&&e.jsx(ve,{projectPath:h?`${r.plugin.installPath}/${h}`:r.plugin.installPath,onFileSelect:d=>{console.log("Selected file:",d)},className:"h-full"})]}):e.jsx("div",{className:"text-center py-12 text-gray-500",children:n("plugins.detail.loadFailed")})]})})},Fe=({plugins:s,isLoading:a,marketplaces:l,onInstallPlugin:i,isInstalling:n,onUninstallPlugin:r,isUninstalling:p,selectedMarketplace:m,onMarketplaceChange:y})=>{const{t}=F("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(null),[f,b]=o.useState(!1),x=s.filter(c=>{const R=c.name.toLowerCase().includes(h.toLowerCase())||c.description.toLowerCase().includes(h.toLowerCase()),ie=!m||c.marketplaceId===m,ce=!f||c.installed;return R&&ie&&ce}),C=A.useMemo(()=>m?l.find(R=>R.id===m)?.displayName||m:t("plugins.browse.filters.allMarketplaces"),[m,l,t]),k=c=>{i({pluginName:c.name,marketplaceName:c.marketplaceName,marketplaceId:c.marketplaceId})},d=c=>{window.confirm(t("plugins.browse.confirmUninstall",{name:c.name}))&&r({marketplaceName:c.marketplaceName,pluginName:c.name})};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):l.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.goAddMarketplace")})]}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center gap-4"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(X,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.browse.searchPlaceholder"),value:h,onChange:c=>S(c.target.value),className:"pl-10"})]}),e.jsx("div",{className:`${u?"":"w-64"}`,children:e.jsxs(G,{value:m??"all",onValueChange:c=>y(c==="all"?null:c),children:[e.jsx(U,{className:"text-gray-900 dark:text-gray-100",children:e.jsx(ne,{children:C})}),e.jsxs(W,{children:[e.jsx(L,{value:"all",children:t("plugins.browse.filters.allMarketplaces")}),l.map(c=>e.jsx(L,{value:c.id,children:c.displayName},c.id))]})]})}),e.jsxs("div",{className:" flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"showOnlyInstalled",checked:f,onChange:c=>b(c.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsx("label",{htmlFor:"showOnlyInstalled",className:"text-sm font-medium text-gray-900 dark:text-gray-300 cursor-pointer whitespace-nowrap",children:t("plugins.browse.filters.showOnlyInstalled")})]})]}),x.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noResults")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.adjustSearch")})]}):e.jsx("div",{className:"space-y-4",children:x.map(c=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx(be,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.name}),c.installed&&e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300 flex items-center space-x-1",children:[e.jsx(fe,{className:"w-3 h-3"}),e.jsx("span",{children:t("plugins.browse.card.installed")})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[t("plugins.browse.card.from")," ",c.marketplace]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.card.version",{version:c.version})}),c.components.commands>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.commands",{count:c.components.commands})})]}),c.components.skills>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.skills",{count:c.components.skills})})]}),c.components.agents>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.agents",{count:c.components.agents})})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>g({marketplace:c.marketplaceName,name:c.name}),className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx(Y,{className:"w-4 h-4 mr-1 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("plugins.browse.actions.details")})]}),c.installed?e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>d(c),disabled:p,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",children:[e.jsx(_,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"ml-1 text-red-600 dark:text-red-400",children:t("plugins.browse.actions.uninstall")})]}):e.jsxs(v,{variant:"outline",size:"sm",disabled:n,onClick:()=>k(c),className:"border-blue-300 dark:border-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:[e.jsx(je,{className:"w-4 h-4 mr-1 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:t("plugins.browse.actions.install")})]})]})]})},`${c.name}@${c.marketplace}`))}),j&&e.jsx(Me,{isOpen:!!j,onClose:()=>g(null),marketplaceName:j.marketplace,pluginName:j.name})]})},Ve=()=>{const{t:s}=F("pages"),{isMobile:a}=z(),[l,i]=o.useState("marketplaces"),[n,r]=o.useState(null),p=c=>{r(c),i("browse")},{marketplaces:m,isLoading:y,addMarketplace:t,isAddingMarketplace:u,syncMarketplace:h,isSyncingMarketplace:S,removeMarketplace:j,isRemovingMarketplace:g}=ke(),{availablePlugins:f,isLoadingAvailable:b,installPlugin:x,isInstallingPlugin:C,uninstallPlugin:k,isUninstallingPlugin:d}=we();return e.jsxs("div",{className:`${a?"p-4":"p-8"}`,children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("plugins.title")}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:s("plugins.subtitle")})]}),e.jsxs(ae,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(te,{className:`grid w-full ${a?"grid-cols-2":"grid-cols-2 max-w-xl"}`,children:[e.jsx(Q,{value:"marketplaces",children:s("plugins.tabs.marketplaces")}),e.jsx(Q,{value:"browse",children:s("plugins.tabs.browse")})]}),e.jsx(V,{value:"marketplaces",className:"mt-6",children:e.jsx(Pe,{marketplaces:m,isLoading:y,onAddMarketplace:t,isAdding:u,onSyncMarketplace:h,isSyncing:S,onRemoveMarketplace:j,isRemoving:g,onMarketplaceClick:p})}),e.jsx(V,{value:"browse",className:"mt-6",children:e.jsx(Fe,{plugins:f,isLoading:b,marketplaces:m,onInstallPlugin:x,isInstalling:C,onUninstallPlugin:k,isUninstalling:d,selectedMarketplace:n,onMarketplaceChange:r})})]})]})};export{Ve as PluginsPage,Ve as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as x}from"./monaco-editor-DHKm5-VF.js";import{u as X,a as D,A as F}from"./agents-ChrA1R0y.js";import{u as Y,a as G,b as H}from"./useAgents-BnDTkOG8.js";import{F as v}from"./FileBrowser-BYweUPH4.js";import{b as S}from"./index-Bn3v3S9-.js";import{u as E}from"./tools-IcPNZlPj.js";import{X as I,V as A,g as J,Y as M}from"./ui-components-D1St49qC.js";const ie=({agent:s,onProjectSelect:c,onClose:g})=>{const{t:r}=E("components"),[l,j]=x.useState(!1),[f,d]=x.useState(!1),[$,u]=x.useState(!1),[B,b]=x.useState(!1),[P,w]=x.useState(""),[q,N]=x.useState(!1),C=Y(),z=G(),k=X(),{data:L,isLoading:Q}=H(s.id),p=L?.projects||[],R=async()=>{j(!0);try{const t=s.id.replace(/[-_]/g,"-"),a=new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),i=`${t}-project-${a}`,m=await C.mutateAsync({agentId:s.id,projectName:i});await k.invalidateQueries({queryKey:["agent-projects",s.id]}),c(m.project.path)}catch(t){console.error("Failed to create project:",t),S(r("projectSelector.createProjectFailed",{error:""}),t instanceof Error?t.message:r("projectSelector.unknownError"))}finally{j(!1)}},K=()=>{u(!0)},T=(t,a)=>{a&&(w(t),u(!1),N(!0))},U=async t=>{j(!0);try{const a=t,i=await C.mutateAsync({agentId:s.id,projectName:a,parentDirectory:P||void 0});await k.invalidateQueries({queryKey:["agent-projects",s.id]}),c(i.project.path)}catch(a){console.error("Failed to create project:",a),S(r("projectSelector.createProjectFailed",{error:""}),a instanceof Error?a.message:r("projectSelector.unknownError"))}finally{j(!1),N(!1),w("")}},W=()=>{d(!0)},_=async(t,a)=>{if(a){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===s.id)&&(n=!0)}catch{}if(console.log("Import path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),n)c(t),b(!1);else if(window.confirm(r("projectSelector.importConfirmation",{agentName:s.name,path:t})))try{await z.mutateAsync({agentId:s.id,projectPath:t}),await k.invalidateQueries({queryKey:["agent-projects",s.id]}),c(t),b(!1)}catch(h){console.error("Failed to import project:",h),S(r("projectSelector.importProjectFailed",{error:""}),h instanceof Error?h.message:r("projectSelector.unknownError"))}}},O=async(t,a)=>{if(a){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===s.id)&&(n=!0)}catch{}console.log("Path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),(n||window.confirm(r("projectSelector.importConfirmation",{agentName:s.name,path:t})))&&(c(t),d(!1))}};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"text-2xl",children:s.ui.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:r("projectSelector.selectProjectDirectory")})]})]}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 flex-shrink-0",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col md:flex-row",children:[e.jsxs("div",{className:"w-full md:w-1/2 p-6 md:border-r border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.projectActions")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:R,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-primary/40 dark:border-primary/60 rounded-lg hover:bg-primary/5 dark:hover:bg-primary/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:`w-6 h-6 ${l?"text-gray-400 dark:text-gray-500":"text-primary"}`})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r(l?"projectSelector.creatingProject":"projectSelector.quickCreateProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.quickCreateDescription")})]})]}),e.jsxs("button",{onClick:K,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.customLocationCreate")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.customLocationDescription")})]})]}),e.jsxs("button",{onClick:W,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(J,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.browseProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.browseDescription")})]})]})]})]}),e.jsxs("div",{className:"w-full md:w-1/2 p-6 flex flex-col min-h-[300px] md:min-h-0",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.recentProjects")}),Q?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-blue-600 dark:border-t-blue-500 rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-sm",children:r("projectSelector.loadingProjects")})]})}):p.length>0?e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{className:"space-y-2 max-h-full overflow-y-auto",children:p.map((t,a)=>e.jsxs("button",{onClick:()=>c(t.path),className:"w-full flex items-center space-x-3 p-4 border border-gray-100 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left",children:[e.jsx("div",{className:"w-5 h-5 flex-shrink-0 text-xl text-primary",children:t.defaultAgentIcon||"📁"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:t.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:t.path}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.lastAccessed",{date:new Date(t.lastAccessed).toLocaleString()})})]})]},t.id||a))})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx(M,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-3"}),e.jsx("p",{className:"text-base font-medium",children:r("projectSelector.noRecentProjects")}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.createProjectToStart")})]})})]})]}),e.jsx("div",{className:"flex justify-end p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsx("button",{onClick:g,className:"px-6 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.cancel")})})]}),f&&e.jsx(v,{title:r("projectSelector.selectProjectDirectory"),allowFiles:!1,allowDirectories:!0,onSelect:O,onClose:()=>d(!1)}),$&&e.jsx(v,{title:r("projectSelector.selectParentDirectory"),allowFiles:!1,allowDirectories:!0,allowNewDirectory:!0,onSelect:T,onClose:()=>u(!1)}),B&&e.jsx(v,{title:r("projectSelector.importProject"),allowFiles:!1,allowDirectories:!0,onSelect:_,onClose:()=>b(!1)}),q&&e.jsx(Z,{parentDirectory:P,onConfirm:U,onCancel:()=>{N(!1),w("")}})]})},Z=({parentDirectory:s,onConfirm:c,onCancel:g})=>{const{t:r}=E("components"),[l,j]=x.useState(""),f=d=>{d.preventDefault(),l.trim()&&c(l.trim())};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectSelector.dialog.createNewProject")}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:r("projectSelector.dialog.projectWillBeCreatedAt")}),e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-700 rounded text-sm font-mono text-gray-800 dark:text-gray-200 break-all",children:s})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"projectName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectSelector.dialog.projectName")}),e.jsx("input",{id:"projectName",type:"text",value:l,onChange:d=>j(d.target.value),placeholder:r("projectSelector.dialog.projectNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent",autoFocus:!0,required:!0})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.dialog.cancel")}),e.jsx("button",{type:"submit",disabled:!l.trim(),className:"px-4 py-2 text-sm bg-blue-600 dark:bg-blue-500 text-white rounded-lg hover:bg-blue-700 dark:hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("projectSelector.dialog.createProject")})]})]})]})})};export{ie as P};
@@ -0,0 +1,21 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{a as $,A as P}from"./agents-ChrA1R0y.js";import{a as ee,b as z,u as Ie}from"./index-Bn3v3S9-.js";import{f as xe}from"./dateFormat-CXa8VnEC.js";import{u as le}from"./tools-IcPNZlPj.js";import{z as Te,al as Ee,$ as te,U as ie,v as Z,aw as De,k as rt,Y as Me,ax as Fe,D as Ce,e as st,X as q,j as me,y as nt,T as lt,g as Se,p as ge,o as Ke,r as be,m as Ae,u as ue,K as de,A as we,t as oe,ak as ce,J as dt,E as ot,ay as ve,az as ct,aA as it,a2 as xt,f as mt}from"./ui-components-D1St49qC.js";import{c as gt}from"./useAgents-BnDTkOG8.js";import{F as Ue}from"./FileBrowser-BYweUPH4.js";import{T as Re,a as Le,b as je,c as Q,d as ze,e as X}from"./table-D0L2RL5i.js";import{f as ht,g as pt}from"./useCommands-mvMu3mMD.js";import{C as yt}from"./CommandForm-Bk7F_HU8.js";import{g as fe}from"./UnifiedToolSelector-CNbPsiuq.js";import{b as bt,c as ut,S as jt}from"./SubagentForm-BdUK1U4y.js";import{u as ft}from"./useProjects-YXOjaOwL.js";import"./syntax-highlighting-CnREyncB.js";const Nt=({projects:l,agents:T,onOpenProject:t,onMemoryManagement:s,onCommandManagement:u,onSubAgentManagement:y,onA2AManagement:k,onDeleteProject:p,onAgentChanged:C,className:m=""})=>{const{t:g}=le("pages"),[f,c]=i.useState(null),E=async(r,w)=>{if(w!==r.defaultAgent)try{c(r.id);const x=await $(`${P}/projects/${encodeURIComponent(r.path)}/default-agent`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:w})});if(x.ok){const j=T.find(K=>K.id===w);j&&C&&C(r.id,j),ee("助手切换成功")}else{const j=await x.json();throw new Error(j.error||"切换助手失败")}}catch(x){console.error("Failed to change agent:",x),z("切换助手失败",x instanceof Error?x.message:"未知错误")}finally{c(null)}},O=(r,w=!1)=>e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>t(r),className:`text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:underline cursor-pointer text-left truncate ${w?"text-base":""}`,children:r.name}),e.jsx("button",{onClick:()=>t(r),className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors flex-shrink-0",title:g("projects.actions.open"),children:e.jsx(De,{className:"w-3 h-3"})})]}),r.description&&e.jsx("div",{className:`text-gray-500 dark:text-gray-400 truncate ${w?"text-sm mt-1":"text-sm max-w-xs"}`,children:r.description})]}),I=r=>{const w=T.filter(j=>j.enabled),x=f===r.id;return e.jsxs("div",{className:"relative inline-block",onClick:j=>j.stopPropagation(),children:[e.jsx("select",{value:r.defaultAgent,onChange:j=>E(r,j.target.value),disabled:x,className:"appearance-none bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 rounded-md px-3 py-1.5 pr-8 text-xs font-medium cursor-pointer border border-gray-200 dark:border-gray-600 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",title:"切换助手",children:w.map(j=>e.jsxs("option",{value:j.id,className:"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:[j.ui.icon," ",j.name]},j.id))}),e.jsx(rt,{className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-3 h-3 text-gray-400 dark:text-gray-300 pointer-events-none"})]})},U=r=>e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(Me,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",title:r.path,children:r.path})]}),S=(r,w)=>e.jsxs("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400",children:[w,e.jsx("span",{children:xe(r)})]}),L=r=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx("button",{onClick:()=>s(r),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Te,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(r),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Ee,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>y(r),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(te,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>k(r),className:"p-1.5 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>p(r),className:"p-1.5 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]});return e.jsxs("div",{className:`space-y-4 ${m}`,children:[e.jsx("div",{className:"md:hidden space-y-4",children:l.map(r=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"p-4 cursor-pointer",onClick:()=>t(r),children:e.jsx("div",{className:"flex items-start space-x-3",children:O(r,!0)})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 text-sm mb-3 px-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.agent"),":"]}),e.jsx("div",{children:I(r)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.lastActive"),":"]}),e.jsx("div",{className:"text-right",children:S(r.lastAccessed,e.jsx(Fe,{className:"w-4 h-4"}))})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("common:path"),":"]}),e.jsx("div",{className:"text-right text-xs truncate ml-2 max-w-[200px]",children:r.path})]})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:g("projects.table.actions")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>s(r),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Te,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>u(r),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Ee,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>y(r),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(te,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>k(r),className:"p-2 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]})})]},r.id))}),e.jsx("div",{className:"hidden md:block bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-x-auto",children:e.jsxs("table",{className:"min-w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky left-0 bg-white dark:bg-gray-800 z-10 w-64",children:g("projects.table.project")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.agent")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:g("common:path")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("common:createdAt")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.lastActive")}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky right-0 bg-white dark:bg-gray-800 z-10 w-32",children:g("projects.table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:l.map((r,w)=>e.jsxs("tr",{className:"group hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 sticky left-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-64 max-w-[256px]",children:e.jsx("div",{className:"truncate",children:O(r)})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap w-32",children:I(r)}),e.jsx("td",{className:"px-6 py-4 max-w-xs truncate",children:U(r)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:S(r.createdAt,e.jsx(Ce,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:S(r.lastAccessed,e.jsx(Fe,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium sticky right-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-32",children:L(r)})]},r.id+"-"+w))})]})})]})},kt=({project:l,onClose:T})=>{const[t,s]=i.useState(""),[u,y]=i.useState(!0),[k,p]=i.useState(!1),[C,m]=i.useState(null);i.useEffect(()=>{(async()=>{try{y(!0),m(null);const c=await $(`${P}/projects/${l.id}/claude-md`);if(c.ok){const E=await c.json();s(E.content||"")}else if(c.status===404)s("");else throw new Error("加载 CLAUDE.md 文件失败")}catch(c){console.error("Failed to load CLAUDE.md:",c),m(c instanceof Error?c.message:"未知错误")}finally{y(!1)}})()},[l.id]);const g=async()=>{try{if(p(!0),m(null),!(await $(`${P}/projects/${l.id}/claude-md`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})})).ok)throw new Error("保存 CLAUDE.md 文件失败");const c=document.getElementById("save-button");if(c){const E=c.textContent;c.textContent="已保存",setTimeout(()=>{c.textContent==="已保存"&&(c.textContent=E)},2e3)}}catch(f){console.error("Failed to save CLAUDE.md:",f),m(f instanceof Error?f.message:"保存失败")}finally{p(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(st,{className:"w-6 h-6 text-blue-600"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"项目记忆管理"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:l.name})]})]}),e.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 flex flex-col p-6 overflow-hidden",children:u?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"正在加载 CLAUDE.md..."})]})}):C?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(me,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"加载失败"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:C})]})}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"编辑项目的记忆文件 (CLAUDE.md),用于存储项目相关的上下文信息和指导。"}),e.jsx("div",{className:"flex-1 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:e.jsx("textarea",{value:t,onChange:f=>s(f.target.value),placeholder:`# 项目记忆
2
+
3
+ 此文件用于存储项目相关的上下文信息、开发指导和重要注意事项。
4
+
5
+ ## 项目概述
6
+ 描述项目的主要功能和目标...
7
+
8
+ ## 开发规范
9
+ 记录代码规范、架构决策等...
10
+
11
+ ## 重要注意事项
12
+ 记录需要特别注意的地方...`,className:"w-full h-full p-4 border-0 resize-none focus:outline-none font-mono text-sm dark:bg-gray-700 dark:text-white dark:placeholder-gray-400",style:{minHeight:"400px"}})})]})}),!u&&!C&&e.jsxs("div",{className:"flex justify-end space-x-3 p-6 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:[e.jsx("button",{onClick:T,className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:"取消"}),e.jsxs("button",{id:"save-button",onClick:g,disabled:k,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center space-x-2",children:[k?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):e.jsx(nt,{className:"w-4 h-4"}),e.jsx("span",{children:k?"保存中...":"保存"})]})]})]})})},wt=({project:l,onClose:T})=>{const{t}=le("components"),{isMobile:s}=Ie(),[u,y]=i.useState(""),[k,p]=i.useState(!1),[C,m]=i.useState(null),[g,f]=i.useState(null),{data:c=[],isLoading:E,error:O,refetch:I}=ht({projectId:l.id,search:u.trim()||void 0}),U=pt(l.id),S=async r=>{try{await U.mutateAsync(r.id),f(null),I()}catch(w){console.error("Failed to delete command:",w)}},L=()=>{p(!1),m(null),I()};return E?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-6xl h-[80vh] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:t("projectCommandsModal.loading")})]})})}):O?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-6xl h-[80vh] flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(me,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:t("projectCommandsModal.error.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t("projectCommandsModal.error.message")}),e.jsxs("div",{className:"flex justify-center space-x-3",children:[e.jsx("button",{onClick:()=>I(),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:t("projectCommandsModal.error.retry")}),e.jsx("button",{onClick:T,className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:t("projectCommandsModal.error.close")})]})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${s?"max-w-full h-[95vh]":"max-w-6xl h-[80vh]"} flex flex-col`,children:[e.jsx("div",{className:`${s?"p-4":"p-6"} border-b border-gray-200 dark:border-gray-700`,children:e.jsxs("div",{className:`flex items-center ${s?"space-x-2":"space-x-3"}`,children:[e.jsx(lt,{className:`${s?"w-5 h-5":"w-6 h-6"} text-green-600`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:`${s?"text-lg":"text-xl"} font-semibold text-gray-900 dark:text-white truncate`,children:t("projectCommandsModal.title")}),e.jsx("p",{className:`${s?"text-xs":"text-sm"} text-gray-600 dark:text-gray-400 truncate`,children:l.name})]}),e.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex-shrink-0",children:e.jsx(q,{className:`${s?"w-4 h-4":"w-5 h-5"}`})})]})}),e.jsx("div",{className:`${s?"p-4":"p-6"} border-b border-gray-200 dark:border-gray-700`,children:e.jsxs("div",{className:`${s?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:s?"":"flex-1 relative",children:[e.jsx(Se,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${s?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("projectCommandsModal.searchPlaceholder"),value:u,onChange:r=>y(r.target.value),className:`pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 ${s?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{m(null),p(!0)},className:`${s?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap ${s?"text-sm":""}`,children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{children:t("projectCommandsModal.createButton")})]})]})}),e.jsx("div",{className:"flex-1 overflow-auto",children:c.length===0?e.jsxs("div",{className:`text-center ${s?"py-8":"py-16"}`,children:[e.jsx("div",{className:`${s?"text-4xl":"text-6xl"} mb-4`,children:"⚡"}),e.jsx("h3",{className:`${s?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(u?"projectCommandsModal.emptyState.noMatchTitle":"projectCommandsModal.emptyState.noCommandsTitle")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${s?"mb-4":"mb-6"}`,children:t(u?"projectCommandsModal.emptyState.noMatchDescription":"projectCommandsModal.emptyState.noCommandsDescription")}),!u&&e.jsx("button",{onClick:()=>{m(null),p(!0)},className:`${s?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("projectCommandsModal.createButton")})]}):e.jsx(e.Fragment,{children:s?e.jsx("div",{className:"p-4 space-y-4",children:c.map((r,w)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsxs("div",{className:"flex items-start space-x-3 mb-3",children:[e.jsx("div",{className:"text-xl mr-3",children:"⚡"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-base font-medium text-gray-900 dark:text-white mb-1",children:[r.namespace?`/${r.namespace}:${r.name}`:`/${r.name}`,r.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:r.argumentHint})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:r.description})]})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("projectCommandsModal.table.model"),":"]}),r.model?e.jsxs("div",{className:"flex items-center text-gray-900 dark:text-white",children:[e.jsx(Ke,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-sm",children:r.model})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectCommandsModal.table.inheritSettings")})]}),e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[t("projectCommandsModal.table.tools"),":"]}),r.allowedTools&&r.allowedTools.length>0?e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-1 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(be,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:t("projectCommandsModal.table.toolsCount",{count:r.allowedTools.length})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:r.allowedTools.map((x,j)=>e.jsx("code",{className:"bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded text-xs",children:fe(x)},j))})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectCommandsModal.table.inheritSettings")})]}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("projectCommandsModal.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(Ae,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:xe(r.createdAt||r.updatedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{m(r),p(!0)},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),t("projectCommandsModal.actions.edit")]}),e.jsx("button",{onClick:()=>f(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("projectCommandsModal.actions.deleteTooltip"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]},r.id+"-"+w))}):e.jsxs(Re,{children:[e.jsx(Le,{children:e.jsxs(je,{children:[e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectCommandsModal.table.command")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectCommandsModal.table.model")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectCommandsModal.table.tools")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectCommandsModal.table.createdAt")}),e.jsx(Q,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectCommandsModal.table.actions")})]})}),e.jsx(ze,{children:c.map((r,w)=>e.jsxs(je,{className:"hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(X,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:[r.namespace?`/${r.namespace}:${r.name}`:`/${r.name}`,r.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-200 px-1.5 py-0.5 rounded text-xs",children:r.argumentHint})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:r.description})]})]})}),e.jsx(X,{className:"px-6 py-4",children:r.model?e.jsxs("div",{className:"text-sm text-gray-900 dark:text-white",children:[e.jsx(Ke,{className:"w-3 h-3 inline mr-1"}),r.model]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectCommandsModal.table.inheritSettings")})}),e.jsx(X,{className:"px-6 py-4",children:r.allowedTools&&r.allowedTools.length>0?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(be,{className:"w-3 h-3"}),e.jsx("span",{children:t("projectCommandsModal.table.toolsCount",{count:r.allowedTools.length})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:r.allowedTools.map((x,j)=>e.jsx("code",{className:"bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded text-xs",children:fe(x)},j))})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectCommandsModal.table.inheritSettings")})}),e.jsx(X,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ae,{className:"w-4 h-4"}),e.jsx("span",{children:xe(r.createdAt||r.updatedAt)})]})}),e.jsx(X,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsxs("button",{onClick:()=>{m(r),p(!0)},className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100 transition-colors",title:t("projectCommandsModal.actions.editTooltip"),children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),t("projectCommandsModal.actions.edit")]}),e.jsx("button",{onClick:()=>f(r),className:"p-2 text-red-600 hover:bg-red-50 rounded-lg transition-colors",title:t("projectCommandsModal.actions.deleteTooltip"),children:e.jsx(Z,{className:"w-4 h-4"})})]})})]},r.id+"-"+w))})]})})}),k&&e.jsx(yt,{command:C,projectId:l.id,onClose:()=>{p(!1),m(null)},onSuccess:L}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60] p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${s?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(me,{className:`${s?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${s?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("projectCommandsModal.deleteConfirm.title")})})]}),e.jsx("p",{className:`${s?"text-sm mb-4":"mb-6"} text-gray-600 dark:text-gray-400`,children:t("projectCommandsModal.deleteConfirm.message",{name:g.name})}),e.jsxs("div",{className:`${s?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>f(null),className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("projectCommandsModal.deleteConfirm.cancel")}),e.jsx("button",{onClick:()=>S(g),disabled:U.isPending,className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:U.isPending?t("projectCommandsModal.deleteConfirm.deleting"):t("projectCommandsModal.deleteConfirm.confirm")})]})]})})]})})},vt=({project:l,onClose:T})=>{const{t}=le("components"),{isMobile:s}=Ie(),[u,y]=i.useState(""),[k,p]=i.useState(!1),[C,m]=i.useState(null),[g,f]=i.useState(null),{data:c=[],isLoading:E,error:O,refetch:I}=bt({projectId:l.id,search:u.trim()||void 0}),U=ut(l.id),S=async x=>{try{await U.mutateAsync(x.id),f(null),I()}catch(j){console.error("Failed to delete subagent:",j)}},L=x=>{m(x),p(!0)},r=()=>{p(!1),m(null)},w=()=>{I(),p(!1),m(null)};return E?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${s?"max-w-full h-[95vh]":"max-w-6xl h-[80vh]"} flex items-center justify-center`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:t("projectSubAgentsModal.loading")})]})})}):O?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${s?"max-w-full h-[95vh]":"max-w-6xl h-[80vh]"} flex items-center justify-center`,children:e.jsxs("div",{className:`text-center ${s?"px-6":""}`,children:[e.jsx(me,{className:`${s?"h-10 w-10":"h-12 w-12"} text-red-500 mx-auto mb-4`}),e.jsx("h3",{className:`${s?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white mb-2`,children:t("projectSubAgentsModal.error.loadFailed")}),e.jsx("p",{className:`${s?"text-sm":""} text-gray-600 dark:text-gray-400 mb-4`,children:t("projectSubAgentsModal.error.loadFailedMessage")}),e.jsxs("div",{className:`${s?"grid grid-cols-2 gap-2":"flex justify-center space-x-3"}`,children:[e.jsx("button",{onClick:()=>I(),className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("projectSubAgentsModal.actions.retry")}),e.jsx("button",{onClick:T,className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors`,children:t("projectSubAgentsModal.actions.close")})]})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${s?"max-w-full h-[95vh]":"max-w-6xl h-[80vh]"} flex flex-col`,children:[e.jsx("div",{className:`${s?"p-4":"p-6"} border-b border-gray-200 dark:border-gray-700`,children:e.jsxs("div",{className:`flex items-center ${s?"space-x-2":"space-x-3"}`,children:[e.jsx(te,{className:`${s?"w-5 h-5":"w-6 h-6"} text-purple-600`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:`${s?"text-lg":"text-xl"} font-semibold text-gray-900 dark:text-white truncate`,children:t("projectSubAgentsModal.title")}),e.jsx("p",{className:`${s?"text-xs":"text-sm"} text-gray-600 dark:text-gray-400 truncate`,children:l.name})]}),e.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex-shrink-0",children:e.jsx(q,{className:`${s?"w-4 h-4":"w-5 h-5"}`})})]})}),e.jsx("div",{className:`${s?"p-4":"p-6"} border-b border-gray-200 dark:border-gray-700`,children:e.jsxs("div",{className:`${s?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:s?"":"flex-1 relative",children:[e.jsx(Se,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${s?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("projectSubAgentsModal.searchPlaceholder"),value:u,onChange:x=>y(x.target.value),className:`pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 ${s?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{m(null),p(!0)},className:`${s?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap ${s?"text-sm":""}`,children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{children:t("projectSubAgentsModal.actions.create")})]})]})}),e.jsx("div",{className:"flex-1 overflow-auto",children:c.length===0?e.jsxs("div",{className:`text-center ${s?"py-8":"py-16"}`,children:[e.jsx("div",{className:`${s?"text-4xl":"text-6xl"} mb-4`,children:"🤖"}),e.jsx("h3",{className:`${s?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(u?"projectSubAgentsModal.emptyState.noResults":"projectSubAgentsModal.emptyState.noSubagents")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${s?"mb-4":"mb-6"}`,children:t(u?"projectSubAgentsModal.emptyState.tryAdjust":"projectSubAgentsModal.emptyState.description")}),!u&&e.jsx("button",{onClick:()=>{m(null),p(!0)},className:`${s?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("projectSubAgentsModal.actions.create")})]}):e.jsx(e.Fragment,{children:s?e.jsx("div",{className:"p-4 space-y-4",children:c.map((x,j)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsxs("div",{className:"flex items-start space-x-3 mb-3",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-base font-medium text-gray-900 dark:text-white mb-1",children:x.name}),x.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:x.description})]})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[t("projectSubAgentsModal.table.tools"),":"]}),x.tools&&x.tools.length>0?e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-1 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(be,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:t("projectSubAgentsModal.table.toolsCount",{count:x.tools.length})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:x.tools.map((K,G)=>e.jsx("code",{className:"bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded text-xs",children:fe(K)},G))})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectSubAgentsModal.table.inheritSettings")})]}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("projectSubAgentsModal.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(Ce,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:xe(x.createdAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>L(x),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),t("projectSubAgentsModal.actions.edit")]}),e.jsx("button",{onClick:()=>f(x),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("projectSubAgentsModal.actions.deleteTooltip"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]},x.id+"-"+j))}):e.jsxs(Re,{children:[e.jsx(Le,{children:e.jsxs(je,{children:[e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectSubAgentsModal.table.subagent")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectSubAgentsModal.table.tools")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectSubAgentsModal.table.createdAt")}),e.jsx(Q,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("projectSubAgentsModal.table.actions")})]})}),e.jsx(ze,{children:c.map((x,j)=>e.jsxs(je,{className:"hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(X,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:x.name}),x.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:x.description})]})]})}),e.jsx(X,{className:"px-6 py-4",children:x.tools&&x.tools.length>0?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(be,{className:"w-3 h-3"}),e.jsx("span",{children:t("projectSubAgentsModal.table.toolsCount",{count:x.tools.length})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:x.tools.map((K,G)=>e.jsx("code",{className:"bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded text-xs",children:fe(K)},G))})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("projectSubAgentsModal.table.inheritSettings")})}),e.jsx(X,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Ce,{className:"w-4 h-4"}),e.jsx("span",{children:xe(x.createdAt)})]})}),e.jsx(X,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsxs("button",{onClick:()=>L(x),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 rounded-md hover:bg-blue-100 transition-colors",title:t("projectSubAgentsModal.actions.editTooltip"),children:[e.jsx(ue,{className:"w-3 h-3 mr-1"}),t("projectSubAgentsModal.actions.edit")]}),e.jsx("button",{onClick:()=>f(x),className:"p-2 text-red-600 hover:bg-red-50 rounded-lg transition-colors",title:t("projectSubAgentsModal.actions.deleteTooltip"),children:e.jsx(Z,{className:"w-4 h-4"})})]})})]},x.id+"-"+j))})]})})}),k&&e.jsx(jt,{subagent:C,projectId:l.id,onClose:r,onSuccess:w}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60] p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${s?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(me,{className:`${s?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${s?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("projectSubAgentsModal.deleteConfirm.title")})})]}),e.jsx("p",{className:`${s?"text-sm mb-4":"mb-6"} text-gray-600 dark:text-gray-400`,children:t("projectSubAgentsModal.deleteConfirm.message",{name:g.name})}),e.jsxs("div",{className:`${s?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>f(null),className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("projectSubAgentsModal.actions.cancel")}),e.jsx("button",{onClick:()=>S(g),disabled:U.isPending,className:`${s?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:U.isPending?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):t("projectSubAgentsModal.actions.delete")})]})]})})]})})},Ct=l=>{const[T,t]=i.useState({mapping:!0,card:!0,keys:!0,config:!0,tasks:!0}),[s,u]=i.useState(null),[y,k]=i.useState(null),[p,C]=i.useState([]),[m,g]=i.useState(null),[f,c]=i.useState([]),E=async()=>{try{t(n=>({...n,mapping:!0}));const d=await $(`${P}/a2a/mapping/${encodeURIComponent(l.path)}`);if(d.ok){const n=await d.json();return u(n),n}else return console.error("Failed to fetch agent mapping"),null}catch(d){return console.error("Error fetching agent mapping:",d),null}finally{t(d=>({...d,mapping:!1}))}},O=async()=>{try{t(n=>({...n,card:!0}));const d=await $(`${P}/a2a/agent-card/${encodeURIComponent(l.path)}`);if(d.ok){const n=await d.json();return k(n),n}else return console.error("Failed to fetch agent card"),null}catch(d){return console.error("Error fetching agent card:",d),null}finally{t(d=>({...d,card:!1}))}};i.useEffect(()=>{(async()=>{await E()?await O():k(null)})()},[l.path]),i.useEffect(()=>{(async()=>{try{t(h=>({...h,keys:!0}));const n=await $(`${P}/a2a/api-keys/${encodeURIComponent(l.path)}`);if(n.ok){const h=await n.json();C(h.apiKeys||[])}else console.error("Failed to fetch API keys")}catch(n){console.error("Error fetching API keys:",n)}finally{t(n=>({...n,keys:!1}))}})()},[l.id]),i.useEffect(()=>{(async()=>{try{t(h=>({...h,config:!0}));const n=await $(`${P}/a2a/config/${encodeURIComponent(l.path)}`);if(n.ok){const h=await n.json();g(h)}else n.status===404&&g({allowedAgents:[],taskTimeout:3e5,maxConcurrentTasks:5})}catch(n){console.error("Error fetching config:",n)}finally{t(n=>({...n,config:!1}))}})()},[l.id]),i.useEffect(()=>{(async()=>{try{if(t(h=>({...h,tasks:!0})),!s)return;const n=await $(`${P}/a2a/tasks/${encodeURIComponent(l.path)}`);if(n.ok){const h=await n.json();c(h.tasks||[])}}catch(n){console.error("Error fetching tasks:",n)}finally{t(n=>({...n,tasks:!1}))}})()},[s]);const I=async d=>{try{const n=await $(`${P}/a2a/api-keys/${encodeURIComponent(l.path)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:d})});if(n.ok){const h=await n.json();return C(F=>[h,...F]),ee("API密钥创建成功"),h}else{const h=await n.json();throw new Error(h.error||"创建失败")}}catch(n){return console.error("Failed to create API key:",n),z("创建API密钥失败",n instanceof Error?n.message:"未知错误"),null}},U=async d=>{try{const n=await $(`${P}/a2a/api-keys/${encodeURIComponent(l.path)}/${d}`,{method:"DELETE"});if(n.ok)return C(h=>h.filter(F=>F.id!==d)),ee("API密钥删除成功"),!0;{const h=await n.json();throw new Error(h.error||"删除失败")}}catch(n){return console.error("Failed to delete API key:",n),z("删除API密钥失败",n instanceof Error?n.message:"未知错误"),!1}},S=async d=>{try{const n=await $(`${P}/a2a/config/${encodeURIComponent(l.path)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(n.ok)return g(d),ee("A2A配置更新成功"),!0;{const h=await n.json();throw new Error(h.error||"更新失败")}}catch(n){return console.error("Failed to update config:",n),z("更新A2A配置失败",n instanceof Error?n.message:"未知错误"),!1}},L=async d=>{if(!m)return!1;const n={...m,allowedAgents:[...m.allowedAgents,d]};return await S(n)},r=async d=>{if(!m)return!1;const n={...m,allowedAgents:m.allowedAgents.filter((h,F)=>F!==d)};return await S(n)},w=async(d,n)=>{if(!m)return!1;const h={...m,allowedAgents:m.allowedAgents.map((F,_)=>_===d?n:F)};return await S(h)};return{loading:T,agentMapping:s,agentCard:y,apiKeys:p,config:m,tasks:f,fetchAgentMapping:E,fetchAgentCard:O,createApiKey:I,deleteApiKey:U,updateConfig:S,addExternalAgent:L,removeExternalAgent:r,updateExternalAgent:w,toggleExternalAgent:async d=>{if(!m)return!1;const n=m.allowedAgents[d];return await w(d,{...n,enabled:!n.enabled})},cancelTask:async d=>{if(!s)return!1;try{const n=await $(`${P}/a2a/tasks/${encodeURIComponent(l.path)}/${d}`,{method:"DELETE"});if(n.ok)return c(h=>h.map(F=>F.id===d?{...F,status:"canceled",completedAt:new Date().toISOString()}:F)),ee("任务已取消"),!0;{const h=await n.json();throw new Error(h.error||"取消失败")}}catch(n){return console.error("Failed to cancel task:",n),z("取消任务失败",n instanceof Error?n.message:"未知错误"),!1}},refreshTasks:async()=>{if(s)try{t(n=>({...n,tasks:!0}));const d=await $(`${P}/a2a/tasks/${encodeURIComponent(l.path)}`);if(d.ok){const n=await d.json();c(n.tasks||[])}}catch(d){console.error("Error refreshing tasks:",d)}finally{t(d=>({...d,tasks:!1}))}},copyToClipboard:async d=>{try{return await navigator.clipboard.writeText(d),ee("已复制到剪贴板"),!0}catch{return z("复制失败"),!1}},importProjects:async d=>{try{const n=await $(`${P}/a2a/import-projects/${encodeURIComponent(l.path)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPaths:d})});if(n.ok){const h=await n.json(),F=await $(`${P}/a2a/config/${encodeURIComponent(l.path)}`);if(F.ok){const _=await F.json();g(_)}return h.totalSuccess>0&&ee(`成功导入 ${h.totalSuccess} 个项目`),h.totalFailed>0&&z(`${h.totalFailed} 个项目导入失败`),h}else{const h=await n.json();throw new Error(h.error||"导入失败")}}catch(n){return console.error("Failed to import projects:",n),z("导入项目失败",n instanceof Error?n.message:"未知错误"),null}},validateAgentUrl:d=>{try{const n=new URL(d);return["http:","https:"].includes(n.protocol)?{valid:!0}:{valid:!1,error:"URL必须使用HTTP或HTTPS协议"}}catch{return{valid:!1,error:"无效的URL格式"}}},formatDate:d=>new Date(d).toLocaleString("zh-CN")}},At=({project:l,onClose:T})=>{const{t}=le("components"),[s,u]=i.useState("overview"),{loading:y,agentMapping:k,agentCard:p,apiKeys:C,config:m,tasks:g,createApiKey:f,deleteApiKey:c,addExternalAgent:E,removeExternalAgent:O,updateExternalAgent:I,toggleExternalAgent:U,copyToClipboard:S,validateAgentUrl:L,formatDate:r,importProjects:w}=Ct(l),{data:x}=ft(),[j,K]=i.useState(!1),[G,B]=i.useState(!1),[Ne,H]=i.useState(!1),[d,n]=i.useState(new Set),[h,F]=i.useState(!1),[_,he]=i.useState(null),[ae,re]=i.useState(""),[se,W]=i.useState(""),[ke,pe]=i.useState(!1),[o,b]=i.useState(""),[N,M]=i.useState(new Set),R=a=>{M(v=>{const D=new Set(v);return D.has(a)?D.delete(a):D.add(a),D})},J=a=>a?"•".repeat(Math.min(a.length,40)):"••••••••••••••••",[A,Y]=i.useState({name:"",url:"",apiKey:"",description:"",enabled:!0}),[V,$e]=i.useState({name:"",url:"",apiKey:""}),Pe=a=>a.trim()?a.length>100?(W(t("a2aManagement.validation.descriptionTooLong")),!1):(W(""),!0):(W(t("a2aManagement.validation.descriptionRequired")),!1),Oe=()=>{const a={name:"",url:"",apiKey:""};let v=!0;if(A.name.trim()?A.name.length>50&&(a.name=t("a2aManagement.validation.agentNameTooLong"),v=!1):(a.name=t("a2aManagement.validation.agentNameRequired"),v=!1),!A.url.trim())a.url=t("a2aManagement.validation.urlRequired"),v=!1;else{const D=L(A.url);D.valid||(a.url=D.error||t("a2aManagement.validation.invalidUrl"),v=!1)}return A.apiKey.trim()||(a.apiKey=t("a2aManagement.validation.apiKeyRequired"),v=!1),$e(a),v},Be=async()=>{if(!Pe(ae))return;const a=await f(ae);a&&a.key&&(re(""),K(!1),W(""),b(a.key),pe(!0))},He=async a=>{confirm(t("a2aManagement.confirmations.deleteApiKey"))&&await c(a)},_e=async()=>{Oe()&&(_!==null&&m?await I(_,A)&&(B(!1),ne()):await E(A)&&(B(!1),ne()))},Je=async a=>{confirm(t("a2aManagement.confirmations.deleteExternalAgent"))&&await O(a)},qe=a=>{if(!m)return;const v=m.allowedAgents[a];Y({name:v.name,url:v.url,apiKey:v.apiKey,description:v.description||"",enabled:v.enabled}),he(a),B(!0)},ne=()=>{Y({name:"",url:"",apiKey:"",description:"",enabled:!0}),he(null),$e({name:"",url:"",apiKey:""})},Ye=async()=>{if(d.size===0){z("请至少选择一个项目");return}F(!0);try{const a=Array.from(d);await w(a)&&(H(!1),n(new Set))}finally{F(!1)}},Ve=a=>{n(v=>{const D=new Set(v);return D.has(a)?D.delete(a):D.add(a),D})},Qe=()=>{if(!p||!C.length)return"";const a=C[0].key||"YOUR_API_KEY_HERE";return`curl -X POST "${`${p.url}/messages`}" \\
13
+ -H "Content-Type: application/json" \\
14
+ -H "Authorization: Bearer ${a}" \\
15
+ -d '{
16
+ "message": "你好,请帮我完成一个任务"
17
+ }'`},Xe=async()=>{const a=Qe();a?await S(a):z("请先创建至少一个 API 密钥")},Ge=()=>e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 px-6",children:e.jsx("nav",{className:"flex space-x-8",children:[{id:"overview",label:t("a2aManagement.tabs.overview"),icon:ie},{id:"keys",label:t("a2aManagement.tabs.apiKeys"),icon:de},{id:"external",label:t("a2aManagement.tabs.external"),icon:te},{id:"tasks",label:t("a2aManagement.tabs.tasks"),icon:we}].map(({id:a,label:v,icon:D})=>e.jsxs("button",{onClick:()=>u(a),className:`flex items-center space-x-2 py-4 px-3 border-b-2 font-medium text-sm transition-colors ${s===a?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(D,{className:"w-4 h-4"}),e.jsx("span",{children:v})]},a))})}),We=()=>{const a=l.path.split("/").pop()||l.path,v=p?.context?.agentType||"claude code",D=`${a} (${v})`;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(de,{className:"w-8 h-8 text-blue-500"}),e.jsxs("div",{className:"ml-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:t("a2aManagement.overview.apiKeys")}),e.jsx("p",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:C.length})]})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(te,{className:"w-8 h-8 text-green-500"}),e.jsxs("div",{className:"ml-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:t("a2aManagement.overview.externalAgents")}),e.jsx("p",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:m?.allowedAgents?.length||0})]})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(we,{className:"w-8 h-8 text-purple-500"}),e.jsxs("div",{className:"ml-4",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:t("a2aManagement.overview.activeTasks")}),e.jsx("p",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:g.filter(ye=>ye.status==="running").length})]})]})})]}),p&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4 flex items-center",children:[e.jsx(te,{className:"w-5 h-5 mr-2"}),t("a2aManagement.overview.agentCard")]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-1",children:D}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:p.description})]}),e.jsx("span",{className:"px-2 py-1 text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 rounded-full",children:p.version})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm text-blue-800 dark:text-blue-200 mb-1",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),"A2A Endpoint"]}),e.jsxs("button",{onClick:Xe,className:"flex items-center space-x-1 px-2 py-1 text-xs bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors",title:"复制 curl 命令",children:[e.jsx(oe,{className:"w-3 h-3"}),e.jsx("span",{children:"复制 curl"})]})]}),e.jsx("code",{className:"text-xs text-blue-700 dark:text-blue-300 font-mono break-all",children:p.url})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h5",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:t("a2aManagement.agentCard.context")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"A2A Agent ID:"}),e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[e.jsx("code",{className:"text-gray-900 dark:text-white font-mono text-xs truncate",children:p.context?.a2aAgentId}),e.jsx("button",{onClick:()=>S(p.context?.a2aAgentId||""),className:"p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 flex-shrink-0",title:t("a2aManagement.actions.copy"),children:e.jsx(oe,{className:"w-3 h-3"})})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Project:"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:p.context?.projectName})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Type:"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:p.context?.agentType})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Category:"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:p.context?.agentCategory})]})]})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:[t("a2aManagement.agentCard.skills")," (",p.skills?.length||0,")"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 max-h-48 overflow-y-auto",children:p.skills?.map((ye,at)=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg p-2 text-xs",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white mb-1 truncate",children:ye.name}),e.jsx("div",{className:"text-gray-500 dark:text-gray-400 line-clamp-2",children:ye.description})]},at))})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(de,{className:"w-3 h-3 mr-1"}),t("a2aManagement.agentCard.security"),": ",p.securitySchemes?.[0]?.type]})})]})]})},Ze=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:t("a2aManagement.apiKeys.title")}),e.jsxs("button",{onClick:()=>K(!0),className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{children:t("a2aManagement.actions.createKey")})]})]}),y.keys?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ce,{className:"w-6 h-6 animate-spin text-blue-500"})}):C.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(de,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("a2aManagement.apiKeys.noKeys")}),e.jsx("button",{onClick:()=>K(!0),className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:t("a2aManagement.apiKeys.createFirstKey")})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-700 dark:text-gray-300",children:t("a2aManagement.apiKeys.description")}),e.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-700 dark:text-gray-300",children:t("a2aManagement.apiKeys.key")}),e.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-700 dark:text-gray-300",children:t("a2aManagement.apiKeys.createdAt")}),e.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-700 dark:text-gray-300",children:t("a2aManagement.apiKeys.lastUsed")}),e.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-700 dark:text-gray-300",children:t("a2aManagement.apiKeys.actions")})]})}),e.jsx("tbody",{children:C.map(a=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("span",{className:"text-gray-900 dark:text-white",children:a.description}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 rounded-full",children:"Active"})]})}),e.jsx("td",{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("code",{className:"text-xs text-gray-700 dark:text-gray-300 font-mono bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded max-w-xs overflow-hidden",children:N.has(a.id)&&a.key?a.key:J(a.key)}),a.key&&e.jsx("button",{onClick:()=>R(a.id),className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:N.has(a.id)?t("a2aManagement.apiKeys.hideKey"):t("a2aManagement.apiKeys.showKey"),children:N.has(a.id)?e.jsx(dt,{className:"w-4 h-4 text-gray-500"}):e.jsx(ot,{className:"w-4 h-4 text-gray-500"})}),e.jsx("button",{onClick:()=>a.key&&S(a.key),className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:t("a2aManagement.actions.copy"),children:e.jsx(oe,{className:"w-4 h-4 text-gray-500"})})]})}),e.jsx("td",{className:"py-3 px-4 text-gray-500 dark:text-gray-400",children:r(a.createdAt)}),e.jsx("td",{className:"py-3 px-4 text-gray-500 dark:text-gray-400",children:a.lastUsed?r(a.lastUsed):"-"}),e.jsx("td",{className:"py-3 px-4 text-right",children:e.jsx("button",{onClick:()=>He(a.id),className:"p-1.5 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("a2aManagement.actions.delete"),children:e.jsx(Z,{className:"w-4 h-4"})})})]},a.id))})]})}),j&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("a2aManagement.modals.createKey.title")}),e.jsx("button",{onClick:()=>{K(!1),re(""),W("")},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("a2aManagement.modals.createKey.description")," *"]}),e.jsx("input",{type:"text",value:ae,onChange:a=>{re(a.target.value),Pe(a.target.value)},placeholder:t("a2aManagement.modals.createKey.descriptionPlaceholder"),className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${se?"border-red-300 dark:border-red-600":"border-gray-300 dark:border-gray-600"}`,maxLength:100,autoFocus:!0}),se&&e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm mt-1",children:se}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("a2aManagement.modals.createKey.descriptionHelp")})]}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-3 mb-4",children:e.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:[e.jsxs("strong",{children:[t("a2aManagement.modals.createKey.important"),":"]})," ",t("a2aManagement.modals.createKey.securityNote")]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{K(!1),re(""),W("")},className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:t("a2aManagement.actions.cancel")}),e.jsx("button",{onClick:Be,disabled:!ae.trim()||!!se||y.keys,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:y.keys?e.jsxs("span",{className:"flex items-center",children:[e.jsx(ce,{className:"w-4 h-4 animate-spin mr-2"}),t("a2aManagement.modals.createKey.creating")]}):t("a2aManagement.actions.createKey")})]})]})]})}),ke&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-lg mx-4",children:[e.jsx("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(de,{className:"w-5 h-5 mr-2 text-green-500"}),t("a2aManagement.modals.newKey.title","API密钥创建成功")]})}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("a2aManagement.modals.newKey.yourKey","您的 API 密钥")}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"p-3 bg-gray-50 dark:bg-gray-900 border border-gray-300 dark:border-gray-600 rounded-lg font-mono text-sm break-all",children:o}),e.jsx("button",{onClick:()=>S(o),className:"absolute top-2 right-2 p-2 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors",title:t("a2aManagement.actions.copy"),children:e.jsx(oe,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-6",children:e.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:[e.jsxs("strong",{children:[t("a2aManagement.modals.newKey.usage","使用方式"),":"]})," ",t("a2aManagement.modals.newKey.usageDetail","在请求头中添加 Authorization: Bearer YOUR_API_KEY")]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs("button",{onClick:()=>S(o),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center space-x-2",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:t("a2aManagement.actions.copyKey","复制密钥")})]}),e.jsx("button",{onClick:()=>{pe(!1),b("")},className:"px-4 py-2 bg-gray-600 text-white rounded-lg hover:bg-gray-700",children:t("a2aManagement.actions.close","关闭")})]})]})]})})]}),et=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:t("a2aManagement.external.title")}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("button",{onClick:()=>H(!0),className:"flex items-center space-x-2 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700",children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{children:t("a2aManagement.actions.importProjects")})]}),e.jsxs("button",{onClick:()=>{ne(),B(!0)},className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{children:t("a2aManagement.actions.addAgent")})]})]})]}),y.config?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ce,{className:"w-6 h-6 animate-spin text-blue-500"})}):!m||m.allowedAgents?.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(te,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("a2aManagement.external.noAgents")}),e.jsx("button",{onClick:()=>{ne(),B(!0)},className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:t("a2aManagement.external.addFirstAgent")})]}):e.jsx("div",{className:"space-y-4",children:m.allowedAgents?.map((a,v)=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("h4",{className:"text-medium font-medium text-gray-900 dark:text-white",children:a.name}),e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${a.enabled?"bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200":"bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-200"}`,children:a.enabled?t("a2aManagement.external.enabled"):t("a2aManagement.external.disabled")})]}),a.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:a.description}),e.jsx("div",{className:"space-y-1 text-sm",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[t("a2aManagement.external.form.url"),":"]}),e.jsxs("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:underline flex items-center",children:[a.url,e.jsx(De,{className:"w-3 h-3 ml-1"})]})]})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>U(v),className:`p-2 rounded-lg transition-colors ${a.enabled?"text-green-600 hover:bg-green-50 dark:hover:bg-green-900/50":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:a.enabled?t("a2aManagement.actions.disable"):t("a2aManagement.actions.enable"),children:a.enabled?e.jsx(ct,{className:"w-4 h-4"}):e.jsx(it,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>qe(v),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("a2aManagement.actions.edit"),children:e.jsx(xt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Je(v),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("a2aManagement.actions.delete"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]})},v))}),G&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t(_!==null?"a2aManagement.external.modal.editTitle":"a2aManagement.external.modal.addTitle")}),e.jsx("button",{onClick:()=>{B(!1),ne()},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("a2aManagement.external.form.name")," *"]}),e.jsx("input",{type:"text",value:A.name,onChange:a=>Y({...A,name:a.target.value}),placeholder:t("a2aManagement.external.form.namePlaceholder"),className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${V.name?"border-red-300 dark:border-red-600":"border-gray-300 dark:border-gray-600"}`,maxLength:50}),V.name&&e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm mt-1",children:V.name})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("a2aManagement.external.form.url")," *"]}),e.jsx("input",{type:"url",value:A.url,onChange:a=>Y({...A,url:a.target.value}),placeholder:t("a2aManagement.external.form.urlPlaceholder"),className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${V.url?"border-red-300 dark:border-red-600":"border-gray-300 dark:border-gray-600"}`}),V.url&&e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm mt-1",children:V.url}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("a2aManagement.external.form.urlHelp")})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t("a2aManagement.external.form.apiKey")," *"]}),e.jsx("input",{type:"password",value:A.apiKey,onChange:a=>Y({...A,apiKey:a.target.value}),placeholder:t("a2aManagement.external.form.apiKeyPlaceholder"),className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${V.apiKey?"border-red-300 dark:border-red-600":"border-gray-300 dark:border-gray-600"}`}),V.apiKey&&e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm mt-1",children:V.apiKey})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:t("a2aManagement.external.form.description")}),e.jsx("textarea",{value:A.description,onChange:a=>Y({...A,description:a.target.value}),placeholder:t("a2aManagement.external.form.descriptionPlaceholder"),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",maxLength:200})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:"agent-enabled",checked:A.enabled,onChange:a=>Y({...A,enabled:a.target.checked}),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("label",{htmlFor:"agent-enabled",className:"ml-2 text-sm text-gray-700 dark:text-gray-300",children:t("a2aManagement.external.form.enableThisAgent")})]}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[e.jsx("button",{onClick:()=>{B(!1),ne()},className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:t("a2aManagement.actions.cancel")}),e.jsx("button",{onClick:_e,disabled:y.config,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:t(_!==null?"a2aManagement.external.modal.saveChanges":"a2aManagement.external.modal.addAgent")})]})]})]})}),Ne&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(ve,{className:"w-5 h-5 mr-2"}),t("a2aManagement.external.importModal.title")]}),e.jsx("button",{onClick:()=>{H(!1),n(new Set)},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t("a2aManagement.external.importModal.description")}),!x||x.projects.length===0?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("a2aManagement.external.importModal.noProjects")})}):e.jsx("div",{className:"space-y-2",children:x.projects.filter(a=>a.path!==l.path).map(a=>e.jsxs("label",{className:"flex items-center p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d.has(a.path),onChange:()=>Ve(a.path),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:a.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.path})]})]},a.path))})]}),e.jsxs("div",{className:"p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[t("a2aManagement.external.importModal.selected"),": ",d.size]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{H(!1),n(new Set)},className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:t("a2aManagement.actions.cancel")}),e.jsx("button",{onClick:Ye,disabled:d.size===0||h,className:"px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:t("a2aManagement.external.importModal.importing")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{children:t("a2aManagement.external.importModal.import")})]})})]})]})]})})]}),tt=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:t("a2aManagement.tasks.title")}),k?y.tasks?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ce,{className:"w-6 h-6 animate-spin text-blue-500"})}):g.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ae,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("a2aManagement.tasks.noTasks")})]}):e.jsx("div",{className:"space-y-4",children:g.map(a=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("h4",{className:"text-medium font-medium text-gray-900 dark:text-white",children:a.id}),e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${a.status==="completed"?"bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200":a.status==="running"?"bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200":a.status==="failed"?"bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200":"bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-200"}`,children:a.status})]}),e.jsxs("div",{className:"space-y-1 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{children:[t("a2aManagement.tasks.createdAt"),": ",r(a.createdAt)]}),a.startedAt&&e.jsxs("div",{children:[t("a2aManagement.tasks.startedAt"),": ",r(a.startedAt)]}),a.completedAt&&e.jsxs("div",{children:[t("a2aManagement.tasks.completedAt"),": ",r(a.completedAt)]})]})]})})},a.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(we,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:t("a2aManagement.tasks.needA2AEnabled")})]})]});return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl mx-4 h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(ie,{className:"w-5 h-5 mr-2"}),t("a2aManagement.title")]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:[t("a2aManagement.project"),": ",l.name]})]}),e.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx("div",{className:"flex-shrink-0",children:Ge()}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[s==="overview"&&We(),s==="keys"&&Ze(),s==="external"&&et(),s==="tasks"&&tt()]})]})]})})},Mt=({isOpen:l,onClose:T,onConfirm:t,agents:s})=>{const{t:u}=le("pages"),[y,k]=i.useState({name:"",agentId:"",directory:"~/claude-code-projects",description:""}),[p,C]=i.useState(!1);i.useEffect(()=>{l&&k({name:"",agentId:s.length>0?s[0].id:"",directory:"~/claude-code-projects",description:""})},[l,s]);const m=c=>{if(!c.startsWith("~/"))return c},g=c=>{c.preventDefault(),y.name&&y.agentId&&t(y)},f=s.find(c=>c.id===y.agentId);return l?e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:u("projects.form.create")}),e.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:g,className:"p-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:u("projects.form.nameRequired")}),e.jsx("input",{type:"text",value:y.name,onChange:c=>k({...y,name:c.target.value}),placeholder:u("projects.form.namePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:u("projects.form.agentType")}),e.jsx("select",{value:y.agentId,onChange:c=>k({...y,agentId:c.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",required:!0,children:s.filter(c=>c.enabled).map(c=>e.jsxs("option",{value:c.id,children:[c.ui.icon," ",c.name]},c.id))}),f&&e.jsx("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"text-2xl",children:f.ui.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:f.name}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:f.description})]})]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:u("projects.form.directory")}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"text",value:y.directory,onChange:c=>k({...y,directory:c.target.value}),className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>C(!0),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",title:u("projects.form.directory"),children:e.jsx(Me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:u("projects.form.directoryNote")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:u("projects.form.description")}),e.jsx("textarea",{value:y.description,onChange:c=>k({...y,description:c.target.value}),placeholder:u("projects.form.descriptionPlaceholder"),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white"})]})]}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[e.jsx("button",{type:"button",onClick:T,className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:u("projects.form.cancel")}),e.jsx("button",{type:"submit",disabled:!y.name||!y.agentId,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:u("projects.createButton")})]})]})]}),p&&e.jsx(Ue,{title:u("projects.form.directory"),initialPath:m(y.directory),allowFiles:!1,allowDirectories:!0,allowNewDirectory:!0,onSelect:(c,E)=>{E&&(k({...y,directory:c}),C(!1))},onClose:()=>C(!1)})]}):null},_t=()=>{const{t:l}=le("pages"),{data:T}=gt(),[t,s]=i.useState([]),[u,y]=i.useState(!0),[k,p]=i.useState(""),[C,m]=i.useState(!1),[g,f]=i.useState(null),[c,E]=i.useState(null),[O,I]=i.useState(null),[U,S]=i.useState(null),[L,r]=i.useState(null),[w,x]=i.useState(!1),[j,K]=i.useState(""),[G,B]=i.useState(!1),H=(T?.agents||[]).filter(o=>o.enabled);i.useEffect(()=>{(async()=>{try{y(!0);const b=await $(`${P}/projects`);if(b.ok){const N=await b.json();s(N.projects||[])}else console.error("Failed to fetch projects:",b.status),s([])}catch(b){console.error("Failed to fetch projects:",b),s([])}finally{y(!1)}})()},[]);const d=t.filter(o=>o.name.toLowerCase().includes(k.toLowerCase())||o.description?.toLowerCase().includes(k.toLowerCase())||o.defaultAgentName.toLowerCase().includes(k.toLowerCase())).sort((o,b)=>new Date(b.lastAccessed).getTime()-new Date(o.lastAccessed).getTime()),n=async o=>{try{const b=await $(`${P}/projects/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:o.agentId,projectName:o.name,parentDirectory:o.directory,description:o.description})});if(b.ok){const N=await b.json();s(J=>[N.project,...J]),m(!1);const M=new URLSearchParams;M.set("project",N.project.path);const R=`/chat/${o.agentId}?${M.toString()}`;window.open(R,"_blank")}else{const N=await b.json();throw new Error(N.error||l("projects.errors.createFailed"))}}catch(b){console.error("Failed to create project:",b),z(l("projects.errors.createFailed"),b instanceof Error?b.message:l("errors:common.unknownError"))}},h=async o=>{if(o.agents.length>0&&!o.defaultAgent){r(o);return}const b=o.defaultAgent||"claude-code";console.log("Opening project:",o.name,"with agent:",b);const N=new URLSearchParams;N.set("project",o.path);const M=`/chat/${b}?${N.toString()}`;console.log("Generated URL:",M),window.open(M,"_blank"),s(R=>R.map(J=>J.id===o.id?{...J,lastAccessed:new Date().toISOString()}:J))},F=async o=>{if(window.confirm(`${l("projects.deleteConfirm")}
18
+
19
+ ${l("projects.deleteNote")}`))try{const N=await $(`${P}/projects/by-id/${o.id}`,{method:"DELETE"});if(N.ok)s(M=>M.filter(R=>R.id!==o.id));else{const M=await N.json();throw new Error(M.error||l("projects.errors.deleteFailed"))}}catch(N){console.error("Failed to delete project:",N),z(l("projects.errors.deleteFailed"),N instanceof Error?N.message:l("errors:common.unknownError"))}},_=o=>{f(o)},he=o=>{E(o)},ae=o=>{I(o)},re=o=>{S(o)},se=(o,b)=>{s(N=>N.map(M=>M.id===o?{...M,defaultAgent:b.id,defaultAgentName:b.name,defaultAgentIcon:b.ui.icon,lastAccessed:new Date().toISOString()}:M))},W=async o=>{if(L)try{const b=await $(`${P}/projects/${encodeURIComponent(L.path)}/select-agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:o})});if(b.ok){const N=await b.json();s(J=>J.map(A=>A.id===L.id?N.project:A)),r(null);const M=new URLSearchParams;M.set("project",N.project.path);const R=`/chat/${o}?${M.toString()}`;window.open(R,"_blank")}else{const N=await b.json();z(l("errors:agent.setFailed"),N.error||l("errors:common.unknownError"))}}catch(b){console.error("Failed to select agent:",b),z(l("errors:agent.setFailed"),b instanceof Error?b.message:l("errors:common.unknownError"))}},ke=async()=>{if(j.trim())try{const o=await $(`${P}/files/browse?path=${encodeURIComponent(j)}`);if(!o.ok)throw new Error("目录不存在或无法访问");if(!(await o.json()).isDirectory)throw new Error("请选择一个目录");const N=H[0];if(!N)throw new Error("没有可用的代理");const M=await $(`${P}/projects/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:N.id,projectPath:j})});if(M.ok){const R=await M.json();if(s(A=>[R.project,...A]),x(!1),K(""),window.confirm(`项目 "${R.project.name}" 导入成功!
20
+
21
+ 是否立即打开该项目?`))if(H.length>1)r(R.project);else{const A=new URLSearchParams;A.set("project",R.project.path);const Y=`/chat/${N.id}?${A.toString()}`;window.open(Y,"_blank")}}else{const R=await M.json();throw new Error(R.error||"导入项目失败")}}catch(o){console.error("Failed to import project:",o),z("导入项目失败",o instanceof Error?o.message:"未知错误")}},pe=(o,b)=>{b&&(K(o),B(!1))};return u?e.jsx("div",{className:"p-8 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:l("projects.loading")})]})}):e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:l("projects.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:l("projects.subtitle")})]})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Se,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:l("projects.searchPlaceholder"),value:k,onChange:o=>p(o.target.value),className:"pl-10 pr-4 py-3 w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white"})]}),e.jsxs("button",{onClick:()=>x(!0),className:"flex items-center space-x-2 px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap font-medium",children:[e.jsx(mt,{className:"w-5 h-5"}),e.jsx("span",{children:"导入项目"})]}),e.jsxs("button",{onClick:()=>m(!0),className:"flex items-center space-x-2 px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors whitespace-nowrap",children:[e.jsx(ge,{className:"w-5 h-5"}),e.jsx("span",{children:l("projects.createButton")})]})]})]}),d.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📁"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:l("projects.noProjects")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:l("projects.selectType")}),!k&&e.jsx("button",{onClick:()=>m(!0),className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:l("projects.createButton")})]}):e.jsx(Nt,{projects:d,agents:H,onOpenProject:h,onMemoryManagement:_,onCommandManagement:he,onSubAgentManagement:ae,onA2AManagement:re,onDeleteProject:F,onAgentChanged:se}),w&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"导入项目"}),e.jsx("button",{onClick:()=>{x(!1),K("")},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"项目目录路径"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"text",value:j,onChange:o=>K(o.target.value),placeholder:"请选择或输入项目目录路径",className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent dark:bg-gray-700 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>B(!0),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",title:"选择目录",children:e.jsx(Me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"选择要导入的现有项目目录"})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",children:e.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:[e.jsx("strong",{children:"说明:"}),"导入的目录将被添加到项目中,并关联到第一个可用的代理。"]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:()=>{x(!1),K("")},className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:"取消"}),e.jsx("button",{type:"button",onClick:ke,disabled:!j.trim(),className:"px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"导入项目"})]})]})]})}),e.jsx(Mt,{isOpen:C,onClose:()=>m(!1),onConfirm:n,agents:H}),g&&e.jsx(kt,{project:g,onClose:()=>f(null)}),c&&e.jsx(wt,{project:c,onClose:()=>E(null)}),O&&e.jsx(vt,{project:O,onClose:()=>I(null)}),U&&e.jsx(At,{project:U,onClose:()=>S(null)}),L&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:l("projects.selectType")}),e.jsx("button",{onClick:()=>r(null),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:l("projects.selectType")})}),e.jsx("div",{className:"space-y-3",children:H.map(o=>e.jsx("button",{onClick:()=>W(o.id),className:"w-full p-4 text-left border border-gray-200 dark:border-gray-700 rounded-lg hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 transition-colors",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"text-2xl",children:o.ui.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:o.name}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:o.description})]})]})},o.id))}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx("button",{onClick:()=>r(null),className:"px-4 py-2 text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:l("projects.form.cancel")})})]})]})}),G&&e.jsx(Ue,{title:"选择项目目录",allowFiles:!1,allowDirectories:!0,onSelect:pe,onClose:()=>B(!1)})]})};export{_t as ProjectsPage};