agentstudio 0.3.4 → 0.4.1
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.
- package/bin/agentstudio.js +44 -4
- package/bin/agentstudio.js.map +1 -1
- package/bin/serviceManager.d.ts.map +1 -1
- package/bin/serviceManager.js +344 -38
- package/bin/serviceManager.js.map +1 -1
- package/config/engineConfig.d.ts +96 -0
- package/config/engineConfig.d.ts.map +1 -0
- package/config/engineConfig.js +429 -0
- package/config/engineConfig.js.map +1 -0
- package/engines/claude/__tests__/supportedModels.test.d.ts +10 -0
- package/engines/claude/__tests__/supportedModels.test.d.ts.map +1 -0
- package/engines/claude/__tests__/supportedModels.test.js +89 -0
- package/engines/claude/__tests__/supportedModels.test.js.map +1 -0
- package/engines/claude/aguiAdapter.d.ts +101 -0
- package/engines/claude/aguiAdapter.d.ts.map +1 -0
- package/engines/claude/aguiAdapter.js +382 -0
- package/engines/claude/aguiAdapter.js.map +1 -0
- package/engines/claude/claudeEngine.d.ts +42 -0
- package/engines/claude/claudeEngine.d.ts.map +1 -0
- package/engines/claude/claudeEngine.js +325 -0
- package/engines/claude/claudeEngine.js.map +1 -0
- package/engines/claude/index.d.ts +8 -0
- package/engines/claude/index.d.ts.map +1 -0
- package/engines/claude/index.js +14 -0
- package/engines/claude/index.js.map +1 -0
- package/engines/cursor/__tests__/a2aAdapter.test.d.ts +6 -0
- package/engines/cursor/__tests__/a2aAdapter.test.d.ts.map +1 -0
- package/engines/cursor/__tests__/a2aAdapter.test.js +376 -0
- package/engines/cursor/__tests__/a2aAdapter.test.js.map +1 -0
- package/engines/cursor/a2aAdapter.d.ts +180 -0
- package/engines/cursor/a2aAdapter.d.ts.map +1 -0
- package/engines/cursor/a2aAdapter.js +405 -0
- package/engines/cursor/a2aAdapter.js.map +1 -0
- package/engines/cursor/aguiAdapter.d.ts +97 -0
- package/engines/cursor/aguiAdapter.d.ts.map +1 -0
- package/engines/cursor/aguiAdapter.js +507 -0
- package/engines/cursor/aguiAdapter.js.map +1 -0
- package/engines/cursor/cursorEngine.d.ts +68 -0
- package/engines/cursor/cursorEngine.d.ts.map +1 -0
- package/engines/cursor/cursorEngine.js +465 -0
- package/engines/cursor/cursorEngine.js.map +1 -0
- package/engines/cursor/index.d.ts +11 -0
- package/engines/cursor/index.d.ts.map +1 -0
- package/engines/cursor/index.js +21 -0
- package/engines/cursor/index.js.map +1 -0
- package/engines/engineManager.d.ts +80 -0
- package/engines/engineManager.d.ts.map +1 -0
- package/engines/engineManager.js +137 -0
- package/engines/engineManager.js.map +1 -0
- package/engines/index.d.ts +26 -0
- package/engines/index.d.ts.map +1 -0
- package/engines/index.js +81 -0
- package/engines/index.js.map +1 -0
- package/engines/types.d.ts +319 -0
- package/engines/types.d.ts.map +1 -0
- package/engines/types.js +69 -0
- package/engines/types.js.map +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +139 -16
- package/index.js.map +1 -1
- package/middleware/auth.d.ts.map +1 -1
- package/middleware/auth.js +4 -0
- package/middleware/auth.js.map +1 -1
- package/package.json +7 -1
- package/public/assets/AgentsPage-D462iGRy.js +10 -0
- package/public/assets/{Button-BoiVlafj.js → Button-B_6lGF64.js} +1 -1
- package/public/assets/ChatPage-NjuRQPaL.js +478 -0
- package/public/assets/{CommandForm-Se4iemMp.js → CommandForm-DwGvE9A_.js} +1 -1
- package/public/assets/CommandsPage-DeUS8fhJ.js +1 -0
- package/public/assets/CursorConfigPage-Bl1Blrbr.js +1 -0
- package/public/assets/{DashboardPage-DbCVzPKz.js → DashboardPage-DH-2iuqf.js} +1 -1
- package/public/assets/EngineGate-DxTYx9wb.js +1 -0
- package/public/assets/{FileBrowser-DcoBWzKK.js → FileBrowser-CeGsJnUL.js} +5 -5
- package/public/assets/{FileExplorer-B41BB0LM.js → FileExplorer-x5R0Tcmk.js} +1 -1
- package/public/assets/GeneralSettingsPage-lhNEJQD_.js +1 -0
- package/public/assets/HooksPage-9fingjdz.js +1 -0
- package/public/assets/LandingPage-BAzi8PDo.js +1 -0
- package/public/assets/LoginPage-kQ_NWy8p.js +16 -0
- package/public/assets/McpAdminSettingsPage-DQHpWHRC.js +7 -0
- package/public/assets/McpPage-DLHfmhSJ.js +20 -0
- package/public/assets/{MemorySettingsPage-DYSuz-hU.js → MemorySettingsPage-CRIPja9X.js} +1 -1
- package/public/assets/ModelsPage-Bb5vSsuc.js +1 -0
- package/public/assets/PluginsPage-BhKM7gV7.js +12 -0
- package/public/assets/ProjectSelector-Cbct6pnn.js +1 -0
- package/public/assets/ProjectsPage-lQo7-7dt.js +21 -0
- package/public/assets/RulesPage-BRnB7__3.js +1 -0
- package/public/assets/ScheduledTasksPage-CZiABTSb.js +1 -0
- package/public/assets/SettingsLayout-BfG7ftoT.js +1 -0
- package/public/assets/SkillsPage-CL6MKxQ9.js +18 -0
- package/public/assets/{SubagentForm-C0R084ja.js → SubagentForm-BzzeWg0W.js} +2 -2
- package/public/assets/{SubagentsPage-BKFNmqxg.js → SubagentsPage-DhFP2kDE.js} +1 -1
- package/public/assets/SystemInfoPage-CFHUN3j8.js +1 -0
- package/public/assets/{TelemetrySettingsPage-Ck2btMol.js → TelemetrySettingsPage-BcZFVBXN.js} +1 -1
- package/public/assets/{ToastTestPage-B79DFhqI.js → ToastTestPage-BtGnZdyk.js} +1 -1
- package/public/assets/{ToolsList-Kfxwp80g.js → ToolsList-CTsQr53G.js} +1 -1
- package/public/assets/{UnifiedToolSelector-CkafUbz3.js → UnifiedToolSelector-BP6fuyzG.js} +1 -1
- package/public/assets/VersionSettingsPage-DjOjyL3X.js +5 -0
- package/public/assets/VoiceSettingsPage-d3l9AWBn.js +1 -0
- package/public/assets/WebSocketTunnelPage-CfHtJR9r.js +1 -0
- package/public/assets/_basePickBy-Bac3af5O.js +1 -0
- package/public/assets/{_baseUniq-COj5YnAO.js → _baseUniq-Dvh9sZ-T.js} +1 -1
- package/public/assets/{agents-3mB536QF.js → agents-KlPdWQ8K.js} +1 -1
- package/public/assets/arc-CRR5EPpK.js +1 -0
- package/public/assets/{architectureDiagram-VXUJARFQ-DD1BwT1T.js → architectureDiagram-VXUJARFQ-Ct1p8kmV.js} +1 -1
- package/public/assets/{blockDiagram-VD42YOAC-DFKUIZc6.js → blockDiagram-VD42YOAC-CX_8YiYn.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-B0VVIIvh.js → c4Diagram-YG6GDRKO-BIBVWIY4.js} +1 -1
- package/public/assets/channel-CPs-2Y_m.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-DM8J7YO9.js → chunk-4BX2VUAB-CQNNXsb5.js} +1 -1
- package/public/assets/{chunk-55IACEB6-BjhdmGlM.js → chunk-55IACEB6-N_ZrGhOu.js} +1 -1
- package/public/assets/{chunk-B4BG7PRW-1RJ6n2xv.js → chunk-B4BG7PRW-CI6DkhbM.js} +1 -1
- package/public/assets/{chunk-DI55MBZ5-1-EHSO67.js → chunk-DI55MBZ5-Dgj-Eo9U.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4-DV3SMJK_.js → chunk-FMBD7UC4-o4B0HzSK.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-IlsCTdDq.js → chunk-QN33PNHL-DXlfdPIk.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-DJXs-Fqo.js → chunk-QZHKN3VN-ZCBUGD7e.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BxHO9wa1.js → chunk-TZMSLE5B-N3lZ106d.js} +1 -1
- package/public/assets/classDiagram-2ON5EDUG-DCwNRxvC.js +1 -0
- package/public/assets/classDiagram-v2-WZHVMYZB-DCwNRxvC.js +1 -0
- package/public/assets/clone-C3DcKvhB.js +1 -0
- package/public/assets/{cose-bilkent-S5V4N54A-BVJXoW_K.js → cose-bilkent-S5V4N54A-Crc39J9q.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-DHDnVshA.js → dagre-6UL2VRFP-nC3WLCf7.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-40qGxDeg.js → diagram-PSM6KHXK-B5DQIDQ3.js} +1 -1
- package/public/assets/diagram-QEK2KX5R-BccDOQuz.js +43 -0
- package/public/assets/{diagram-S2PKOQOG-D7AX72a5.js → diagram-S2PKOQOG-D-Cv16WE.js} +1 -1
- package/public/assets/{erDiagram-Q2GNP2WA-BHsgeBpL.js → erDiagram-Q2GNP2WA-Dr0ZgvnS.js} +1 -1
- package/public/assets/{flowDiagram-NV44I4VS-BYqChOSE.js → flowDiagram-NV44I4VS-DGbbfVi5.js} +1 -1
- package/public/assets/{ganttDiagram-LVOFAZNH-CZFFSLKX.js → ganttDiagram-LVOFAZNH-C-3Wnf96.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-C5Bgrf0J.js → gitGraphDiagram-NY62KEGX--Q8whT5z.js} +1 -1
- package/public/assets/{graph-BP5lFRBg.js → graph-CO1DMS2E.js} +1 -1
- package/public/assets/{index-BEPv9Bqe.js → index-B5hSSnK3.js} +58 -58
- package/public/assets/index-gbHlIp96.css +1 -0
- package/public/assets/infoDiagram-F6ZHWCRC-DSR9cM2B.js +2 -0
- package/public/assets/{journeyDiagram-XKPGCS4Q--abC1RHz.js → journeyDiagram-XKPGCS4Q-Cc00zHNt.js} +1 -1
- package/public/assets/{kanban-definition-3W4ZIXB7-BJeChfWu.js → kanban-definition-3W4ZIXB7-BF_gHshF.js} +6 -6
- package/public/assets/{layout-DjAix4WK.js → layout-BxoLV88o.js} +1 -1
- package/public/assets/{linear-Cw0z8VNY.js → linear-Y8e2e012.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-U_T9xIUk.js → mindmap-definition-VGOIOE7T-CzpuQA4p.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-B0mT9OgH.js → pieDiagram-ADFJNKIX-B22MhIcy.js} +2 -2
- package/public/assets/{quadrantDiagram-AYHSOK5B-BWdlgO0u.js → quadrantDiagram-AYHSOK5B-CTT9bIA8.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-B-8LxsGB.js → requirementDiagram-UZGBJVZJ-B_vjXDH9.js} +1 -1
- package/public/assets/{sankeyDiagram-TZEHDZUN-OXuxkgGA.js → sankeyDiagram-TZEHDZUN-CKfZ4633.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-Bt5twlzi.js → sequenceDiagram-WL72ISMW-BmTPN6j6.js} +1 -1
- package/public/assets/{stateDiagram-FKZM4ZOC-Dmph7TeW.js → stateDiagram-FKZM4ZOC-y2fQE1C7.js} +1 -1
- package/public/assets/stateDiagram-v2-4FDKWEC3-C4CM6z52.js +1 -0
- package/public/assets/{table-DjMdAdjH.js → table-BJUz-ck5.js} +1 -1
- package/public/assets/{timeline-definition-IT6M3QCI-CcV8nyIH.js → timeline-definition-IT6M3QCI-DsXlR68n.js} +1 -1
- package/public/assets/{tools-BAI9XHGS.js → tools-BZTR2NP1.js} +1 -1
- package/public/assets/{treemap-KMMF4GRG-DBuwkj4f.js → treemap-KMMF4GRG-Cecs9uxX.js} +1 -1
- package/public/assets/{ui-components-DaGtjl0g.js → ui-components-DjgDPiqV.js} +153 -128
- package/public/assets/useAgents-8KXN6U61.js +2 -0
- package/public/assets/{useClaudeVersions-Cy71v4HE.js → useClaudeVersions-DicHLV6A.js} +1 -1
- package/public/assets/useCommands-DbSH48ba.js +1 -0
- package/public/assets/{useProjects-XgfgISgV.js → useProjects-Bbh6hJMM.js} +1 -1
- package/public/assets/{useSessions-CQgq4d84.js → useSessions-DOa4-xiB.js} +1 -1
- package/public/assets/{xychartDiagram-PRI3JC2R-Bo9K-U2S.js → xychartDiagram-PRI3JC2R-C2IWhyM7.js} +1 -1
- package/public/index.html +5 -5
- package/public/wechat-qr-code.png +0 -0
- package/routes/a2a.d.ts +7 -0
- package/routes/a2a.d.ts.map +1 -1
- package/routes/a2a.js +193 -21
- package/routes/a2a.js.map +1 -1
- package/routes/agents.d.ts.map +1 -1
- package/routes/agents.js +45 -2
- package/routes/agents.js.map +1 -1
- package/routes/agui.d.ts +16 -0
- package/routes/agui.d.ts.map +1 -0
- package/routes/agui.js +520 -0
- package/routes/agui.js.map +1 -0
- package/routes/commands.d.ts.map +1 -1
- package/routes/commands.js +35 -3
- package/routes/commands.js.map +1 -1
- package/routes/cursorA2a.d.ts +18 -0
- package/routes/cursorA2a.d.ts.map +1 -0
- package/routes/cursorA2a.js +393 -0
- package/routes/cursorA2a.js.map +1 -0
- package/routes/engine.d.ts +12 -0
- package/routes/engine.d.ts.map +1 -0
- package/routes/engine.js +178 -0
- package/routes/engine.js.map +1 -0
- package/routes/gitVersions.d.ts +10 -0
- package/routes/gitVersions.d.ts.map +1 -0
- package/routes/gitVersions.js +147 -0
- package/routes/gitVersions.js.map +1 -0
- package/routes/hooks.d.ts +11 -0
- package/routes/hooks.d.ts.map +1 -0
- package/routes/hooks.js +303 -0
- package/routes/hooks.js.map +1 -0
- package/routes/mcp.d.ts.map +1 -1
- package/routes/mcp.js +28 -3
- package/routes/mcp.js.map +1 -1
- package/routes/plugins.d.ts.map +1 -1
- package/routes/plugins.js +317 -4
- package/routes/plugins.js.map +1 -1
- package/routes/rules.d.ts +9 -0
- package/routes/rules.d.ts.map +1 -0
- package/routes/rules.js +470 -0
- package/routes/rules.js.map +1 -0
- package/routes/sessions.d.ts.map +1 -1
- package/routes/sessions.js +64 -30
- package/routes/sessions.js.map +1 -1
- package/routes/speechToText.d.ts +8 -0
- package/routes/speechToText.d.ts.map +1 -0
- package/routes/speechToText.js +216 -0
- package/routes/speechToText.js.map +1 -0
- package/schemas/a2a.d.ts +2 -2
- package/services/__tests__/agentImporter.test.d.ts +5 -0
- package/services/__tests__/agentImporter.test.d.ts.map +1 -0
- package/services/__tests__/agentImporter.test.js +379 -0
- package/services/__tests__/agentImporter.test.js.map +1 -0
- package/services/__tests__/marketplaceUpdateService.test.d.ts +5 -0
- package/services/__tests__/marketplaceUpdateService.test.d.ts.map +1 -0
- package/services/__tests__/marketplaceUpdateService.test.js +227 -0
- package/services/__tests__/marketplaceUpdateService.test.js.map +1 -0
- package/services/__tests__/pluginInstaller.test.js +172 -0
- package/services/__tests__/pluginInstaller.test.js.map +1 -1
- package/services/a2a/__tests__/agentCardService.test.js +224 -0
- package/services/a2a/__tests__/agentCardService.test.js.map +1 -1
- package/services/a2a/__tests__/cursorA2aService.test.d.ts +6 -0
- package/services/a2a/__tests__/cursorA2aService.test.d.ts.map +1 -0
- package/services/a2a/__tests__/cursorA2aService.test.js +359 -0
- package/services/a2a/__tests__/cursorA2aService.test.js.map +1 -0
- package/services/a2a/agentCardService.d.ts +22 -0
- package/services/a2a/agentCardService.d.ts.map +1 -1
- package/services/a2a/agentCardService.js +246 -0
- package/services/a2a/agentCardService.js.map +1 -1
- package/services/a2a/cursorA2aService.d.ts +126 -0
- package/services/a2a/cursorA2aService.d.ts.map +1 -0
- package/services/a2a/cursorA2aService.js +336 -0
- package/services/a2a/cursorA2aService.js.map +1 -0
- package/services/agentImporter.d.ts +62 -0
- package/services/agentImporter.d.ts.map +1 -0
- package/services/agentImporter.js +335 -0
- package/services/agentImporter.js.map +1 -0
- package/services/cursorConfigService.d.ts +75 -0
- package/services/cursorConfigService.d.ts.map +1 -0
- package/services/cursorConfigService.js +538 -0
- package/services/cursorConfigService.js.map +1 -0
- package/services/gitVersionService.d.ts +52 -0
- package/services/gitVersionService.d.ts.map +1 -0
- package/services/gitVersionService.js +377 -0
- package/services/gitVersionService.js.map +1 -0
- package/services/marketplaceUpdateService.d.ts +66 -0
- package/services/marketplaceUpdateService.d.ts.map +1 -0
- package/services/marketplaceUpdateService.js +364 -0
- package/services/marketplaceUpdateService.js.map +1 -0
- package/services/mcpAdmin/__tests__/scheduledTaskTools.test.d.ts +5 -0
- package/services/mcpAdmin/__tests__/scheduledTaskTools.test.d.ts.map +1 -0
- package/services/mcpAdmin/__tests__/scheduledTaskTools.test.js +429 -0
- package/services/mcpAdmin/__tests__/scheduledTaskTools.test.js.map +1 -0
- package/services/mcpAdmin/tools/index.d.ts +1 -0
- package/services/mcpAdmin/tools/index.d.ts.map +1 -1
- package/services/mcpAdmin/tools/index.js +5 -1
- package/services/mcpAdmin/tools/index.js.map +1 -1
- package/services/mcpAdmin/tools/scheduledTaskTools.d.ts +64 -0
- package/services/mcpAdmin/tools/scheduledTaskTools.d.ts.map +1 -0
- package/services/mcpAdmin/tools/scheduledTaskTools.js +1002 -0
- package/services/mcpAdmin/tools/scheduledTaskTools.js.map +1 -0
- package/services/mcpAdmin/types.d.ts +1 -1
- package/services/mcpAdmin/types.d.ts.map +1 -1
- package/services/pluginInstaller.d.ts +55 -1
- package/services/pluginInstaller.d.ts.map +1 -1
- package/services/pluginInstaller.js +437 -13
- package/services/pluginInstaller.js.map +1 -1
- package/services/sessionEventBus.d.ts +67 -0
- package/services/sessionEventBus.d.ts.map +1 -0
- package/services/sessionEventBus.js +106 -0
- package/services/sessionEventBus.js.map +1 -0
- package/services/speechToText/__tests__/speechToText.test.d.ts +5 -0
- package/services/speechToText/__tests__/speechToText.test.d.ts.map +1 -0
- package/services/speechToText/__tests__/speechToText.test.js +208 -0
- package/services/speechToText/__tests__/speechToText.test.js.map +1 -0
- package/services/speechToText/index.d.ts +25 -0
- package/services/speechToText/index.d.ts.map +1 -0
- package/services/speechToText/index.js +228 -0
- package/services/speechToText/index.js.map +1 -0
- package/services/speechToText/providers/aliyun.d.ts +22 -0
- package/services/speechToText/providers/aliyun.d.ts.map +1 -0
- package/services/speechToText/providers/aliyun.js +185 -0
- package/services/speechToText/providers/aliyun.js.map +1 -0
- package/services/speechToText/providers/google.d.ts +24 -0
- package/services/speechToText/providers/google.d.ts.map +1 -0
- package/services/speechToText/providers/google.js +205 -0
- package/services/speechToText/providers/google.js.map +1 -0
- package/services/speechToText/providers/openaiCompatible.d.ts +22 -0
- package/services/speechToText/providers/openaiCompatible.d.ts.map +1 -0
- package/services/speechToText/providers/openaiCompatible.js +198 -0
- package/services/speechToText/providers/openaiCompatible.js.map +1 -0
- package/services/speechToText/providers/tencent.d.ts +23 -0
- package/services/speechToText/providers/tencent.d.ts.map +1 -0
- package/services/speechToText/providers/tencent.js +215 -0
- package/services/speechToText/providers/tencent.js.map +1 -0
- package/services/speechToText/types.d.ts +102 -0
- package/services/speechToText/types.d.ts.map +1 -0
- package/services/speechToText/types.js +43 -0
- package/services/speechToText/types.js.map +1 -0
- package/services/taskExecutor/__tests__/mcp-tools-integration.test.d.ts +8 -2
- package/services/taskExecutor/__tests__/mcp-tools-integration.test.d.ts.map +1 -1
- package/services/taskExecutor/__tests__/mcp-tools-integration.test.js +215 -72
- package/services/taskExecutor/__tests__/mcp-tools-integration.test.js.map +1 -1
- package/services/taskExecutor/taskWorker.js +9 -1
- package/services/taskExecutor/taskWorker.js.map +1 -1
- package/services/telemetry.js +1 -1
- package/types/a2a.d.ts +20 -0
- package/types/a2a.d.ts.map +1 -1
- package/types/engine.d.ts +314 -0
- package/types/engine.d.ts.map +1 -0
- package/types/engine.js +14 -0
- package/types/engine.js.map +1 -0
- package/types/hooks.d.ts +45 -0
- package/types/hooks.d.ts.map +1 -0
- package/types/hooks.js +9 -0
- package/types/hooks.js.map +1 -0
- package/types/plugins.d.ts +86 -2
- package/types/plugins.d.ts.map +1 -1
- package/types/plugins.js +1 -0
- package/types/plugins.js.map +1 -1
- package/types/rules.d.ts +51 -0
- package/types/rules.d.ts.map +1 -0
- package/types/rules.js +9 -0
- package/types/rules.js.map +1 -0
- package/utils/__tests__/cursorIdeAgentParser.test.d.ts +7 -0
- package/utils/__tests__/cursorIdeAgentParser.test.d.ts.map +1 -0
- package/utils/__tests__/cursorIdeAgentParser.test.js +289 -0
- package/utils/__tests__/cursorIdeAgentParser.test.js.map +1 -0
- package/utils/cursorCliHistoryParser.d.ts +58 -0
- package/utils/cursorCliHistoryParser.d.ts.map +1 -0
- package/utils/cursorCliHistoryParser.js +664 -0
- package/utils/cursorCliHistoryParser.js.map +1 -0
- package/utils/cursorIdeAgentParser.d.ts +49 -0
- package/utils/cursorIdeAgentParser.d.ts.map +1 -0
- package/utils/cursorIdeAgentParser.js +332 -0
- package/utils/cursorIdeAgentParser.js.map +1 -0
- package/public/assets/AgentsPage-gSnkPp2k.js +0 -10
- package/public/assets/ChatPage-BMrfVkpt.js +0 -471
- package/public/assets/CommandsPage-B6u4IO7L.js +0 -1
- package/public/assets/GeneralSettingsPage-BbEbWJUQ.js +0 -1
- package/public/assets/LandingPage-DFPm2d4Y.js +0 -1
- package/public/assets/LoginPage-D5kZJqhk.js +0 -16
- package/public/assets/McpAdminSettingsPage-D32iUEjH.js +0 -7
- package/public/assets/McpPage-QT4qs391.js +0 -20
- package/public/assets/PluginsPage-BotzuK9f.js +0 -1
- package/public/assets/ProjectSelector-DujNObqr.js +0 -1
- package/public/assets/ProjectsPage-CRWe6HPl.js +0 -21
- package/public/assets/ScheduledTasksPage-Beeurg-w.js +0 -1
- package/public/assets/SettingsLayout-BfkBUyI_.js +0 -1
- package/public/assets/SkillsPage-B59bAr6W.js +0 -18
- package/public/assets/SystemInfoPage-D89s7PjE.js +0 -1
- package/public/assets/VersionSettingsPage-CaB4PH6h.js +0 -5
- package/public/assets/WebSocketTunnelPage-Cbru_-hL.js +0 -1
- package/public/assets/_basePickBy-5fAM04Ra.js +0 -1
- package/public/assets/arc-C2gTU2ZR.js +0 -1
- package/public/assets/channel-DcVTcy-S.js +0 -1
- package/public/assets/classDiagram-2ON5EDUG-BXVT6Q7h.js +0 -1
- package/public/assets/classDiagram-v2-WZHVMYZB-BXVT6Q7h.js +0 -1
- package/public/assets/clone-Bp6orjIq.js +0 -1
- package/public/assets/diagram-QEK2KX5R-BfMGeeRo.js +0 -43
- package/public/assets/index-BgR-BTTw.css +0 -1
- package/public/assets/infoDiagram-F6ZHWCRC-C6OApgqf.js +0 -2
- package/public/assets/stateDiagram-v2-4FDKWEC3-DyE8O3Kx.js +0 -1
- package/public/assets/useAgents-D5EDAc_E.js +0 -2
- package/public/assets/useCommands-BgoCfyuu.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as x}from"./monaco-editor-BWfQfpij.js";import{T as be,a as fe,b as te,c as Q,d as ye,e as z}from"./table-BJUz-ck5.js";import{g as ke,a as f,b as re,u as Z,c as X,A as J}from"./agents-KlPdWQ8K.js";import{U as we}from"./UnifiedToolSelector-BP6fuyzG.js";import{u as Y}from"./tools-BZTR2NP1.js";import{r as je,d as ve,aN as Ne,X as V,v as le,S as Se,E as se,e as Te,J as Ce,y as Fe}from"./ui-components-DjgDPiqV.js";import{B as H}from"./Button-B_6lGF64.js";import{F as $e}from"./FileExplorer-x5R0Tcmk.js";import{T as Ee}from"./ToolsList-CTsQr53G.js";import{e as De,c as Le,a as Me}from"./index-B5hSSnK3.js";import"./syntax-highlighting-DGbNjS3S.js";class Pe{baseURL=`${ke()}/skills`;async getAllSkills(l){const a=new URLSearchParams;l?.scope&&a.append("scope",l.scope),l?.includeDisabled&&a.append("includeDisabled","true");const r=await f(`${this.baseURL}?${a.toString()}`);if(!r.ok)throw new Error(`Failed to fetch skills: ${r.statusText}`);const n=await r.json();return this.transformToSkillListItems(n.skills)}async getSkill(l,a){const r=a?`?scope=${a}`:"",n=await f(`${this.baseURL}/${l}${r}`);if(n.status===404)return null;if(!n.ok)throw new Error(`Failed to fetch skill: ${n.statusText}`);return(await n.json()).skill}async createSkill(l){const a=await f(`${this.baseURL}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!a.ok){const n=await a.json();throw new Error(n.error||"Failed to create skill")}return(await a.json()).skill}async updateSkill(l,a){const r=await f(`${this.baseURL}/${l}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!r.ok){const c=await r.json();throw new Error(c.error||"Failed to update skill")}return(await r.json()).skill}async deleteSkill(l,a){const r=a?`?scope=${a}`:"",n=await f(`${this.baseURL}/${l}${r}`,{method:"DELETE"});if(n.status===404)return!1;if(!n.ok)throw new Error(`Failed to delete skill: ${n.statusText}`);return!0}async getSkillDirectoryInfo(l){const a=await f(`${this.baseURL}/${l}/directory`);if(a.status===404)return null;if(!a.ok)throw new Error(`Failed to fetch skill directory info: ${a.statusText}`);return(await a.json()).directoryInfo}async validateSkillManifest(l){const a=await f(`${this.baseURL}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:l})});if(!a.ok)throw new Error(`Failed to validate skill manifest: ${a.statusText}`);return await a.json()}async getSkillFile(l,a){const r=await f(`${this.baseURL}/${l}/files/${a}`);if(!r.ok)throw new Error(`Failed to fetch skill file: ${r.statusText}`);return(await r.json()).content}async updateSkillFile(l,a,r){const n=await f(`${this.baseURL}/${l}/files/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:r})});if(!n.ok)throw new Error(`Failed to update skill file: ${n.statusText}`)}transformToSkillListItems(l){return l.map(a=>({id:a.id,name:a.name,description:a.description,scope:a.scope,projectName:a.scope==="project"?"Current Project":void 0,source:a.source,enabled:a.enabled,createdAt:a.createdAt,updatedAt:a.updatedAt,allowedTools:a.allowedTools,toolCount:a.allowedTools?.length||0,usageCount:0,lastUsed:void 0}))}}const P=new Pe,y={all:["skills"],lists:()=>[...y.all,"list"],list:t=>[...y.lists(),t],details:()=>[...y.all,"detail"],detail:t=>[...y.details(),t],directory:t=>[...y.all,"directory",t]},Ae=t=>re({queryKey:y.list(t||{}),queryFn:()=>P.getAllSkills(t),staleTime:300*1e3}),Ie=(t,l)=>re({queryKey:y.detail(t),queryFn:()=>P.getSkill(t,l),enabled:!!t,staleTime:300*1e3}),Re=()=>{const t=Z();return X({mutationFn:l=>P.createSkill(l),onSuccess:l=>{t.invalidateQueries({queryKey:y.lists()}),t.setQueryData(y.detail(l.id),l)},onError:l=>{console.error("Failed to create skill:",l)}})},Ue=()=>{const t=Z();return X({mutationFn:({skillId:l,updates:a})=>P.updateSkill(l,a),onSuccess:l=>{t.setQueryData(y.detail(l.id),l),t.invalidateQueries({queryKey:y.lists()})},onError:l=>{console.error("Failed to update skill:",l)}})},Be=()=>{const t=Z();return X({mutationFn:({skillId:l,scope:a})=>P.deleteSkill(l,a),onSuccess:(l,{skillId:a})=>{t.removeQueries({queryKey:y.detail(a)}),t.invalidateQueries({queryKey:y.lists()})},onError:l=>{console.error("Failed to delete skill:",l)}})},Ke=()=>X({mutationFn:t=>P.validateSkillManifest(t),onError:t=>{console.error("Failed to validate skill manifest:",t)}}),We=({onClose:t,onSuccess:l,editSkill:a})=>{const{t:r}=Y(["skills","common"]),n=!!a,[c,p]=x.useState("basic"),[o,m]=x.useState({name:"",description:"",allowedTools:[],content:"",additionalFiles:[]}),[h,k]=x.useState([]),[v,F]=x.useState(""),[D,L]=x.useState(!1),[N,T]=x.useState([]),[g,w]=x.useState([]),[$,A]=x.useState(!1),I=Re(),R=Ue(),M=Ke(),B=Ie(a?.id||"",a?.scope||"user"),S=n?B.data:null,G=n?B.isLoading:!1,[K,U]=x.useState(0),[W,E]=x.useState(0),[d,C]=x.useState(!1);x.useEffect(()=>{if(!d){const s=[...N];$&&s.push(...g),m(i=>({...i,allowedTools:s})),U(Date.now())}},[N,g,$,d]),x.useEffect(()=>{!d&&(o.name||o.description)&&U(Date.now())},[o.name,o.description,d]),x.useEffect(()=>{!d&&o.content&&E(Date.now())},[o.content,d]),x.useEffect(()=>{if(n&&S){m({name:S.name,description:S.description,allowedTools:S.allowedTools||[],content:"",additionalFiles:(S.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 s=S.allowedTools||[],i=s.filter(u=>!u.startsWith("mcp__")),b=s.filter(u=>u.startsWith("mcp__"));T(i),w(b),A(b.length>0),(async()=>{try{const u=await fetch(`/api/skills/${a.id}/files/SKILL.md`);if(u.ok){const ge=await u.json();m(pe=>({...pe,content:ge.content})),E(Date.now())}}catch(u){console.error("Failed to load skill manifest:",u)}})()}},[n,S,a]),x.useEffect(()=>{if(o.content){const i=setTimeout(async()=>{try{const b=await M.mutateAsync(o.content);k(b.errors.map(j=>j.message)||[])}catch{k(["Validation failed"])}},500);return()=>clearTimeout(i)}},[o.content,M]);const q=async()=>{try{if(n){const s={name:o.name,description:o.description,allowedTools:o.allowedTools,content:o.content,additionalFiles:o.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await R.mutateAsync({skillId:a.id,updates:s})}else{const s={name:o.name,description:o.description,scope:"user",allowedTools:o.allowedTools,content:o.content,additionalFiles:o.additionalFiles.map(i=>({name:i.name,path:i.path,type:i.type,content:i.content}))};await I.mutateAsync(s)}l()}catch(s){console.error(n?"Failed to update skill:":"Failed to create skill:",s),alert(r(n?"errors.updateFailed":"errors.createFailed"))}},O=()=>{const s={id:Math.random().toString(36).substr(2,9),name:"New File",path:"new-file.md",type:"markdown",content:""};m(i=>({...i,additionalFiles:[...i.additionalFiles,s]}))},oe=s=>{m(i=>({...i,additionalFiles:i.additionalFiles.filter(b=>b.id!==s)}))},_=(s,i)=>{m(b=>({...b,additionalFiles:b.additionalFiles.map(j=>j.id===s?{...j,...i}:j)}))},ne=o.name.trim()!==""&&!v&&o.description.trim()!==""&&o.content.trim()!==""&&h.length===0,ie=()=>{switch(c){case"basic":return o.name.trim()!==""&&!v&&o.description.trim()!=="";case"manifest":return o.content.trim()!==""&&h.length===0;case"files":return!0;default:return!1}},ee=()=>{if(!d){if(C(!0),K>W){if(o.name&&o.description){const s=ae(o.name,o.description,o.allowedTools);m(i=>({...i,content:s})),E(Date.now())}}else if(W>K){const s=qe(o.content);if(s&&(s.name&&s.name!==o.name||s.description&&s.description!==o.description||s.allowedTools&&JSON.stringify(s.allowedTools)!==JSON.stringify(o.allowedTools))){m(u=>({...u,name:s.name||u.name,description:s.description||u.description,allowedTools:s.allowedTools||u.allowedTools}));const b=(s.allowedTools||[]).filter(u=>!u.startsWith("mcp__")),j=(s.allowedTools||[]).filter(u=>u.startsWith("mcp__"));T(b),w(j),A(j.length>0),U(Date.now())}}else if(!o.content&&o.name&&o.description){const s=ae(o.name,o.description,o.allowedTools);m(i=>({...i,content:s})),E(Date.now())}setTimeout(()=>C(!1),100)}},de=()=>{ee(),c==="basic"?p("manifest"):c==="manifest"&&p("files")},ce=s=>{ee(),p(s)},xe=[{id:"basic",label:r("create.tabs.basic"),icon:je},{id:"manifest",label:r("create.tabs.manifest"),icon:ve},{id:"files",label:r("create.tabs.files"),icon:Ne}],ue=s=>s?s.length>64?"技能名称不能超过64个字符":/^[a-z0-9-]+$/.test(s)?s.startsWith("-")||s.endsWith("-")?"不能以连字符开始或结束":s.includes("--")?"不能包含连续的连字符":"":"只能使用小写字母、数字和连字符":"",me=s=>{m(i=>({...i,name:s})),F(ue(s))},he=s=>{s.key==="Escape"&&t()};return n&&G?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:he,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:n?`编辑技能 - ${a?.name}`:r("create.title")}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 dark:text-gray-300",children:n?"修改现有技能的配置和功能":r("create.subtitle")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[c!=="files"?e.jsx("button",{onClick:de,disabled:!ie(),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:r("common:actions.next")}):e.jsx("button",{onClick:q,disabled:!ne||I.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:I.isPending||R.isPending?r("common:status.saving"):r(n?"common:actions.save":"common:actions.create")}),e.jsx("button",{onClick:t,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(V,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:xe.map(s=>{const i=s.icon,b=c===s.id,j=s.id==="basic"&&o.name.trim()!==""&&o.description.trim()!==""||s.id==="manifest"&&o.content.trim()!==""&&h.length===0||s.id==="files";return e.jsxs("button",{onClick:()=>ce(s.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"}),s.label,j&&e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500"})]},s.id)})}),e.jsxs("div",{className:"flex-1 overflow-auto p-6",children:[c==="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:o.name,onChange:s=>me(s.target.value),disabled:n,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 ${n?"bg-gray-100 text-gray-500 cursor-not-allowed dark:bg-gray-600 dark:text-gray-400":v?"border-red-500 focus:ring-red-500 focus:border-red-500":"border-gray-300"}`,placeholder:"my-awesome-skill"}),v?e.jsx("p",{className:"text-xs text-red-500 mt-1 dark:text-red-400",children:v}):e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:n?"技能名称在编辑模式下不能修改":"只能使用小写字母、数字和连字符,最多64个字符"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2 dark:text-gray-300",children:r("create.basic.description")}),e.jsx("textarea",{value:o.description,onChange:s=>{m(i=>({...i,description:s.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:r("create.basic.descriptionPlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:r("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:r("create.basic.allowedTools")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>L(!D),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:r("create.basic.selectTools")}),(N.length>0||g.length>0)&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["常规工具 ",N.length," 个",g.length>0&&`, MCP工具 ${g.length} 个`]})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 dark:text-gray-400",children:r("create.basic.allowedToolsHint")})]})]}),c==="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:r("create.content.skillManifest")}),e.jsx("textarea",{value:o.content,onChange:s=>m(i=>({...i,content:s.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"}),h.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:[r("editor.errors.validationErrors"),":"]}),e.jsx("ul",{className:"text-sm text-red-700 space-y-1 dark:text-red-300",children:h.map((s,i)=>e.jsxs("li",{children:["• ",s]},i))})]})]})}),c==="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:r("create.content.additionalFiles")}),e.jsxs("button",{onClick:O,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(le,{className:"w-4 h-4"}),r("create.content.addFile")]})]}),o.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:r("create.content.noFiles")}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 dark:text-gray-400",children:r("create.content.noFilesHint")})]}):e.jsx("div",{className:"space-y-4",children:o.additionalFiles.map(s=>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:s.name,onChange:i=>_(s.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:r("create.content.fileName")}),e.jsx("input",{type:"text",value:s.path,onChange:i=>_(s.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:r("create.content.filePath")}),e.jsxs("select",{value:s.type,onChange:i=>_(s.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:r("create.content.fileType.markdown")}),e.jsx("option",{value:"text",children:r("create.content.fileType.text")}),e.jsx("option",{value:"script",children:r("create.content.fileType.script")}),e.jsx("option",{value:"template",children:r("create.content.fileType.template")}),e.jsx("option",{value:"other",children:r("create.content.fileType.other")})]})]}),e.jsx("button",{onClick:()=>oe(s.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(V,{className:"w-4 h-4"})})]}),e.jsx("textarea",{value:s.content,onChange:i=>_(s.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:r("create.content.fileContent")})]},s.id))})]})]})]}),e.jsx(we,{isOpen:D,onClose:()=>L(!1),selectedRegularTools:N,onRegularToolsChange:T,selectedMcpTools:g,onMcpToolsChange:w,mcpToolsEnabled:$,onMcpEnabledChange:A})]})};function qe(t){try{const l=t.match(/^---\s*\n(.*?)\n---/s);if(!l)return null;const r=l[1].split(`
|
|
2
|
+
`),n={};for(const c of r){const p=c.trim();if(p.startsWith("name:"))n.name=p.replace("name:","").trim();else if(p.startsWith("description:"))n.description=p.replace("description:","").trim();else if(p.startsWith("allowed-tools:")){const o=p.replace("allowed-tools:","").trim();if(o.startsWith("[")&&o.endsWith("]")){const m=o.slice(1,-1).split(",").map(h=>h.trim().replace(/^"(.*)"$/,"$1")).filter(h=>h.length>0);n.allowedTools=m}}}return n}catch(l){return console.error("Failed to parse skill content:",l),null}}function ae(t,l,a){const r=a.length>0?`
|
|
3
|
+
allowed-tools: [${a.map(c=>`"${c}"`).join(", ")}]`:"",n=t.split("-").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" ");return`---
|
|
4
|
+
name: ${t}
|
|
5
|
+
description: ${l}${r}
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# ${n}
|
|
9
|
+
|
|
10
|
+
## Description
|
|
11
|
+
${l}
|
|
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 Oe=({skill:t,onClose:l})=>{const{t:a}=Y("skills"),[r,n]=x.useState(""),[c,p]=x.useState(!0),[o,m]=x.useState([]);return x.useEffect(()=>{(async()=>{try{p(!0);const k=await f(`${J}/skills/${t.id}/files/SKILL.md`);if(k.ok){const F=await k.json();n(F.content)}const v=await f(`${J}/skills/${t.id}?scope=${t.scope}`);if(v.ok){const N=((await v.json()).skill?.files||[]).filter(g=>!g.path.endsWith("SKILL.md")),T=await Promise.all(N.map(async g=>{try{const w=await f(`${J}/skills/${t.id}/files/${g.path}`);if(w.ok){const $=await w.json();return{name:g.path,content:$.content}}}catch(w){console.error(`Failed to load file ${g.path}:`,w)}return null}));m(T.filter(Boolean))}}catch(k){console.error("Failed to load skill content:",k)}finally{p(!1)}})()},[t.id,t.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:t.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:a("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:t.source==="plugin"?a("source.plugin"):a("source.local")})]})]}),e.jsx(H,{variant:"ghost",onClick:l,className:"ml-4",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:c?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:a("detail.description")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t.description})]}),t.allowedTools&&t.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:a("detail.allowedTools")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.allowedTools.map(h=>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:h},h))})]}),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:r})})]}),o.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:a("detail.additionalFiles")}),e.jsx("div",{className:"space-y-4",children:o.map(h=>e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:h.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:h.content})})]},h.name))})]})]})}),e.jsx("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end",children:e.jsx(H,{variant:"outline",onClick:l,children:a("detail.close")})})]})})},_e=({isOpen:t,onClose:l,skillName:a,installPath:r})=>{const{t:n}=Y("skills");return t?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:[a," - ",n("detail.files")]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r})]}),e.jsx(H,{variant:"ghost",onClick:l,className:"ml-4",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:e.jsx($e,{projectPath:r,onFileSelect:c=>{console.log("Selected file:",c)},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(H,{variant:"outline",onClick:l,children:n("detail.close")})})]})}):null},Qe=()=>{const{t}=Y("skills"),{isCursorEngine:l,engineType:a}=De(),r=Le(),n=l,[c,p]=x.useState(""),[o,m]=x.useState(null),[h,k]=x.useState(!1),[v,F]=x.useState(!1),[D,L]=x.useState(null),[N,T]=x.useState(!1),[g,w]=x.useState(null),[$,A]=x.useState({}),{data:I=[],isLoading:R,error:M}=Ae({scope:"user",includeDisabled:!1}),B=Be(),S=I.filter(d=>d.name.toLowerCase().includes(c.toLowerCase())||d.description.toLowerCase().includes(c.toLowerCase())),G=d=>{L(d),F(!0)},K=d=>{m(d),k(!0)},U=async d=>{try{const C=await f(`${J}/skills/${d.id}?scope=${d.scope}`);if(C.ok){const O=(await C.json()).skill;O.installPath&&(w({name:d.name,installPath:O.installPath}),T(!0))}}catch(C){console.error("Failed to fetch skill data:",C)}},W=async d=>{if(await r({title:t("deleteTitle","删除确认"),message:t("deleteConfirm",{name:d.name}),confirmText:t("common.delete","删除"),cancelText:t("common.cancel","取消"),variant:"danger"}))try{await B.mutateAsync({skillId:d.id,scope:"user"})}catch(q){console.error("Failed to delete skill:",q),Me(t("errors.deleteFailed"))}},E=()=>{m(null),k(!0)};return M?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:t("errors.loadFailed")}),e.jsx("p",{className:"text-red-600 text-sm mt-1 dark:text-red-300",children:M instanceof Error?M.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:t("title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",children:t("subtitle")})]})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Se,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:t("searchPlaceholder"),value:c,onChange:d=>p(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"})]}),n?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg text-yellow-700 dark:text-yellow-400 text-sm",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsxs("span",{children:["只读模式 (",a==="cursor-cli"?"Cursor":a,")"]})]}):e.jsxs("button",{onClick:E,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(le,{className:"w-5 h-5"}),e.jsx("span",{children:t("createButton")})]})]})]}),R?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"})}):S.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(c?"noSkillsSearch":"noSkills")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t(c?"adjustSearch":"createFirst")}),!c&&!n&&e.jsx("button",{onClick:E,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:t("createButton")}),n&&e.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-400",children:"配置来自 ~/.cursor/skills(只读)"})]}):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(be,{children:[e.jsx(fe,{children:e.jsxs(te,{children:[e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-48",children:t("table.skill")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-96",children:t("table.tools")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-40",children:t("table.updated")}),e.jsx(Q,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider w-32",children:t("table.actions")})]})}),e.jsx(ye,{children:S.map(d=>e.jsxs(te,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(z,{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:t("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"?t("source.plugin"):t("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(z,{className:"px-6 py-4",children:e.jsx(Ee,{tools:d.allowedTools||[],id:d.id,expandedTools:$,setExpandedTools:A,isMobile:!1,emptyMessage:"无工具限制"})}),e.jsxs(z,{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:t("preview.usage",{count:d.usageCount})})]}),e.jsx(z,{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"||n?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>G(d),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:t("preview.actions.view"),children:e.jsx(se,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>U(d),className:"p-1 text-purple-600 hover:bg-purple-50 dark:hover:bg-purple-900/50 rounded transition-colors",title:t("preview.actions.browseFiles"),children:e.jsx(Te,{className:"w-4 h-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(d),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:t("preview.actions.edit"),children:e.jsx(Ce,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>W(d),className:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded transition-colors",title:t("preview.actions.delete"),children:e.jsx(Fe,{className:"w-4 h-4"})})]})})})]},d.id))})]})}),h&&e.jsx(We,{onClose:()=>{k(!1),m(null)},onSuccess:()=>{k(!1),m(null)},editSkill:o||void 0}),v&&D&&e.jsx(Oe,{skill:D,onClose:()=>{F(!1),L(null)}}),N&&g&&e.jsx(_e,{isOpen:N,skillName:g.name,installPath:g.installPath,onClose:()=>{T(!1),w(null)}})]})},rt=()=>e.jsx(Qe,{});export{rt as SkillsPage};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as b}from"./monaco-editor-BWfQfpij.js";import{b as A,u as w,c as k,a as m,A as g,i as H}from"./agents-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as b}from"./monaco-editor-BWfQfpij.js";import{b as A,u as w,c as k,a as m,A as g,i as H}from"./agents-KlPdWQ8K.js";import{U as V}from"./UnifiedToolSelector-BP6fuyzG.js";import{u as X}from"./tools-BZTR2NP1.js";import{c as Y,o as Z,a4 as I,U as ee,a7 as te,j as F}from"./ui-components-DjgDPiqV.js";const se=async(t={})=>{try{const o=new URLSearchParams;t.search&&o.append("search",t.search);const n=await m(`${g}/subagents?${o}`);if(!n.ok)throw new Error("Failed to fetch subagents");return n.json()}catch(o){if(H(o))return[];throw o}},re=async t=>{const o=await m(`${g}/subagents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok){const n=await o.json();throw new Error(n.error||"Failed to create subagent")}return o.json()},oe=async({id:t,...o})=>{const n=await m(`${g}/subagents/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!n.ok){const h=await n.json();throw new Error(h.error||"Failed to update subagent")}return n.json()},ae=async t=>{const o=await m(`${g}/subagents/${t}`,{method:"DELETE"});if(!o.ok){const n=await o.json();throw new Error(n.error||"Failed to delete subagent")}},we=(t={})=>A({queryKey:["subagents",t],queryFn:()=>se(t),retry:!1}),ne=()=>{const t=w();return k({mutationFn:re,onSuccess:()=>{t.invalidateQueries({queryKey:["subagents"]})}})},ce=()=>{const t=w();return k({mutationFn:oe,onSuccess:o=>{t.invalidateQueries({queryKey:["subagents"]}),t.invalidateQueries({queryKey:["subagent",o.id]})}})},ke=()=>{const t=w();return k({mutationFn:ae,onSuccess:()=>{t.invalidateQueries({queryKey:["subagents"]})}})},ie=async(t,o={})=>{const n=await m(`${g}/projects`);if(!n.ok)throw new Error("Failed to fetch project info");const r=(await n.json()).projects.find(i=>i.id===t);if(!r)throw new Error("Project not found");const c=new URLSearchParams;c.append("projectPath",r.path),o.search&&c.append("search",o.search);const l=await m(`${g}/subagents?${c}`);if(!l.ok)throw new Error("Failed to fetch project subagents");return l.json()},ve=t=>A({queryKey:["subagents","project",t.projectId,t.search],queryFn:()=>ie(t.projectId,{search:t.search}),staleTime:1e3*60*5}),le=async(t,o)=>{const n=await m(`${g}/projects`);if(!n.ok)throw new Error("Failed to fetch project info");const r=(await n.json()).projects.find(i=>i.id===t);if(!r)throw new Error("Project not found");const c=new URLSearchParams;c.append("projectPath",r.path);const l=await m(`${g}/subagents?${c}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok){const i=await l.json();throw new Error(i.error||"Failed to create subagent")}return l.json()},de=async(t,o)=>{const n=await m(`${g}/projects`);if(!n.ok)throw new Error("Failed to fetch project info");const r=(await n.json()).projects.find(u=>u.id===t);if(!r)throw new Error("Project not found");const{id:c,...l}=o,i=new URLSearchParams;i.append("projectPath",r.path);const f=await m(`${g}/subagents/${c}?${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!f.ok){const u=await f.json();throw new Error(u.error||"Failed to update subagent")}return f.json()},ue=async(t,o)=>{const n=await m(`${g}/projects`);if(!n.ok)throw new Error("Failed to fetch project info");const r=(await n.json()).projects.find(i=>i.id===t);if(!r)throw new Error("Project not found");const c=new URLSearchParams;c.append("projectPath",r.path);const l=await m(`${g}/subagents/${o}?${c}`,{method:"DELETE"});if(!l.ok){const i=await l.json();throw new Error(i.error||"Failed to delete subagent")}},me=t=>{const o=w();return k({mutationFn:n=>le(t,n),onSuccess:()=>{o.invalidateQueries({queryKey:["subagents","project",t]})}})},ge=t=>{const o=w();return k({mutationFn:n=>de(t,n),onSuccess:n=>{o.invalidateQueries({queryKey:["subagents","project",t]}),o.invalidateQueries({queryKey:["subagent",n.id]})}})},Se=t=>{const o=w();return k({mutationFn:n=>ue(t,n),onSuccess:()=>{o.invalidateQueries({queryKey:["subagents","project",t]})}})},pe=[{value:"user",label:"个人Subagent",description:"存储在用户配置中,仅个人使用"},{value:"project",label:"项目Subagent",description:"存储在项目中,项目成员共享"}],Fe=({subagent:t,projectId:o,onClose:n,onSuccess:h})=>{const{t:r}=X("components"),[c,l]=b.useState({name:"",description:"",content:"",scope:o?"project":"user",tools:[]}),[i,f]=b.useState({}),[u,J]=b.useState(!1),[N,C]=b.useState(""),[M,R]=b.useState(!1),[y,E]=b.useState([]),[j,v]=b.useState([]),[D,T]=b.useState(!1),U=o?me(o):ne(),Q=o?ge(o):ce(),S=!!t,K=s=>{const a=[];return a.push(`name: ${s.name}`),s.description&&a.push(`description: ${s.description}`),s.tools&&s.tools.length>0&&a.push(`tools: ${s.tools.join(", ")}`),a.length>0?`---
|
|
2
2
|
${a.join(`
|
|
3
3
|
`)}
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
${s.content}`:s.content},O=s=>{const a=s.match(/^---\n(.*?)\n---\n\n?(.*)/s);if(!a)return{content:s};const[,d,x]=a,p={content:x};return d.split(`
|
|
7
|
-
`).forEach($=>{const P=$.indexOf(":");if(P===-1)return;const B=$.substring(0,P).trim(),q=$.substring(P+1).trim();switch(B){case"name":p.name=q;break;case"description":p.description=q;break;case"tools":p.tools=q.split(",").map(G=>G.trim()).filter(Boolean);break}}),p};b.useEffect(()=>{if(t){const s=t.tools||[],a=s.filter(x=>x.startsWith("mcp__")),d=s.filter(x=>!x.startsWith("mcp__"));l({name:t.name,description:t.description,content:t.content,scope:t.scope,tools:s}),E(d),v(a),T(a.length>0),C(K({name:t.name,description:t.description,content:t.content,scope:t.scope,tools:s}))}},[t]);const W=()=>{const s={};return c.name.trim()?/^[a-z0-9-]+$/.test(c.name)||(s.name=r("subagentForm.validation.nameFormat")):s.name=r("subagentForm.validation.nameRequired"),c.description.trim()||(s.description=r("subagentForm.validation.descriptionRequired")),c.content.trim()||(s.content=r("subagentForm.validation.contentRequired")),f(s),Object.keys(s).length===0},z=async s=>{s.preventDefault();let a=c;if(u){const d=O(N);a={...c,...d}}if(W())try{if(S&&t){const d={description:a.description,content:a.content,tools:a.tools};await Q.mutateAsync({id:t.id,...d})}else await U.mutateAsync(a);h(),n()}catch(d){console.error("Error saving subagent:",d),f({submit:d instanceof Error?d.message:r("subagentForm.errors.saveFailed")})}},_=()=>{if(u){const s=O(N),a=s.tools||[],d=a.filter(p=>p.startsWith("mcp__")),x=a.filter(p=>!p.startsWith("mcp__"));l(p=>({...p,...s,tools:a})),E(x),v(d),T(d.length>0)}else C(K(c));J(!u)},L=U.isPending||Q.isPending;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 max-w-4xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:r(S?"subagentForm.title.edit":"subagentForm.title.create")}),e.jsxs("div",{className:"flex items-center bg-gray-100 dark:bg-gray-700 rounded-lg p-1",children:[e.jsxs("button",{type:"button",onClick:()=>!u||_(),className:`flex items-center space-x-1 px-3 py-1.5 rounded-md text-sm transition-colors ${u?"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white":"bg-white dark:bg-gray-800 text-blue-600 shadow-sm"}`,children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx("span",{children:r("subagentForm.mode.form")})]}),e.jsxs("button",{type:"button",onClick:()=>u||_(),className:`flex items-center space-x-1 px-3 py-1.5 rounded-md text-sm transition-colors ${u?"bg-white dark:bg-gray-800 text-blue-600 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx("span",{children:r("subagentForm.mode.code")})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg transition-colors",children:r("subagentForm.actions.cancel")}),e.jsxs("button",{type:"submit",form:"subagent-form",disabled:L,className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-lg transition-colors",children:[e.jsx(I,{className:"h-4 w-4"}),e.jsx("span",{children:r(L?"subagentForm.actions.saving":S?"subagentForm.actions.saveChanges":"subagentForm.actions.create")})]})]})]}),e.jsx("form",{id:"subagent-form",onSubmit:z,className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"p-6 space-y-6",children:[u?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start space-x-2 p-3 bg-blue-50 dark:bg-blue-900/30 rounded-lg",children:[e.jsx(ee,{className:"h-5 w-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:r("subagentForm.codeMode.title")}),e.jsx("p",{children:r("subagentForm.codeMode.description")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.codeMode.label")}),e.jsx("textarea",{value:N,onChange:s=>C(s.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:r("subagentForm.codeMode.placeholder")})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[r("subagentForm.fields.name.label"),e.jsx(te,{className:"inline h-4 w-4 ml-1 text-gray-400"})]}),e.jsx("input",{type:"text",value:c.name,onChange:s=>l(a=>({...a,name:s.target.value})),className:`w-full px-3 py-2 border rounded-lg dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.name?"border-red-500":"border-gray-300 dark:border-gray-600"}`,placeholder:r("subagentForm.fields.name.placeholder"),disabled:S}),i.name&&e.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-1"}),i.name]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.scope.label")}),e.jsx("select",{value:c.scope,onChange:s=>l(a=>({...a,scope:s.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-gray-100",disabled:!0,children:o?e.jsx("option",{value:"project",children:r("subagentForm.fields.scope.projectScope")}):pe.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.description.label")}),e.jsx("input",{type:"text",value:c.description,onChange:s=>l(a=>({...a,description:s.target.value})),className:`w-full px-3 py-2 border rounded-lg dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.description?"border-red-500":"border-gray-300 dark:border-gray-600"}`,placeholder:r("subagentForm.fields.description.placeholder")}),i.description&&e.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-1"}),i.description]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.tools.label")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>
|
|
7
|
+
`).forEach($=>{const P=$.indexOf(":");if(P===-1)return;const B=$.substring(0,P).trim(),q=$.substring(P+1).trim();switch(B){case"name":p.name=q;break;case"description":p.description=q;break;case"tools":p.tools=q.split(",").map(G=>G.trim()).filter(Boolean);break}}),p};b.useEffect(()=>{if(t){const s=t.tools||[],a=s.filter(x=>x.startsWith("mcp__")),d=s.filter(x=>!x.startsWith("mcp__"));l({name:t.name,description:t.description,content:t.content,scope:t.scope,tools:s}),E(d),v(a),T(a.length>0),C(K({name:t.name,description:t.description,content:t.content,scope:t.scope,tools:s}))}},[t]);const W=()=>{const s={};return c.name.trim()?/^[a-z0-9-]+$/.test(c.name)||(s.name=r("subagentForm.validation.nameFormat")):s.name=r("subagentForm.validation.nameRequired"),c.description.trim()||(s.description=r("subagentForm.validation.descriptionRequired")),c.content.trim()||(s.content=r("subagentForm.validation.contentRequired")),f(s),Object.keys(s).length===0},z=async s=>{s.preventDefault();let a=c;if(u){const d=O(N);a={...c,...d}}if(W())try{if(S&&t){const d={description:a.description,content:a.content,tools:a.tools};await Q.mutateAsync({id:t.id,...d})}else await U.mutateAsync(a);h(),n()}catch(d){console.error("Error saving subagent:",d),f({submit:d instanceof Error?d.message:r("subagentForm.errors.saveFailed")})}},_=()=>{if(u){const s=O(N),a=s.tools||[],d=a.filter(p=>p.startsWith("mcp__")),x=a.filter(p=>!p.startsWith("mcp__"));l(p=>({...p,...s,tools:a})),E(x),v(d),T(d.length>0)}else C(K(c));J(!u)},L=U.isPending||Q.isPending;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 max-w-4xl w-full max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:r(S?"subagentForm.title.edit":"subagentForm.title.create")}),e.jsxs("div",{className:"flex items-center bg-gray-100 dark:bg-gray-700 rounded-lg p-1",children:[e.jsxs("button",{type:"button",onClick:()=>!u||_(),className:`flex items-center space-x-1 px-3 py-1.5 rounded-md text-sm transition-colors ${u?"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white":"bg-white dark:bg-gray-800 text-blue-600 shadow-sm"}`,children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx("span",{children:r("subagentForm.mode.form")})]}),e.jsxs("button",{type:"button",onClick:()=>u||_(),className:`flex items-center space-x-1 px-3 py-1.5 rounded-md text-sm transition-colors ${u?"bg-white dark:bg-gray-800 text-blue-600 shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx("span",{children:r("subagentForm.mode.code")})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("button",{type:"button",onClick:n,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg transition-colors",children:r("subagentForm.actions.cancel")}),e.jsxs("button",{type:"submit",form:"subagent-form",disabled:L,className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed text-white rounded-lg transition-colors",children:[e.jsx(I,{className:"h-4 w-4"}),e.jsx("span",{children:r(L?"subagentForm.actions.saving":S?"subagentForm.actions.saveChanges":"subagentForm.actions.create")})]})]})]}),e.jsx("form",{id:"subagent-form",onSubmit:z,className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"p-6 space-y-6",children:[u?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start space-x-2 p-3 bg-blue-50 dark:bg-blue-900/30 rounded-lg",children:[e.jsx(ee,{className:"h-5 w-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-300",children:[e.jsx("p",{className:"font-medium",children:r("subagentForm.codeMode.title")}),e.jsx("p",{children:r("subagentForm.codeMode.description")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.codeMode.label")}),e.jsx("textarea",{value:N,onChange:s=>C(s.target.value),className:"w-full h-96 px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:r("subagentForm.codeMode.placeholder")})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[r("subagentForm.fields.name.label"),e.jsx(te,{className:"inline h-4 w-4 ml-1 text-gray-400"})]}),e.jsx("input",{type:"text",value:c.name,onChange:s=>l(a=>({...a,name:s.target.value})),className:`w-full px-3 py-2 border rounded-lg dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.name?"border-red-500":"border-gray-300 dark:border-gray-600"}`,placeholder:r("subagentForm.fields.name.placeholder"),disabled:S}),i.name&&e.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-1"}),i.name]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.scope.label")}),e.jsx("select",{value:c.scope,onChange:s=>l(a=>({...a,scope:s.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 bg-gray-100",disabled:!0,children:o?e.jsx("option",{value:"project",children:r("subagentForm.fields.scope.projectScope")}):pe.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.description.label")}),e.jsx("input",{type:"text",value:c.description,onChange:s=>l(a=>({...a,description:s.target.value})),className:`w-full px-3 py-2 border rounded-lg dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 ${i.description?"border-red-500":"border-gray-300 dark:border-gray-600"}`,placeholder:r("subagentForm.fields.description.placeholder")}),i.description&&e.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-1"}),i.description]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.tools.label")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{type:"button",onClick:()=>R(!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:r("subagentForm.fields.tools.selectTools")}),(y.length>0||j.length>0)&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r("subagentForm.fields.tools.regularToolsCount",{count:y.length}),j.length>0&&`, ${r("subagentForm.fields.tools.mcpToolsCount",{count:j.length})}`]}),e.jsx(V,{isOpen:M,onClose:()=>R(!1),selectedRegularTools:y,selectedMcpTools:j,mcpToolsEnabled:D,onRegularToolsChange:s=>{E(s);const a=D?[...s,...j]:s;l({...c,tools:a})},onMcpToolsChange:s=>{v(s);const a=[...y,...s];l({...c,tools:a})},onMcpEnabledChange:s=>{if(T(s),!s)v([]),l({...c,tools:y});else{const a=[...y,...j];l({...c,tools:a})}}})]}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:r("subagentForm.fields.tools.hint")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("subagentForm.fields.content.label")}),e.jsx("textarea",{value:c.content,onChange:s=>l(a=>({...a,content:s.target.value})),className:`w-full h-48 px-3 py-2 border rounded-lg dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-y ${i.content?"border-red-500":"border-gray-300 dark:border-gray-600"}`,placeholder:r("subagentForm.fields.content.placeholder")}),i.content&&e.jsxs("p",{className:"mt-1 text-sm text-red-600 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-1"}),i.content]})]})]}),i.submit&&e.jsx("div",{className:"mt-4 p-3 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400 flex items-center",children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),i.submit]})})]})})]})})};export{Fe as S,ke as a,ve as b,Se as c,we as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as i}from"./monaco-editor-BWfQfpij.js";import{T as D,a as B,b as f,c as o,d as R,e as m}from"./table-DjMdAdjH.js";import{u as H,a as L,S as q}from"./SubagentForm-C0R084ja.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{b as z}from"./index-BEPv9Bqe.js";import{T as k}from"./ToolsList-Kfxwp80g.js";import{u as J}from"./tools-BAI9XHGS.js";import{j as G,g as I,v as K,a5 as v,E as w,J as $,y as h}from"./ui-components-DaGtjl0g.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-3mB536QF.js";import"./UnifiedToolSelector-CkafUbz3.js";const re=()=>{const{t:s}=J("pages"),{isMobile:t}=z(),[a,S]=i.useState(""),[C,n]=i.useState(!1),[T,d]=i.useState(null),[g,c]=i.useState(null),[p,y]=i.useState({}),{data:b=[],isLoading:F,error:E,refetch:j}=H({search:a.trim()||void 0}),u=L(),M=async r=>{try{await u.mutateAsync(r.id),c(null)}catch(l){console.error("Failed to delete subagent:",l)}},x=r=>{d(r),n(!0)},A=()=>{n(!1),d(null)},P=()=>{j()};return F?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`animate-spin rounded-full ${t?"h-8 w-8":"h-12 w-12"} border-b-2 border-blue-600 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("div",{className:`text-gray-600 dark:text-gray-400 ${t?"text-sm":""}`,children:s("settings.subagents.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G,{className:`${t?"h-8 w-8":"h-12 w-12"} text-red-500 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white mb-2`,children:s("settings.subagents.loadFailed")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mb-4 text-sm":"mb-4"}`,children:s("settings.subagents.loadFailedMessage")}),e.jsx("button",{onClick:()=>j(),className:`${t?"px-4 py-2.5 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:t?"mb-4":"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:`${t?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("settings.subagents.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mt-1":"mt-2"}`,children:s("settings.subagents.subtitle")})]})}),e.jsxs("div",{className:t?"space-y-3":"flex items-center space-x-4",children:[e.jsxs("div",{className:`${t?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:s("settings.subagents.searchPlaceholder"),value:a,onChange:r=>S(r.target.value),className:`pl-10 pr-4 ${t?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${t?"text-sm":"whitespace-nowrap"}`,children:[e.jsx(K,{className:t?"w-4 h-4":"w-5 h-5"}),e.jsx("span",{children:s("settings.subagents.createButton")})]})]})]}),b.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:`${t?"text-4xl":"text-6xl"} mb-4`,children:"🤖"}),e.jsx("h3",{className:`${t?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:s(a?"settings.subagents.noSubagentsSearch":"settings.subagents.noSubagents")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:s(a?"settings.subagents.adjustSearch":"settings.subagents.createFirst")}),!a&&e.jsx("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.createButton")})]}):e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"space-y-4",children:b.map((r,l)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${t?"text-lg":"text-xl"} mr-3`,children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`${t?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.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:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[s("settings.subagents.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!0,emptyMessage:s("settings.subagents.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[s("settings.subagents.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(v,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(r.createdAt)})]})]})]}),e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})]},r.id+"-"+l))}):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(D,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.subagent")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.tools")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.createdAt")}),e.jsx(o,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.actions")})]})}),e.jsx(R,{children:b.map((r,l)=>e.jsxs(f,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(m,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.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:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:r.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!1,emptyMessage:s("settings.subagents.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{children:N(r.createdAt)})]})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.viewTitle"),children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.editTitle"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})})]},r.id+"-"+l))})]})})}),C&&e.jsx(q,{subagent:T,onClose:A,onSuccess:P}),g&&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 ${t?"w-full max-w-sm":"max-w-md w-full"}`,children:[e.jsx("div",{className:`${t?"px-4 py-3":"px-6 py-4"} border-b border-gray-200 dark:border-gray-700`,children:e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white`,children:s("settings.subagents.deleteConfirm.title")})}),e.jsxs("div",{className:`${t?"px-4 py-3":"px-6 py-4"}`,children:[e.jsx("p",{className:`${t?"text-sm":""} text-gray-600 dark:text-gray-400`,children:s("settings.subagents.deleteConfirm.message",{name:g.name})}),e.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${t?"mt-1 text-xs":"mt-2"}`,children:s("settings.subagents.deleteConfirm.warning")})]}),e.jsxs("div",{className:`${t?"grid grid-cols-2 gap-2 px-4 py-3":"flex items-center justify-end space-x-3 px-6 py-4"} border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50`,children:[e.jsx("button",{onClick:()=>c(null),className:`${t?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors`,children:s("settings.subagents.deleteConfirm.cancel")}),e.jsxs("button",{onClick:()=>M(g),disabled:u.isPending,className:`${t?"flex items-center justify-center space-x-1 px-3 py-2.5 text-sm":"flex items-center space-x-2 px-4 py-2"} bg-red-600 hover:bg-red-700 disabled:bg-red-400 text-white rounded-lg transition-colors`,children:[u.isPending?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):e.jsx(h,{className:`${t?"h-3 w-3":"h-4 w-4"}`}),e.jsx("span",{children:s("settings.subagents.deleteConfirm.delete")})]})]})]})})]})};export{re as SubagentsPage};
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as i}from"./monaco-editor-BWfQfpij.js";import{T as D,a as B,b as f,c as o,d as R,e as m}from"./table-BJUz-ck5.js";import{u as H,a as L,S as q}from"./SubagentForm-BzzeWg0W.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{b as z}from"./index-B5hSSnK3.js";import{T as k}from"./ToolsList-CTsQr53G.js";import{u as J}from"./tools-BZTR2NP1.js";import{j as G,S as I,v as K,a6 as v,E as w,J as $,y as h}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";import"./UnifiedToolSelector-BP6fuyzG.js";const re=()=>{const{t:s}=J("pages"),{isMobile:t}=z(),[a,S]=i.useState(""),[C,n]=i.useState(!1),[T,d]=i.useState(null),[g,c]=i.useState(null),[p,y]=i.useState({}),{data:b=[],isLoading:F,error:E,refetch:j}=H({search:a.trim()||void 0}),u=L(),M=async r=>{try{await u.mutateAsync(r.id),c(null)}catch(l){console.error("Failed to delete subagent:",l)}},x=r=>{d(r),n(!0)},A=()=>{n(!1),d(null)},P=()=>{j()};return F?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:`animate-spin rounded-full ${t?"h-8 w-8":"h-12 w-12"} border-b-2 border-blue-600 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("div",{className:`text-gray-600 dark:text-gray-400 ${t?"text-sm":""}`,children:s("settings.subagents.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G,{className:`${t?"h-8 w-8":"h-12 w-12"} text-red-500 mx-auto ${t?"mb-3":"mb-4"}`}),e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white mb-2`,children:s("settings.subagents.loadFailed")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mb-4 text-sm":"mb-4"}`,children:s("settings.subagents.loadFailedMessage")}),e.jsx("button",{onClick:()=>j(),className:`${t?"px-4 py-2.5 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:t?"mb-4":"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:`${t?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("settings.subagents.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${t?"mt-1":"mt-2"}`,children:s("settings.subagents.subtitle")})]})}),e.jsxs("div",{className:t?"space-y-3":"flex items-center space-x-4",children:[e.jsxs("div",{className:`${t?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:s("settings.subagents.searchPlaceholder"),value:a,onChange:r=>S(r.target.value),className:`pl-10 pr-4 ${t?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent ${t?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-2.5 px-4 flex items-center justify-center space-x-2":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${t?"text-sm":"whitespace-nowrap"}`,children:[e.jsx(K,{className:t?"w-4 h-4":"w-5 h-5"}),e.jsx("span",{children:s("settings.subagents.createButton")})]})]})]}),b.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:`${t?"text-4xl":"text-6xl"} mb-4`,children:"🤖"}),e.jsx("h3",{className:`${t?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:s(a?"settings.subagents.noSubagentsSearch":"settings.subagents.noSubagents")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:s(a?"settings.subagents.adjustSearch":"settings.subagents.createFirst")}),!a&&e.jsx("button",{onClick:()=>{d(null),n(!0)},className:`${t?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:s("settings.subagents.createButton")})]}):e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"space-y-4",children:b.map((r,l)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${t?"text-lg":"text-xl"} mr-3`,children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:`${t?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.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:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[s("settings.subagents.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!0,emptyMessage:s("settings.subagents.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[s("settings.subagents.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(v,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(r.createdAt)})]})]})]}),e.jsx("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})]},r.id+"-"+l))}):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(D,{children:[e.jsx(B,{children:e.jsxs(f,{children:[e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.subagent")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.tools")}),e.jsx(o,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.createdAt")}),e.jsx(o,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("settings.subagents.table.actions")})]})}),e.jsx(R,{children:b.map((r,l)=>e.jsxs(f,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(m,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${r.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:r.source==="plugin"?s("settings.subagents.source.plugin"):s("settings.subagents.source.local")})]}),r.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs",children:r.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(k,{tools:r.tools||[],id:r.id,expandedTools:p,setExpandedTools:y,isMobile:!1,emptyMessage:s("settings.subagents.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(v,{className:"w-4 h-4"}),e.jsx("span",{children:N(r.createdAt)})]})}),e.jsx(m,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:r.source==="plugin"?e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.viewTitle"),children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>x(r),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:s("settings.subagents.actions.editTitle"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),s("settings.subagents.actions.edit")]}),e.jsx("button",{onClick:()=>c(r),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:s("settings.subagents.actions.deleteTitle"),children:e.jsx(h,{className:"w-4 h-4"})})]})})})]},r.id+"-"+l))})]})})}),C&&e.jsx(q,{subagent:T,onClose:A,onSuccess:P}),g&&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 ${t?"w-full max-w-sm":"max-w-md w-full"}`,children:[e.jsx("div",{className:`${t?"px-4 py-3":"px-6 py-4"} border-b border-gray-200 dark:border-gray-700`,children:e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white`,children:s("settings.subagents.deleteConfirm.title")})}),e.jsxs("div",{className:`${t?"px-4 py-3":"px-6 py-4"}`,children:[e.jsx("p",{className:`${t?"text-sm":""} text-gray-600 dark:text-gray-400`,children:s("settings.subagents.deleteConfirm.message",{name:g.name})}),e.jsx("p",{className:`text-gray-500 dark:text-gray-400 ${t?"mt-1 text-xs":"mt-2"}`,children:s("settings.subagents.deleteConfirm.warning")})]}),e.jsxs("div",{className:`${t?"grid grid-cols-2 gap-2 px-4 py-3":"flex items-center justify-end space-x-3 px-6 py-4"} border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50`,children:[e.jsx("button",{onClick:()=>c(null),className:`${t?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors`,children:s("settings.subagents.deleteConfirm.cancel")}),e.jsxs("button",{onClick:()=>M(g),disabled:u.isPending,className:`${t?"flex items-center justify-center space-x-1 px-3 py-2.5 text-sm":"flex items-center space-x-2 px-4 py-2"} bg-red-600 hover:bg-red-700 disabled:bg-red-400 text-white rounded-lg transition-colors`,children:[u.isPending?e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}):e.jsx(h,{className:`${t?"h-3 w-3":"h-4 w-4"}`}),e.jsx("span",{children:s("settings.subagents.deleteConfirm.delete")})]})]})]})})]})};export{re as SubagentsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{f as h,g as y}from"./index-B5hSSnK3.js";import{u as b}from"./tools-BZTR2NP1.js";import{U as p,V as j,K as u,M as r,Y as l,_ as f,$ as k,a0 as N,d as v}from"./ui-components-DjgDPiqV.js";import"./monaco-editor-BWfQfpij.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";const R=()=>{const{t:s}=b("pages"),{currentVersion:d,latestVersion:a,hasUpdate:n,forceCheck:o,isChecking:i,dismissUpdate:m,showUpdateNotification:x}=h(),{systemInfo:t,refetch:c}=y(),g=()=>{o(),c()};return e.jsxs("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center",children:[e.jsx(p,{className:"w-6 h-6 mr-2"}),s("settings.systemInfo.title")]}),e.jsx("p",{className:"mt-1 text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.subtitle")})]}),e.jsxs("button",{onClick:g,disabled:i,className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(j,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),s("settings.systemInfo.checkUpdate")]})]}),x&&a&&e.jsx("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-900/30 dark:to-indigo-900/30 border border-blue-200 dark:border-blue-800 rounded-xl p-6",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-start space-x-4",children:[e.jsx("div",{className:"p-3 bg-blue-100 dark:bg-blue-800 rounded-full",children:e.jsx(u,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-blue-900 dark:text-blue-100",children:s("settings.systemInfo.updateAvailable")}),e.jsx("p",{className:"mt-1 text-blue-700 dark:text-blue-300",children:s("version.newVersionAvailable",{version:a})}),e.jsxs("div",{className:"mt-4 flex space-x-3",children:[e.jsxs("a",{href:"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(r,{className:"w-4 h-4 mr-2"}),s("settings.systemInfo.viewReleases")]}),e.jsx("button",{onClick:m,className:"inline-flex items-center px-4 py-2 text-blue-700 dark:text-blue-300 bg-blue-100 dark:bg-blue-800 hover:bg-blue-200 dark:hover:bg-blue-700 rounded-lg transition-colors",children:s("version.dismiss")})]})]})]})})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(l,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.versionInfo")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.appName")}),e.jsx("p",{className:"mt-1 text-lg font-semibold text-gray-900 dark:text-white",children:t?.app.name||"AgentStudio"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.currentVersion")}),e.jsxs("div",{className:"mt-1 flex items-center",children:[e.jsxs("span",{className:"text-lg font-mono text-gray-900 dark:text-white",children:["v",d||t?.app.version||"-"]}),!n&&e.jsxs("span",{className:"ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:[e.jsx(f,{className:"w-3 h-3 mr-1"}),s("settings.systemInfo.upToDate")]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.latestVersion")}),e.jsx("p",{className:"mt-1 text-lg font-mono text-gray-900 dark:text-white",children:a?`v${a}`:"-"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:["Node.js ",s("settings.systemInfo.version")]}),e.jsx("p",{className:"mt-1 font-mono text-gray-900 dark:text-white",children:t?.runtime.nodeVersion||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.platform")}),e.jsxs("p",{className:"mt-1 text-gray-900 dark:text-white capitalize",children:[t?.runtime.platform||"-"," (",t?.runtime.arch||"-",")"]})]})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(k,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.runtimeInfo")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Node.js"}),e.jsx("p",{className:"mt-1 font-mono text-gray-900 dark:text-white",children:t?.runtime.nodeVersion||"-"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.platform")}),e.jsx("p",{className:"mt-1 text-gray-900 dark:text-white capitalize",children:t?.runtime.platform||"-"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.architecture")}),e.jsx("p",{className:"mt-1 text-gray-900 dark:text-white",children:t?.runtime.arch||"-"})]})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[e.jsx(r,{className:"w-5 h-5 mr-2"}),s("settings.systemInfo.links")]})}),e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("a",{href:t?.links.github||"https://github.com/okguitar/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(N,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"GitHub"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewSource")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.releases||"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(l,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"Releases"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewReleases")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.changelog||"https://github.com/okguitar/agentstudio/blob/main/CHANGELOG.md",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(v,{className:"w-6 h-6 text-gray-700 dark:text-gray-300 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"Changelog"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewChangelog")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]}),e.jsxs("a",{href:t?.links.npm||"https://www.npmjs.com/package/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center p-4 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:[e.jsx(l,{className:"w-6 h-6 text-red-600 dark:text-red-400 mr-3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:"npm"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s("settings.systemInfo.viewNpm")})]}),e.jsx(r,{className:"w-4 h-4 text-gray-400 ml-auto"})]})]})})]})]})};export{R as SystemInfoPage};
|
package/public/assets/{TelemetrySettingsPage-Ck2btMol.js → TelemetrySettingsPage-BcZFVBXN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{W as i}from"./monaco-editor-BWfQfpij.js";import{i as d,
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{W as i}from"./monaco-editor-BWfQfpij.js";import{i as d,h as c}from"./index-B5hSSnK3.js";import{u as m}from"./tools-BZTR2NP1.js";import{a1 as o,a2 as a,a3 as x,j as g}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";const f=()=>{const{t:s}=m("pages"),[t,l]=i.useState(d()),n=()=>{const r=!t;c(r),l(r)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:s("settings.telemetry.title","Telemetry & Analytics")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.telemetry.description","Manage anonymous usage data collection")})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`p-3 rounded-xl ${t?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(o,{className:`w-6 h-6 ${t?"text-blue-600 dark:text-blue-400":"text-gray-500"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white",children:s("settings.telemetry.enableTelemetry","Enable Anonymous Telemetry")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s("settings.telemetry.enableDescription","Help improve AgentStudio by sharing anonymous usage data")})]})]}),e.jsx("button",{onClick:n,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.jsx("div",{className:`px-6 py-3 border-t ${t?"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800":"bg-gray-50 dark:bg-gray-700/50 border-gray-200 dark:border-gray-700"}`,children:e.jsx("div",{className:"flex items-center gap-2 text-sm",children:t?e.jsxs(e.Fragment,{children:[e.jsx(a,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-green-700 dark:text-green-400",children:s("settings.telemetry.statusEnabled","Telemetry is enabled. Thank you for helping improve AgentStudio!")})]}):e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"w-4 h-4 text-gray-500"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("settings.telemetry.statusDisabled","Telemetry is disabled. No data is being collected.")})]})})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(a,{className:"w-5 h-5 text-green-500"}),s("settings.telemetry.whatWeCollect","What We Collect")]}),e.jsxs("ul",{className:"space-y-3 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.installId","Anonymous Installation ID")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.installIdDesc","A random UUID to distinguish installations, not linked to your identity")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.version","App Version & OS")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.versionDesc","Helps us understand which versions and platforms are most used")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.features","Feature Usage")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.featuresDesc","Which features are used (without content or personal data)")})]})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-green-500 mt-0.5",children:"✓"}),e.jsxs("div",{children:[e.jsx("strong",{children:s("settings.telemetry.collect.errors","Error Reports")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-0.5",children:s("settings.telemetry.collect.errorsDesc","Sanitized error messages and stack traces (file paths removed)")})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h3",{className:"font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(g,{className:"w-5 h-5 text-red-500"}),s("settings.telemetry.whatWeNeverCollect","What We Never Collect")]}),e.jsxs("ul",{className:"space-y-3 text-sm text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.files","File contents, code, or project data")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.keys","API keys, passwords, or credentials")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.pii","Personal identifying information (name, email, IP)")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-red-500 mt-0.5",children:"✗"}),e.jsx("span",{children:s("settings.telemetry.neverCollect.conversations","Chat conversations or AI responses")})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-xl border border-blue-200 dark:border-blue-800 p-4",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsxs("strong",{children:[s("settings.telemetry.privacyNote","Privacy First"),":"]})," ",s("settings.telemetry.privacyNoteDesc","All telemetry data is anonymized and aggregated. We cannot identify individual users. You can disable telemetry at any time.")]})})]})};export{f as TelemetrySettingsPage,f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./data-structures-ChC1tqVg.js";import{s as e,a as o,
|
|
1
|
+
import{j as s}from"./data-structures-ChC1tqVg.js";import{s as e,a as o,d as r}from"./index-B5hSSnK3.js";import"./monaco-editor-BWfQfpij.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";import"./tools-BZTR2NP1.js";import"./ui-components-DjgDPiqV.js";const l=()=>s.jsxs("div",{className:"p-8 space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold mb-6",children:"Toast Test Page"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("button",{onClick:()=>e("Success!","This is a success message"),className:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700",children:"Show Success Toast"}),s.jsx("button",{onClick:()=>o("Error!","This is an error message"),className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 ml-4",children:"Show Error Toast"}),s.jsx("button",{onClick:()=>r("Info","This is an info message"),className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 ml-4",children:"Show Info Toast"})]})]});export{l as ToastTestPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{g as a}from"./UnifiedToolSelector-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{g as a}from"./UnifiedToolSelector-BP6fuyzG.js";import{D as d,H as m,k as p}from"./ui-components-DjgDPiqV.js";const u=({tools:t,id:s,expandedTools:o,setExpandedTools:i,isMobile:g=!1,emptyMessage:c="继承全局设置"})=>{const n=g?3:5,x=o[s]||!1;return!t||t.length===0?e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:c}):e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>i(r=>({...r,[s]:!r[s]})),className:"flex items-center space-x-2 text-sm text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors mb-2 group",children:[e.jsx(d,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[t.length," 个工具"]}),x?e.jsx(m,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"}):e.jsx(p,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"})]}),x&&e.jsx("div",{className:`flex flex-wrap gap-1.5 ${g?"max-h-40":"max-h-48"} overflow-y-auto pr-2`,children:t.map((r,l)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-1 rounded text-xs font-mono border border-green-200 dark:border-green-800 hover:bg-green-100 dark:hover:bg-green-900/50 transition-colors",title:a(r),children:a(r)},l))}),!x&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.slice(0,n).map((r,l)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-0.5 rounded text-xs font-mono",title:a(r),children:a(r)},l)),t.length>n&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:["+",t.length-n]})]})]})};export{u as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./data-structures-ChC1tqVg.js";import{r as g}from"./monaco-editor-BWfQfpij.js";import{a as Q,A as Z}from"./agents-3mB536QF.js";import{u as M}from"./tools-BAI9XHGS.js";import{X as R,ab as ee,al as te,Y as N,am as O,an as E,U as re,j as D,k as se,l as ae}from"./ui-components-DaGtjl0g.js";const I={Bash:"终端命令",BashOutput:"终端命令输出",KillBash:"杀死终端命令",Edit:"文件编辑",Read:"读取文件",Write:"写入文件",Glob:"文件搜索",Grep:"文本搜索",NotebookEdit:"笔记本编辑",WebFetch:"网页获取",WebSearch:"网络搜索",TodoWrite:"任务管理",Task:"任务执行",ExitPlanMode:"退出计划模式",Skill:"技能调用"},ne={Bash:"执行命令行操作",BashOutput:"获取终端命令输出",KillBash:"杀死终端命令",Edit:"编辑文件内容",Read:"读取文件内容",Write:"创建或覆盖文件",Glob:"使用通配符搜索文件",Grep:"在文件中搜索文本",NotebookEdit:"编辑Jupyter笔记本",WebFetch:"获取网页内容",WebSearch:"搜索网络信息",TodoWrite:"创建和管理待办事项",Task:"执行复杂任务",ExitPlanMode:"退出计划模式",Skill:"调用预定义的技能"};function U(d){return I[d]||d}function le(d){return ne[d]||""}function ie(){const d=new Set([...Object.keys(I)]);return Array.from(d).map(m=>({name:m,label:U(m),description:le(m)}))}const b=ie(),ge=({isOpen:d,onClose:m,selectedRegularTools:l,onRegularToolsChange:f,selectedMcpTools:i,onMcpToolsChange:h,mcpToolsEnabled:F,onMcpEnabledChange:G,presetTools:y=[],readonly:P=!1})=>{const{t:c}=M("components"),[u,K]=g.useState([]),[v,A]=g.useState(!1),[p,T]=g.useState(null),[C,Y]=g.useState(new Set),[S,W]=g.useState("regular");g.useEffect(()=>{d&&q()},[d]);const q=async()=>{A(!0),T(null);try{const e=await Q(`${Z}/mcp`);if(!e.ok)throw new Error("Failed to fetch MCP configurations");const r=await e.json();K(r.servers||[])}catch(e){console.error("Failed to fetch MCP servers:",e),T(e instanceof Error?e.message:"Unknown error")}finally{A(!1)}},L=e=>y.some(r=>r.name===e&&r.enabled),j=e=>{if(y.some(s=>s.name===e&&s.enabled))return!0;const r=e.split("__");if(r.length===3&&r[0]==="mcp"){const s=`${r[1]}.${r[2]}`;if(y.some(x=>x.name===s&&x.enabled))return!0;const a=`mcp__${r[1]}__${r[2]}`;if(y.some(x=>x.name===a&&x.enabled))return!0}return!1},z=e=>{L(e)&&l.includes(e)||(l.includes(e)?f(l.filter(r=>r!==e)):f([...l,e]))},H=e=>{j(e)&&i.includes(e)||(i.includes(e)?h(i.filter(r=>r!==e)):h([...i,e]))},J=e=>{const r=new Set(C);r.has(e)?r.delete(e):r.add(e),Y(r)},B=e=>{const r=u.find(s=>s.name===e);return!r||!r.tools?!1:r.tools.some(s=>{const a=`mcp__${e}__${s}`;return j(a)})},V=(e,r)=>{const s=u.find(n=>n.name===e);if(!s||!s.tools)return;const a=s.tools.map(n=>`mcp__${e}__${n}`),x=B(e);if(r)if(x){const n=a.filter(o=>!j(o));h(i.filter(o=>!n.includes(o)))}else h(i.filter(n=>!a.includes(n)));else{const n=[...i];a.forEach(o=>{n.includes(o)||n.push(o)}),h(n)}},X=e=>{const r=u.find(a=>a.name===e);return!r||!r.tools?!1:r.tools.map(a=>`mcp__${e}__${a}`).every(a=>i.includes(a))};return d?t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",onClick:m,children:t.jsxs("div",{className:"unified-tool-selector-popup w-96 max-h-[500px] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg flex flex-col",onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"p-4 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:c("unifiedToolSelector.title")}),t.jsx("button",{type:"button",onClick:m,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:t.jsx(R,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex space-x-1 mb-2 bg-gray-100 dark:bg-gray-700 rounded-lg p-1",children:[t.jsxs("button",{type:"button",onClick:()=>W("regular"),className:`flex-1 flex items-center justify-center space-x-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S==="regular"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[t.jsx(ee,{className:"w-4 h-4"}),t.jsx("span",{children:c("unifiedToolSelector.tabs.regular")}),l.length>0&&t.jsx("span",{className:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 text-xs rounded-full px-2 py-0.5 min-w-[20px] text-center",children:l.length})]}),t.jsxs("button",{type:"button",onClick:()=>W("mcp"),className:`flex-1 flex items-center justify-center space-x-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S==="mcp"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[t.jsx(te,{className:"w-4 h-4"}),t.jsx("span",{children:c("unifiedToolSelector.tabs.mcp")}),i.length>0&&t.jsx("span",{className:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 text-xs rounded-full px-2 py-0.5 min-w-[20px] text-center",children:i.filter(e=>e.startsWith("mcp__")&&e.split("__").length===3).length})]})]})]}),t.jsx("div",{className:"px-4 pb-4 overflow-y-auto flex-1",children:S==="regular"?t.jsx("div",{className:"space-y-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex items-center justify-end p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 font-medium",children:c("unifiedToolSelector.selectAll")}),t.jsx("button",{type:"button",onClick:()=>{l.length===b.length?f([]):f(b.map(e=>e.name))},className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${l.length===b.length||l.length>0?"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600 hover:border-blue-500"}`,children:l.length===b.length?t.jsx(N,{className:"w-3 h-3"}):l.length>0?t.jsx(O,{className:"w-3 h-3"}):null})]})}),b.map(e=>{const r=l.includes(e.name),s=L(e.name),a=P||s&&r;return t.jsx("div",{className:`flex items-center justify-between p-2 rounded ${a?"bg-gray-50 dark:bg-gray-700":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{type:"button",onClick:()=>z(e.name),disabled:a,className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${r?s?"bg-orange-500 border-orange-500 text-white cursor-not-allowed":"bg-blue-600 border-blue-600 text-white":a?"border-gray-200 dark:border-gray-600 cursor-not-allowed":"border-gray-300 dark:border-gray-600 hover:border-blue-500"}`,children:r&&(s?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}))}),t.jsxs("span",{className:`text-sm ${a?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`,children:[U(e.name)," (",e.name,")",s&&t.jsxs("span",{className:"ml-1 text-xs text-orange-600 dark:text-orange-400",children:["[",c("unifiedToolSelector.preset"),"]"]})]})]})},e.name)})]})}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-end p-2",children:t.jsxs("label",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:c("unifiedToolSelector.enableMcpTools")}),t.jsx("input",{type:"checkbox",checked:F,onChange:e=>G(e.target.checked),className:"w-4 h-4 text-green-600 border-gray-300 dark:border-gray-600 rounded focus:ring-green-500"})]})}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(re,{className:"w-4 h-4 text-gray-400 animate-spin mr-2"}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("unifiedToolSelector.loading")})]}),p&&t.jsxs("div",{className:"flex items-center justify-center py-4 text-red-600 dark:text-red-400",children:[t.jsx(D,{className:"w-4 h-4 mr-2"}),t.jsx("span",{className:"text-sm",children:p})]}),!v&&!p&&u.length===0&&t.jsx("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:t.jsx("span",{className:"text-sm",children:c("unifiedToolSelector.noMcpServers")})}),!v&&!p&&u.map(e=>{const r=C.has(e.name),s=e.status==="active",a=X(e.name),x=e.tools?.some(o=>i.includes(`mcp__${e.name}__${o}`)),n=B(e.name);return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between p-3",children:[t.jsxs("button",{type:"button",onClick:()=>J(e.name),className:"flex items-center space-x-2 flex-1 text-left hover:bg-gray-50 dark:hover:bg-gray-700 -m-1 p-1 rounded transition-colors",disabled:!s,children:[r?t.jsx(se,{className:"w-4 h-4 text-gray-400"}):t.jsx(ae,{className:"w-4 h-4 text-gray-400"}),t.jsx("div",{className:`w-2 h-2 rounded-full ${s?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:`font-medium ${s?"text-gray-900 dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:e.name}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("unifiedToolSelector.toolsCount",{count:e.tools?.length||0})})]}),s&&e.tools&&e.tools.length>0&&t.jsx("button",{type:"button",onClick:()=>V(e.name,a),className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${a?n?"bg-orange-500 border-orange-500 text-white":"bg-green-600 border-green-600 text-white":x?n?"bg-orange-400 border-orange-400 text-white":"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600 hover:border-green-500"}`,children:a?n?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}):x?t.jsx(O,{className:"w-3 h-3"}):null})]}),r&&s&&e.tools&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3 space-y-2",children:e.tools.map(o=>{const _=`mcp__${e.name}__${o}`,$=i.includes(_),k=j(_),w=P||k&&$;return t.jsx("div",{className:`flex items-center justify-between p-2 rounded ${w?"bg-gray-50 dark:bg-gray-700":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{type:"button",onClick:()=>H(_),disabled:w,className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${$?k?"bg-orange-500 border-orange-500 text-white cursor-not-allowed":"bg-green-600 border-green-600 text-white":w?"border-gray-200 dark:border-gray-600 cursor-not-allowed":"border-gray-300 dark:border-gray-600 hover:border-green-500"}`,children:$&&(k?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}))}),t.jsxs("span",{className:`text-sm ${w?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`,children:[o,k&&t.jsxs("span",{className:"ml-1 text-xs text-orange-600 dark:text-orange-400",children:["[",c("unifiedToolSelector.preset"),"]"]})]})]})},o)})}),!s&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:t.jsxs("div",{className:"flex items-center text-red-600 dark:text-red-400",children:[t.jsx(D,{className:"w-4 h-4 mr-2"}),t.jsx("span",{className:"text-sm",children:e.error||c("unifiedToolSelector.serverUnavailable")})]})})]},e.name)})]})})]})}):null};export{ge as U,U as g};
|
|
1
|
+
import{j as t}from"./data-structures-ChC1tqVg.js";import{r as g}from"./monaco-editor-BWfQfpij.js";import{a as Q,A as Z}from"./agents-KlPdWQ8K.js";import{u as M}from"./tools-BZTR2NP1.js";import{X as R,ac as ee,at as te,_ as N,au as O,av as E,V as re,j as D,k as se,l as ae}from"./ui-components-DjgDPiqV.js";const I={Bash:"终端命令",BashOutput:"终端命令输出",KillBash:"杀死终端命令",Edit:"文件编辑",Read:"读取文件",Write:"写入文件",Glob:"文件搜索",Grep:"文本搜索",NotebookEdit:"笔记本编辑",WebFetch:"网页获取",WebSearch:"网络搜索",TodoWrite:"任务管理",Task:"任务执行",ExitPlanMode:"退出计划模式",Skill:"技能调用"},ne={Bash:"执行命令行操作",BashOutput:"获取终端命令输出",KillBash:"杀死终端命令",Edit:"编辑文件内容",Read:"读取文件内容",Write:"创建或覆盖文件",Glob:"使用通配符搜索文件",Grep:"在文件中搜索文本",NotebookEdit:"编辑Jupyter笔记本",WebFetch:"获取网页内容",WebSearch:"搜索网络信息",TodoWrite:"创建和管理待办事项",Task:"执行复杂任务",ExitPlanMode:"退出计划模式",Skill:"调用预定义的技能"};function F(d){return I[d]||d}function ie(d){return ne[d]||""}function le(){const d=new Set([...Object.keys(I)]);return Array.from(d).map(m=>({name:m,label:F(m),description:ie(m)}))}const b=le(),ge=({isOpen:d,onClose:m,selectedRegularTools:i,onRegularToolsChange:f,selectedMcpTools:l,onMcpToolsChange:h,mcpToolsEnabled:G,onMcpEnabledChange:U,presetTools:y=[],readonly:P=!1})=>{const{t:c}=M("components"),[u,K]=g.useState([]),[v,A]=g.useState(!1),[p,T]=g.useState(null),[C,V]=g.useState(new Set),[S,W]=g.useState("regular");g.useEffect(()=>{d&&q()},[d]);const q=async()=>{A(!0),T(null);try{const e=await Q(`${Z}/mcp`);if(!e.ok)throw new Error("Failed to fetch MCP configurations");const r=await e.json();K(r.servers||[])}catch(e){console.error("Failed to fetch MCP servers:",e),T(e instanceof Error?e.message:"Unknown error")}finally{A(!1)}},L=e=>y.some(r=>r.name===e&&r.enabled),j=e=>{if(y.some(s=>s.name===e&&s.enabled))return!0;const r=e.split("__");if(r.length===3&&r[0]==="mcp"){const s=`${r[1]}.${r[2]}`;if(y.some(x=>x.name===s&&x.enabled))return!0;const a=`mcp__${r[1]}__${r[2]}`;if(y.some(x=>x.name===a&&x.enabled))return!0}return!1},z=e=>{L(e)&&i.includes(e)||(i.includes(e)?f(i.filter(r=>r!==e)):f([...i,e]))},H=e=>{j(e)&&l.includes(e)||(l.includes(e)?h(l.filter(r=>r!==e)):h([...l,e]))},J=e=>{const r=new Set(C);r.has(e)?r.delete(e):r.add(e),V(r)},B=e=>{const r=u.find(s=>s.name===e);return!r||!r.tools?!1:r.tools.some(s=>{const a=`mcp__${e}__${s}`;return j(a)})},X=(e,r)=>{const s=u.find(n=>n.name===e);if(!s||!s.tools)return;const a=s.tools.map(n=>`mcp__${e}__${n}`),x=B(e);if(r)if(x){const n=a.filter(o=>!j(o));h(l.filter(o=>!n.includes(o)))}else h(l.filter(n=>!a.includes(n)));else{const n=[...l];a.forEach(o=>{n.includes(o)||n.push(o)}),h(n)}},Y=e=>{const r=u.find(a=>a.name===e);return!r||!r.tools?!1:r.tools.map(a=>`mcp__${e}__${a}`).every(a=>l.includes(a))};return d?t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",onClick:m,children:t.jsxs("div",{className:"unified-tool-selector-popup w-96 max-h-[500px] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg flex flex-col",onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"p-4 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:c("unifiedToolSelector.title")}),t.jsx("button",{type:"button",onClick:m,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:t.jsx(R,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"flex space-x-1 mb-2 bg-gray-100 dark:bg-gray-700 rounded-lg p-1",children:[t.jsxs("button",{type:"button",onClick:()=>W("regular"),className:`flex-1 flex items-center justify-center space-x-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S==="regular"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[t.jsx(ee,{className:"w-4 h-4"}),t.jsx("span",{children:c("unifiedToolSelector.tabs.regular")}),i.length>0&&t.jsx("span",{className:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 text-xs rounded-full px-2 py-0.5 min-w-[20px] text-center",children:i.length})]}),t.jsxs("button",{type:"button",onClick:()=>W("mcp"),className:`flex-1 flex items-center justify-center space-x-2 px-3 py-2 rounded-md text-sm font-medium transition-colors ${S==="mcp"?"bg-white dark:bg-gray-800 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[t.jsx(te,{className:"w-4 h-4"}),t.jsx("span",{children:c("unifiedToolSelector.tabs.mcp")}),l.length>0&&t.jsx("span",{className:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 text-xs rounded-full px-2 py-0.5 min-w-[20px] text-center",children:l.filter(e=>e.startsWith("mcp__")&&e.split("__").length===3).length})]})]})]}),t.jsx("div",{className:"px-4 pb-4 overflow-y-auto flex-1",children:S==="regular"?t.jsx("div",{className:"space-y-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex items-center justify-end p-2 hover:bg-gray-50 dark:hover:bg-gray-700 rounded",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 font-medium",children:c("unifiedToolSelector.selectAll")}),t.jsx("button",{type:"button",onClick:()=>{i.length===b.length?f([]):f(b.map(e=>e.name))},className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${i.length===b.length||i.length>0?"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600 hover:border-blue-500"}`,children:i.length===b.length?t.jsx(N,{className:"w-3 h-3"}):i.length>0?t.jsx(O,{className:"w-3 h-3"}):null})]})}),b.map(e=>{const r=i.includes(e.name),s=L(e.name),a=P||s&&r;return t.jsx("div",{className:`flex items-center justify-between p-2 rounded ${a?"bg-gray-50 dark:bg-gray-700":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{type:"button",onClick:()=>z(e.name),disabled:a,className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${r?s?"bg-orange-500 border-orange-500 text-white cursor-not-allowed":"bg-blue-600 border-blue-600 text-white":a?"border-gray-200 dark:border-gray-600 cursor-not-allowed":"border-gray-300 dark:border-gray-600 hover:border-blue-500"}`,children:r&&(s?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}))}),t.jsxs("span",{className:`text-sm ${a?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`,children:[F(e.name)," (",e.name,")",s&&t.jsxs("span",{className:"ml-1 text-xs text-orange-600 dark:text-orange-400",children:["[",c("unifiedToolSelector.preset"),"]"]})]})]})},e.name)})]})}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-end p-2",children:t.jsxs("label",{className:"flex items-center space-x-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:c("unifiedToolSelector.enableMcpTools")}),t.jsx("input",{type:"checkbox",checked:G,onChange:e=>U(e.target.checked),className:"w-4 h-4 text-green-600 border-gray-300 dark:border-gray-600 rounded focus:ring-green-500"})]})}),v&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(re,{className:"w-4 h-4 text-gray-400 animate-spin mr-2"}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("unifiedToolSelector.loading")})]}),p&&t.jsxs("div",{className:"flex items-center justify-center py-4 text-red-600 dark:text-red-400",children:[t.jsx(D,{className:"w-4 h-4 mr-2"}),t.jsx("span",{className:"text-sm",children:p})]}),!v&&!p&&u.length===0&&t.jsx("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:t.jsx("span",{className:"text-sm",children:c("unifiedToolSelector.noMcpServers")})}),!v&&!p&&u.map(e=>{const r=C.has(e.name),s=e.status==="active",a=Y(e.name),x=e.tools?.some(o=>l.includes(`mcp__${e.name}__${o}`)),n=B(e.name);return t.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between p-3",children:[t.jsxs("button",{type:"button",onClick:()=>J(e.name),className:"flex items-center space-x-2 flex-1 text-left hover:bg-gray-50 dark:hover:bg-gray-700 -m-1 p-1 rounded transition-colors",disabled:!s,children:[r?t.jsx(se,{className:"w-4 h-4 text-gray-400"}):t.jsx(ae,{className:"w-4 h-4 text-gray-400"}),t.jsx("div",{className:`w-2 h-2 rounded-full ${s?"bg-green-500":"bg-red-500"}`}),t.jsx("span",{className:`font-medium ${s?"text-gray-900 dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:e.name}),t.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:c("unifiedToolSelector.toolsCount",{count:e.tools?.length||0})})]}),s&&e.tools&&e.tools.length>0&&t.jsx("button",{type:"button",onClick:()=>X(e.name,a),className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${a?n?"bg-orange-500 border-orange-500 text-white":"bg-green-600 border-green-600 text-white":x?n?"bg-orange-400 border-orange-400 text-white":"bg-blue-600 border-blue-600 text-white":"border-gray-300 dark:border-gray-600 hover:border-green-500"}`,children:a?n?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}):x?t.jsx(O,{className:"w-3 h-3"}):null})]}),r&&s&&e.tools&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3 space-y-2",children:e.tools.map(o=>{const _=`mcp__${e.name}__${o}`,$=l.includes(_),k=j(_),w=P||k&&$;return t.jsx("div",{className:`flex items-center justify-between p-2 rounded ${w?"bg-gray-50 dark:bg-gray-700":"hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{type:"button",onClick:()=>H(_),disabled:w,className:`w-4 h-4 border-2 rounded flex items-center justify-center transition-colors ${$?k?"bg-orange-500 border-orange-500 text-white cursor-not-allowed":"bg-green-600 border-green-600 text-white":w?"border-gray-200 dark:border-gray-600 cursor-not-allowed":"border-gray-300 dark:border-gray-600 hover:border-green-500"}`,children:$&&(k?t.jsx(E,{className:"w-3 h-3"}):t.jsx(N,{className:"w-3 h-3"}))}),t.jsxs("span",{className:`text-sm ${w?"text-gray-400 dark:text-gray-500":"text-gray-700 dark:text-gray-300"}`,children:[o,k&&t.jsxs("span",{className:"ml-1 text-xs text-orange-600 dark:text-orange-400",children:["[",c("unifiedToolSelector.preset"),"]"]})]})]})},o)})}),!s&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-3",children:t.jsxs("div",{className:"flex items-center text-red-600 dark:text-red-400",children:[t.jsx(D,{className:"w-4 h-4 mr-2"}),t.jsx("span",{className:"text-sm",children:e.error||c("unifiedToolSelector.serverUnavailable")})]})})]},e.name)})]})})]})}):null};export{ge as U,F as g};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{W as L,r as v}from"./monaco-editor-BWfQfpij.js";import{c as le,a as w,s as M}from"./index-B5hSSnK3.js";import{u as ne,a as oe,b as de,c as ce,d as pe,f as ue}from"./useClaudeVersions-DicHLV6A.js";import{F as xe}from"./FileBrowser-CeGsJnUL.js";import{u as C}from"./tools-BZTR2NP1.js";import{v as R,aO as F,E as U,I as me,J as ge,y as he,r as q,X as K,a9 as be,M as ye,f as fe,e as ke,a4 as ve}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";async function Ne(s){try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(s),!0;{const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();const u=document.execCommand("copy");return document.body.removeChild(t),u}}catch(t){return console.error("Failed to copy to clipboard:",t),!1}}const G=[{id:"glm",name:"GLM (智谱AI)",alias:"glm",description:"使用智谱AI的GLM模型服务,兼容Anthropic API",versionDescription:"智谱AI GLM模型 - Anthropic兼容版本",apiTokenUrl:"https://www.bigmodel.cn/claude-code?ic=IHK4TGHUDI",logoUrl:"https://chatglm.cn/img/icons/favicon-32x32.png",envVars:[{key:"ANTHROPIC_BASE_URL",value:"https://open.bigmodel.cn/api/anthropic",isRequired:!0,description:"智谱AI的Anthropic兼容端点"},{key:"ANTHROPIC_AUTH_TOKEN",value:"",isRequired:!0,placeholder:"YOUR_API_KEY",description:"您的智谱AI API密钥(必填)"}],models:[{id:"glm-4.7",name:"GLM-4.7",isVision:!1,description:"智谱AI GLM-4.7 最新版本"},{id:"glm-4.6",name:"GLM-4.6",isVision:!1,description:"智谱AI GLM-4.6 模型"},{id:"glm-4.5",name:"GLM-4.5",isVision:!1,description:"智谱AI GLM-4.5 模型"},{id:"glm-4.5v",name:"GLM-4.5V",isVision:!0,description:"智谱AI GLM-4.5V 视觉模型"},{id:"glm-4.5-flash",name:"GLM-4.5-Flash",isVision:!1,description:"智谱AI GLM-4.5-Flash 快速模型"},{id:"glm-4.5-air",name:"GLM-4.5-Air",isVision:!1,description:"智谱AI GLM-4.5-Air 轻量级模型"}]},{id:"deepseek",name:"DeepSeek",alias:"deepseek",description:"使用DeepSeek的高性能模型服务",versionDescription:"DeepSeek高性能模型 - Anthropic兼容版本",apiTokenUrl:"https://platform.deepseek.com/api_keys",logoUrl:"https://chat.deepseek.com/favicon.svg",envVars:[{key:"ANTHROPIC_BASE_URL",value:"https://api.deepseek.com/anthropic",isRequired:!0,description:"DeepSeek的Anthropic兼容端点"},{key:"ANTHROPIC_AUTH_TOKEN",value:"",isRequired:!0,placeholder:"YOUR_DEEPSEEK_API_KEY",description:"您的DeepSeek API密钥(必填)"},{key:"API_TIMEOUT_MS",value:"600000",isRequired:!1,description:"API请求超时时间(毫秒)"},{key:"ANTHROPIC_MODEL",value:"deepseek-chat",isRequired:!1,description:"使用的DeepSeek模型名称"},{key:"ANTHROPIC_SMALL_FAST_MODEL",value:"deepseek-chat",isRequired:!1,description:"快速轻量级模型名称"},{key:"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",value:"1",isRequired:!1,description:"禁用非必要流量(1=启用,0=禁用)"}],models:[{id:"deepseek-chat",name:"DeepSeek Chat",isVision:!1,description:"DeepSeek Chat 最新对话模型"},{id:"deepseek-reasoner",name:"DeepSeek Reasoner",isVision:!1,description:"DeepSeek Reasoner 推理模型"}]},{id:"kimi",name:"Kimi K2 (月之暗面)",alias:"kimi-k2",description:"使用Kimi K2模型服务,支持Anthropic API兼容",versionDescription:"Kimi K2模型 - Anthropic兼容版本",apiTokenUrl:"https://platform.moonshot.cn/console/api-keys",logoUrl:"https://statics.moonshot.cn/kimi-web-seo/favicon.ico",envVars:[{key:"ANTHROPIC_BASE_URL",value:"https://api.moonshot.cn/anthropic",isRequired:!0,description:"Kimi的Anthropic兼容端点"},{key:"ANTHROPIC_AUTH_TOKEN",value:"",isRequired:!0,placeholder:"sk-YOURKEY",description:"您的Kimi API密钥(必填,以sk-开头)"}],models:[{id:"kimi-k2-0905-preview",name:"Kimi K2 0905 Preview",isVision:!1,description:"Kimi K2 2024年9月5日预览版"},{id:"kimi-k2-0711-preview",name:"Kimi K2 0711 Preview",isVision:!1,description:"Kimi K2 2024年7月11日预览版"},{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo Preview",isVision:!1,description:"Kimi K2 Turbo 预览版"},{id:"kimi-latest",name:"Kimi Latest",isVision:!0,description:"Kimi 最新版本视觉模型"}]},{id:"minimax",name:"MiniMax",alias:"minimax",description:"使用MiniMax的高性能模型服务,支持Anthropic API兼容",versionDescription:"MiniMax模型 - Anthropic兼容版本",apiTokenUrl:"https://platform.minimaxi.com/user-center/basic-information/interface-key",logoUrl:"https://agent.minimaxi.com/assets/logo/favicon.png?v=4",envVars:[{key:"ANTHROPIC_BASE_URL",value:"https://api.minimaxi.com/anthropic",isRequired:!0,description:"MiniMax的Anthropic兼容端点"},{key:"ANTHROPIC_AUTH_TOKEN",value:"",isRequired:!0,placeholder:"<MINIMAX_API_KEY>",description:"您的MiniMax API密钥(必填)"},{key:"API_TIMEOUT_MS",value:"3000000",isRequired:!1,description:"API请求超时时间(毫秒)"},{key:"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",value:"1",isRequired:!1,description:"禁用非必要流量(1=启用,0=禁用)"},{key:"ANTHROPIC_MODEL",value:"MiniMax-M2",isRequired:!1,description:"使用的MiniMax模型名称"},{key:"ANTHROPIC_SMALL_FAST_MODEL",value:"MiniMax-M2",isRequired:!1,description:"快速轻量级模型名称"},{key:"ANTHROPIC_DEFAULT_SONNET_MODEL",value:"MiniMax-M2",isRequired:!1,description:"默认Sonnet模型名称"},{key:"ANTHROPIC_DEFAULT_OPUS_MODEL",value:"MiniMax-M2",isRequired:!1,description:"默认Opus模型名称"},{key:"ANTHROPIC_DEFAULT_HAIKU_MODEL",value:"MiniMax-M2",isRequired:!1,description:"默认Haiku模型名称"}],models:[{id:"MiniMax-M2",name:"MiniMax M2",isVision:!1,description:"MiniMax M2 最新模型"}]}],je=({onQuickCreateWithTemplate:s,onAddVersion:t})=>{const{t:u}=C("pages");return e.jsxs("div",{className:"flex items-center space-x-3",children:[G.map(a=>e.jsxs("button",{onClick:()=>s(a),className:`flex items-center space-x-2 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600
|
|
2
|
+
text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700
|
|
3
|
+
hover:border-purple-400 dark:hover:border-purple-500 transition-all duration-200 group`,title:u(`settings.supplier.templates.providers.${a.id}.description`),children:[a.logoUrl&&e.jsx("img",{src:a.logoUrl,alt:a.name,className:"w-5 h-5 flex-shrink-0",onError:g=>{g.currentTarget.style.display="none"}}),e.jsx("span",{className:"text-sm font-medium group-hover:text-purple-600 dark:group-hover:text-purple-400",children:u(`settings.supplier.templates.providers.${a.id}.name`)})]},a.id)),e.jsxs("button",{onClick:t,className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(R,{className:"w-4 h-4"}),e.jsx("span",{children:u("settings.supplier.addSupplier")})]})]})},Ae=({version:s,isDefault:t,onCopyCommand:u,onSetDefault:a,onEdit:g,onDelete:h})=>{const{t:l}=C("pages");return e.jsx("div",{className:`p-4 border rounded-lg ${t?"border-blue-200 bg-blue-50 dark:border-blue-700 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"flex items-center space-x-3",children:e.jsxs("h4",{className:"font-medium text-gray-900 dark:text-white flex items-center space-x-2",children:[e.jsx("span",{children:s.name}),e.jsxs("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:["(",s.alias,")"]}),s.isSystem&&e.jsx("span",{className:"px-2 py-1 text-xs bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 rounded",children:l("settings.supplier.systemLabel")}),t&&e.jsxs("span",{className:"px-2 py-1 text-xs bg-blue-200 dark:bg-blue-700 text-blue-700 dark:text-blue-200 rounded flex items-center space-x-1",children:[e.jsx(F,{className:"w-3 h-3"}),e.jsx("span",{children:l("settings.supplier.defaultLabel")})]})]})}),s.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:s.description}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:[e.jsxs("span",{className:"font-medium",children:[l("settings.supplier.pathLabel"),":"]})," ",s.executablePath]}),s.environmentVariables&&Object.keys(s.environmentVariables).length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[l("settings.supplier.envVarsLabel"),":"]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:Object.entries(s.environmentVariables).map(([i,n])=>e.jsxs("span",{className:"px-2 py-1 text-xs bg-gray-100 dark:bg-gray-600 text-gray-700 dark:text-gray-300 rounded",children:[i,"=",n]},i))})]}),s.models&&s.models.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[l("settings.supplier.modelsLabel"),":"]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.models.map(i=>e.jsxs("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded flex items-center space-x-1",children:[e.jsx("span",{children:i.name}),i.isVision&&e.jsx(U,{className:"w-3 h-3"})]},i.id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>u(s),className:"p-2 text-gray-500 dark:text-gray-400 hover:text-green-600 rounded-lg hover:bg-green-50 dark:hover:bg-green-900/20 transition-colors",title:l("settings.supplier.copyCommand"),children:e.jsx(me,{className:"w-4 h-4"})}),!t&&e.jsx("button",{onClick:()=>a(s),className:"p-2 text-gray-500 dark:text-gray-400 hover:text-yellow-600 rounded-lg hover:bg-yellow-50 dark:hover:bg-yellow-900/20 transition-colors",title:l("settings.supplier.setAsDefault"),children:e.jsx(F,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>g(s),className:"p-2 text-gray-500 dark:text-gray-400 hover:text-blue-600 rounded-lg hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors",title:l("settings.supplier.edit"),children:e.jsx(ge,{className:"w-4 h-4"})}),!s.isSystem&&e.jsx("button",{onClick:()=>h(s),className:"p-2 text-gray-500 dark:text-gray-400 hover:text-red-600 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",title:l("settings.supplier.delete"),children:e.jsx(he,{className:"w-4 h-4"})})]})]})})},we=({versions:s,defaultVersionId:t,isLoading:u,onCopyCommand:a,onSetDefault:g,onEdit:h,onDelete:l})=>{const{t:i}=C("pages");return u?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"})}):s.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-3 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("settings.supplier.noSuppliers")}),e.jsx("p",{className:"text-sm",children:i("settings.supplier.clickToAddFirst")})]}):e.jsx("div",{className:"space-y-3",children:s.map(n=>e.jsx(Ae,{version:n,isDefault:n.id===t,onCopyCommand:a,onSetDefault:g,onEdit:h,onDelete:l},n.id))})},Ce=({models:s,modelInput:t,onAddModel:u,onUpdateModel:a,onRemoveModel:g,onModelInputChange:h})=>{const{t:l}=C("pages");return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:l("settings.supplier.form.models")}),e.jsxs("div",{className:"space-y-3",children:[s.length>0&&e.jsx("div",{className:"space-y-2",children:s.map((i,n)=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 bg-blue-50 dark:bg-blue-900/20 rounded",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-2",children:[e.jsx("input",{type:"text",value:i.id,onChange:o=>{const y=s[n].id;a(y,{id:o.target.value})},className:"px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:l("settings.supplier.form.modelId")}),e.jsx("input",{type:"text",value:i.name,onChange:o=>{const y=s[n].id;a(y,{name:o.target.value})},className:"px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:l("settings.supplier.form.modelName")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("label",{className:"flex items-center space-x-1 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:i.isVision,onChange:o=>{const y=s[n].id;a(y,{isVision:o.target.checked})},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{children:l("settings.supplier.form.visionModel")})]}),i.isVision&&e.jsx(U,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})]})]}),e.jsx("button",{onClick:()=>{const o=s[n].id;g(o)},className:"p-1 text-red-500 hover:text-red-700 rounded flex-shrink-0",children:e.jsx(K,{className:"w-4 h-4"})})]},`model-${n}`))}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx("input",{type:"text",value:t.id,onChange:i=>h({...t,id:i.target.value}),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:l("settings.supplier.form.modelId")}),e.jsx("input",{type:"text",value:t.name,onChange:i=>h({...t,name:i.target.value}),className:"px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:l("settings.supplier.form.modelName")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("label",{className:"flex items-center space-x-1 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:t.isVision,onChange:i=>h({...t,isVision:i.target.checked}),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{children:l("settings.supplier.form.visionModel")})]}),e.jsxs("button",{onClick:u,disabled:!t.id||!t.name,className:"px-3 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-1",children:[e.jsx(R,{className:"w-4 h-4"}),e.jsx("span",{children:l("settings.supplier.form.addModel")})]})]})]})]})]})},Te=({environmentVariables:s,envVarInput:t,currentTemplateTokenUrl:u,onAddEnvironmentVariable:a,onUpdateEnvironmentVariable:g,onRemoveEnvironmentVariable:h,onEnvVarInputChange:l,onAuthTokenChange:i})=>{const{t:n}=C("pages"),[o,y]=L.useState(!1),[j,b]=L.useState(""),k=c=>/^[a-zA-Z0-9]{4}\*\*\*[a-zA-Z0-9]{4}$/.test(c)||c==="***";L.useEffect(()=>{const c=s.ANTHROPIC_AUTH_TOKEN||"";k(c)?b(""):b(c)},[s]);const S=c=>{b(c);const f=s.ANTHROPIC_AUTH_TOKEN||"",T=k(f)?c.length>0:c!==f;i&&i(T),g("ANTHROPIC_AUTH_TOKEN",c)},A=()=>{y(!o)};return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:n("settings.supplier.form.envVars")}),e.jsxs("div",{className:"space-y-3",children:[Object.keys(s).length>0&&e.jsx("div",{className:"space-y-2",children:Object.entries(s).map(([c,f])=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 bg-gray-50 dark:bg-gray-700 rounded",children:[e.jsxs("div",{className:"flex-1 flex items-center space-x-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 whitespace-nowrap",children:[c," ="]}),c==="ANTHROPIC_AUTH_TOKEN"?e.jsxs("div",{className:"flex-1 relative flex items-center",children:[e.jsx("input",{type:o?"text":"password",value:j,onChange:N=>S(N.target.value),placeholder:k(f)?"点击输入新的API密钥":n("settings.supplier.form.emptyValue"),className:"flex-1 px-2 py-1 pr-20 text-sm border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("div",{className:"absolute right-2 flex items-center space-x-1",children:[k(f)&&e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 bg-gray-200 dark:bg-gray-600 px-2 py-0.5 rounded",children:"已隐藏"}),e.jsx("button",{type:"button",onClick:A,className:"p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",title:o?"隐藏":"显示",children:o?e.jsx(be,{className:"w-3 h-3"}):e.jsx(U,{className:"w-3 h-3"})})]}),u&&(k(f)||!f)&&e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"ml-2 inline-flex items-center space-x-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 whitespace-nowrap",children:[e.jsx(ye,{className:"w-3 h-3"}),e.jsx("span",{children:n("settings.supplier.form.getApiKey")})]})]}):e.jsx("input",{type:"text",value:f,onChange:N=>g(c,N.target.value),placeholder:n("settings.supplier.form.emptyValue"),className:"flex-1 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsx("button",{onClick:()=>h(c),className:"p-1 text-red-500 hover:text-red-700 rounded flex-shrink-0",children:e.jsx(K,{className:"w-4 h-4"})})]},c))}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"text",value:t.key,onChange:c=>l({...t,key:c.target.value}),className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:n("settings.supplier.form.varName")}),e.jsx("input",{type:"text",value:t.value,onChange:c=>l({...t,value:c.target.value}),className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:n("settings.supplier.form.varValue")}),e.jsx("button",{onClick:a,disabled:!t.key||!t.value,className:"px-3 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors",children:e.jsx(R,{className:"w-4 h-4"})})]})]})]})},Se=({editingVersion:s,isCreating:t,isFromTemplate:u,formData:a,envVarInput:g,modelInput:h,currentTemplateTokenUrl:l,isSaving:i,onApplyTemplate:n,onCancel:o,onSave:y,onSelectExecutablePath:j,onFormDataChange:b,onEnvVarInputChange:k,onModelInputChange:S,onAddEnvironmentVariable:A,onUpdateEnvironmentVariable:c,onRemoveEnvironmentVariable:f,onAddModel:N,onUpdateModel:T,onRemoveModel:V,onAuthTokenChange:_})=>{const{t:p}=C("pages");return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-2xl max-h-[90vh] mx-4 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:p(s?"settings.supplier.form.editTitle":"settings.supplier.form.createTitle")}),s?.isSystem&&e.jsx("span",{className:"px-2 py-1 text-xs bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 rounded",children:p("settings.supplier.systemLabel")})]}),e.jsx("button",{onClick:o,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(K,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:e.jsxs("div",{className:"space-y-4",children:[s?.isSystem&&e.jsxs("div",{className:"p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e.jsx("h4",{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:"系统版本编辑"})]}),e.jsx("p",{className:"text-xs text-blue-700 dark:text-blue-400 mt-2",children:"系统版本是自动检测的 Claude Code 版本,某些字段(如可执行路径)无法修改,但您可以配置支持的模型。"})]}),t&&!u&&e.jsxs("div",{className:"p-4 bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-3",children:[e.jsx(fe,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"}),e.jsx("h4",{className:"text-sm font-medium text-purple-800 dark:text-purple-300",children:p("settings.supplier.templates.title")})]}),e.jsx("p",{className:"text-xs text-purple-700 dark:text-purple-400 mb-3",children:p("settings.supplier.templates.description")}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:G.map(m=>e.jsx("button",{onClick:()=>n(m),className:`p-3 bg-white dark:bg-gray-800 border border-purple-200 dark:border-purple-700
|
|
4
|
+
hover:border-purple-400 dark:hover:border-purple-500 rounded-md text-left
|
|
5
|
+
transition-all duration-200 group`,children:e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[m.logoUrl&&e.jsx("img",{src:m.logoUrl,alt:m.name,className:"w-6 h-6 flex-shrink-0",onError:I=>{I.currentTarget.style.display="none"}}),e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white group-hover:text-purple-600 dark:group-hover:text-purple-400",children:p(`settings.supplier.templates.providers.${m.id}.name`)})]}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:p(`settings.supplier.templates.providers.${m.id}.description`)})]})},m.id))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[p("settings.supplier.form.supplierName")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:a.name||"",onChange:m=>b({...a,name:m.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:p("settings.supplier.form.supplierNamePlaceholder"),disabled:s?.isSystem})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[p("settings.supplier.form.alias")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:a.alias||"",onChange:m=>b({...a,alias:m.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:p("settings.supplier.form.aliasPlaceholder"),disabled:s?.isSystem})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:p("settings.supplier.form.description")}),e.jsx("textarea",{value:a.description||"",onChange:m=>b({...a,description:m.target.value}),rows:2,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:p("settings.supplier.form.descriptionPlaceholder"),disabled:s?.isSystem})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:p("settings.supplier.form.executablePath")}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"text",value:a.executablePath||"",onChange:m=>b({...a,executablePath:m.target.value}),className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:p("settings.supplier.form.executablePathPlaceholder"),disabled:s?.isSystem}),e.jsx("button",{onClick:j,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",title:p("settings.supplier.form.browseFile"),disabled:s?.isSystem,children:e.jsx(ke,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx(Ce,{models:a.models||[],modelInput:h,onAddModel:N,onUpdateModel:T,onRemoveModel:V,onModelInputChange:S}),e.jsx(Te,{environmentVariables:a.environmentVariables||{},envVarInput:g,currentTemplateTokenUrl:l,onAddEnvironmentVariable:A,onUpdateEnvironmentVariable:c,onRemoveEnvironmentVariable:f,onEnvVarInputChange:k,onAuthTokenChange:_})]})}),e.jsxs("div",{className:"flex justify-end space-x-3 p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("button",{onClick:o,className:"px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:p("settings.supplier.form.cancel")}),e.jsxs("button",{onClick:y,disabled:i,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:bg-blue-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-2",children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{children:p(i?"settings.supplier.form.saving":s?"settings.supplier.form.update":"settings.supplier.form.create")})]})]})]})})},Ue=()=>{const{t:s}=C("pages"),t=le(),[u,a]=v.useState(!1),[g,h]=v.useState(null),[l,i]=v.useState(!1),[n,o]=v.useState({name:"",alias:"",description:"",executablePath:"",environmentVariables:{},models:[]}),[y,j]=v.useState({key:"",value:""}),[b,k]=v.useState({id:"",name:"",isVision:!1}),[S,A]=v.useState(!1),[c,f]=v.useState(null),[N,T]=v.useState(!1),{data:V,isLoading:_}=ne(),p=oe(),m=de(),I=ce(),B=pe(),O=()=>{o({name:"",alias:"",description:"",executablePath:"",environmentVariables:{},models:[]}),j({key:"",value:""}),k({id:"",name:"",isVision:!1}),T(!1)},$=()=>{a(!0),h(null),i(!1),O()},Y=r=>{a(!0),h(null),i(!0),O(),setTimeout(()=>{D(r)},0)},D=r=>{const d={};r.envVars.forEach(P=>{d[P.key]=P.value});const x=s(`settings.supplier.templates.providers.${r.id}.name`),E=s(`settings.supplier.templates.providers.${r.id}.description`);o(P=>({...P,name:x,alias:r.alias,description:E,environmentVariables:d,models:r.models||[]})),f(r.apiTokenUrl||null)},W=r=>{h(r),a(!1),i(!1),o({name:r.name,alias:r.alias,description:r.description||"",executablePath:r.executablePath,environmentVariables:r.environmentVariables||{},models:r.models||[]})},H=()=>{a(!1),h(null),i(!1),O()},z=()=>{y.key&&y.value&&(o(r=>({...r,environmentVariables:{...r.environmentVariables,[y.key]:y.value}})),j({key:"",value:""}))},Q=()=>{b.id&&b.name&&(o(r=>({...r,models:[...r.models||[],{id:b.id,name:b.name,isVision:b.isVision,description:b.name}]})),k({id:"",name:"",isVision:!1}))},X=r=>{o(d=>({...d,models:(d.models||[]).filter(x=>x.id!==r)}))},Z=(r,d)=>{o(x=>({...x,models:(x.models||[]).map(E=>E.id===r?{...E,...d}:E)}))},J=r=>{o(d=>{if(!d.environmentVariables)return d;const x={...d.environmentVariables};return delete x[r],{...d,environmentVariables:x}})},ee=()=>{A(!0)},se=(r,d)=>{d||o(x=>({...x,executablePath:r})),A(!1)},re=async()=>{try{if(!n.name||!n.alias){w(s("settings.supplier.errors.requiredFields"));return}const r={...n,executablePath:n.executablePath?.trim()||void 0,description:n.description?.trim()||void 0};g?(await m.mutateAsync({id:g.id,data:{...r,authTokenChanged:N}}),M(s("settings.supplier.success.updateVersion"))):(await p.mutateAsync(r),M(s("settings.supplier.success.createVersion"))),H()}catch(r){console.error("Error saving version:",r),w(s("settings.supplier.errors.saveFailed"),r instanceof Error?r.message:void 0)}},te=async r=>{if(r.isSystem){w(s("settings.supplier.errors.cannotDeleteSystem"));return}if(await t({title:s("settings.supplier.deleteTitle","删除确认"),message:s("settings.supplier.confirmDelete",{alias:r.alias}),confirmText:s("common.delete","删除"),cancelText:s("common.cancel","取消"),variant:"danger"}))try{await I.mutateAsync(r.id),M(s("settings.supplier.success.deleteVersion"))}catch(x){console.error("Error deleting version:",x),w(s("settings.supplier.errors.deleteFailed"),x instanceof Error?x.message:void 0)}},ae=async r=>{try{await B.mutateAsync(r.id),M(s("settings.supplier.success.setDefault",{alias:r.alias}))}catch(d){console.error("Error setting default version:",d),w(s("settings.supplier.errors.setDefaultFailed"),d instanceof Error?d.message:void 0)}},ie=async r=>{try{const d=await ue(r.id);await Ne(d)?M(s("settings.supplier.success.copyCommand")):w(s("settings.supplier.errors.copyFailed"),d)}catch(d){console.error("Error copying command:",d),w(s("settings.supplier.errors.copyFailed"))}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:s("settings.supplier.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.supplier.subtitle")})]}),e.jsx("div",{className:"flex items-center space-x-3",children:e.jsx(je,{onQuickCreateWithTemplate:Y,onAddVersion:$})})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsx("div",{className:"space-y-6",children:e.jsx(we,{versions:V?.versions||[],defaultVersionId:V?.defaultVersionId||"",isLoading:_,onCopyCommand:ie,onSetDefault:ae,onEdit:W,onDelete:te})})}),(u||g)&&e.jsx(Se,{editingVersion:g,isCreating:u,isFromTemplate:l,formData:n,envVarInput:y,modelInput:b,currentTemplateTokenUrl:c,isSaving:p.isPending||m.isPending,onApplyTemplate:D,onCancel:H,onSave:re,onSelectExecutablePath:ee,onFormDataChange:o,onEnvVarInputChange:j,onModelInputChange:k,onAddEnvironmentVariable:z,onUpdateEnvironmentVariable:(r,d)=>{o(x=>({...x,environmentVariables:{...x.environmentVariables,[r]:d}}))},onRemoveEnvironmentVariable:J,onAddModel:Q,onUpdateModel:Z,onRemoveModel:X,onAuthTokenChange:T}),S&&e.jsx(xe,{title:s("settings.supplier.form.selectExecutable"),allowFiles:!0,allowDirectories:!1,onSelect:se,onClose:()=>A(!1)})]})};export{Ue as VersionSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as c}from"./monaco-editor-BWfQfpij.js";import{a as v,A as w}from"./agents-KlPdWQ8K.js";import{u as D}from"./tools-BZTR2NP1.js";import{V as h,j as T,ah as R,a4 as G,C as L,ai as p,a9 as m,E as b}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";const a={openai:{name:"OpenAI Whisper",description:"高质量语音识别,支持多语言",docsUrl:"https://platform.openai.com/docs/guides/speech-to-text"},groq:{name:"Groq Whisper",description:"超快速度,价格便宜,兼容 OpenAI API",docsUrl:"https://console.groq.com"},aliyun:{name:"阿里云语音识别",description:"国内访问快,中文识别准确",docsUrl:"https://help.aliyun.com/document_detail/84435.html"},tencent:{name:"腾讯云语音识别",description:"国内访问快,支持多种语言",docsUrl:"https://cloud.tencent.com/document/product/1093"},google:{name:"Google Cloud Speech-to-Text",description:"高质量语音识别,支持 125+ 语言和变体",docsUrl:"https://cloud.google.com/speech-to-text/docs"}},H=()=>{D(["pages","components"]);const[l,j]=c.useState(null),[U,C]=c.useState(!0),[S,K]=c.useState(!1),[I,o]=c.useState(null),[A,x]=c.useState(null),[n,$]=c.useState({}),[i,E]=c.useState(null),k=c.useCallback(async()=>{C(!0),o(null);try{const t=await v(`${w}/speech-to-text/settings`);if(t.ok){const r=await t.json();j(r)}else throw new Error("Failed to load settings")}catch(t){o(t instanceof Error?t.message:"加载设置失败")}finally{C(!1)}},[]),O=c.useCallback(async()=>{if(l){K(!0),o(null),x(null);try{const t=await v(`${w}/speech-to-text/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(t.ok){const r=await t.json();j(r.settings),x("设置已保存"),setTimeout(()=>x(null),3e3)}else{const r=await t.json();throw new Error(r.message||"保存失败")}}catch(t){o(t instanceof Error?t.message:"保存设置失败")}finally{K(!1)}}},[l]),y=c.useCallback(async t=>{E(t),o(null),x(null);try{const r=await v(`${w}/speech-to-text/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t})});if(r.ok)x(`${a[t].name} 配置验证成功`),setTimeout(()=>x(null),3e3);else{const d=await r.json();throw new Error(d.message||"测试失败")}}catch(r){o(r instanceof Error?r.message:"测试失败")}finally{E(null)}},[]);c.useEffect(()=>{k()},[k]);const s=(t,r)=>{if(!l)return;const d={...l},u=t.split(".");let N=d;for(let f=0;f<u.length-1;f++)N=N[u[f]];N[u[u.length-1]]=r,j(d)},g=t=>{$(r=>({...r,[t]:!r[t]}))},P=(t,r)=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:d=>s(`providers.${t}.enabled`,d.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用"})]}),r.enabled&&e.jsxs("button",{onClick:()=>y(t),disabled:i===t,className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded-lg transition-colors",children:[i===t?e.jsx(h,{className:"w-4 h-4 animate-spin"}):e.jsx(p,{className:"w-4 h-4"}),e.jsx("span",{children:"测试"})]})]}),r.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n[`${t}.apiKey`]?"text":"password",value:r.apiKey,onChange:d=>s(`providers.${t}.apiKey`,d.target.value),placeholder:"sk-...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g(`${t}.apiKey`),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n[`${t}.apiKey`]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Base URL"}),e.jsx("input",{type:"text",value:r.baseUrl,onChange:d=>s(`providers.${t}.baseUrl`,d.target.value),placeholder:t==="openai"?"https://api.openai.com/v1":"https://api.groq.com/openai/v1",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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Model"}),e.jsx("input",{type:"text",value:r.model,onChange:d=>s(`providers.${t}.model`,d.target.value),placeholder:t==="openai"?"whisper-1":"whisper-large-v3",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"})]})]})]}),q=t=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:r=>s("providers.aliyun.enabled",r.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用"})]}),t.enabled&&e.jsxs("button",{onClick:()=>y("aliyun"),disabled:i==="aliyun",className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded-lg transition-colors",children:[i==="aliyun"?e.jsx(h,{className:"w-4 h-4 animate-spin"}):e.jsx(p,{className:"w-4 h-4"}),e.jsx("span",{children:"测试"})]})]}),t.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"AccessKey ID"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n["aliyun.accessKeyId"]?"text":"password",value:t.accessKeyId,onChange:r=>s("providers.aliyun.accessKeyId",r.target.value),placeholder:"LTAI...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g("aliyun.accessKeyId"),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n["aliyun.accessKeyId"]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"AccessKey Secret"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n["aliyun.accessKeySecret"]?"text":"password",value:t.accessKeySecret,onChange:r=>s("providers.aliyun.accessKeySecret",r.target.value),placeholder:"...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g("aliyun.accessKeySecret"),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n["aliyun.accessKeySecret"]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"AppKey"}),e.jsx("input",{type:"text",value:t.appKey,onChange:r=>s("providers.aliyun.appKey",r.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"})]})]})]}),_=t=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:r=>s("providers.tencent.enabled",r.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用"})]}),t.enabled&&e.jsxs("button",{onClick:()=>y("tencent"),disabled:i==="tencent",className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded-lg transition-colors",children:[i==="tencent"?e.jsx(h,{className:"w-4 h-4 animate-spin"}):e.jsx(p,{className:"w-4 h-4"}),e.jsx("span",{children:"测试"})]})]}),t.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"SecretId"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n["tencent.secretId"]?"text":"password",value:t.secretId,onChange:r=>s("providers.tencent.secretId",r.target.value),placeholder:"AKID...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g("tencent.secretId"),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n["tencent.secretId"]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"SecretKey"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n["tencent.secretKey"]?"text":"password",value:t.secretKey,onChange:r=>s("providers.tencent.secretKey",r.target.value),placeholder:"...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g("tencent.secretKey"),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n["tencent.secretKey"]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"AppId (可选)"}),e.jsx("input",{type:"text",value:t.appId,onChange:r=>s("providers.tencent.appId",r.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"})]})]})]}),F=t=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:r=>s("providers.google.enabled",r.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启用"})]}),t.enabled&&e.jsxs("button",{onClick:()=>y("google"),disabled:i==="google",className:"flex items-center space-x-1 px-3 py-1 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 rounded-lg transition-colors",children:[i==="google"?e.jsx(h,{className:"w-4 h-4 animate-spin"}):e.jsx(p,{className:"w-4 h-4"}),e.jsx("span",{children:"测试"})]})]}),t.enabled&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:n["google.apiKey"]?"text":"password",value:t.apiKey,onChange:r=>s("providers.google.apiKey",r.target.value),placeholder:"AIza...",className:"w-full px-3 py-2 pr-10 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>g("google.apiKey"),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:n["google.apiKey"]?e.jsx(m,{className:"w-4 h-4"}):e.jsx(b,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"在 Google Cloud Console 创建 API Key,并启用 Speech-to-Text API"})]})})]});return U?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(h,{className:"w-6 h-6 animate-spin text-gray-400"})}):l?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(R,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"语音输入设置"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"配置语音转文字服务供应商"})]})]}),e.jsxs("button",{onClick:O,disabled:S,className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 transition-colors",children:[S?e.jsx(h,{className:"w-4 h-4 animate-spin"}):e.jsx(G,{className:"w-4 h-4"}),e.jsx("span",{children:"保存设置"})]})]}),I&&e.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-red-50 dark:bg-red-900/30 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx(T,{className:"w-5 h-5 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-red-800 dark:text-red-300",children:I})]}),A&&e.jsxs("div",{className:"flex items-center space-x-2 p-4 bg-green-50 dark:bg-green-900/30 border border-green-200 dark:border-green-800 rounded-lg",children:[e.jsx(L,{className:"w-5 h-5 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-green-800 dark:text-green-300",children:A})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"启用语音输入"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"在聊天输入框显示语音输入按钮"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:t=>s("enabled",t.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})}),l.enabled&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-white mb-4",children:"默认供应商"}),e.jsx("select",{value:l.defaultProvider,onChange:t=>s("defaultProvider",t.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",children:Object.entries(a).map(([t,r])=>e.jsx("option",{value:t,children:r.name},t))})]}),l.enabled&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"供应商配置"}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:a.openai.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.openai.description})]}),e.jsx("a",{href:a.openai.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"文档"})]}),P("openai",l.providers.openai)]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:a.groq.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.groq.description})]}),e.jsx("a",{href:a.groq.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"文档"})]}),P("groq",l.providers.groq)]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:a.aliyun.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.aliyun.description})]}),e.jsx("a",{href:a.aliyun.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"文档"})]}),q(l.providers.aliyun)]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:a.tencent.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.tencent.description})]}),e.jsx("a",{href:a.tencent.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"文档"})]}),_(l.providers.tencent)]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:a.google.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.google.description})]}),e.jsx("a",{href:a.google.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 dark:text-blue-400 hover:underline",children:"文档"})]}),F(l.providers.google)]})]})]}):e.jsxs("div",{className:"text-center py-12 text-red-500",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2"}),e.jsx("p",{children:"加载设置失败"}),e.jsx("button",{onClick:k,className:"mt-4 px-4 py-2 text-blue-600 hover:bg-blue-50 rounded-lg",children:"重试"})]})};export{H as VoiceSettingsPage,H as default};
|