agentstudio 0.1.20 → 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 (164) hide show
  1. package/index.d.ts.map +1 -1
  2. package/index.js +5 -0
  3. package/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/public/assets/{AgentsPage-CKTz2ND6.js → AgentsPage-Nvg2xu6K.js} +2 -2
  6. package/public/assets/{Button-Dg6ni5Yl.js → Button-Co56C389.js} +1 -1
  7. package/public/assets/{ChatPage-DkO3kzY2.js → ChatPage-D6sol0ad.js} +5 -5
  8. package/public/assets/{CommandForm-CIfw9mVj.js → CommandForm-Bk7F_HU8.js} +1 -1
  9. package/public/assets/{CommandsPage-BgN0E41K.js → CommandsPage-DZHyOdKd.js} +1 -1
  10. package/public/assets/{DashboardPage-Duu6pBON.js → DashboardPage-29qC7Ev1.js} +2 -2
  11. package/public/assets/{FileBrowser-Bnm7ZyGT.js → FileBrowser-BYweUPH4.js} +4 -4
  12. package/public/assets/FileExplorer-DNYj6Tsx.js +1 -0
  13. package/public/assets/{GeneralSettingsPage-BJTiwSqP.js → GeneralSettingsPage-D9Xa7Nd8.js} +1 -1
  14. package/public/assets/LandingPage-CjnT-cvO.js +1 -0
  15. package/public/assets/{LoginPage-DCI_RABC.js → LoginPage-DcaGNCXH.js} +3 -3
  16. package/public/assets/McpAdminSettingsPage-DgR3E2Bd.js +7 -0
  17. package/public/assets/{McpPage-Dj4bE6a2.js → McpPage-CtWf1CoL.js} +1 -1
  18. package/public/assets/{MemorySettingsPage-v7kI6DEB.js → MemorySettingsPage-JTry4Ccp.js} +1 -1
  19. package/public/assets/PluginsPage-D-BHjQ3P.js +1 -0
  20. package/public/assets/{ProjectSelector-DKkhmVGz.js → ProjectSelector-DSXOjMQC.js} +1 -1
  21. package/public/assets/{ProjectsPage-6nGz1v6U.js → ProjectsPage-lLUk4-Xa.js} +5 -5
  22. package/public/assets/ScheduledTasksPage-5hPbd9Vs.js +1 -0
  23. package/public/assets/{SettingsLayout-stXQCl6u.js → SettingsLayout-DGJspXLp.js} +1 -1
  24. package/public/assets/SkillsPage-DBw0m7D2.js +18 -0
  25. package/public/assets/{SubagentForm-iYJ0l9vh.js → SubagentForm-BdUK1U4y.js} +1 -1
  26. package/public/assets/{SubagentsPage-ksh-LWAC.js → SubagentsPage-Dnq70IFd.js} +1 -1
  27. package/public/assets/{ToastTestPage-pxyInZeD.js → ToastTestPage-BfJQRFIm.js} +1 -1
  28. package/public/assets/{ToolsList-CWZLcBx2.js → ToolsList-Dl5F2fWk.js} +1 -1
  29. package/public/assets/UnifiedToolSelector-CNbPsiuq.js +1 -0
  30. package/public/assets/{VersionSettingsPage-ClLBqAIC.js → VersionSettingsPage-BfoCcham.js} +1 -1
  31. package/public/assets/{_basePickBy-Ce1_TuBk.js → _basePickBy-7C_e0Xv1.js} +1 -1
  32. package/public/assets/{_baseUniq-Dt6C4BgZ.js → _baseUniq-eGJNLBzx.js} +1 -1
  33. package/public/assets/{agents-C4aCwcCz.js → agents-ChrA1R0y.js} +1 -1
  34. package/public/assets/arc-CuA752eE.js +1 -0
  35. package/public/assets/{architectureDiagram-VXUJARFQ-rnurJGX4.js → architectureDiagram-VXUJARFQ-BnPYh1OW.js} +1 -1
  36. package/public/assets/{blockDiagram-VD42YOAC-CM33sjhb.js → blockDiagram-VD42YOAC-72nsMt_i.js} +1 -1
  37. package/public/assets/{c4Diagram-YG6GDRKO-B1tJjciL.js → c4Diagram-YG6GDRKO-BNJSAXcg.js} +1 -1
  38. package/public/assets/channel-CIunGC5m.js +1 -0
  39. package/public/assets/{chunk-4BX2VUAB-vbzk_8Ta.js → chunk-4BX2VUAB-RPxkCWhH.js} +1 -1
  40. package/public/assets/{chunk-55IACEB6-CNXjTgeK.js → chunk-55IACEB6-3ePDt0kp.js} +1 -1
  41. package/public/assets/{chunk-B4BG7PRW-CykotMKj.js → chunk-B4BG7PRW-CBg_BBfl.js} +1 -1
  42. package/public/assets/{chunk-DI55MBZ5-DbZodDrP.js → chunk-DI55MBZ5-DIh69TUJ.js} +1 -1
  43. package/public/assets/{chunk-FMBD7UC4-u0h-4JXb.js → chunk-FMBD7UC4-BbjwhyTe.js} +1 -1
  44. package/public/assets/{chunk-QN33PNHL-B7VLbRpC.js → chunk-QN33PNHL-BpH-o_YR.js} +1 -1
  45. package/public/assets/{chunk-QZHKN3VN-DfcZEdwM.js → chunk-QZHKN3VN-DYB7rh5Q.js} +1 -1
  46. package/public/assets/{chunk-TZMSLE5B-BP4O9iGm.js → chunk-TZMSLE5B-DPCYEVb3.js} +1 -1
  47. package/public/assets/classDiagram-2ON5EDUG-aUQHFsTA.js +1 -0
  48. package/public/assets/classDiagram-v2-WZHVMYZB-aUQHFsTA.js +1 -0
  49. package/public/assets/clone-Ckf7tA1V.js +1 -0
  50. package/public/assets/{cose-bilkent-S5V4N54A-CSV8iDOr.js → cose-bilkent-S5V4N54A-CnpfmL-Y.js} +1 -1
  51. package/public/assets/{dagre-6UL2VRFP-S5vHkFwY.js → dagre-6UL2VRFP-DR9x77Xf.js} +1 -1
  52. package/public/assets/{diagram-PSM6KHXK-Bl4NbJsm.js → diagram-PSM6KHXK-SONPsQNx.js} +1 -1
  53. package/public/assets/{diagram-QEK2KX5R-D-6ipdkt.js → diagram-QEK2KX5R-BKYFSfC1.js} +1 -1
  54. package/public/assets/{diagram-S2PKOQOG-DBuN3kfb.js → diagram-S2PKOQOG-CkM0APZj.js} +1 -1
  55. package/public/assets/{erDiagram-Q2GNP2WA-DEhlyUw1.js → erDiagram-Q2GNP2WA-BX1DpOGx.js} +1 -1
  56. package/public/assets/{flowDiagram-NV44I4VS-PsSk5-Xf.js → flowDiagram-NV44I4VS-HAAlzNbq.js} +1 -1
  57. package/public/assets/{ganttDiagram-LVOFAZNH-PfD-vtKp.js → ganttDiagram-LVOFAZNH-BqzWexqa.js} +1 -1
  58. package/public/assets/{gitGraphDiagram-NY62KEGX-CUq51Mt1.js → gitGraphDiagram-NY62KEGX-CIPmSp43.js} +1 -1
  59. package/public/assets/{graph-Bc5M3bvZ.js → graph-m515btDj.js} +1 -1
  60. package/public/assets/{index-ImPzdvfG.js → index-Bn3v3S9-.js} +47 -47
  61. package/public/assets/index-DWieeYj4.css +1 -0
  62. package/public/assets/infoDiagram-F6ZHWCRC-Pn4yNWrF.js +2 -0
  63. package/public/assets/{journeyDiagram-XKPGCS4Q-CTyau8Sh.js → journeyDiagram-XKPGCS4Q-BfzTomS0.js} +1 -1
  64. package/public/assets/{kanban-definition-3W4ZIXB7-2R3dHQq1.js → kanban-definition-3W4ZIXB7-Cgju7b-L.js} +1 -1
  65. package/public/assets/{layout-BCktuL_6.js → layout-BKQfQSxJ.js} +1 -1
  66. package/public/assets/{linear-lHuinZOC.js → linear-DigtLz3B.js} +1 -1
  67. package/public/assets/{mindmap-definition-VGOIOE7T-Dl8qR3zk.js → mindmap-definition-VGOIOE7T-qopraVFy.js} +1 -1
  68. package/public/assets/{pieDiagram-ADFJNKIX-Bqcukh_c.js → pieDiagram-ADFJNKIX-BcoaAI-L.js} +2 -2
  69. package/public/assets/{quadrantDiagram-AYHSOK5B-C_uML1JV.js → quadrantDiagram-AYHSOK5B-D-DwcoSd.js} +1 -1
  70. package/public/assets/{requirementDiagram-UZGBJVZJ-QUbH9ShO.js → requirementDiagram-UZGBJVZJ-DbQCpx77.js} +1 -1
  71. package/public/assets/{sankeyDiagram-TZEHDZUN-CEomXpQ1.js → sankeyDiagram-TZEHDZUN-BVk8387S.js} +1 -1
  72. package/public/assets/{sequenceDiagram-WL72ISMW-DNsDMjTd.js → sequenceDiagram-WL72ISMW-BdzICjxO.js} +1 -1
  73. package/public/assets/{stateDiagram-FKZM4ZOC-BA_Narwp.js → stateDiagram-FKZM4ZOC-CYY-uUvJ.js} +1 -1
  74. package/public/assets/stateDiagram-v2-4FDKWEC3-Dh2Kvomq.js +1 -0
  75. package/public/assets/{tabManager-CkNKjP4G.js → tabManager-B2LQO_Ll.js} +1 -1
  76. package/public/assets/{table-CSWCaVuS.js → table-D0L2RL5i.js} +1 -1
  77. package/public/assets/{timeline-definition-IT6M3QCI-DeEgHBeI.js → timeline-definition-IT6M3QCI-BAvjPYvX.js} +1 -1
  78. package/public/assets/{tools-C7xmF_rB.js → tools-IcPNZlPj.js} +1 -1
  79. package/public/assets/{treemap-KMMF4GRG-5HQSTjk6.js → treemap-KMMF4GRG-DtkpVA56.js} +1 -1
  80. package/public/assets/{ui-components-BNdpaz32.js → ui-components-D1St49qC.js} +129 -119
  81. package/public/assets/{useAgents-C9aEFOWD.js → useAgents-BnDTkOG8.js} +1 -1
  82. package/public/assets/{useClaudeVersions-CcFqpR2o.js → useClaudeVersions-CD59tFWM.js} +1 -1
  83. package/public/assets/{useCommands-BadxYHf2.js → useCommands-mvMu3mMD.js} +1 -1
  84. package/public/assets/{useProjects-Dgk7ldPq.js → useProjects-YXOjaOwL.js} +1 -1
  85. package/public/assets/{xychartDiagram-PRI3JC2R-C7BNHmgo.js → xychartDiagram-PRI3JC2R-ByBTDWE2.js} +1 -1
  86. package/public/index.html +5 -5
  87. package/routes/mcp.d.ts +23 -0
  88. package/routes/mcp.d.ts.map +1 -1
  89. package/routes/mcp.js +21 -18
  90. package/routes/mcp.js.map +1 -1
  91. package/routes/mcpAdmin.d.ts +16 -0
  92. package/routes/mcpAdmin.d.ts.map +1 -0
  93. package/routes/mcpAdmin.js +308 -0
  94. package/routes/mcpAdmin.js.map +1 -0
  95. package/routes/mcpAdminManagement.d.ts +17 -0
  96. package/routes/mcpAdminManagement.d.ts.map +1 -0
  97. package/routes/mcpAdminManagement.js +345 -0
  98. package/routes/mcpAdminManagement.js.map +1 -0
  99. package/services/mcpAdmin/__tests__/adminApiKeyService.test.d.ts +5 -0
  100. package/services/mcpAdmin/__tests__/adminApiKeyService.test.d.ts.map +1 -0
  101. package/services/mcpAdmin/__tests__/adminApiKeyService.test.js +289 -0
  102. package/services/mcpAdmin/__tests__/adminApiKeyService.test.js.map +1 -0
  103. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.d.ts +5 -0
  104. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.d.ts.map +1 -0
  105. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.js +345 -0
  106. package/services/mcpAdmin/__tests__/mcpAdminRoutes.test.js.map +1 -0
  107. package/services/mcpAdmin/__tests__/mcpAdminServer.test.d.ts +5 -0
  108. package/services/mcpAdmin/__tests__/mcpAdminServer.test.d.ts.map +1 -0
  109. package/services/mcpAdmin/__tests__/mcpAdminServer.test.js +453 -0
  110. package/services/mcpAdmin/__tests__/mcpAdminServer.test.js.map +1 -0
  111. package/services/mcpAdmin/__tests__/tools.test.d.ts +5 -0
  112. package/services/mcpAdmin/__tests__/tools.test.d.ts.map +1 -0
  113. package/services/mcpAdmin/__tests__/tools.test.js +371 -0
  114. package/services/mcpAdmin/__tests__/tools.test.js.map +1 -0
  115. package/services/mcpAdmin/adminApiKeyService.d.ts +61 -0
  116. package/services/mcpAdmin/adminApiKeyService.d.ts.map +1 -0
  117. package/services/mcpAdmin/adminApiKeyService.js +270 -0
  118. package/services/mcpAdmin/adminApiKeyService.js.map +1 -0
  119. package/services/mcpAdmin/index.d.ts +10 -0
  120. package/services/mcpAdmin/index.d.ts.map +1 -0
  121. package/services/mcpAdmin/index.js +43 -0
  122. package/services/mcpAdmin/index.js.map +1 -0
  123. package/services/mcpAdmin/mcpAdminServer.d.ts +76 -0
  124. package/services/mcpAdmin/mcpAdminServer.d.ts.map +1 -0
  125. package/services/mcpAdmin/mcpAdminServer.js +243 -0
  126. package/services/mcpAdmin/mcpAdminServer.js.map +1 -0
  127. package/services/mcpAdmin/tools/agentTools.d.ts +27 -0
  128. package/services/mcpAdmin/tools/agentTools.d.ts.map +1 -0
  129. package/services/mcpAdmin/tools/agentTools.js +359 -0
  130. package/services/mcpAdmin/tools/agentTools.js.map +1 -0
  131. package/services/mcpAdmin/tools/index.d.ts +15 -0
  132. package/services/mcpAdmin/tools/index.d.ts.map +1 -0
  133. package/services/mcpAdmin/tools/index.js +30 -0
  134. package/services/mcpAdmin/tools/index.js.map +1 -0
  135. package/services/mcpAdmin/tools/mcpServerTools.d.ts +27 -0
  136. package/services/mcpAdmin/tools/mcpServerTools.d.ts.map +1 -0
  137. package/services/mcpAdmin/tools/mcpServerTools.js +334 -0
  138. package/services/mcpAdmin/tools/mcpServerTools.js.map +1 -0
  139. package/services/mcpAdmin/tools/projectTools.d.ts +27 -0
  140. package/services/mcpAdmin/tools/projectTools.d.ts.map +1 -0
  141. package/services/mcpAdmin/tools/projectTools.js +353 -0
  142. package/services/mcpAdmin/tools/projectTools.js.map +1 -0
  143. package/services/mcpAdmin/tools/systemTools.d.ts +23 -0
  144. package/services/mcpAdmin/tools/systemTools.d.ts.map +1 -0
  145. package/services/mcpAdmin/tools/systemTools.js +241 -0
  146. package/services/mcpAdmin/tools/systemTools.js.map +1 -0
  147. package/services/mcpAdmin/types.d.ts +124 -0
  148. package/services/mcpAdmin/types.d.ts.map +1 -0
  149. package/services/mcpAdmin/types.js +18 -0
  150. package/services/mcpAdmin/types.js.map +1 -0
  151. package/public/assets/FileExplorer-Dy8ZFDtK.js +0 -1
  152. package/public/assets/LandingPage-CCqtSDce.js +0 -1
  153. package/public/assets/PluginsPage-CQ08px0h.js +0 -1
  154. package/public/assets/ScheduledTasksPage-Dv8qPeLY.js +0 -1
  155. package/public/assets/SkillsPage-DlQPlwG5.js +0 -18
  156. package/public/assets/UnifiedToolSelector-A2UIt1Xn.js +0 -1
  157. package/public/assets/arc-c63c3GDw.js +0 -1
  158. package/public/assets/channel-6fK1csbi.js +0 -1
  159. package/public/assets/classDiagram-2ON5EDUG-PrDkNsdA.js +0 -1
  160. package/public/assets/classDiagram-v2-WZHVMYZB-PrDkNsdA.js +0 -1
  161. package/public/assets/clone-CXX9AxT7.js +0 -1
  162. package/public/assets/index-TEVaBQiv.css +0 -1
  163. package/public/assets/infoDiagram-F6ZHWCRC-BTR1hJCm.js +0 -2
  164. package/public/assets/stateDiagram-v2-4FDKWEC3-Cy5am68v.js +0 -1
@@ -0,0 +1,124 @@
1
+ /**
2
+ * MCP Admin Server Types
3
+ *
4
+ * Type definitions for the MCP Admin Server that provides
5
+ * management APIs via MCP HTTP Streamable protocol.
6
+ */
7
+ export interface JsonRpcRequest {
8
+ jsonrpc: '2.0';
9
+ id: string | number | null;
10
+ method: string;
11
+ params?: Record<string, unknown>;
12
+ }
13
+ export interface JsonRpcResponse {
14
+ jsonrpc: '2.0';
15
+ id: string | number | null;
16
+ result?: unknown;
17
+ error?: JsonRpcError;
18
+ }
19
+ export interface JsonRpcError {
20
+ code: number;
21
+ message: string;
22
+ data?: unknown;
23
+ }
24
+ export declare const JSON_RPC_ERRORS: {
25
+ readonly PARSE_ERROR: {
26
+ readonly code: -32700;
27
+ readonly message: "Parse error";
28
+ };
29
+ readonly INVALID_REQUEST: {
30
+ readonly code: -32600;
31
+ readonly message: "Invalid Request";
32
+ };
33
+ readonly METHOD_NOT_FOUND: {
34
+ readonly code: -32601;
35
+ readonly message: "Method not found";
36
+ };
37
+ readonly INVALID_PARAMS: {
38
+ readonly code: -32602;
39
+ readonly message: "Invalid params";
40
+ };
41
+ readonly INTERNAL_ERROR: {
42
+ readonly code: -32603;
43
+ readonly message: "Internal error";
44
+ };
45
+ };
46
+ export interface McpServerInfo {
47
+ name: string;
48
+ version: string;
49
+ }
50
+ export interface McpCapabilities {
51
+ tools?: Record<string, unknown>;
52
+ resources?: Record<string, unknown>;
53
+ prompts?: Record<string, unknown>;
54
+ }
55
+ export interface McpInitializeParams {
56
+ protocolVersion: string;
57
+ capabilities: McpCapabilities;
58
+ clientInfo: {
59
+ name: string;
60
+ version: string;
61
+ };
62
+ }
63
+ export interface McpInitializeResult {
64
+ protocolVersion: string;
65
+ capabilities: McpCapabilities;
66
+ serverInfo: McpServerInfo;
67
+ }
68
+ export interface McpTool {
69
+ name: string;
70
+ description: string;
71
+ inputSchema: {
72
+ type: 'object';
73
+ properties: Record<string, unknown>;
74
+ required?: string[];
75
+ };
76
+ }
77
+ export interface McpToolsListResult {
78
+ tools: McpTool[];
79
+ }
80
+ export interface McpToolCallParams {
81
+ name: string;
82
+ arguments?: Record<string, unknown>;
83
+ }
84
+ export interface McpToolCallResult {
85
+ content: Array<{
86
+ type: 'text' | 'image' | 'resource';
87
+ text?: string;
88
+ data?: string;
89
+ mimeType?: string;
90
+ }>;
91
+ isError?: boolean;
92
+ }
93
+ export interface AdminApiKey {
94
+ id: string;
95
+ keyHash: string;
96
+ encryptedKey: string;
97
+ description: string;
98
+ createdAt: string;
99
+ lastUsedAt?: string;
100
+ revokedAt?: string;
101
+ permissions: AdminPermission[];
102
+ /** Optional list of allowed tool names. If undefined or empty, all tools are allowed (based on permissions). */
103
+ allowedTools?: string[];
104
+ /** Whether the key is enabled. Defaults to true if not specified. */
105
+ enabled?: boolean;
106
+ }
107
+ export interface AdminApiKeyRegistry {
108
+ version: '1.0.0';
109
+ keys: AdminApiKey[];
110
+ }
111
+ export type AdminPermission = 'projects:read' | 'projects:write' | 'agents:read' | 'agents:write' | 'mcp:read' | 'mcp:write' | 'system:read' | 'system:write' | 'admin:*';
112
+ export interface ToolContext {
113
+ apiKeyId: string;
114
+ permissions: AdminPermission[];
115
+ /** Optional list of allowed tool names. If undefined, all tools are allowed (based on permissions). */
116
+ allowedTools?: string[];
117
+ }
118
+ export type ToolHandler = (params: Record<string, unknown>, context: ToolContext) => Promise<McpToolCallResult>;
119
+ export interface ToolDefinition {
120
+ tool: McpTool;
121
+ handler: ToolHandler;
122
+ requiredPermissions: AdminPermission[];
123
+ }
124
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/mcpAdmin/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;CAMlB,CAAC;AAMX,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,eAAe,CAAC;IAC9B,UAAU,EAAE,aAAa,CAAC;CAC3B;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,gHAAgH;IAChH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,aAAa,GACb,cAAc,GACd,SAAS,CAAC;AAMd,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,uGAAuG;IACvG,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB,EAAE,eAAe,EAAE,CAAC;CACxC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Admin Server Types
4
+ *
5
+ * Type definitions for the MCP Admin Server that provides
6
+ * management APIs via MCP HTTP Streamable protocol.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.JSON_RPC_ERRORS = void 0;
10
+ // Standard JSON-RPC error codes
11
+ exports.JSON_RPC_ERRORS = {
12
+ PARSE_ERROR: { code: -32700, message: 'Parse error' },
13
+ INVALID_REQUEST: { code: -32600, message: 'Invalid Request' },
14
+ METHOD_NOT_FOUND: { code: -32601, message: 'Method not found' },
15
+ INVALID_PARAMS: { code: -32602, message: 'Invalid params' },
16
+ INTERNAL_ERROR: { code: -32603, message: 'Internal error' },
17
+ };
18
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/mcpAdmin/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA0BH,gCAAgC;AACnB,QAAA,eAAe,GAAG;IAC7B,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE;IACrD,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC7D,gBAAgB,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE;IAC/D,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAC3D,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE;CACnD,CAAC"}
@@ -1 +0,0 @@
1
- import{c as Se}from"./syntax-highlighting-CnREyncB.js";import{j as e,T as He}from"./data-structures-C0h9Oap1.js";import{r as c,W as Fe}from"./monaco-editor-DHKm5-VF.js";import{ap as u,E as Te,V as Me,a1 as De,aq as Ae,L as T,ar as Re,X as ne,as as Ve,k as Ie,l as Oe}from"./ui-components-BNdpaz32.js";import{u as me,a as _,A as M}from"./agents-C4aCwcCz.js";import{u as ue}from"./tools-C7xmF_rB.js";function $e(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L192 480l157.1-52.2L384 32H0zm313.1 80l-4.8 47.3L193 208.6l-.3.1h111.5l-12.8 146.6-98.2 28.7-98.8-29.2-6.4-73.9h48.9l3.2 38.3 52.6 13.3 54.7-15.4 3.7-61.6-166.3-.5v-.1l-.2.1-3.6-46.3L193.1 162l6.5-2.7H76.7L70.9 112h242.2z"},child:[]}]})(r)}function ie(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"},child:[]}]})(r)}function Be(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"},child:[]}]})(r)}function Pe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM243.8 381.4c0 43.6-25.6 63.5-62.9 63.5-33.7 0-53.2-17.4-63.2-38.5l34.3-20.7c6.6 11.7 12.6 21.6 27.1 21.6 13.8 0 22.6-5.4 22.6-26.5V237.7h42.1v143.7zm99.6 63.5c-39.1 0-64.4-18.6-76.7-43l34.3-19.8c9 14.7 20.8 25.6 41.5 25.6 17.4 0 28.6-8.7 28.6-20.8 0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5 0-31.6 24.1-55.6 61.6-55.6 26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18-12.3 0-20.1 7.8-20.1 18 0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2 0 37.8-29.8 58.6-69.7 58.6z"},child:[]}]})(r)}function _e(r){return u({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"},child:[]}]})(r)}function qe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(r)}function We(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M418.2 177.2c-5.4-1.8-10.8-3.5-16.2-5.1.9-3.7 1.7-7.4 2.5-11.1 12.3-59.6 4.2-107.5-23.1-123.3-26.3-15.1-69.2.6-112.6 38.4-4.3 3.7-8.5 7.6-12.5 11.5-2.7-2.6-5.5-5.2-8.3-7.7-45.5-40.4-91.1-57.4-118.4-41.5-26.2 15.2-34 60.3-23 116.7 1.1 5.6 2.3 11.1 3.7 16.7-6.4 1.8-12.7 3.8-18.6 5.9C38.3 196.2 0 225.4 0 255.6c0 31.2 40.8 62.5 96.3 81.5 4.5 1.5 9 3 13.6 4.3-1.5 6-2.8 11.9-4 18-10.5 55.5-2.3 99.5 23.9 114.6 27 15.6 72.4-.4 116.6-39.1 3.5-3.1 7-6.3 10.5-9.7 4.4 4.3 9 8.4 13.6 12.4 42.8 36.8 85.1 51.7 111.2 36.6 27-15.6 35.8-62.9 24.4-120.5-.9-4.4-1.9-8.9-3-13.5 3.2-.9 6.3-1.9 9.4-2.9 57.7-19.1 99.5-50 99.5-81.7 0-30.3-39.4-59.7-93.8-78.4zM282.9 92.3c37.2-32.4 71.9-45.1 87.7-36 16.9 9.7 23.4 48.9 12.8 100.4-.7 3.4-1.4 6.7-2.3 10-22.2-5-44.7-8.6-67.3-10.6-13-18.6-27.2-36.4-42.6-53.1 3.9-3.7 7.7-7.2 11.7-10.7zM167.2 307.5c5.1 8.7 10.3 17.4 15.8 25.9-15.6-1.7-31.1-4.2-46.4-7.5 4.4-14.4 9.9-29.3 16.3-44.5 4.6 8.8 9.3 17.5 14.3 26.1zm-30.3-120.3c14.4-3.2 29.7-5.8 45.6-7.8-5.3 8.3-10.5 16.8-15.4 25.4-4.9 8.5-9.7 17.2-14.2 26-6.3-14.9-11.6-29.5-16-43.6zm27.4 68.9c6.6-13.8 13.8-27.3 21.4-40.6s15.8-26.2 24.4-38.9c15-1.1 30.3-1.7 45.9-1.7s31 .6 45.9 1.7c8.5 12.6 16.6 25.5 24.3 38.7s14.9 26.7 21.7 40.4c-6.7 13.8-13.9 27.4-21.6 40.8-7.6 13.3-15.7 26.2-24.2 39-14.9 1.1-30.4 1.6-46.1 1.6s-30.9-.5-45.6-1.4c-8.7-12.7-16.9-25.7-24.6-39s-14.8-26.8-21.5-40.6zm180.6 51.2c5.1-8.8 9.9-17.7 14.6-26.7 6.4 14.5 12 29.2 16.9 44.3-15.5 3.5-31.2 6.2-47 8 5.4-8.4 10.5-17 15.5-25.6zm14.4-76.5c-4.7-8.8-9.5-17.6-14.5-26.2-4.9-8.5-10-16.9-15.3-25.2 16.1 2 31.5 4.7 45.9 8-4.6 14.8-10 29.2-16.1 43.4zM256.2 118.3c10.5 11.4 20.4 23.4 29.6 35.8-19.8-.9-39.7-.9-59.5 0 9.8-12.9 19.9-24.9 29.9-35.8zM140.2 57c16.8-9.8 54.1 4.2 93.4 39 2.5 2.2 5 4.6 7.6 7-15.5 16.7-29.8 34.5-42.9 53.1-22.6 2-45 5.5-67.2 10.4-1.3-5.1-2.4-10.3-3.5-15.5-9.4-48.4-3.2-84.9 12.6-94zm-24.5 263.6c-4.2-1.2-8.3-2.5-12.4-3.9-21.3-6.7-45.5-17.3-63-31.2-10.1-7-16.9-17.8-18.8-29.9 0-18.3 31.6-41.7 77.2-57.6 5.7-2 11.5-3.8 17.3-5.5 6.8 21.7 15 43 24.5 63.6-9.6 20.9-17.9 42.5-24.8 64.5zm116.6 98c-16.5 15.1-35.6 27.1-56.4 35.3-11.1 5.3-23.9 5.8-35.3 1.3-15.9-9.2-22.5-44.5-13.5-92 1.1-5.6 2.3-11.2 3.7-16.7 22.4 4.8 45 8.1 67.9 9.8 13.2 18.7 27.7 36.6 43.2 53.4-3.2 3.1-6.4 6.1-9.6 8.9zm24.5-24.3c-10.2-11-20.4-23.2-30.3-36.3 9.6.4 19.5.6 29.5.6 10.3 0 20.4-.2 30.4-.7-9.2 12.7-19.1 24.8-29.6 36.4zm130.7 30c-.9 12.2-6.9 23.6-16.5 31.3-15.9 9.2-49.8-2.8-86.4-34.2-4.2-3.6-8.4-7.5-12.7-11.5 15.3-16.9 29.4-34.8 42.2-53.6 22.9-1.9 45.7-5.4 68.2-10.5 1 4.1 1.9 8.2 2.7 12.2 4.9 21.6 5.7 44.1 2.5 66.3zm18.2-107.5c-2.8.9-5.6 1.8-8.5 2.6-7-21.8-15.6-43.1-25.5-63.8 9.6-20.4 17.7-41.4 24.5-62.9 5.2 1.5 10.2 3.1 15 4.7 46.6 16 79.3 39.8 79.3 58 0 19.6-34.9 44.9-84.8 61.4zm-149.7-15c25.3 0 45.8-20.5 45.8-45.8s-20.5-45.8-45.8-45.8c-25.3 0-45.8 20.5-45.8 45.8s20.5 45.8 45.8 45.8z"},child:[]}]})(r)}function Ue(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(r)}function le(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm57.1 120H305c7.7 0 13.4 7.1 11.7 14.7l-38 168c-1.2 5.5-6.1 9.3-11.7 9.3h-38c-5.5 0-10.3-3.8-11.6-9.1-25.8-103.5-20.8-81.2-25.6-110.5h-.5c-1.1 14.3-2.4 17.4-25.6 110.5-1.3 5.3-6.1 9.1-11.6 9.1H117c-5.6 0-10.5-3.9-11.7-9.4l-37.8-168c-1.7-7.5 4-14.6 11.7-14.6h24.5c5.7 0 10.7 4 11.8 9.7 15.6 78 20.1 109.5 21 122.2 1.6-10.2 7.3-32.7 29.4-122.7 1.3-5.4 6.1-9.1 11.7-9.1h29.1c5.6 0 10.4 3.8 11.7 9.2 24 100.4 28.8 124 29.6 129.4-.2-11.2-2.6-17.8 21.6-129.2 1-5.6 5.9-9.5 11.5-9.5zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function q(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function Je(r){return u({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(r)}function Ke(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"},child:[]}]})(r)}function j(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(r)}function Ge(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4.708 5.578L2.061 8.224l2.647 2.646-.708.708-3-3V7.87l3-3 .708.708zm7-.708L11 5.578l2.647 2.646L11 10.87l.708.708 3-3V7.87l-3-3zM4.908 13l.894.448 5-10L9.908 3l-5 10z"},child:[]}]})(r)}function oe(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(r)}function de(r){return u({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"},child:[]}]})(r)}const Xe=(r,l)=>me({queryKey:["file-content",r,l],queryFn:async()=>{if(!r)throw new Error("File path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("projectPath",l);const h=await _(`${M}/files/read?${d.toString()}`);if(!h.ok)throw h.status===403?new Error("访问被拒绝:文件在项目目录之外"):h.status===404?new Error("文件不存在"):new Error(`读取文件失败 (${h.status})`);return h.json()},enabled:!!r,staleTime:6e4,retry:!1}),Qe=(r,l)=>me({queryKey:["file-tree-lazy",r,l],queryFn:async()=>{if(!r)throw new Error("Project path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("showHiddenFiles","true");const h=await _(`${M}/files/browse?${d.toString()}`);if(!h.ok)throw new Error("Failed to browse directory");const i=await h.json(),x=[];for(const f of i.items)f.isDirectory?x.push({...f,children:[]}):x.push(f);return x},enabled:!!r,staleTime:3e4});class Ye{events=new Map;on(l,d){this.events.has(l)||this.events.set(l,[]),this.events.get(l).push(d)}off(l,d){const h=this.events.get(l);if(h){const i=h.indexOf(d);i>-1&&h.splice(i,1)}}emit(l,...d){const h=this.events.get(l);h&&h.forEach(i=>{try{i(...d)}catch(x){console.error(`Error in event handler for ${l}:`,x)}})}clear(){this.events.clear()}}const he=new Ye,xe={AI_RESPONSE_COMPLETE:"ai_response_complete",REFRESH_AGENT_CONTENT:"refresh_agent_content"},Ze=c.lazy(()=>Se(()=>import("./monaco-editor-DHKm5-VF.js").then(r=>r.i),[])),et=new Map([["js",e.jsx(Pe,{color:"#f7df1e"},"js")],["jsx",e.jsx(We,{color:"#61dafb"},"jsx")],["ts",e.jsx(de,{color:"#3178c6"},"ts")],["tsx",e.jsx(de,{color:"#3178c6"},"tsx")],["css",e.jsx($e,{color:"#1572b6"},"css")],["html",e.jsx(ie,{color:"#e34f26"},"html")],["htm",e.jsx(ie,{color:"#e34f26"},"htm")],["json",e.jsx(oe,{color:"#f9d71c"},"json")],["jsonl",e.jsx(oe,{color:"#e6a23c"},"jsonl")],["md",e.jsx(_e,{color:"#083fa1"},"md")],["csv",e.jsx(q,{color:"#00a86b"},"csv")],["pdf",e.jsx(Ue,{color:"#d63031"},"pdf")],["ppt",e.jsx(le,{color:"#d63031"},"ppt")],["pptx",e.jsx(le,{color:"#d63031"},"pptx")],["ico",e.jsx(j,{color:"#a9a9a9"},"ico")],["png",e.jsx(j,{color:"#a9a9a9"},"png")],["jpg",e.jsx(j,{color:"#a9a9a9"},"jpg")],["jpeg",e.jsx(j,{color:"#a9a9a9"},"jpeg")],["gif",e.jsx(j,{color:"#a9a9a9"},"gif")],["svg",e.jsx(j,{color:"#a9a9a9"},"svg")],["webp",e.jsx(j,{color:"#a9a9a9"},"webp")],["py",e.jsx(qe,{color:"#3776ab"},"py")],["java",e.jsx(Be,{color:"#007396"},"java")]]),P=({node:r})=>{const l=r.data.isHidden;if(r.data.isDirectory){const x=l?"#9ca3af":"#87b3d6";return r.isOpen?e.jsx(Je,{color:x}):e.jsx(Ke,{color:x})}const d=r.data.name.split(".").pop()?.toLowerCase()||"",h=l?"#9ca3af":"#6d8a9f",i=l?{opacity:.6}:{};return e.jsx("span",{style:i,children:et.get(d)||e.jsx(q,{color:h})})},tt=(r="")=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"dockerfile";switch(r.split(".").pop()?.toLowerCase()||""){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"css":case"scss":case"sass":case"less":return"css";case"json":case"jsonl":return"json";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"csv":return"csv";case"py":return"python";case"java":return"java";case"xml":return"xml";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"conf":case"config":case"ini":return"ini";case"nginx":return"nginx";case"sql":return"sql";case"go":return"go";case"rs":return"rust";case"c":case"cpp":case"cc":case"cxx":return"cpp";case"h":case"hpp":return"cpp";case"cs":return"csharp";case"php":return"php";case"rb":return"ruby";case"swift":return"swift";case"kt":return"kotlin";case"dockerfile":return"dockerfile";default:return"plaintext"}},rt=({imageUrl:r,fileName:l})=>{const{t:d}=ue("components"),[h,i]=c.useState(!0),[x,f]=c.useState(!1);return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:x?e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:d("fileExplorer.imageLoadFailed")}),e.jsx("p",{className:"text-sm mt-2",children:l})]}):e.jsxs("div",{className:"relative max-w-full max-h-full",children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(T,{className:"w-8 h-8 animate-spin text-gray-400"})}),e.jsx("img",{src:r,alt:l,className:"max-w-full max-h-full object-contain bg-white dark:bg-gray-900 rounded shadow-lg",onLoad:()=>i(!1),onError:()=>{i(!1),f(!0)},style:{display:x?"none":"block"}})]})})},st=r=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"text";const d=r.split(".").pop()?.toLowerCase()||"",h=["js","jsx","ts","tsx","css","scss","sass","less","html","htm","json","jsonl","md","markdown","txt","py","java","xml","yaml","yml","sh","bash","bat","cmd","php","rb","go","rs","cpp","c","h","hpp","cc","cxx","cs","swift","kt","scala","clj","sql","dockerfile","gitignore","env","csv","tsv","conf","config","ini","toml","nginx","apache","properties","cfg"],i=["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"];return h.includes(d)?"text":i.includes(d)?"image":"binary"},at=({node:r,style:l,dragHandle:d,isLoading:h=!1,onDirectoryToggle:i,onFileSelect:x})=>{const f=c.useCallback(y=>{y.preventDefault(),y.stopPropagation(),r.data.isDirectory?i?.(r):x?.(r)},[r,i,x]);return e.jsxs("div",{style:l,ref:d,className:`flex items-center cursor-pointer px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 ${r.isSelected?"bg-blue-100 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,onClick:f,children:[r.data.isDirectory&&e.jsx("span",{className:"mr-1 flex items-center",children:h?e.jsx(T,{className:"w-3 h-3 animate-spin text-gray-400"}):e.jsx(Oe,{className:`w-3 h-3 transition-transform text-gray-400 ${r.isOpen?"rotate-90":""}`})}),e.jsx("span",{className:"mr-2 flex items-center",children:e.jsx(P,{node:r})}),e.jsx("span",{className:`text-sm truncate flex-1 ${r.data.isHidden?"text-gray-400 dark:text-gray-500 italic":"text-gray-700 dark:text-gray-300"}`,children:r.data.name}),!r.data.isDirectory&&r.data.size&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:[(r.data.size/1024).toFixed(1),"KB"]})]})},F=5,mt=({projectPath:r,onFileSelect:l,className:d="",height:h="100vh"})=>{const{t:i}=ue("components"),[x,f]=c.useState([]),[y,D]=c.useState(null),[fe,W]=c.useState(600),[z,A]=c.useState(!1),k=c.useRef(null),R=c.useRef(null),V=c.useRef(null),[U,ge]=c.useState(0),[J,pe]=c.useState(""),[ye,ve]=c.useState(document.documentElement.classList.contains("dark")),[L,S]=c.useState(new Set),[N,K]=c.useState([]),[I,H]=c.useState(new Set),[g,je]=c.useState(!1),[G,X]=c.useState(!1),{data:E,isLoading:O,error:Q,refetch:C}=Qe(r,g),p=c.useMemo(()=>x.find(t=>t.isActive)||null,[x]),{data:Y,isLoading:be,error:Z}=Xe(p?p.path:void 0,r);c.useEffect(()=>{const t=new MutationObserver(s=>{s.forEach(o=>{o.attributeName==="class"&&ve(document.documentElement.classList.contains("dark"))})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),c.useEffect(()=>{if(E){const t=m=>m.filter(a=>g||!a.isHidden).map(a=>({id:a.path,name:a.name,path:a.path,isDirectory:a.isDirectory,size:a.size,modified:a.modified,isHidden:a.isHidden,children:a.children?t(a.children):void 0})),s=(m,a=new Set)=>(m.forEach(n=>{n.isDirectory&&n.children&&n.children.length>0&&(a.add(n.path),s(n.children,a))}),a),o=s(E);S(o),K(t(E))}},[E,g]);const ee=c.useCallback(async t=>{if(!(L.has(t)||I.has(t))){H(s=>new Set(s).add(t));try{const s=new URLSearchParams;s.append("path",t),g&&s.append("showHiddenFiles","true");const o=await _(`${M}/files/browse?${s.toString()}`);if(!o.ok)throw new Error("Failed to browse directory");const m=await o.json(),a=[];for(const n of m.items)n.isDirectory?a.push({...n,children:[]}):a.push(n);K(n=>{const b=Le=>Le.map(w=>w.path===t?{...w,children:a.map(v=>({id:v.path,name:v.name,path:v.path,isDirectory:v.isDirectory,size:v.size,modified:v.modified,isHidden:v.isHidden,children:v.isDirectory?[]:void 0}))}:w.children?{...w,children:b(w.children)}:w);return b(n)}),S(n=>new Set(n).add(t)),V.current&&a.length>0&&a.forEach(n=>{n.isDirectory&&V.current?.close(n.path)})}catch(s){throw console.error("Failed to load directory children:",s),s}finally{H(s=>{const o=new Set(s);return o.delete(t),o})}}},[L,I,g]),$=c.useCallback(()=>{S(new Set),H(new Set),C()},[C]),we=c.useCallback(()=>{je(t=>!t)},[]);c.useEffect(()=>{S(new Set),H(new Set),C()},[g,C]),c.useEffect(()=>{const t=()=>{if(k.current){const m=k.current.getBoundingClientRect(),a=m.height>0?m.height:600;W(a)}};let s=null;k.current&&(s=new ResizeObserver(m=>{for(const a of m){const{height:n}=a.contentRect;n>0&&W(n)}}),s.observe(k.current));const o=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(o),window.removeEventListener("resize",t),s&&s.disconnect()}},[E]),c.useEffect(()=>{const t=s=>{R.current&&!R.current.contains(s.target)&&A(!1)};if(z)return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[z]),c.useEffect(()=>{const t=s=>{console.log("🔄 Received AI_RESPONSE_COMPLETE event in FileExplorer:",s),s.projectPath===r&&(console.log("🔄 Auto-refreshing file tree after AI response completion"),$())};return he.on(xe.AI_RESPONSE_COMPLETE,t),()=>{he.off(xe.AI_RESPONSE_COMPLETE,t)}},[r,$]);const te=N,ke=c.useMemo(()=>{const t={},s=o=>{o.forEach(m=>{m.isDirectory&&(t[m.id]=!1,m.children&&s(m.children))})};return N&&N.length>0&&s(N),t},[N]),re=c.useCallback((t,s=!1)=>({id:`tab-${t.path}`,name:t.name,path:t.path,isPinned:s,isActive:!1}),[]),B=c.useCallback((t,s=!1)=>{f(o=>{const m=o.findIndex(a=>a.path===t.path);if(m!==-1)return o.map((a,n)=>({...a,isActive:n===m,isPinned:s||a.isPinned}));{const a=re(t,s);return!s&&y?(D(a.id),o.map(n=>n.id===y?{...a,isActive:!0}:{...n,isActive:!1})):(s||D(a.id),[...o.map(n=>({...n,isActive:!1})),{...a,isActive:!0}])}}),l?.(t.path)},[re,y,l]),se=c.useCallback(t=>{f(s=>{const o=s.findIndex(n=>n.id===t);if(o===-1)return s;const m=s[o],a=s.filter(n=>n.id!==t);if(m.isActive&&a.length>0){const n=Math.min(o,a.length-1);a[n]={...a[n],isActive:!0}}return y===t&&D(null),a})},[y]),ae=c.useCallback(t=>{f(s=>s.map(o=>({...o,isActive:o.id===t})))},[]),[ce,Ne]=c.useState({}),Ee=c.useCallback(t=>{const s=Date.now(),o=ce[t.data.path]||0;if(s-o<300)return;Ne(b=>({...b,[t.data.path]:s}));const m=t.isOpen,a=t.data.children&&t.data.children.length>0,n=L.has(t.data.path);m?t.close():!a&&!n?(t.open(),ee(t.data.path).catch(b=>{console.error("Failed to load directory children:",b),t.close()})):t.open()},[ce,L,ee]),Ce=c.useCallback(t=>{t.select();const s=Date.now(),o=s-U<300&&J===t.data.path;ge(s),pe(t.data.path),o?B(t.data,!0):setTimeout(()=>{Date.now()-s>=300&&B(t.data,!1)},300)},[B,U,J]),ze=()=>{if(!p)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.selectFile")})]})});if(be)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:i("fileExplorer.loading")})]})});if(Z)return e.jsx("div",{className:"flex items-center justify-center h-full text-red-500 dark:text-red-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Z.message}),e.jsx("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:p.path})]})});switch(st(p.name)){case"image":const s=new URLSearchParams;s.append("path",p.path),r&&s.append("projectPath",r),s.append("binary","true");const o=`${M}/files/read?${s.toString()}`;return e.jsx(rt,{imageUrl:o,fileName:p.name});case"text":return Y?e.jsx(Fe.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"})}),children:e.jsx(Ze,{height:"100%",theme:ye?"vs-dark":"vs-light",language:tt(p.name),value:Y.content,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1}})}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:i("fileExplorer.cannotReadFile")})});default:return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.previewNotSupported")}),e.jsxs("p",{className:"text-sm mt-2",children:[i("fileExplorer.fileLabel"),": ",p.name]})]})})}};return Q?e.jsx("div",{className:`flex items-center justify-center h-full text-red-500 dark:text-red-400 ${d}`,style:{height:h},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Q.message}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:[i("fileExplorer.projectPath"),": ",r]}),e.jsx("button",{onClick:()=>C(),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:i("fileExplorer.retry")})]})}):e.jsxs("div",{className:`flex h-full bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${d}`,children:[!G&&e.jsxs("div",{className:"w-80 border-r border-gray-200 dark:border-gray-700 flex flex-col h-full",children:[e.jsx("div",{className:"h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:i("fileExplorer.title")}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:we,className:`p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors ${g?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"}`,title:g?"隐藏文件和文件夹":"显示隐藏文件和文件夹",children:g?e.jsx(Te,{className:"w-4 h-4"}):e.jsx(Me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:$,className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("common:actions.refresh"),disabled:O,children:e.jsx(De,{className:`w-4 h-4 ${O?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(!0),className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.collapsePanel"),children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})}),e.jsx("div",{ref:k,className:"flex-1 min-h-0 pl-2",children:O?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:i("fileExplorer.loading")})]})}):te.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:i("fileExplorer.emptyDirectory")})}):e.jsx(He,{data:te,width:320,height:fe,indent:20,rowHeight:36,initialOpenState:ke,ref:V,children:t=>e.jsx(at,{...t,isLoading:I.has(t.node.data.path),onDirectoryToggle:Ee,onFileSelect:Ce})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"h-12 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:[G&&e.jsx("button",{onClick:()=>X(!1),className:"p-1.5 mx-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.expandPanel"),children:e.jsx(Re,{className:"w-4 h-4"})}),x.length>0?e.jsxs("div",{className:"flex items-center h-full w-full",children:[e.jsx("div",{className:"flex items-center h-full flex-1",children:x.slice(0,Math.min(F,x.length)).map(t=>e.jsxs("div",{className:`group relative flex items-center h-full px-3 border-r border-gray-200 dark:border-gray-700 cursor-pointer transition-colors ${t.isActive?"bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"} ${t.isPinned?"":"italic"}`,onClick:()=>ae(t.id),title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,style:{minWidth:"120px",maxWidth:"180px"},children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 text-sm truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))}),x.length>F&&e.jsxs("div",{className:"relative",ref:R,children:[e.jsxs("button",{className:"flex items-center h-full px-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-white transition-colors border-l border-gray-200 dark:border-gray-700",onClick:()=>A(!z),title:`${x.length-F} more tabs`,children:[e.jsx(Ve,{className:"w-4 h-4"}),e.jsx(Ie,{className:"w-3 h-3 ml-1"})]}),z&&e.jsx("div",{className:"absolute top-full right-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-48 max-h-64 overflow-y-auto",children:x.slice(F).map(t=>e.jsxs("div",{className:`flex items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 ${t.isActive?"bg-blue-50 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"} ${t.isPinned?"":"italic"}`,onClick:()=>{ae(t.id),A(!1)},title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))})]})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-full text-gray-500 dark:text-gray-400",children:e.jsx("span",{className:"text-sm",children:i("fileExplorer.noFiles")})})]}),e.jsx("div",{className:"flex-1 bg-gray-50 dark:bg-gray-900 min-h-0",children:ze()})]})]})};export{xe as E,mt as F,he as e};
@@ -1 +0,0 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{u as n}from"./tools-C7xmF_rB.js";import{J as l,l as d,o as r,G as o,K as c,U as x,e as m,Z as g,N as h}from"./ui-components-BNdpaz32.js";import{L as s}from"./index-ImPzdvfG.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-C4aCwcCz.js";const y=()=>{const{t}=n("pages");return i.useEffect(()=>{document.title=t("landing.pageTitle");const a=document.querySelector('meta[name="description"]');a&&a.setAttribute("content",t("landing.metaDescription"))},[t]),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-blue-50",children:[e.jsx("nav",{className:"bg-white/80 backdrop-blur-sm border-b border-gray-200 sticky top-0 z-50",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex justify-between items-center h-16",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("img",{src:"/cc-studio.png",alt:"AgentStudio",className:"w-8 h-8"}),e.jsx("span",{className:"text-xl font-bold text-gray-900",children:"AgentStudio"})]}),e.jsxs(s,{to:"/dashboard",className:"inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors duration-200",children:[t("landing.nav.enterWorkspace"),e.jsx(l,{className:"ml-2 w-4 h-4"})]})]})})}),e.jsx("section",{className:"pt-20 pb-16 px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto text-center",children:[e.jsxs("h1",{className:"text-5xl sm:text-6xl font-bold text-gray-900 mb-6",children:[e.jsx("span",{className:"bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent",children:t("landing.hero.title")}),e.jsx("br",{}),t("landing.hero.subtitle")]}),e.jsx("p",{className:"text-xl text-gray-600 mb-8 max-w-3xl mx-auto leading-relaxed",children:t("landing.hero.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(s,{to:"/dashboard",className:"inline-flex items-center px-8 py-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-xl transition-all duration-200 shadow-lg hover:shadow-xl",children:[t("landing.hero.startNow"),e.jsx(d,{className:"ml-2 w-5 h-5"})]}),e.jsxs("a",{href:"https://github.com/okguitar/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-8 py-4 bg-white hover:bg-gray-50 text-gray-700 font-semibold rounded-xl border border-gray-300 transition-all duration-200",children:[e.jsx(r,{className:"mr-2 w-5 h-5"}),t("landing.hero.viewSource")]})]})]})}),e.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-white",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-4",children:t("landing.features.title")}),e.jsx("p",{className:"text-lg text-gray-600 max-w-2xl mx-auto",children:t("landing.features.subtitle")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-indigo-50 p-8 rounded-2xl border border-blue-100",children:[e.jsx("div",{className:"w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(o,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.modernWeb.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.modernWeb.description")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-purple-50 to-pink-50 p-8 rounded-2xl border border-purple-100",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(c,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.multiModel.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.multiModel.description")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-green-50 to-emerald-50 p-8 rounded-2xl border border-green-100",children:[e.jsx("div",{className:"w-12 h-12 bg-green-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(x,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.agentSystem.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.agentSystem.description")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-orange-50 to-red-50 p-8 rounded-2xl border border-orange-100",children:[e.jsx("div",{className:"w-12 h-12 bg-orange-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(m,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.fileManagement.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.fileManagement.description")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-teal-50 to-cyan-50 p-8 rounded-2xl border border-teal-100",children:[e.jsx("div",{className:"w-12 h-12 bg-teal-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(g,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.professionalTools.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.professionalTools.description")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-gray-50 to-slate-50 p-8 rounded-2xl border border-gray-100",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-600 rounded-lg flex items-center justify-center mb-6",children:e.jsx(h,{className:"w-6 h-6 text-white"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-3",children:t("landing.features.secureReliable.title")}),e.jsx("p",{className:"text-gray-600 leading-relaxed",children:t("landing.features.secureReliable.description")})]})]})]})}),e.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900 mb-6",children:t("landing.quickStart.title")}),e.jsx("p",{className:"text-lg text-gray-600 mb-8",children:t("landing.quickStart.subtitle")}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-indigo-50 p-8 rounded-2xl border border-blue-100",children:[e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:t("landing.quickStart.endUserTitle")}),e.jsx("div",{className:"bg-gray-900 rounded-lg p-4 text-left text-sm text-green-400 font-mono mb-4",children:e.jsx("div",{children:"curl -fsSL https://raw.githubusercontent.com/okguitar/agentstudio/main/scripts/remote-install.sh | bash"})}),e.jsx("p",{className:"text-gray-600 text-sm",children:t("landing.quickStart.endUserDescription")})]}),e.jsxs("div",{className:"bg-gradient-to-br from-purple-50 to-pink-50 p-8 rounded-2xl border border-purple-100",children:[e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-4",children:t("landing.quickStart.developerTitle")}),e.jsxs("div",{className:"bg-gray-900 rounded-lg p-4 text-left text-sm text-green-400 font-mono mb-4",children:[e.jsx("div",{children:"git clone https://github.com/okguitar/agentstudio.git"}),e.jsx("div",{children:"cd agentstudio"}),e.jsx("div",{children:"pnpm install && pnpm run dev"})]}),e.jsx("p",{className:"text-gray-600 text-sm",children:t("landing.quickStart.developerDescription")})]})]})]})}),e.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-gradient-to-r from-blue-600 to-purple-600",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h2",{className:"text-3xl font-bold text-white mb-6",children:t("landing.cta.title")}),e.jsx("p",{className:"text-xl text-blue-100 mb-8",children:t("landing.cta.subtitle")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(s,{to:"/dashboard",className:"inline-flex items-center px-8 py-4 bg-white hover:bg-gray-100 text-blue-600 font-semibold rounded-xl transition-all duration-200 shadow-lg",children:[t("landing.cta.start"),e.jsx(l,{className:"ml-2 w-5 h-5"})]}),e.jsxs("a",{href:"https://github.com/okguitar/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-8 py-4 bg-blue-500 hover:bg-blue-400 text-white font-semibold rounded-xl border border-blue-400 transition-all duration-200",children:[e.jsx(r,{className:"mr-2 w-5 h-5"}),"GitHub"]})]})]})}),e.jsx("footer",{className:"bg-gray-900 text-gray-300 py-12 px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-8",children:[e.jsxs("div",{className:"col-span-1 md:col-span-2",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("img",{src:"/cc-studio.png",alt:"AgentStudio",className:"w-8 h-8"}),e.jsx("span",{className:"text-xl font-bold text-white",children:"AgentStudio"})]}),e.jsx("p",{className:"text-gray-400 mb-4 max-w-md",children:t("landing.footer.description")}),e.jsx("div",{className:"text-sm text-gray-500",children:t("landing.footer.copyright")})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-semibold mb-4",children:t("landing.footer.product")}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsx("li",{children:e.jsx(s,{to:"/dashboard",className:"hover:text-white transition-colors",children:t("landing.footer.workspace")})}),e.jsx("li",{children:e.jsx("a",{href:"https://github.com/okguitar/agentstudio",className:"hover:text-white transition-colors",children:t("landing.footer.sourceCode")})}),e.jsx("li",{children:e.jsx("a",{href:"https://github.com/okguitar/agentstudio/releases",className:"hover:text-white transition-colors",children:t("landing.footer.releases")})})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-white font-semibold mb-4",children:t("landing.footer.support")}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[e.jsx("li",{children:e.jsx("a",{href:"https://github.com/okguitar/agentstudio/wiki",className:"hover:text-white transition-colors",children:t("landing.footer.documentation")})}),e.jsx("li",{children:e.jsx("a",{href:"https://github.com/okguitar/agentstudio/issues",className:"hover:text-white transition-colors",children:t("landing.footer.issues")})}),e.jsx("li",{children:e.jsx("a",{href:"https://github.com/okguitar/agentstudio/discussions",className:"hover:text-white transition-colors",children:t("landing.footer.discussions")})})]})]})]})})})]})};export{y as default};
@@ -1 +0,0 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o,W as A}from"./monaco-editor-DHKm5-VF.js";import{b as Z,u as D,c as E,a as w,A as N}from"./agents-C4aCwcCz.js";import{b as P,a as T,s as H,u as z}from"./index-ImPzdvfG.js";import{u as F}from"./tools-C7xmF_rB.js";import{c as de,B as v}from"./Button-Dg6ni5Yl.js";import{aB as I,aC as K,f as q,g as X,p as J,a1 as oe,v as _,X as ue,E as Y,e as me,a2 as xe,aD as ge,Z as pe,K as he,o as ye,aE as be,C as fe,a8 as je}from"./ui-components-BNdpaz32.js";import{F as ve}from"./FileExplorer-Dy8ZFDtK.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};
@@ -1 +0,0 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o,W as ve}from"./monaco-editor-DHKm5-VF.js";import{T as xe,a as ue,b as U,c as k,d as ge,e as j}from"./table-CSWCaVuS.js";import{u as G,b as M,c as D,a as N,A as S}from"./agents-C4aCwcCz.js";import{c as we}from"./useAgents-C9aEFOWD.js";import{u as Ne}from"./useProjects-Dgk7ldPq.js";import{u as Se}from"./useClaudeVersions-CcFqpR2o.js";import{b as u,a as C}from"./index-ImPzdvfG.js";import{m as R,K as Ce,f as Te,ak as ie,k as he,D as Ee,aj as me,O as ye,y as Ie,al as Ae,L as X,l as $e,e as ce,n as pe,C as be,Q as qe,p as oe,am as Me,an as Pe,a1 as De,ao as Re,u as Fe,v as Ke}from"./ui-components-BNdpaz32.js";import"./syntax-highlighting-CnREyncB.js";import"./tools-C7xmF_rB.js";const d={all:["scheduled-tasks"],lists:()=>[...d.all,"list"],list:()=>[...d.lists()],details:()=>[...d.all,"detail"],detail:t=>[...d.details(),t],history:t=>[...d.all,"history",t],status:()=>[...d.all,"status"]},Oe=()=>G({queryKey:d.list(),queryFn:async()=>{const t=await N(`${S}/scheduled-tasks`);if(!t.ok)throw new Error("Failed to fetch scheduled tasks");return t.json()},refetchInterval:t=>t.state.data?.some(c=>c.lastRunStatus==="running")?3e3:!1}),Qe=(t,n=50)=>G({queryKey:d.history(t),queryFn:async()=>{const l=await N(`${S}/scheduled-tasks/${t}/history?limit=${n}`);if(!l.ok)throw new Error("Failed to fetch task execution history");return l.json()},enabled:!!t,refetchInterval:l=>l.state.data?.some(I=>I.status==="running")?3e3:!1}),Le=()=>G({queryKey:d.status(),queryFn:async()=>{const t=await N(`${S}/scheduled-tasks/status`);if(!t.ok)throw new Error("Failed to fetch scheduler status");return t.json()},refetchInterval:3e4}),Ve=()=>{const t=M();return D({mutationFn:async n=>{const l=await N(`${S}/scheduled-tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to create scheduled task")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},He=()=>{const t=M();return D({mutationFn:async({taskId:n,data:l})=>{const c=await N(`${S}/scheduled-tasks/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!c.ok){const g=await c.json().catch(()=>({}));throw new Error(g.error||"Failed to update scheduled task")}return c.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},Be=()=>{const t=M();return D({mutationFn:async n=>{const l=await N(`${S}/scheduled-tasks/${n}`,{method:"DELETE"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to delete scheduled task")}},onSuccess:()=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.status()})}})},ze=()=>{const t=M();return D({mutationFn:async n=>{const l=await N(`${S}/scheduled-tasks/${n}/toggle`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to toggle scheduled task")}return l.json()},onSuccess:n=>{t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.detail(n.id)}),t.invalidateQueries({queryKey:d.status()})}})},je=()=>{const t=M();return D({mutationFn:async n=>{const l=await N(`${S}/scheduled-tasks/${n}/run`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to run scheduled task")}return l.json()},onSuccess:(n,l)=>{t.invalidateQueries({queryKey:d.detail(l)}),t.invalidateQueries({queryKey:d.lists()}),t.invalidateQueries({queryKey:d.history(l)})}})},Ue=()=>{const t=M();return D({mutationFn:async n=>{const l=await N(`${S}/scheduled-tasks/executions/${n}/stop`,{method:"POST"});if(!l.ok){const c=await l.json().catch(()=>({}));throw new Error(c.error||"Failed to stop execution")}return l.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.all})}})},_e=()=>G({queryKey:[...d.all,"running"],queryFn:async()=>{const t=await N(`${S}/scheduled-tasks/running`);if(!t.ok)throw new Error("Failed to fetch running executions");return t.json()},refetchInterval:3e3}),We=()=>{const t=M();return D({mutationFn:async()=>{const n=await N(`${S}/scheduled-tasks/scheduler/enable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to enable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Je=()=>{const t=M();return D({mutationFn:async()=>{const n=await N(`${S}/scheduled-tasks/scheduler/disable`,{method:"POST"});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.error||"Failed to disable scheduler")}return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:d.status()})}})},Xe=[{label:"每 5 分钟",value:"*/5 * * * *"},{label:"每 15 分钟",value:"*/15 * * * *"},{label:"每 30 分钟",value:"*/30 * * * *"},{label:"每小时",value:"0 * * * *"},{label:"每天 9:00",value:"0 9 * * *"},{label:"每天 18:00",value:"0 18 * * *"},{label:"每周一 9:00",value:"0 9 * * 1"},{label:"每月 1 日 9:00",value:"0 9 1 * *"}],Ge=t=>{if(!t){const n=new Date;return n.setHours(n.getHours()+1),n.setMinutes(0),n.setSeconds(0),n.toISOString().slice(0,16)}return new Date(t).toISOString().slice(0,16)},Ye=t=>new Date(t).toISOString(),Ze=({task:t,agents:n,onSave:l,onCancel:c})=>{const g=!!t,I=Ve(),F=He(),K=je(),{data:V}=Ne(),P=V?.projects||[],{data:x}=Se(),[f,H]=o.useState(t?.name||""),[v,B]=o.useState(t?.description||""),[m,A]=o.useState(t?.agentId||""),[b,O]=o.useState(t?.projectPath||""),[y,s]=o.useState(t?.schedule.type||"interval"),[i,h]=o.useState(t?.schedule.intervalMinutes||30),[p,_]=o.useState(t?.schedule.cronExpression||"*/30 * * * *"),[z,Y]=o.useState(Ge(t?.schedule.executeAt)),[$,Z]=o.useState(t?.triggerMessage||""),[T,ee]=o.useState(t?.enabled??!0),[q,te]=o.useState(!!t?.modelOverride?.modelId),[r,w]=o.useState(t?.modelOverride?.versionId||""),[E,ae]=o.useState(t?.modelOverride?.modelId||""),[re,ne]=o.useState(!1),[se,le]=o.useState(!1),Q=o.useMemo(()=>x?.versions?r?x.versions.find(de=>de.id===r)?.models||[]:(x.versions.find(L=>L.id===x.defaultVersionId)||x.versions[0])?.models||[]:[],[x,r]);o.useEffect(()=>{q&&Q.length>0&&(Q.some(L=>L.id===E)||ae(Q[0].id))},[Q,E,q]),o.useEffect(()=>{!m&&n.length>0&&A(n[0].id)},[m,n]),o.useEffect(()=>{!b&&P.length>0&&O(P[0].path)},[b,P]);const W=()=>y==="interval"?{type:"interval",intervalMinutes:i}:y==="once"?{type:"once",executeAt:Ye(z)}:{type:"cron",cronExpression:p},J=()=>{if(!(!q||!E))return{versionId:r||void 0,modelId:E}},fe=async()=>{if(!f.trim()){u("请输入任务名称");return}if(!m){u("请选择 Agent");return}if(!b){u("请选择项目路径");return}if(!$.trim()){u("请输入触发消息");return}if(y==="interval"&&(!i||i<1)){u("间隔时间必须大于 0");return}if(y==="cron"&&!p.trim()){u("请输入 Cron 表达式");return}if(y==="once"){const a=new Date(z).getTime();if(isNaN(a)){u("请选择有效的执行时间");return}if(a<=Date.now()){u("执行时间必须在未来");return}}ne(!0);try{if(g)await F.mutateAsync({taskId:t.id,data:{name:f.trim(),description:v.trim()||void 0,agentId:m,projectPath:b,schedule:W(),triggerMessage:$.trim(),enabled:T,modelOverride:J()}}),C("任务已更新");else{const a={name:f.trim(),description:v.trim()||void 0,agentId:m,projectPath:b,schedule:W(),triggerMessage:$.trim(),enabled:T,modelOverride:J()};await I.mutateAsync(a),C("任务已创建")}l()}catch{u(g?"更新失败":"创建失败")}finally{ne(!1)}},ke=async()=>{if(!f.trim()){u("请输入任务名称");return}if(!m){u("请选择 Agent");return}if(!b){u("请选择项目路径");return}if(!$.trim()){u("请输入触发消息");return}le(!0);try{let a;if(g)await F.mutateAsync({taskId:t.id,data:{name:f.trim(),description:v.trim()||void 0,agentId:m,projectPath:b,schedule:W(),triggerMessage:$.trim(),enabled:T,modelOverride:J()}}),a=t.id,C("任务已更新");else{const L={name:f.trim(),description:v.trim()||void 0,agentId:m,projectPath:b,schedule:W(),triggerMessage:$.trim(),enabled:T,modelOverride:J()};a=(await I.mutateAsync(L)).id,C("任务已创建")}await K.mutateAsync(a),C("任务已开始执行,请在执行历史中查看结果"),l()}catch{u("操作失败")}finally{le(!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-5xl max-h-[90vh] overflow-hidden 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",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:g?"编辑定时任务":"创建定时任务"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]}),e.jsx("button",{onClick:c,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5"}),"基本信息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"任务名称 *"}),e.jsx("input",{type:"text",value:f,onChange:a=>H(a.target.value),placeholder:"例如:每日代码检查",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"描述"}),e.jsx("input",{type:"text",value:v,onChange:a=>B(a.target.value),placeholder:"可选的任务描述",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(Ce,{className:"w-5 h-5"}),"执行配置"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"执行 Agent *"}),e.jsx("select",{value:m,onChange:a=>A(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:n.map(a=>e.jsxs("option",{value:a.id,children:[a.ui?.icon||"🤖"," ",a.name]},a.id))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4"}),"项目路径 *"]}),e.jsx("select",{value:b,onChange:a=>O(a.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:P.map(a=>e.jsx("option",{value:a.path,children:a.name||a.path},a.path))}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Agent 将在此项目目录下执行"})]}),e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"覆盖模型配置"})]}),e.jsx("button",{type:"button",onClick:()=>te(!q),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${q?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${q?"translate-x-5":"translate-x-1"}`})})]}),q&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"可以为定时任务指定不同于 Agent 默认的模型"}),x?.versions&&x.versions.length>1&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"供应商"}),e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:r,onChange:a=>w(a.target.value),className:"w-full appearance-none px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"",children:x.defaultVersionId?`默认 (${x.versions.find(a=>a.id===x.defaultVersionId)?.name})`:"默认"}),x.versions.filter(a=>a.id!==x.defaultVersionId).map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]}),e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none text-gray-500",children:e.jsx(he,{className:"w-4 h-4"})})]})]}),Q.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 dark:text-gray-400 mb-1",children:"模型"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Q.map(a=>e.jsxs("button",{type:"button",onClick:()=>ae(a.id),className:`flex items-center justify-between px-3 py-2 text-sm rounded-lg border transition-all ${E===a.id?"border-purple-500 bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300 shadow-sm":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 text-gray-700 dark:text-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ie,{className:"w-4 h-4 opacity-70"}),e.jsx("span",{className:"font-medium",children:a.name})]}),a.isVision&&e.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded text-gray-500",children:"Vision"})]},a.id))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5"}),"调度规则"]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"interval",checked:y==="interval",onChange:()=>s("interval"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"间隔执行"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"cron",checked:y==="cron",onChange:()=>s("cron"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Cron 表达式"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"scheduleType",value:"once",checked:y==="once",onChange:()=>s("once"),className:"mr-2"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"仅执行一次"})]})]}),y==="interval"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"间隔时间(分钟)"}),e.jsx("input",{type:"number",min:1,max:10080,value:i,onChange:a=>h(parseInt(a.target.value)||30),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["每隔 ",i," 分钟执行一次"]})]}),y==="cron"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Cron 表达式"}),e.jsx("input",{type:"text",value:p,onChange:a=>_(a.target.value),placeholder:"*/30 * * * *",className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white font-mono focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:Xe.map(a=>e.jsx("button",{type:"button",onClick:()=>_(a.value),className:`px-2 py-1 text-xs rounded-full border transition-colors ${p===a.value?"bg-blue-100 border-blue-300 text-blue-700 dark:bg-blue-900 dark:border-blue-700 dark:text-blue-300":"bg-gray-50 border-gray-200 text-gray-600 hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700"}`,children:a.label},a.value))})]}),y==="once"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1 flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4"}),"执行时间"]}),e.jsx("input",{type:"datetime-local",value:z,onChange:a=>Y(a.target.value),min:new Date().toISOString().slice(0,16),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"任务将在指定时间执行一次后自动禁用"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(me,{className:"w-5 h-5"}),"触发消息"]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"发送给 Agent 的消息 *"}),e.jsx("textarea",{value:$,onChange:a=>Z(a.target.value),placeholder:"请检查代码质量并生成报告...",rows:5,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-y"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"定时触发时,这条消息会发送给选定的 Agent"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用任务"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"创建后立即开始调度"})]}),e.jsx("button",{type:"button",onClick:()=>ee(!T),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${T?"bg-blue-600":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${T?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:c,className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:"取消"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:ke,disabled:re||se,className:"inline-flex items-center px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors disabled:opacity-50",title:"保存任务并立即执行一次",children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),se?"执行中...":"保存并执行"]}),e.jsxs("button",{onClick:fe,disabled:re||se,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:[e.jsx(Ie,{className:"w-4 h-4 mr-2"}),re?"保存中...":"保存"]})]})]})]})})]})})},et=({taskId:t,taskName:n,agentId:l,projectPath:c,onBack:g})=>{const{data:I=[],isLoading:F}=Qe(t),[K,V]=o.useState(new Set),P=s=>{V(i=>{const h=new Set(i);return h.has(s)?h.delete(s):h.add(s),h})},x=s=>s?new Date(s).toLocaleString("zh-CN"):"-",f=s=>new Date(s).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),H=s=>{if(!s.completedAt)return"-";const i=new Date(s.startedAt).getTime(),p=new Date(s.completedAt).getTime()-i;return p<1e3?`${p}ms`:p<6e4?`${(p/1e3).toFixed(1)}s`:`${Math.floor(p/6e4)}m ${Math.floor(p%6e4/1e3)}s`},v=s=>{switch(s){case"running":return e.jsx(X,{className:"w-5 h-5 text-blue-500 animate-spin"});case"success":return e.jsx(be,{className:"w-5 h-5 text-green-500"});case"error":return e.jsx(pe,{className:"w-5 h-5 text-red-500"});default:return e.jsx(R,{className:"w-5 h-5 text-gray-400"})}},B=s=>{switch(s){case"running":return e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"运行中"});case"success":return e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"成功"});case"error":return e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"失败"});default:return e.jsx("span",{className:"text-gray-500",children:"未知"})}},m=s=>{switch(s){case"error":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20";case"warn":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-900/20";case"info":return"text-blue-600 dark:text-blue-400";case"debug":return"text-gray-500 dark:text-gray-400";default:return"text-gray-600 dark:text-gray-400"}},A=s=>{switch(s){case"system":return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400";case"assistant":return"bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-400";case"tool_use":return"bg-purple-100 text-purple-600 dark:bg-purple-900 dark:text-purple-400";case"result":return"bg-green-100 text-green-600 dark:bg-green-900 dark:text-green-400";case"error":return"bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-400";default:return"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}},b=s=>{const i=s.agentId||l,h=s.projectPath||c;if(!i||!s.sessionId)return null;let p=`/chat/${encodeURIComponent(i)}?session=${encodeURIComponent(s.sessionId)}`;return h&&(p+=`&project=${encodeURIComponent(h)}`),p},O=(s,i)=>{i.stopPropagation();const h=b(s);h&&window.open(h,"_blank")},y=s=>!s||s.length===0?e.jsx("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:"暂无执行日志"}):e.jsx("div",{className:"space-y-1 max-h-96 overflow-y-auto",children:s.map((i,h)=>e.jsxs("div",{className:`flex items-start gap-2 px-3 py-1.5 rounded text-sm font-mono ${m(i.level)}`,children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500 shrink-0 w-24",children:f(i.timestamp)}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs shrink-0 ${A(i.type)}`,children:i.type}),e.jsx("span",{className:"flex-1 break-all whitespace-pre-wrap",children:i.message})]},h))});return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:g,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",children:e.jsx(Ae,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"执行历史"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["任务:",n]})]})]}),F?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(X,{className:"w-8 h-8 animate-spin text-gray-400"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx(R,{className:"w-12 h-12 mx-auto text-gray-400 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-500 dark:text-gray-400",children:"任务尚未执行过"})]}):e.jsx("div",{className:"bg-white dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(xe,{children:[e.jsx(ue,{children:e.jsxs(U,{children:[e.jsx(k,{className:"w-[40px]"}),e.jsx(k,{className:"w-[80px]",children:"状态"}),e.jsx(k,{children:"开始时间"}),e.jsx(k,{children:"完成时间"}),e.jsx(k,{children:"耗时"}),e.jsx(k,{children:"结果摘要"}),e.jsx(k,{className:"w-[100px]",children:"操作"})]})}),e.jsx(ge,{children:I.map(s=>e.jsxs(ve.Fragment,{children:[e.jsxs(U,{className:"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800",onClick:()=>P(s.id),children:[e.jsx(j,{className:"p-2",children:e.jsx("button",{className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:K.has(s.id)?e.jsx(he,{className:"w-4 h-4 text-gray-500"}):e.jsx($e,{className:"w-4 h-4 text-gray-500"})})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[v(s.status),B(s.status)]})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:x(s.startedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:x(s.completedAt)})}),e.jsx(j,{children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:H(s)})}),e.jsx(j,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.logs&&s.logs.length>0&&e.jsx("span",{title:"有详细日志",children:e.jsx(ce,{className:"w-4 h-4 text-gray-400 shrink-0"})}),s.error?e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 max-w-md truncate",children:s.error}):s.responseSummary?e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-md truncate",children:s.responseSummary}):e.jsx("span",{className:"text-sm text-gray-400",children:"-"})]})}),e.jsx(j,{children:s.sessionId&&b(s)&&e.jsx("button",{onClick:i=>O(s,i),className:"inline-flex items-center justify-center p-2 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors",title:"在新窗口继续会话",children:e.jsx(me,{className:"w-4 h-4"})})})]}),K.has(s.id)&&e.jsx(U,{children:e.jsx(j,{colSpan:7,className:"bg-gray-50 dark:bg-gray-800/50 p-4",children:e.jsxs("div",{className:"space-y-3",children:[s.errorStack&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("h4",{className:"text-sm font-medium text-red-700 dark:text-red-400 mb-2",children:"错误堆栈"}),e.jsx("pre",{className:"text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap overflow-x-auto",children:s.errorStack})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2",children:[e.jsx(ce,{className:"w-4 h-4"}),"执行日志",s.logs&&e.jsxs("span",{className:"text-xs text-gray-400",children:["(",s.logs.length," 条)"]})]}),y(s.logs)]}),s.sessionId&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Session ID: ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded",children:s.sessionId})]})]})})})]},s.id))})]})})]})},ut=()=>{const t=M(),{data:n=[],isLoading:l}=Oe(),{data:c}=we(!0),{data:g}=Le(),I=Be(),F=ze(),K=je(),V=Ue(),{data:P}=_e(),x=We(),f=Je(),[H,v]=o.useState(null),[B,m]=o.useState(!1),[A,b]=o.useState(null),O=r=>P?.executions?.find(E=>E.taskId===r)?.executionId||null,y=c?.agents||[],s=r=>y.find(E=>E.id===r)?.name||r,i=r=>{if(r.schedule.type==="interval"&&r.schedule.intervalMinutes){const w=r.schedule.intervalMinutes;return w<60?`每 ${w} 分钟`:`每 ${Math.floor(w/60)} 小时`}return r.schedule.type==="cron"&&r.schedule.cronExpression?r.schedule.cronExpression:r.schedule.type==="once"&&r.schedule.executeAt?`一次性 @ ${new Date(r.schedule.executeAt).toLocaleString("zh-CN")}`:"-"},h=r=>r?new Date(r).toLocaleString("zh-CN"):"-",p=async r=>{try{await F.mutateAsync(r.id),C(r.enabled?"任务已暂停":"任务已启用")}catch{u("操作失败")}},_=async r=>{if(confirm(`确定要删除任务 "${r.name}" 吗?`))try{await I.mutateAsync(r.id),C("任务已删除")}catch{u("删除失败")}},z=async r=>{try{await K.mutateAsync(r.id),C("任务已开始执行"),t.invalidateQueries({queryKey:d.lists()})}catch{u("执行失败")}},Y=async r=>{const w=O(r.id);if(!w){u("找不到正在运行的执行");return}try{await V.mutateAsync(w),C("任务已停止"),t.invalidateQueries({queryKey:d.lists()})}catch{u("停止失败")}},$=async()=>{if(g)try{g.enabled?(await f.mutateAsync(),C("调度器已禁用")):(await x.mutateAsync(),C("调度器已启用"))}catch{u("操作失败")}},Z=r=>{v(r),m(!0)},T=()=>{v(null),m(!0)},ee=()=>{v(null),m(!1),t.invalidateQueries({queryKey:d.lists()})},q=()=>{v(null),m(!1)},te=r=>r.lastRunStatus==="running"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:[e.jsx(X,{className:"w-3 h-3 mr-1 animate-spin"}),"运行中"]}):r.lastRunStatus==="success"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),"成功"]}):r.lastRunStatus==="error"?e.jsxs("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),"失败"]}):e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:"未执行"});if(A){const r=n.find(w=>w.id===A);return e.jsx(et,{taskId:A,taskName:r?.name||A,agentId:r?.agentId,projectPath:r?.projectPath,onBack:()=>b(null)})}return 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.jsxs("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(R,{className:"w-8 h-8"}),"定时任务"]}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:"配置 Agent 的自动执行计划"})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[g&&e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("button",{onClick:$,disabled:x.isPending||f.isPending,className:`flex items-center gap-2 px-3 py-1.5 rounded-lg transition-colors ${g.enabled?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 hover:bg-green-100 dark:hover:bg-green-900/30":"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 hover:bg-orange-100 dark:hover:bg-orange-900/30"} ${x.isPending||f.isPending?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,title:g.enabled?"点击禁用调度器":"点击启用调度器",children:[e.jsx(R,{className:`w-4 h-4 ${x.isPending||f.isPending?"animate-pulse":""}`}),e.jsx("span",{className:"font-medium",children:g.enabled?"调度器已启用":"调度器已禁用"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(qe,{className:"w-4 h-4"}),e.jsxs("span",{children:["活跃: ",g.activeTaskCount," / 运行中: ",g.runningTaskCount]})]})]}),e.jsxs("button",{onClick:T,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(oe,{className:"w-5 h-5 mr-2"}),"新建任务"]})]})]}),l?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(X,{className:"w-8 h-8 animate-spin text-gray-400"})}):n.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(R,{className:"w-16 h-16 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:"暂无定时任务"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"创建定时任务来让 Agent 自动执行工作"}),e.jsxs("button",{onClick:T,className:"inline-flex items-center px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(oe,{className:"w-5 h-5 mr-2"}),"创建第一个任务"]})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(xe,{children:[e.jsx(ue,{children:e.jsxs(U,{children:[e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"状态"}),e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"任务名称"}),e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Agent"}),e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"调度规则"}),e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"上次执行"}),e.jsx(k,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"下次执行"}),e.jsx(k,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"操作"})]})}),e.jsx(ge,{children:n.map(r=>e.jsxs(U,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>p(r),className:`p-1 rounded-full transition-colors ${r.enabled?"text-green-600 hover:bg-green-100 dark:hover:bg-green-900":"text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:r.enabled?"点击暂停":"点击启用",children:r.enabled?e.jsx(ye,{className:"w-5 h-5 fill-current"}):e.jsx(Me,{className:"w-5 h-5"})})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r.name}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.description})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:s(r.agentId)})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-mono text-gray-600 dark:text-gray-400",children:i(r)})}),e.jsx(j,{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[te(r),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:h(r.lastRunAt)})]})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:r.enabled?h(r.nextRunAt):"-"})}),e.jsx(j,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.lastRunStatus==="running"?e.jsx("button",{onClick:()=>Y(r),className:"p-2 text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"停止执行",children:e.jsx(Pe,{className:"w-4 h-4"})}):e.jsx("button",{onClick:()=>z(r),className:"p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded-lg transition-colors",title:"立即执行",children:e.jsx(De,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>b(r.id),className:"p-2 text-gray-500 hover:text-purple-600 hover:bg-purple-50 dark:hover:bg-purple-900 rounded-lg transition-colors",title:"执行历史",children:e.jsx(Re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>Z(r),className:"p-2 text-gray-500 hover:text-green-600 hover:bg-green-50 dark:hover:bg-green-900 rounded-lg transition-colors",title:"编辑",children:e.jsx(Fe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>_(r),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded-lg transition-colors",title:"删除",children:e.jsx(Ke,{className:"w-4 h-4"})})]})})]},r.id))})]})}),B&&e.jsx(Ze,{task:H,agents:y,onSave:ee,onCancel:q})]})};export{ut as ScheduledTasksPage,ut as default};
@@ -1,18 +0,0 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as c}from"./monaco-editor-DHKm5-VF.js";import{T as ge,a as be,b as Z,c as q,d as fe,e as O}from"./table-CSWCaVuS.js";import{g as ye,a as f,u as te,b as X,c as V,A as Q}from"./agents-C4aCwcCz.js";import{U as ke}from"./UnifiedToolSelector-A2UIt1Xn.js";import{u as J}from"./tools-C7xmF_rB.js";import{Q as we,e as je,az as ve,X as _,p as ae,g as Ne,E as Se,f as Te,u as Ce,v as Fe}from"./ui-components-BNdpaz32.js";import{B as z}from"./Button-Dg6ni5Yl.js";import{F as $e}from"./FileExplorer-Dy8ZFDtK.js";import{T as Ee}from"./ToolsList-CWZLcBx2.js";import"./syntax-highlighting-CnREyncB.js";import"./index-ImPzdvfG.js";class De{baseURL=`${ye()}/skills`;async getAllSkills(r){const s=new URLSearchParams;r?.scope&&s.append("scope",r.scope),r?.includeDisabled&&s.append("includeDisabled","true");const l=await f(`${this.baseURL}?${s.toString()}`);if(!l.ok)throw new Error(`Failed to fetch skills: ${l.statusText}`);const o=await l.json();return this.transformToSkillListItems(o.skills)}async getSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`);if(o.status===404)return null;if(!o.ok)throw new Error(`Failed to fetch skill: ${o.statusText}`);return(await o.json()).skill}async createSkill(r){const s=await f(`${this.baseURL}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok){const o=await s.json();throw new Error(o.error||"Failed to create skill")}return(await s.json()).skill}async updateSkill(r,s){const l=await f(`${this.baseURL}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!l.ok){const x=await l.json();throw new Error(x.error||"Failed to update skill")}return(await l.json()).skill}async deleteSkill(r,s){const l=s?`?scope=${s}`:"",o=await f(`${this.baseURL}/${r}${l}`,{method:"DELETE"});if(o.status===404)return!1;if(!o.ok)throw new Error(`Failed to delete skill: ${o.statusText}`);return!0}async getSkillDirectoryInfo(r){const s=await f(`${this.baseURL}/${r}/directory`);if(s.status===404)return null;if(!s.ok)throw new Error(`Failed to fetch skill directory info: ${s.statusText}`);return(await s.json()).directoryInfo}async validateSkillManifest(r){const s=await f(`${this.baseURL}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!s.ok)throw new Error(`Failed to validate skill manifest: ${s.statusText}`);return await s.json()}async getSkillFile(r,s){const l=await f(`${this.baseURL}/${r}/files/${s}`);if(!l.ok)throw new Error(`Failed to fetch skill file: ${l.statusText}`);return(await l.json()).content}async updateSkillFile(r,s,l){const o=await f(`${this.baseURL}/${r}/files/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l})});if(!o.ok)throw new Error(`Failed to update skill file: ${o.statusText}`)}transformToSkillListItems(r){return r.map(s=>({id:s.id,name:s.name,description:s.description,scope:s.scope,projectName:s.scope==="project"?"Current Project":void 0,source:s.source,enabled:s.enabled,createdAt:s.createdAt,updatedAt:s.updatedAt,allowedTools:s.allowedTools,toolCount:s.allowedTools?.length||0,usageCount:0,lastUsed:void 0}))}}const A=new De,y={all:["skills"],lists:()=>[...y.all,"list"],list:a=>[...y.lists(),a],details:()=>[...y.all,"detail"],detail:a=>[...y.details(),a],directory:a=>[...y.all,"directory",a]},Le=a=>te({queryKey:y.list(a||{}),queryFn:()=>A.getAllSkills(a),staleTime:300*1e3}),Me=(a,r)=>te({queryKey:y.detail(a),queryFn:()=>A.getSkill(a,r),enabled:!!a,staleTime:300*1e3}),Pe=()=>{const a=X();return V({mutationFn:r=>A.createSkill(r),onSuccess:r=>{a.invalidateQueries({queryKey:y.lists()}),a.setQueryData(y.detail(r.id),r)},onError:r=>{console.error("Failed to create skill:",r)}})},Ae=()=>{const a=X();return V({mutationFn:({skillId:r,updates:s})=>A.updateSkill(r,s),onSuccess:r=>{a.setQueryData(y.detail(r.id),r),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to update skill:",r)}})},Ie=()=>{const a=X();return V({mutationFn:({skillId:r,scope:s})=>A.deleteSkill(r,s),onSuccess:(r,{skillId:s})=>{a.removeQueries({queryKey:y.detail(s)}),a.invalidateQueries({queryKey:y.lists()})},onError:r=>{console.error("Failed to delete skill:",r)}})},Re=()=>V({mutationFn:a=>A.validateSkillManifest(a),onError:a=>{console.error("Failed to validate skill manifest:",a)}}),Ue=({onClose:a,onSuccess:r,editSkill:s})=>{const{t:l}=J(["skills","common"]),o=!!s,[x,p]=c.useState("basic"),[n,h]=c.useState({name:"",description:"",allowedTools:[],content:"",additionalFiles:[]}),[m,j]=c.useState([]),[k,F]=c.useState(""),[$,M]=c.useState(!1),[S,E]=c.useState([]),[g,v]=c.useState([]),[T,I]=c.useState(!1),P=Pe(),R=Ae(),U=Re(),B=Me(s?.id||"",s?.scope||"user"),C=o?B.data:null,K=o?B.isLoading:!1,[d,N]=c.useState(0),[H,D]=c.useState(0),[L,Y]=c.useState(!1);c.useEffect(()=>{if(!L){const t=[...S];T&&t.push(...g),h(i=>({...i,allowedTools:t})),N(Date.now())}},[S,g,T,L]),c.useEffect(()=>{!L&&(n.name||n.description)&&N(Date.now())},[n.name,n.description,L]),c.useEffect(()=>{!L&&n.content&&D(Date.now())},[n.content,L]),c.useEffect(()=>{if(o&&C){h({name:C.name,description:C.description,allowedTools:C.allowedTools||[],content:"",additionalFiles:(C.files||[]).filter(u=>!u.path.endsWith("SKILL.md")).map(u=>({id:Math.random().toString(36).substr(2,9),name:u.name,path:u.path,type:u.type,content:""}))});const t=C.allowedTools||[],i=t.filter(u=>!u.startsWith("mcp__")),b=t.filter(u=>u.startsWith("mcp__"));E(i),v(b),I(b.length>0),(async()=>{try{const u=await fetch(`/api/skills/${s.id}/files/SKILL.md`);if(u.ok){const he=await u.json();h(pe=>({...pe,content:he.content})),D(Date.now())}}catch(u){console.error("Failed to load skill manifest:",u)}})()}},[o,C,s]),c.useEffect(()=>{if(n.content){const i=setTimeout(async()=>{try{const b=await U.mutateAsync(n.content);j(b.errors.map(w=>w.message)||[])}catch{j(["Validation failed"])}},500);return()=>clearTimeout(i)}},[n.content,U]);const se=async()=>{try{if(o){const t={name:n.name,description:n.description,allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await R.mutateAsync({skillId:s.id,updates:t})}else{const t={name:n.name,description:n.description,scope:"user",allowedTools:n.allowedTools,content:n.content,additionalFiles:n.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await P.mutateAsync(t)}r()}catch(t){console.error(o?"Failed to update skill:":"Failed to create skill:",t),alert(l(o?"errors.updateFailed":"errors.createFailed"))}},re=()=>{const t={id:Math.random().toString(36).substr(2,9),name:"New File",path:"new-file.md",type:"markdown",content:""};h(i=>({...i,additionalFiles:[...i.additionalFiles,t]}))},le=t=>{h(i=>({...i,additionalFiles:i.additionalFiles.filter(b=>b.id!==t)}))},W=(t,i)=>{h(b=>({...b,additionalFiles:b.additionalFiles.map(w=>w.id===t?{...w,...i}:w)}))},ne=n.name.trim()!==""&&!k&&n.description.trim()!==""&&n.content.trim()!==""&&m.length===0,oe=()=>{switch(x){case"basic":return n.name.trim()!==""&&!k&&n.description.trim()!=="";case"manifest":return n.content.trim()!==""&&m.length===0;case"files":return!0;default:return!1}},G=()=>{if(!L){if(Y(!0),d>H){if(n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}}else if(H>d){const t=Be(n.content);if(t&&(t.name&&t.name!==n.name||t.description&&t.description!==n.description||t.allowedTools&&JSON.stringify(t.allowedTools)!==JSON.stringify(n.allowedTools))){h(u=>({...u,name:t.name||u.name,description:t.description||u.description,allowedTools:t.allowedTools||u.allowedTools}));const b=(t.allowedTools||[]).filter(u=>!u.startsWith("mcp__")),w=(t.allowedTools||[]).filter(u=>u.startsWith("mcp__"));E(b),v(w),I(w.length>0),N(Date.now())}}else if(!n.content&&n.name&&n.description){const t=ee(n.name,n.description,n.allowedTools);h(i=>({...i,content:t})),D(Date.now())}setTimeout(()=>Y(!1),100)}},ie=()=>{G(),x==="basic"?p("manifest"):x==="manifest"&&p("files")},de=t=>{G(),p(t)},ce=[{id:"basic",label:l("create.tabs.basic"),icon:we},{id:"manifest",label:l("create.tabs.manifest"),icon:je},{id:"files",label:l("create.tabs.files"),icon:ve}],xe=t=>t?t.length>64?"技能名称不能超过64个字符":/^[a-z0-9-]+$/.test(t)?t.startsWith("-")||t.endsWith("-")?"不能以连字符开始或结束":t.includes("--")?"不能包含连续的连字符":"":"只能使用小写字母、数字和连字符":"",ue=t=>{h(i=>({...i,name:t})),F(xe(t))},me=t=>{t.key==="Escape"&&a()};return o&&K?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsx("div",{className:"bg-white rounded-lg p-6 w-full max-w-md",children:e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})})}):e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onKeyDown:me,children:[e.jsxs("div",{className:"bg-white rounded-lg w-full max-w-3xl max-h-[90vh] overflow-hidden flex flex-col dark:bg-gray-800 dark:text-white",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.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:o?`编辑技能 - ${s?.name}`:l("create.title")}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 dark:text-gray-300",children:o?"修改现有技能的配置和功能":l("create.subtitle")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[x!=="files"?e.jsx("button",{onClick:ie,disabled:!oe(),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 dark:bg-blue-500 dark:hover:bg-blue-600",children:l("common:actions.next")}):e.jsx("button",{onClick:se,disabled:!ne||P.isPending||R.isPending,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 dark:bg-blue-500 dark:hover:bg-blue-600",children:P.isPending||R.isPending?l("common:status.saving"):l(o?"common:actions.save":"common:actions.create")}),e.jsx("button",{onClick:a,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700",children:e.jsx(_,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:ce.map(t=>{const i=t.icon,b=x===t.id,w=t.id==="basic"&&n.name.trim()!==""&&n.description.trim()!==""||t.id==="manifest"&&n.content.trim()!==""&&m.length===0||t.id==="files";return e.jsxs("button",{onClick:()=>de(t.id),className:`flex items-center gap-2 px-6 py-3 font-medium text-sm transition-colors ${b?"text-blue-600 border-b-2 border-blue-600 dark:text-blue-400 dark:border-blue-400":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"}`,children:[e.jsx(i,{className:"w-4 h-4"}),t.label,w&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"})]},t.id)})}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[x==="basic"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:"技能名称 (Slug)"}),e.jsx("input",{type:"text",value:n.name,onChange:t=>ue(t.target.value),disabled:o,className:`w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400 font-mono ${o?"bg-gray-100 text-gray-500 cursor-not-allowed dark:bg-gray-600 dark:text-gray-400":k?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300"}`,placeholder:"my-awesome-skill"}),k?e.jsx("p",{className:"text-xs text-red-500 mt-1 dark:text-red-400",children:k}):e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:o?"技能名称在编辑模式下不能修改":"只能使用小写字母、数字和连字符,最多64个字符"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.description")}),e.jsx("textarea",{value:n.description,onChange:t=>{h(i=>({...i,description:t.target.value}))},rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.basic.descriptionPlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.descriptionHint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.basic.allowedTools")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>M(!$),className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg transition-colors text-sm",children:l("create.basic.selectTools")}),(S.length>0||g.length>0)&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["常规工具 ",S.length," 个",g.length>0&&`, MCP工具 ${g.length} 个`]})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:l("create.basic.allowedToolsHint")})]})]}),x==="manifest"&&e.jsx("div",{className:"space-y-6 max-w-2xl",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:l("create.content.skillManifest")}),e.jsx("textarea",{value:n.content,onChange:t=>h(i=>({...i,content:t.target.value})),rows:15,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400"}),m.length>0&&e.jsxs("div",{className:"mt-2 p-3 bg-red-50 border border-red-200 rounded-lg dark:bg-red-900/20 dark:border-red-800",children:[e.jsxs("h4",{className:"text-sm font-medium text-red-800 mb-1 dark:text-red-400",children:[l("editor.errors.validationErrors"),":"]}),e.jsx("ul",{className:"text-sm text-red-700 space-y-1 dark:text-red-300",children:m.map((t,i)=>e.jsxs("li",{children:["• ",t]},i))})]})]})}),x==="files"&&e.jsxs("div",{className:"space-y-6 max-w-2xl",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:l("create.content.additionalFiles")}),e.jsxs("button",{onClick:re,className:"flex items-center gap-2 px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors dark:bg-green-500 dark:hover:bg-green-600",children:[e.jsx(ae,{className:"w-4 h-4"}),l("create.content.addFile")]})]}),n.additionalFiles.length===0?e.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-gray-300 rounded-lg",children:[e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:l("create.content.noFiles")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 dark:text-gray-400",children:l("create.content.noFilesHint")})]}):e.jsx("div",{className:"space-y-4",children:n.additionalFiles.map(t=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("input",{type:"text",value:t.name,onChange:i=>W(t.id,{name:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileName")}),e.jsx("input",{type:"text",value:t.path,onChange:i=>W(t.id,{path:i.target.value}),className:"flex-1 px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.filePath")}),e.jsxs("select",{value:t.type,onChange:i=>W(t.id,{type:i.target.value}),className:"px-2 py-1 border border-gray-300 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:focus:ring-blue-400 dark:focus:border-blue-400",children:[e.jsx("option",{value:"markdown",children:l("create.content.fileType.markdown")}),e.jsx("option",{value:"text",children:l("create.content.fileType.text")}),e.jsx("option",{value:"script",children:l("create.content.fileType.script")}),e.jsx("option",{value:"template",children:l("create.content.fileType.template")}),e.jsx("option",{value:"other",children:l("create.content.fileType.other")})]})]}),e.jsx("button",{onClick:()=>le(t.id),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded transition-colors dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20",children:e.jsx(_,{className:"w-4 h-4"})})]}),e.jsx("textarea",{value:t.content,onChange:i=>W(t.id,{content:i.target.value}),rows:6,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none font-mono text-sm resize-none dark:bg-gray-700 dark:border-gray-600 dark:text-white dark:placeholder-gray-400 dark:focus:ring-blue-400 dark:focus:border-blue-400",placeholder:l("create.content.fileContent")})]},t.id))})]})]})]}),e.jsx(ke,{isOpen:$,onClose:()=>M(!1),selectedRegularTools:S,onRegularToolsChange:E,selectedMcpTools:g,onMcpToolsChange:v,mcpToolsEnabled:T,onMcpEnabledChange:I})]})};function Be(a){try{const r=a.match(/^---\s*\n(.*?)\n---/s);if(!r)return null;const l=r[1].split(`
2
- `),o={};for(const x of l){const p=x.trim();if(p.startsWith("name:"))o.name=p.replace("name:","").trim();else if(p.startsWith("description:"))o.description=p.replace("description:","").trim();else if(p.startsWith("allowed-tools:")){const n=p.replace("allowed-tools:","").trim();if(n.startsWith("[")&&n.endsWith("]")){const h=n.slice(1,-1).split(",").map(m=>m.trim().replace(/^"(.*)"$/,"$1")).filter(m=>m.length>0);o.allowedTools=h}}}return o}catch(r){return console.error("Failed to parse skill content:",r),null}}function ee(a,r,s){const l=s.length>0?`
3
- allowed-tools: [${s.map(x=>`"${x}"`).join(", ")}]`:"",o=a.split("-").map(x=>x.charAt(0).toUpperCase()+x.slice(1)).join(" ");return`---
4
- name: ${a}
5
- description: ${r}${l}
6
- ---
7
-
8
- # ${o}
9
-
10
- ## Description
11
- ${r}
12
-
13
- ## Instructions
14
- Provide clear, step-by-step guidance for Claude on how to use this skill.
15
-
16
- ## Examples
17
- Show concrete examples of using this skill.
18
- `}const Ke=({skill:a,onClose:r})=>{const{t:s}=J("skills"),[l,o]=c.useState(""),[x,p]=c.useState(!0),[n,h]=c.useState([]);return c.useEffect(()=>{(async()=>{try{p(!0);const j=await f(`${Q}/skills/${a.id}/files/SKILL.md`);if(j.ok){const F=await j.json();o(F.content)}const k=await f(`${Q}/skills/${a.id}?scope=${a.scope}`);if(k.ok){const S=((await k.json()).skill?.files||[]).filter(g=>!g.path.endsWith("SKILL.md")),E=await Promise.all(S.map(async g=>{try{const v=await f(`${Q}/skills/${a.id}/files/${g.path}`);if(v.ok){const T=await v.json();return{name:g.path,content:T.content}}}catch(v){console.error(`Failed to load file ${g.path}:`,v)}return null}));h(E.filter(Boolean))}}catch(j){console.error("Failed to load skill content:",j)}finally{p(!1)}})()},[a.id,a.scope]),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 shadow-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:a.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",children:s("scope.user")}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300",children:a.source==="plugin"?s("source.plugin"):s("source.local")})]})]}),e.jsx(z,{variant:"ghost",onClick:r,className:"ml-4",children:e.jsx(_,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:x?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"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("detail.description")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:a.description})]}),a.allowedTools&&a.allowedTools.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("detail.allowedTools")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.allowedTools.map(m=>e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-mono bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",children:m},m))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"SKILL.md"}),e.jsx("pre",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 text-sm overflow-x-auto",children:e.jsx("code",{className:"text-gray-800 dark:text-gray-200",children:l})})]}),n.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("detail.additionalFiles")}),e.jsx("div",{className:"space-y-4",children:n.map(m=>e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:m.name}),e.jsx("pre",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 text-sm overflow-x-auto",children:e.jsx("code",{className:"text-gray-800 dark:text-gray-200",children:m.content})})]},m.name))})]})]})}),e.jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end",children:e.jsx(z,{variant:"outline",onClick:r,children:s("detail.close")})})]})})},We=({isOpen:a,onClose:r,skillName:s,installPath:l})=>{const{t:o}=J("skills");return a?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 shadow-xl max-w-[1200px] w-full h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:[s," - ",o("detail.files")]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:l})]}),e.jsx(z,{variant:"ghost",onClick:r,className:"ml-4",children:e.jsx(_,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:e.jsx($e,{projectPath:l,onFileSelect:x=>{console.log("Selected file:",x)},className:"h-full"})}),e.jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end",children:e.jsx(z,{variant:"outline",onClick:r,children:o("detail.close")})})]})}):null},qe=()=>{const{t:a}=J("skills"),[r,s]=c.useState(""),[l,o]=c.useState(null),[x,p]=c.useState(!1),[n,h]=c.useState(!1),[m,j]=c.useState(null),[k,F]=c.useState(!1),[$,M]=c.useState(null),[S,E]=c.useState({}),{data:g=[],isLoading:v,error:T}=Le({scope:"user",includeDisabled:!1}),I=Ie(),P=g.filter(d=>d.name.toLowerCase().includes(r.toLowerCase())||d.description.toLowerCase().includes(r.toLowerCase())),R=d=>{j(d),h(!0)},U=d=>{o(d),p(!0)},B=async d=>{try{const N=await f(`${Q}/skills/${d.id}?scope=${d.scope}`);if(N.ok){const D=(await N.json()).skill;D.installPath&&(M({name:d.name,installPath:D.installPath}),F(!0))}}catch(N){console.error("Failed to fetch skill data:",N)}},C=async d=>{if(window.confirm(a("deleteConfirm",{name:d.name})))try{await I.mutateAsync({skillId:d.id,scope:"user"})}catch(N){console.error("Failed to delete skill:",N),alert(a("errors.deleteFailed"))}},K=()=>{o(null),p(!0)};return T?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 dark:bg-red-900/20 dark:border-red-800",children:[e.jsx("h3",{className:"text-red-800 font-medium dark:text-red-400",children:a("errors.loadFailed")}),e.jsx("p",{className:"text-red-600 text-sm mt-1 dark:text-red-300",children:T instanceof Error?T.message:"An unknown error occurred"})]})}):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:a("title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:a("subtitle")})]})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ne,{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:a("searchPlaceholder"),value:r,onChange:d=>s(d.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:K,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(ae,{className:"w-5 h-5"}),e.jsx("span",{children:a("createButton")})]})]})]}),v?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):P.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:a(r?"noSkillsSearch":"noSkills")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:a(r?"adjustSearch":"createFirst")}),!r&&e.jsx("button",{onClick:K,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:a("createButton")})]}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(ge,{children:[e.jsx(be,{children:e.jsxs(Z,{children:[e.jsx(q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-48",children:a("table.skill")}),e.jsx(q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-96",children:a("table.tools")}),e.jsx(q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-40",children:a("table.updated")}),e.jsx(q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-32",children:a("table.actions")})]})}),e.jsx(fe,{children:P.map(d=>e.jsxs(Z,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(O,{className:"px-6 py-4 max-w-xs",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-2xl mr-4 flex-shrink-0",children:"⚡"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`text-sm font-medium ${d.enabled?"text-gray-900 dark:text-white":"text-gray-600 dark:text-gray-400"} truncate`,children:d.name}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 flex-shrink-0",children:a("scope.user")}),e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium flex-shrink-0 ${d.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:d.source==="plugin"?a("source.plugin"):a("source.local")})]}),e.jsx("div",{className:`text-sm ${d.enabled?"text-gray-500 dark:text-gray-400":"text-gray-400 dark:text-gray-500"} line-clamp-2`,children:d.description})]})]})}),e.jsx(O,{className:"px-6 py-4",children:e.jsx(Ee,{tools:d.allowedTools||[],id:d.id,expandedTools:S,setExpandedTools:E,isMobile:!1,emptyMessage:"无工具限制"})}),e.jsxs(O,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-40",children:[new Date(d.updatedAt).toLocaleDateString(),d.usageCount!==void 0&&d.usageCount>0&&e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:a("preview.usage",{count:d.usageCount})})]}),e.jsx(O,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium w-32",children:e.jsx("div",{className:"flex items-center space-x-2",children:d.source==="plugin"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>R(d),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:a("preview.actions.view"),children:e.jsx(Se,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>B(d),className:"p-1 text-purple-600 hover:bg-purple-50 dark:hover:bg-purple-900/50 rounded transition-colors",title:a("preview.actions.browseFiles"),children:e.jsx(Te,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>U(d),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:a("preview.actions.edit"),children:e.jsx(Ce,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>C(d),className:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded transition-colors",title:a("preview.actions.delete"),children:e.jsx(Fe,{className:"w-4 h-4"})})]})})})]},d.id))})]})}),x&&e.jsx(Ue,{onClose:()=>{p(!1),o(null)},onSuccess:()=>{p(!1),o(null)},editSkill:l||void 0}),n&&m&&e.jsx(Ke,{skill:m,onClose:()=>{h(!1),j(null)}}),k&&$&&e.jsx(We,{isOpen:k,skillName:$.name,installPath:$.installPath,onClose:()=>{F(!1),M(null)}})]})},tt=()=>e.jsx(qe,{});export{tt as SkillsPage};