agentstudio 0.4.2 → 0.4.3
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/config/engineConfig.d.ts +15 -0
- package/config/engineConfig.d.ts.map +1 -1
- package/config/engineConfig.js +30 -0
- package/config/engineConfig.js.map +1 -1
- package/config/index.d.ts.map +1 -1
- package/config/index.js +14 -0
- package/config/index.js.map +1 -1
- package/config/paths.d.ts +5 -0
- package/config/paths.d.ts.map +1 -1
- package/config/paths.js +6 -1
- package/config/paths.js.map +1 -1
- package/engines/claude/__tests__/supportedModels.test.d.ts +6 -4
- package/engines/claude/__tests__/supportedModels.test.d.ts.map +1 -1
- package/engines/claude/__tests__/supportedModels.test.js +55 -13
- package/engines/claude/__tests__/supportedModels.test.js.map +1 -1
- package/engines/claude/aguiAdapter.d.ts.map +1 -1
- package/engines/claude/aguiAdapter.js +8 -0
- package/engines/claude/aguiAdapter.js.map +1 -1
- package/engines/claude/claudeEngine.d.ts +36 -3
- package/engines/claude/claudeEngine.d.ts.map +1 -1
- package/engines/claude/claudeEngine.js +132 -13
- package/engines/claude/claudeEngine.js.map +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +29 -2
- package/index.js.map +1 -1
- package/middleware/callChain.d.ts +10 -0
- package/middleware/callChain.d.ts.map +1 -0
- package/middleware/callChain.js +24 -0
- package/middleware/callChain.js.map +1 -0
- package/middleware/requestId.d.ts +8 -0
- package/middleware/requestId.d.ts.map +1 -0
- package/middleware/requestId.js +18 -0
- package/middleware/requestId.js.map +1 -0
- package/package.json +1 -1
- package/prompts/gameDevSystemPrompt.d.ts +15 -0
- package/prompts/gameDevSystemPrompt.d.ts.map +1 -0
- package/prompts/gameDevSystemPrompt.js +37 -0
- package/prompts/gameDevSystemPrompt.js.map +1 -0
- package/prompts/vibeGamingPrompt.d.ts +13 -0
- package/prompts/vibeGamingPrompt.d.ts.map +1 -0
- package/prompts/vibeGamingPrompt.js +125 -0
- package/prompts/vibeGamingPrompt.js.map +1 -0
- package/public/assets/{AgentsPage-BsZdkqzM.js → AgentsPage-CHee5mUh.js} +1 -1
- package/public/assets/{Button-CMTSYiKV.js → Button-D5qiS7CR.js} +1 -1
- package/public/assets/ChatPage-B7-rn9mH.js +478 -0
- package/public/assets/{CommandForm-DwGvE9A_.js → CommandForm-CMfgHNm5.js} +1 -1
- package/public/assets/{CommandsPage-qDWzq8xp.js → CommandsPage-B4rjtVWk.js} +1 -1
- package/public/assets/{CursorConfigPage-DpUdJzRi.js → CursorConfigPage-DQ-3b3ti.js} +1 -1
- package/public/assets/{DashboardPage-BhqKOzob.js → DashboardPage-BowdW2Xj.js} +1 -1
- package/public/assets/{EngineGate-BjHJu955.js → EngineGate-DYNvEEbW.js} +1 -1
- package/public/assets/{FileBrowser-DboOOM_v.js → FileBrowser-DHyCacM6.js} +1 -1
- package/public/assets/{FileExplorer-x5R0Tcmk.js → FileExplorer-BprfeAH_.js} +1 -1
- package/public/assets/GeneralSettingsPage-C6hJ_zTw.js +1 -0
- package/public/assets/{HooksPage-DDGc0GGV.js → HooksPage-BwE2Zm3X.js} +1 -1
- package/public/assets/{LandingPage-CvY4n9Rh.js → LandingPage-DKvwbGX1.js} +1 -1
- package/public/assets/{LoginPage-C-PZfjYC.js → LoginPage-BpZhqRAN.js} +1 -1
- package/public/assets/{McpAdminSettingsPage-CIILVzB8.js → McpAdminSettingsPage-DuvsM5TX.js} +1 -1
- package/public/assets/{McpPage-B4nQUJag.js → McpPage-Hu8vyMhX.js} +1 -1
- package/public/assets/{MemorySettingsPage-eu6tsuUh.js → MemorySettingsPage-gIWSsrES.js} +1 -1
- package/public/assets/{ModelsPage-Bb5vSsuc.js → ModelsPage-Cosb3hHI.js} +1 -1
- package/public/assets/PluginsPage-CuNui9NV.js +12 -0
- package/public/assets/{ProjectSelector-CybrDbBY.js → ProjectSelector-CyBlHb2H.js} +1 -1
- package/public/assets/{ProjectsPage-DRl-0B4G.js → ProjectsPage-DYhCvH07.js} +1 -1
- package/public/assets/{RulesPage-DUt33RkX.js → RulesPage-C32P_Aqz.js} +1 -1
- package/public/assets/{ScheduledTasksPage-CTDYYRIN.js → ScheduledTasksPage-ixn5qoiD.js} +1 -1
- package/public/assets/SettingsLayout-C_7jR0Te.js +1 -0
- package/public/assets/{SkillsPage-Lzw8I9vR.js → SkillsPage-C-WS4N1Y.js} +1 -1
- package/public/assets/{SubagentForm-BzzeWg0W.js → SubagentForm-BbxljQUp.js} +1 -1
- package/public/assets/{SubagentsPage-bX2XWdJ0.js → SubagentsPage-D66TBaeN.js} +1 -1
- package/public/assets/{SystemInfoPage-nEIQbtwG.js → SystemInfoPage-DXVUncTe.js} +1 -1
- package/public/assets/{TelemetrySettingsPage-q167I4G9.js → TelemetrySettingsPage-Cp3vOu7X.js} +1 -1
- package/public/assets/{ToastTestPage-j224d3QR.js → ToastTestPage-03up9yZR.js} +1 -1
- package/public/assets/{ToolsList-CTsQr53G.js → ToolsList-BZFBEuvQ.js} +1 -1
- package/public/assets/UnifiedToolSelector-DJN7ASu1.js +1 -0
- package/public/assets/{VersionSettingsPage-BwpwiLyl.js → VersionSettingsPage-DppWaX--.js} +1 -1
- package/public/assets/{VoiceSettingsPage-d3l9AWBn.js → VoiceSettingsPage-BWJLeedX.js} +1 -1
- package/public/assets/{WebSocketTunnelPage-BqEUE7mr.js → WebSocketTunnelPage-BPeSTgEZ.js} +1 -1
- package/public/assets/{_basePickBy-DHabY031.js → _basePickBy-0UeYrifO.js} +1 -1
- package/public/assets/{_baseUniq-B1lmu3qr.js → _baseUniq-Q0NUbuSr.js} +1 -1
- package/public/assets/{agents-KlPdWQ8K.js → agents-DR9EZMs5.js} +1 -1
- package/public/assets/{arc-6sRLTBcr.js → arc-BV8erW1-.js} +1 -1
- package/public/assets/{architectureDiagram-VXUJARFQ-kwdTmjuB.js → architectureDiagram-VXUJARFQ-BIodTu6s.js} +1 -1
- package/public/assets/{blockDiagram-VD42YOAC-CYO9EYkJ.js → blockDiagram-VD42YOAC-4H3KjsGf.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-gAp3--Ee.js → c4Diagram-YG6GDRKO-J2ovCYEr.js} +1 -1
- package/public/assets/channel-gveiJv4S.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-DQVsL-J6.js → chunk-4BX2VUAB-D7Mc44O6.js} +1 -1
- package/public/assets/{chunk-55IACEB6-DVsfnY5X.js → chunk-55IACEB6-CMASo37Z.js} +1 -1
- package/public/assets/{chunk-B4BG7PRW-BNmOvuIn.js → chunk-B4BG7PRW-2T3W2IB6.js} +1 -1
- package/public/assets/{chunk-DI55MBZ5-BkucWe8Y.js → chunk-DI55MBZ5-FR9qswmO.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4-BsvfEdnB.js → chunk-FMBD7UC4-Bz2LO9q3.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-DSecsNtM.js → chunk-QN33PNHL-D7mfK9Pm.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-DhvrZSqy.js → chunk-QZHKN3VN-AkuNbqQU.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BqQ674GC.js → chunk-TZMSLE5B-DtY3rhWy.js} +1 -1
- package/public/assets/classDiagram-2ON5EDUG-f-lJUj27.js +1 -0
- package/public/assets/classDiagram-v2-WZHVMYZB-f-lJUj27.js +1 -0
- package/public/assets/clone-D5-Tsf9e.js +1 -0
- package/public/assets/{cose-bilkent-S5V4N54A-D9ZC6LmB.js → cose-bilkent-S5V4N54A-BuEw-qDX.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-s7YD2ZcY.js → dagre-6UL2VRFP-D-NrLBGh.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-C7jhP5tx.js → diagram-PSM6KHXK-BFjWOHNz.js} +1 -1
- package/public/assets/{diagram-QEK2KX5R-B348GmS1.js → diagram-QEK2KX5R-C0YlDb8t.js} +1 -1
- package/public/assets/{diagram-S2PKOQOG-Cu-zjwc9.js → diagram-S2PKOQOG-BLKbR12g.js} +1 -1
- package/public/assets/{erDiagram-Q2GNP2WA-tM4HKBpy.js → erDiagram-Q2GNP2WA-Cov6xnUk.js} +1 -1
- package/public/assets/{flowDiagram-NV44I4VS-DjCIshpi.js → flowDiagram-NV44I4VS-DTMKSJI1.js} +1 -1
- package/public/assets/{ganttDiagram-LVOFAZNH-Q6plkI5G.js → ganttDiagram-LVOFAZNH-DR0bcfHY.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-B3Uw90Yt.js → gitGraphDiagram-NY62KEGX-CvxYSabY.js} +1 -1
- package/public/assets/{graph-Bp0jlxBT.js → graph-BYXvelIL.js} +1 -1
- package/public/assets/{index-f67nhEoX.js → index-BIGPvi1D.js} +44 -44
- package/public/assets/infoDiagram-F6ZHWCRC-CL9g-UgS.js +2 -0
- package/public/assets/{journeyDiagram-XKPGCS4Q-CgQogtHU.js → journeyDiagram-XKPGCS4Q-Df8G0pW8.js} +1 -1
- package/public/assets/{kanban-definition-3W4ZIXB7-Cv7kVxyy.js → kanban-definition-3W4ZIXB7-DhoP7TG_.js} +1 -1
- package/public/assets/{layout-6bkH32V1.js → layout-CgO4Vp_y.js} +1 -1
- package/public/assets/{linear-DWoZ6Tbm.js → linear-CaY74pOB.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-D5wd9HsH.js → mindmap-definition-VGOIOE7T-CVK2y0WQ.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-8vPxErLm.js → pieDiagram-ADFJNKIX-BQt_waQk.js} +1 -1
- package/public/assets/{quadrantDiagram-AYHSOK5B-Pn0NZ9k7.js → quadrantDiagram-AYHSOK5B-DvLFoDeH.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-C7u8MiN1.js → requirementDiagram-UZGBJVZJ-C4lqjEUP.js} +1 -1
- package/public/assets/{sankeyDiagram-TZEHDZUN-C660O4mw.js → sankeyDiagram-TZEHDZUN-BKIDyl6M.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-pXBA2_3B.js → sequenceDiagram-WL72ISMW-BeyhJ61U.js} +1 -1
- package/public/assets/{stateDiagram-FKZM4ZOC-CxZMM1Lf.js → stateDiagram-FKZM4ZOC-CKyn6eKl.js} +1 -1
- package/public/assets/stateDiagram-v2-4FDKWEC3-DogBVcJE.js +1 -0
- package/public/assets/{table-Clz57edU.js → table-BgVewkB5.js} +1 -1
- package/public/assets/{timeline-definition-IT6M3QCI-Crg44TaP.js → timeline-definition-IT6M3QCI-Cm5SIAmT.js} +1 -1
- package/public/assets/tools-crrPnehB.js +1 -0
- package/public/assets/{treemap-KMMF4GRG-bFxwBWXw.js → treemap-KMMF4GRG-CUMeoVWM.js} +1 -1
- package/public/assets/{ui-components-DjgDPiqV.js → ui-components-D1pZO0y-.js} +1 -1
- package/public/assets/{useAgents-8KXN6U61.js → useAgents-M4lcWvy0.js} +1 -1
- package/public/assets/{useClaudeVersions-DicHLV6A.js → useClaudeVersions-CKT_fq1t.js} +1 -1
- package/public/assets/{useCommands-DbSH48ba.js → useCommands-vaoVPEDI.js} +1 -1
- package/public/assets/{useProjects-Bbh6hJMM.js → useProjects-D1ElB-WS.js} +1 -1
- package/public/assets/{useSessions-DOa4-xiB.js → useSessions-Dp1kUl43.js} +1 -1
- package/public/assets/{xychartDiagram-PRI3JC2R-DG3KmjD-.js → xychartDiagram-PRI3JC2R-Cy-SHDyX.js} +1 -1
- package/public/index.html +4 -4
- package/routes/a2a.d.ts.map +1 -1
- package/routes/a2a.js +27 -7
- package/routes/a2a.js.map +1 -1
- package/routes/agents.d.ts.map +1 -1
- package/routes/agents.js +234 -38
- package/routes/agents.js.map +1 -1
- package/routes/agui.d.ts.map +1 -1
- package/routes/agui.js +44 -1
- package/routes/agui.js.map +1 -1
- package/routes/gitVersions.d.ts.map +1 -1
- package/routes/gitVersions.js +80 -1
- package/routes/gitVersions.js.map +1 -1
- package/routes/marketplaceSkills.d.ts +18 -0
- package/routes/marketplaceSkills.d.ts.map +1 -0
- package/routes/marketplaceSkills.js +190 -0
- package/routes/marketplaceSkills.js.map +1 -0
- package/routes/plugins.d.ts.map +1 -1
- package/routes/plugins.js +48 -7
- package/routes/plugins.js.map +1 -1
- package/routes/projects.d.ts.map +1 -1
- package/routes/projects.js +34 -0
- package/routes/projects.js.map +1 -1
- package/schemas/a2a.d.ts +35 -4
- package/schemas/a2a.d.ts.map +1 -1
- package/schemas/a2a.js +9 -1
- package/schemas/a2a.js.map +1 -1
- package/services/__tests__/agentImporter.test.js +197 -0
- package/services/__tests__/agentImporter.test.js.map +1 -1
- package/services/__tests__/pluginInstaller.test.js +2 -1
- package/services/__tests__/pluginInstaller.test.js.map +1 -1
- package/services/agentImporter.d.ts +7 -0
- package/services/agentImporter.d.ts.map +1 -1
- package/services/agentImporter.js +57 -4
- package/services/agentImporter.js.map +1 -1
- package/services/builtinMarketplaceService.d.ts +56 -0
- package/services/builtinMarketplaceService.d.ts.map +1 -0
- package/services/builtinMarketplaceService.js +328 -0
- package/services/builtinMarketplaceService.js.map +1 -0
- package/services/claudeSession.d.ts.map +1 -1
- package/services/claudeSession.js +15 -4
- package/services/claudeSession.js.map +1 -1
- package/services/claudeVersionStorage.js +6 -6
- package/services/claudeVersionStorage.js.map +1 -1
- package/services/gitVersionService.d.ts +22 -0
- package/services/gitVersionService.d.ts.map +1 -1
- package/services/gitVersionService.js +117 -19
- package/services/gitVersionService.js.map +1 -1
- package/services/marketplaceSkillService.d.ts +129 -0
- package/services/marketplaceSkillService.d.ts.map +1 -0
- package/services/marketplaceSkillService.js +358 -0
- package/services/marketplaceSkillService.js.map +1 -0
- package/services/marketplaceUpdateService.d.ts.map +1 -1
- package/services/marketplaceUpdateService.js +29 -2
- package/services/marketplaceUpdateService.js.map +1 -1
- package/services/pluginCopyInstall.d.ts +60 -0
- package/services/pluginCopyInstall.d.ts.map +1 -0
- package/services/pluginCopyInstall.js +290 -0
- package/services/pluginCopyInstall.js.map +1 -0
- package/services/pluginInstallStrategy.d.ts +39 -0
- package/services/pluginInstallStrategy.d.ts.map +1 -0
- package/services/pluginInstallStrategy.js +50 -0
- package/services/pluginInstallStrategy.js.map +1 -0
- package/services/pluginInstaller.d.ts +10 -0
- package/services/pluginInstaller.d.ts.map +1 -1
- package/services/pluginInstaller.js +70 -20
- package/services/pluginInstaller.js.map +1 -1
- package/services/pluginParser.d.ts +17 -1
- package/services/pluginParser.d.ts.map +1 -1
- package/services/pluginParser.js +161 -84
- package/services/pluginParser.js.map +1 -1
- package/services/pluginPaths.d.ts +3 -3
- package/services/pluginPaths.d.ts.map +1 -1
- package/services/pluginPaths.js +33 -14
- package/services/pluginPaths.js.map +1 -1
- package/services/pluginScanner.js +2 -2
- package/services/pluginScanner.js.map +1 -1
- package/services/pluginSymlink.d.ts +10 -0
- package/services/pluginSymlink.d.ts.map +1 -1
- package/services/pluginSymlink.js +117 -1
- package/services/pluginSymlink.js.map +1 -1
- package/services/preSendGuard/__tests__/preSendGuard.test.d.ts +2 -0
- package/services/preSendGuard/__tests__/preSendGuard.test.d.ts.map +1 -0
- package/services/preSendGuard/__tests__/preSendGuard.test.js +102 -0
- package/services/preSendGuard/__tests__/preSendGuard.test.js.map +1 -0
- package/services/preSendGuard/configResolver.d.ts +8 -0
- package/services/preSendGuard/configResolver.d.ts.map +1 -0
- package/services/preSendGuard/configResolver.js +181 -0
- package/services/preSendGuard/configResolver.js.map +1 -0
- package/services/preSendGuard/index.d.ts +9 -0
- package/services/preSendGuard/index.d.ts.map +1 -0
- package/services/preSendGuard/index.js +165 -0
- package/services/preSendGuard/index.js.map +1 -0
- package/services/preSendGuard/providers/httpAuditProvider.d.ts +3 -0
- package/services/preSendGuard/providers/httpAuditProvider.d.ts.map +1 -0
- package/services/preSendGuard/providers/httpAuditProvider.js +98 -0
- package/services/preSendGuard/providers/httpAuditProvider.js.map +1 -0
- package/services/preSendGuard/providers/noopProvider.d.ts +3 -0
- package/services/preSendGuard/providers/noopProvider.d.ts.map +1 -0
- package/services/preSendGuard/providers/noopProvider.js +13 -0
- package/services/preSendGuard/providers/noopProvider.js.map +1 -0
- package/services/runFinishedHooks.d.ts +29 -0
- package/services/runFinishedHooks.d.ts.map +1 -0
- package/services/runFinishedHooks.js +57 -0
- package/services/runFinishedHooks.js.map +1 -0
- package/testing/index.d.ts +18 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +25 -0
- package/testing/index.js.map +1 -0
- package/testing/mockSdkQuery.d.ts +49 -0
- package/testing/mockSdkQuery.d.ts.map +1 -0
- package/testing/mockSdkQuery.js +209 -0
- package/testing/mockSdkQuery.js.map +1 -0
- package/testing/scenarioLoader.d.ts +71 -0
- package/testing/scenarioLoader.d.ts.map +1 -0
- package/testing/scenarioLoader.js +224 -0
- package/testing/scenarioLoader.js.map +1 -0
- package/types/a2a.d.ts +5 -0
- package/types/a2a.d.ts.map +1 -1
- package/types/agents.d.ts +32 -0
- package/types/agents.d.ts.map +1 -1
- package/types/agents.js +1 -0
- package/types/agents.js.map +1 -1
- package/types/engine.d.ts +6 -0
- package/types/engine.d.ts.map +1 -1
- package/types/plugins.d.ts +12 -2
- package/types/plugins.d.ts.map +1 -1
- package/types/preSendGuard.d.ts +51 -0
- package/types/preSendGuard.d.ts.map +1 -0
- package/types/preSendGuard.js +3 -0
- package/types/preSendGuard.js.map +1 -0
- package/utils/__tests__/claudeUtils.test.js +89 -1
- package/utils/__tests__/claudeUtils.test.js.map +1 -1
- package/utils/claudeUtils.d.ts +1 -1
- package/utils/claudeUtils.d.ts.map +1 -1
- package/utils/claudeUtils.js +92 -37
- package/utils/claudeUtils.js.map +1 -1
- package/public/assets/ChatPage-D8buVhfb.js +0 -478
- package/public/assets/GeneralSettingsPage-DYdwai51.js +0 -1
- package/public/assets/PluginsPage-DD92Xk6X.js +0 -12
- package/public/assets/SettingsLayout-LGC-0pQl.js +0 -1
- package/public/assets/UnifiedToolSelector-BP6fuyzG.js +0 -1
- package/public/assets/channel-D9wyZF1L.js +0 -1
- package/public/assets/classDiagram-2ON5EDUG-DwEqkkEb.js +0 -1
- package/public/assets/classDiagram-v2-WZHVMYZB-DwEqkkEb.js +0 -1
- package/public/assets/clone-3wFPaI2j.js +0 -1
- package/public/assets/infoDiagram-F6ZHWCRC-HUfwv_JT.js +0 -2
- package/public/assets/stateDiagram-v2-4FDKWEC3-CmurzrWf.js +0 -1
- package/public/assets/tools-BZTR2NP1.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as l}from"./monaco-editor-BWfQfpij.js";import{b as I,c as Z,d as J,e as K}from"./useCommands-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as l}from"./monaco-editor-BWfQfpij.js";import{b as I,c as Z,d as J,e as K}from"./useCommands-vaoVPEDI.js";import{U as Q}from"./UnifiedToolSelector-DJN7ASu1.js";import{u as U}from"./tools-crrPnehB.js";import{c as V,o as X,a4 as Y,j as ee}from"./ui-components-D1pZO0y-.js";const le=({command:o,projectId:x,onClose:_,onSuccess:z})=>{const{t:a}=U("components"),{t:C}=U("common"),[s,n]=l.useState({name:o?"":"optimize",description:o?"":a("commandForm.exampleDescription"),content:o?"":a("commandForm.exampleContent"),scope:x?"project":"user",namespace:o?"":"frontend",argumentHint:o?"":"[filename] [options]",allowedTools:[],model:""}),[c,T]=l.useState({}),[u,q]=l.useState(!1),[S,p]=l.useState(""),[H,f]=l.useState(!0),[M,$]=l.useState(!1),[m,E]=l.useState([]),[i,j]=l.useState([]),[R,P]=l.useState(!1),w=x?I(x):Z(),N=x?J(x):K(),h=!!o,k=r=>{const t=[];return r.description&&t.push(`description: ${r.description}`),r.argumentHint&&t.push(`argument-hint: ${r.argumentHint}`),r.namespace&&t.push(`namespace: ${r.namespace}`),r.allowedTools&&r.allowedTools.length>0&&t.push(`allowed-tools: ${r.allowedTools.join(", ")}`),r.model&&t.push(`model: ${r.model}`),t.length>0?`---
|
|
2
2
|
${t.join(`
|
|
3
3
|
`)}
|
|
4
4
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as n}from"./monaco-editor-BWfQfpij.js";import{T as R,a as O,b as k,c as x,d as q,e as m}from"./table-Clz57edU.js";import{u as z,a as J}from"./useCommands-DbSH48ba.js";import{C as G}from"./CommandForm-DwGvE9A_.js";import{f as w}from"./dateFormat-CXa8VnEC.js";import{b as I}from"./index-f67nhEoX.js";import{T as v}from"./ToolsList-CTsQr53G.js";import{u as K}from"./tools-BZTR2NP1.js";import{j as C,S as Q,v as U,E as $,o as T,m as S,J as F,y as A}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";import"./UnifiedToolSelector-BP6fuyzG.js";const ne=()=>{const{t}=K("pages"),{isMobile:a}=I(),[d]=n.useState({scope:"user"}),[i,M]=n.useState(""),[E,r]=n.useState(!1),[H,l]=n.useState(null),[h,o]=n.useState(null),[y,j]=n.useState({}),{data:p,isLoading:P,error:D,refetch:N}=z({...d,search:i.trim()||void 0}),B=p?.commands||[],g=p?.readOnly||!1,f=p?.engine||"claude-sdk",u=J(),L=async s=>{try{await u.mutateAsync(s.id),o(null)}catch(c){console.error("Failed to delete command:",c)}},b=B.filter(s=>!(d.scope&&d.scope!=="all"&&s.scope!==d.scope||d.namespace&&s.namespace!==d.namespace));return P?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 h-32 w-32 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("commands.loading")})]})}):D?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"h-16 w-16 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 text-lg mb-2",children:t("commands.error.loadFailed")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t("commands.error.cannotLoadCommands")}),e.jsx("button",{onClick:()=>N(),className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors",children:t("commands.error.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:`${a?"mb-4":"flex items-center justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:t("commands.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mt-1":"mt-2"}`,children:t("commands.subtitle")})]})}),e.jsxs("div",{className:`${a?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${a?"":"flex-1"} relative`,children:[e.jsx(Q,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("commands.searchPlaceholder"),value:i,onChange:s=>M(s.target.value),className:`pl-10 pr-4 ${a?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${a?"text-sm":""}`})]}),g?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($,{className:"w-4 h-4"}),e.jsxs("span",{children:["只读模式 (",f==="cursor-cli"?"Cursor":f,")"]})]}):e.jsxs("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-2.5 px-4":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${a?"text-sm":""}`,children:[e.jsx(U,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:t("commands.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:`${a?"text-4xl":"text-6xl"} mb-4`,children:"⚡"}),e.jsx("h3",{className:`${a?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(i?"commands.empty.noMatchingCommands":"commands.empty.noCommands")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t(i?"commands.empty.adjustSearch":"commands.empty.createFirst")}),!i&&!g&&e.jsx("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("commands.createButton")}),g&&e.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-400",children:"配置来自 ~/.cursor/commands(只读)"})]}):e.jsx(e.Fragment,{children:a?e.jsx("div",{className:"space-y-4",children:b.map((s,c)=>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:`${a?"text-lg":"text-xl"} mr-3`,children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:`${a?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:[s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`,s.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.model"),":"]}),s.model?e.jsxs("div",{className:"flex items-center text-gray-900 dark:text-white",children:[e.jsx(T,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-sm",children:s.model})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})]}),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:[t("commands.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(v,{tools:s.allowedTools||[],id:s.id,expandedTools:y,setExpandedTools:j,isMobile:!0,emptyMessage:t("commands.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(S,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:w(s.createdAt||s.updatedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(F,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx(A,{className:"w-4 h-4"})})]})]},s.id+"-"+c))}):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(R,{children:[e.jsx(O,{children:e.jsxs(k,{children:[e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.command")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.model")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.tools")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.createdAt")}),e.jsx(x,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.actions")})]})}),e.jsx(q,{children:b.map((s,c)=>e.jsxs(k,{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",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${s.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:s.source==="plugin"?t("commands.source.plugin"):t("commands.source.local")}),s.argumentHint&&e.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs mt-1",children:s.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:s.model?e.jsxs("div",{className:"text-sm text-gray-900 dark:text-white",children:[e.jsx(T,{className:"w-3 h-3 inline mr-1"}),s.model]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(v,{tools:s.allowedTools||[],id:s.id,expandedTools:y,setExpandedTools:j,isMobile:!1,emptyMessage:t("commands.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(S,{className:"w-4 h-4"}),e.jsx("span",{children:w(s.createdAt||s.updatedAt)})]})}),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:s.source==="plugin"||g?e.jsxs("button",{onClick:()=>{l(s),r(!0)},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:t("commands.actions.view"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("commands.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},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:t("commands.actions.editCommand"),children:[e.jsx(F,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx(A,{className:"w-4 h-4"})})]})})})]},s.id+"-"+c))})]})})}),E&&e.jsx(G,{command:H,onClose:()=>{r(!1),l(null)},onSuccess:()=>{r(!1),l(null),N()}}),h&&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 ${a?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(C,{className:`${a?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${a?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("commands.delete.title")})})]}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mb-4 text-sm":"mb-6"}`,children:t("commands.delete.confirmMessage",{name:h.name})}),e.jsxs("div",{className:`${a?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>o(null),className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("commands.delete.cancel")}),e.jsx("button",{onClick:()=>L(h),disabled:u.isPending,className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:u.isPending?t("commands.delete.deleting"):t("commands.delete.delete")})]})]})})]})};export{ne as CommandsPage};
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as n}from"./monaco-editor-BWfQfpij.js";import{T as R,a as O,b as k,c as x,d as q,e as m}from"./table-BgVewkB5.js";import{u as z,a as J}from"./useCommands-vaoVPEDI.js";import{C as G}from"./CommandForm-CMfgHNm5.js";import{f as w}from"./dateFormat-CXa8VnEC.js";import{b as I}from"./index-BIGPvi1D.js";import{T as v}from"./ToolsList-BZFBEuvQ.js";import{u as K}from"./tools-crrPnehB.js";import{j as C,S as Q,v as U,E as $,o as T,m as S,J as F,y as A}from"./ui-components-D1pZO0y-.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-DR9EZMs5.js";import"./UnifiedToolSelector-DJN7ASu1.js";const ne=()=>{const{t}=K("pages"),{isMobile:a}=I(),[d]=n.useState({scope:"user"}),[i,M]=n.useState(""),[E,r]=n.useState(!1),[H,l]=n.useState(null),[h,o]=n.useState(null),[y,j]=n.useState({}),{data:p,isLoading:P,error:D,refetch:N}=z({...d,search:i.trim()||void 0}),B=p?.commands||[],g=p?.readOnly||!1,f=p?.engine||"claude-sdk",u=J(),L=async s=>{try{await u.mutateAsync(s.id),o(null)}catch(c){console.error("Failed to delete command:",c)}},b=B.filter(s=>!(d.scope&&d.scope!=="all"&&s.scope!==d.scope||d.namespace&&s.namespace!==d.namespace));return P?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 h-32 w-32 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("commands.loading")})]})}):D?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"h-16 w-16 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 text-lg mb-2",children:t("commands.error.loadFailed")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t("commands.error.cannotLoadCommands")}),e.jsx("button",{onClick:()=>N(),className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors",children:t("commands.error.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:`${a?"mb-4":"flex items-center justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:t("commands.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mt-1":"mt-2"}`,children:t("commands.subtitle")})]})}),e.jsxs("div",{className:`${a?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${a?"":"flex-1"} relative`,children:[e.jsx(Q,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("commands.searchPlaceholder"),value:i,onChange:s=>M(s.target.value),className:`pl-10 pr-4 ${a?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${a?"text-sm":""}`})]}),g?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($,{className:"w-4 h-4"}),e.jsxs("span",{children:["只读模式 (",f==="cursor-cli"?"Cursor":f,")"]})]}):e.jsxs("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-2.5 px-4":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${a?"text-sm":""}`,children:[e.jsx(U,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:t("commands.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:`${a?"text-4xl":"text-6xl"} mb-4`,children:"⚡"}),e.jsx("h3",{className:`${a?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(i?"commands.empty.noMatchingCommands":"commands.empty.noCommands")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t(i?"commands.empty.adjustSearch":"commands.empty.createFirst")}),!i&&!g&&e.jsx("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("commands.createButton")}),g&&e.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-400",children:"配置来自 ~/.cursor/commands(只读)"})]}):e.jsx(e.Fragment,{children:a?e.jsx("div",{className:"space-y-4",children:b.map((s,c)=>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:`${a?"text-lg":"text-xl"} mr-3`,children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:`${a?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:[s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`,s.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.model"),":"]}),s.model?e.jsxs("div",{className:"flex items-center text-gray-900 dark:text-white",children:[e.jsx(T,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-sm",children:s.model})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})]}),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:[t("commands.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(v,{tools:s.allowedTools||[],id:s.id,expandedTools:y,setExpandedTools:j,isMobile:!0,emptyMessage:t("commands.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(S,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:w(s.createdAt||s.updatedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(F,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx(A,{className:"w-4 h-4"})})]})]},s.id+"-"+c))}):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(R,{children:[e.jsx(O,{children:e.jsxs(k,{children:[e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.command")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.model")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.tools")}),e.jsx(x,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.createdAt")}),e.jsx(x,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.actions")})]})}),e.jsx(q,{children:b.map((s,c)=>e.jsxs(k,{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",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${s.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:s.source==="plugin"?t("commands.source.plugin"):t("commands.source.local")}),s.argumentHint&&e.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs mt-1",children:s.description})]})]})}),e.jsx(m,{className:"px-6 py-4",children:s.model?e.jsxs("div",{className:"text-sm text-gray-900 dark:text-white",children:[e.jsx(T,{className:"w-3 h-3 inline mr-1"}),s.model]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})}),e.jsx(m,{className:"px-6 py-4",children:e.jsx(v,{tools:s.allowedTools||[],id:s.id,expandedTools:y,setExpandedTools:j,isMobile:!1,emptyMessage:t("commands.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(S,{className:"w-4 h-4"}),e.jsx("span",{children:w(s.createdAt||s.updatedAt)})]})}),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:s.source==="plugin"||g?e.jsxs("button",{onClick:()=>{l(s),r(!0)},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:t("commands.actions.view"),children:[e.jsx($,{className:"w-3 h-3 mr-1"}),t("commands.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},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:t("commands.actions.editCommand"),children:[e.jsx(F,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx(A,{className:"w-4 h-4"})})]})})})]},s.id+"-"+c))})]})})}),E&&e.jsx(G,{command:H,onClose:()=>{r(!1),l(null)},onSuccess:()=>{r(!1),l(null),N()}}),h&&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 ${a?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(C,{className:`${a?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${a?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("commands.delete.title")})})]}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mb-4 text-sm":"mb-6"}`,children:t("commands.delete.confirmMessage",{name:h.name})}),e.jsxs("div",{className:`${a?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>o(null),className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("commands.delete.cancel")}),e.jsx("button",{onClick:()=>L(h),disabled:u.isPending,className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:u.isPending?t("commands.delete.deleting"):t("commands.delete.delete")})]})]})})]})};export{ne as CommandsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{b as o,A as m}from"./agents-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{b as o,A as m}from"./agents-DR9EZMs5.js";import{e as p}from"./index-BIGPvi1D.js";import{N as g}from"./EngineGate-DYNvEEbW.js";import{V as x,j as h,$ as y,aj as b,ak as j,Z as u,Y as f,C as N,e as k,N as w}from"./ui-components-D1pZO0y-.js";import"./monaco-editor-BWfQfpij.js";import"./syntax-highlighting-DGbNjS3S.js";import"./tools-crrPnehB.js";async function v(){const s=await fetch(`${m}/engine/cursor-config`);if(!s.ok)throw new Error("Failed to fetch Cursor config");return s.json()}const L=()=>{const{paths:s,isCursorEngine:n}=p(),{data:t,isLoading:d,error:i,refetch:l}=o({queryKey:["cursor-config"],queryFn:v,enabled:n,staleTime:3e4});return n?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Cursor 配置概览"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:["读取自 ",s?.userConfigDir]})]}),e.jsxs("button",{onClick:()=>l(),disabled:d,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-700 disabled:opacity-50",children:[e.jsx(x,{className:`w-4 h-4 ${d?"animate-spin":""}`}),"刷新"]})]}),i&&e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:e.jsxs("div",{className:"flex items-center gap-2 text-red-700 dark:text-red-400",children:[e.jsx(h,{className:"w-5 h-5"}),e.jsxs("span",{children:["加载配置失败: ",i.message]})]})}),d&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(x,{className:"w-8 h-8 animate-spin text-gray-400"})}),t&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(a,{title:"MCP 服务器",icon:y,count:t.mcp.length,emptyText:"未配置 MCP 服务器",children:t.mcp.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r.name}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.url||r.command})]}),e.jsx("span",{className:"text-xs px-2 py-1 bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400 rounded",children:r.url?"HTTP":"stdio"})]},r.name))}),e.jsx(a,{title:"规则",icon:b,count:t.rules.length,emptyText:"未配置规则",children:t.rules.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r.name}),r.frontmatter.description&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.frontmatter.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.frontmatter.alwaysApply&&e.jsx("span",{className:"text-xs px-2 py-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 rounded",children:"始终应用"}),e.jsx("span",{className:"text-xs text-gray-400",children:r.scope})]})]},r.path))}),e.jsx(a,{title:"命令",icon:j,count:t.commands.length,emptyText:"未配置命令",children:t.commands.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("span",{className:"font-medium text-gray-900 dark:text-white",children:["/",r.name]}),e.jsx("span",{className:"text-xs text-gray-400",children:r.scope})]},r.path))}),e.jsx(a,{title:"技能",icon:u,count:t.skills.length,emptyText:"未配置技能",children:t.skills.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r.frontmatter.name||r.name}),r.frontmatter.description&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate max-w-[200px]",children:r.frontmatter.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.isBuiltin&&e.jsx("span",{className:"text-xs px-2 py-1 bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400 rounded",children:"内置"}),e.jsx("span",{className:"text-xs text-gray-400",children:r.scope})]})]},r.path))}),e.jsx(a,{title:"插件",icon:f,count:t.plugins?.user?.length||0,emptyText:"未安装插件",children:t.plugins?.user?.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r}),e.jsx(N,{className:"w-4 h-4 text-green-500"})]},r))}),e.jsx(a,{title:"市场源",icon:k,count:t.marketplaces?Object.keys(t.marketplaces).length:0,emptyText:"未配置市场源",children:t.marketplaces&&Object.entries(t.marketplaces).map(([r,c])=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gray-100 dark:border-gray-700 last:border-0",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:c.repo})]}),e.jsx("a",{href:`https://github.com/${c.repo}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 hover:text-blue-600",children:e.jsx(w,{className:"w-4 h-4"})})]},r))})]})]}):e.jsx("div",{className:"p-6",children:e.jsx(g,{feature:"Cursor 配置",description:"此页面仅在使用 Cursor CLI 引擎时可用。"})})};function a({title:s,icon:n,count:t,emptyText:d,children:i}){return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s})]}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t," 项"]})]}),e.jsx("div",{className:"px-4 py-2 max-h-64 overflow-y-auto",children:t===0?e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 py-4 text-center",children:d}):i})]})}export{L as CursorConfigPage,L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as d}from"./monaco-editor-BWfQfpij.js";import{u as B}from"./useProjects-Bbh6hJMM.js";import{u as O,a as Q}from"./useAgents-8KXN6U61.js";import{u as _,c as W,a as X}from"./useSessions-DOa4-xiB.js";import{u as G}from"./agents-KlPdWQ8K.js";import{u as J,s as x,a as S}from"./index-f67nhEoX.js";import{u as Y}from"./tools-BZTR2NP1.js";import{p as Z,F as ee,d as ae,o as se,q as re,f as te,e as le,r as de,s as oe,t as ne,u as h,L as b,v as ie,k as ce,w as ue,x as ge,y as me,j as xe,X as he}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";const Ve=()=>{const{t:s}=Y("pages"),A=J(),I=G(),{data:F,isLoading:$}=B(),{data:D}=O(!0),{data:M,refetch:p}=_(),T=Q(),[i,f]=d.useState(""),[t,u]=d.useState(null),[j,g]=d.useState(!1),[y,k]=d.useState(!1),[w,v]=d.useState(!1),[N,C]=d.useState(null),o=F?.projects||[],n=D?.agents||[],c=M?.sessions||[];d.useEffect(()=>{o.length>0&&!t&&u(o[0])},[o,t]);const m=a=>{if(!a)return n[0];if(a.defaultAgent){const r=n.find(l=>l.id===a.defaultAgent);if(r)return r}return n[0]},q=async()=>{const a=n.find(r=>r.id==="claude-code")||n[0];if(a){k(!0);try{const r="default-workspace",l=await T.mutateAsync({agentId:a.id,projectName:r});await I.invalidateQueries({queryKey:["projects"]}),u(l.project),x(s("dashboard.projectCreated.title",{defaultValue:"项目创建成功"}),s("dashboard.projectCreated.message",{defaultValue:"已经为您创建项目:{{name}},你现在可以开始与 Agent 工作了。",name:r}))}catch(r){console.error("Failed to create default project:",r)}finally{k(!1)}}},V=()=>{const a=m(t);if(!i.trim()||!t||!a)return;const r=encodeURIComponent(i),l=`/chat/${a.id}?project=${encodeURIComponent(t.path)}&message=${r}`;window.open(l,"_blank")},E=async a=>{C(a);try{await X(a),await p(),x(s("dashboard.sessions.closed",{defaultValue:"会话已关闭"}),s("dashboard.sessions.closedMessage",{defaultValue:"会话已成功关闭"}))}catch(r){console.error("Failed to close session:",r),S(s("dashboard.sessions.closeFailed",{defaultValue:"关闭失败"}),r instanceof Error?r.message:s("dashboard.sessions.closeError",{defaultValue:"无法关闭会话"}))}finally{C(null)}},L=async()=>{if(c.length!==0){v(!0);try{const a=await W();await p(),x(s("dashboard.sessions.allCleared",{defaultValue:"全部清除"}),s("dashboard.sessions.allClearedMessage",{defaultValue:"已清除 {{count}} 个会话",count:a.clearedCount}))}catch(a){console.error("Failed to clear all sessions:",a),S(s("dashboard.sessions.clearFailed",{defaultValue:"清除失败"}),a instanceof Error?a.message:s("dashboard.sessions.clearError",{defaultValue:"无法清除会话"}))}finally{v(!1)}}},R=[{icon:Z,label:s("dashboard.templates.organizeFiles",{defaultValue:"整理文件"}),prompt:"帮我整理一下当前目录下的文件。请先分析目录结构,然后提出整理方案让我确认,最后再执行。"},{icon:ee,label:s("dashboard.templates.analyzeFiles",{defaultValue:"文件分析"}),prompt:"帮我分析一下当前项目的文件结构和代码情况,给出概要报告。"},{icon:ae,label:s("dashboard.templates.writeDoc",{defaultValue:"写一份文档"}),prompt:"帮我为这个项目写一份 README 文档,包含项目介绍、安装步骤和使用说明。"},{icon:se,label:s("dashboard.templates.codeReview",{defaultValue:"代码审查"}),prompt:"帮我审查一下这个项目的代码质量,包括代码风格、潜在问题和改进建议。"},{icon:re,label:s("dashboard.templates.checkWeather",{defaultValue:"查深圳天气"}),prompt:"查一下深圳现在的天气情况。"},{icon:te,label:s("dashboard.templates.quickTask",{defaultValue:"自由提问"}),prompt:""}],z=[{icon:le,label:s("dashboard.quickLinks.projects",{defaultValue:"项目管理"}),path:"/projects",color:"text-blue-500 bg-blue-50 dark:bg-blue-900/30"},{icon:de,label:s("dashboard.quickLinks.modelSettings",{defaultValue:"模型供应商"}),path:"/settings/suppliers",color:"text-purple-500 bg-purple-50 dark:bg-purple-900/30"},{icon:oe,label:s("dashboard.quickLinks.scheduledTasks",{defaultValue:"定时任务"}),path:"/scheduled-tasks",color:"text-green-500 bg-green-50 dark:bg-green-900/30"},{icon:ne,label:s("dashboard.quickLinks.customAgents",{defaultValue:"自定义 Agent"}),path:"/agents",color:"text-orange-500 bg-orange-50 dark:bg-orange-900/30"}],U=a=>{if(a){const r=m(t);if(t&&r){const l=encodeURIComponent(a),P=`/chat/${r.id}?project=${encodeURIComponent(t.path)}&message=${l}`;window.open(P,"_blank")}else f(a)}},H=!$&&o.length===0,K=a=>{const r=Math.floor(a/1e3);if(r<60)return`${r}s`;const l=Math.floor(r/60);return l<60?`${l}m`:`${Math.floor(l/60)}h`};return e.jsx("div",{className:"h-full flex flex-col bg-gray-50 dark:bg-gray-900 overflow-auto",children:e.jsxs("div",{className:"flex-1 flex flex-col items-center px-6 py-8",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-900 dark:text-white",children:s("dashboard.welcome.title",{defaultValue:"让我们开始工作吧"})})}),e.jsxs("div",{className:"w-full max-w-2xl",children:[H&&e.jsxs("div",{className:"mb-6 p-6 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-2xl text-center",children:[e.jsx(h,{className:"w-12 h-12 text-amber-500 mx-auto mb-3"}),e.jsx("h3",{className:"text-lg font-medium text-amber-800 dark:text-amber-200 mb-2",children:s("dashboard.noProjectsHint.title",{defaultValue:"还没有项目"})}),e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-300 mb-4",children:s("dashboard.noProjectsHint.description",{defaultValue:"创建一个项目来开始与 AI 协作"})}),e.jsx("button",{onClick:q,disabled:y||n.length===0,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-amber-600 hover:bg-amber-700 disabled:bg-amber-400 text-white rounded-xl font-medium transition-colors",children:y?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:s("dashboard.noProjectsHint.creating",{defaultValue:"创建中..."})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsx("span",{children:s("dashboard.noProjectsHint.createButton",{defaultValue:"一键创建默认项目"})})]})})]}),e.jsx("div",{className:"mb-6 grid grid-cols-2 md:grid-cols-3 gap-3",children:R.map((a,r)=>e.jsxs("button",{onClick:()=>U(a.prompt),className:"flex items-center gap-3 px-4 py-3.5 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-600/50 hover:border-gray-300 dark:hover:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-700 hover:shadow-md text-left transition-all group",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-gray-100 dark:bg-gray-700 rounded-lg",children:e.jsx(a.icon,{className:"w-5 h-5 text-gray-500 dark:text-gray-300"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:a.label})]},r))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("textarea",{value:i,onChange:a=>f(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),V())},placeholder:s("dashboard.inputPlaceholder",{defaultValue:"描述你想要完成的任务..."}),className:"w-full px-5 py-4 text-base bg-transparent border-none outline-none resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500",rows:3}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>g(!j),className:"flex items-center gap-2 px-3 py-1.5 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500 transition-colors",children:[e.jsx(h,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 max-w-[150px] truncate",children:t?.name||s("dashboard.selectProject",{defaultValue:"选择项目"})}),e.jsx(ce,{className:"w-3.5 h-3.5 text-gray-400"})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>g(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-2 w-72 bg-white dark:bg-gray-800 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 z-20 max-h-64 overflow-y-auto",children:[o.map(a=>e.jsxs("button",{onClick:()=>{u(a),g(!1)},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700/50 flex items-center gap-3 first:rounded-t-xl last:rounded-b-xl ${t?.id===a.id?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[e.jsx(h,{className:`w-4 h-4 flex-shrink-0 ${t?.id===a.id?"text-blue-500":"text-gray-400"}`}),e.jsx("span",{className:`text-sm truncate ${t?.id===a.id?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"}`,children:a.name})]},a.id)),o.length===0&&e.jsx("div",{className:"px-4 py-6 text-center text-gray-500 text-sm",children:s("dashboard.noProjects",{defaultValue:"暂无项目"})})]})]})]}),e.jsxs("button",{onClick:V,disabled:!i.trim()||!t||!m(t),className:"flex items-center gap-2 px-5 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 dark:disabled:bg-gray-600 text-white rounded-xl font-medium transition-colors disabled:cursor-not-allowed",children:[e.jsx("span",{children:s("dashboard.startChat",{defaultValue:"开始对话"})}),e.jsx(ue,{className:"w-4 h-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-sm text-gray-400 dark:text-gray-500",children:[e.jsx(ge,{className:"w-4 h-4 animate-bounce"}),e.jsx("span",{children:s("dashboard.welcome.subtitle",{defaultValue:"选择一个项目,开始与 AI 协作完成任务"})})]})]}),e.jsxs("div",{className:"mt-10",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-4 text-center",children:s("dashboard.quickLinks.title",{defaultValue:"快捷入口"})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:z.map((a,r)=>e.jsxs("button",{onClick:()=>A(a.path),className:"flex flex-col items-center gap-2 p-4 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:shadow-md transition-all group",children:[e.jsx("div",{className:`p-2.5 rounded-lg ${a.color}`,children:e.jsx(a.icon,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:a.label})]},r))})]}),c.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:[s("dashboard.sessions.title",{defaultValue:"活跃会话"})," (",c.length,")"]}),e.jsxs("button",{onClick:L,disabled:w,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",children:[w?e.jsx(b,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:s("dashboard.sessions.clearAll",{defaultValue:"清除全部"})})]})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 divide-y divide-gray-100 dark:divide-gray-700 max-h-64 overflow-y-auto",children:c.map(a=>{const r=a.projectPath?a.projectPath.split("/").pop()||a.projectPath:"-",l=a.sessionTitle||`${s("dashboard.sessions.session",{defaultValue:"会话"})} ${a.sessionId.slice(0,8)}`;return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.status==="confirmed"?"bg-green-500":"bg-amber-500"}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate font-medium",children:l}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 mt-0.5",children:[e.jsx("span",{className:"truncate max-w-[120px]",title:r,children:r}),e.jsx("span",{children:"•"}),e.jsx("span",{children:a.agentId}),a.modelId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded",children:a.modelId.replace("claude-","").replace(/-\d{8}$/,"")})]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:K(a.idleTimeMs)}),a.heartbeatTimedOut&&e.jsx("span",{className:"text-amber-500 flex items-center gap-1",children:e.jsx(xe,{className:"w-3 h-3"})})]})]})]}),e.jsx("button",{onClick:()=>E(a.sessionId),disabled:N===a.sessionId,className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",title:s("dashboard.sessions.close",{defaultValue:"关闭会话"}),children:N===a.sessionId?e.jsx(b,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"})})]},a.sessionId)})})]})]})]})})};export{Ve as DashboardPage};
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as d}from"./monaco-editor-BWfQfpij.js";import{u as B}from"./useProjects-D1ElB-WS.js";import{u as O,a as Q}from"./useAgents-M4lcWvy0.js";import{u as _,c as W,a as X}from"./useSessions-Dp1kUl43.js";import{u as G}from"./agents-DR9EZMs5.js";import{u as J,s as x,a as S}from"./index-BIGPvi1D.js";import{u as Y}from"./tools-crrPnehB.js";import{p as Z,F as ee,d as ae,o as se,q as re,f as te,e as le,r as de,s as oe,t as ne,u as h,L as b,v as ie,k as ce,w as ue,x as ge,y as me,j as xe,X as he}from"./ui-components-D1pZO0y-.js";import"./syntax-highlighting-DGbNjS3S.js";const Ve=()=>{const{t:s}=Y("pages"),A=J(),I=G(),{data:F,isLoading:$}=B(),{data:D}=O(!0),{data:M,refetch:p}=_(),T=Q(),[i,f]=d.useState(""),[t,u]=d.useState(null),[j,g]=d.useState(!1),[y,k]=d.useState(!1),[w,v]=d.useState(!1),[N,C]=d.useState(null),o=F?.projects||[],n=D?.agents||[],c=M?.sessions||[];d.useEffect(()=>{o.length>0&&!t&&u(o[0])},[o,t]);const m=a=>{if(!a)return n[0];if(a.defaultAgent){const r=n.find(l=>l.id===a.defaultAgent);if(r)return r}return n[0]},q=async()=>{const a=n.find(r=>r.id==="claude-code")||n[0];if(a){k(!0);try{const r="default-workspace",l=await T.mutateAsync({agentId:a.id,projectName:r});await I.invalidateQueries({queryKey:["projects"]}),u(l.project),x(s("dashboard.projectCreated.title",{defaultValue:"项目创建成功"}),s("dashboard.projectCreated.message",{defaultValue:"已经为您创建项目:{{name}},你现在可以开始与 Agent 工作了。",name:r}))}catch(r){console.error("Failed to create default project:",r)}finally{k(!1)}}},V=()=>{const a=m(t);if(!i.trim()||!t||!a)return;const r=encodeURIComponent(i),l=`/chat/${a.id}?project=${encodeURIComponent(t.path)}&message=${r}`;window.open(l,"_blank")},E=async a=>{C(a);try{await X(a),await p(),x(s("dashboard.sessions.closed",{defaultValue:"会话已关闭"}),s("dashboard.sessions.closedMessage",{defaultValue:"会话已成功关闭"}))}catch(r){console.error("Failed to close session:",r),S(s("dashboard.sessions.closeFailed",{defaultValue:"关闭失败"}),r instanceof Error?r.message:s("dashboard.sessions.closeError",{defaultValue:"无法关闭会话"}))}finally{C(null)}},L=async()=>{if(c.length!==0){v(!0);try{const a=await W();await p(),x(s("dashboard.sessions.allCleared",{defaultValue:"全部清除"}),s("dashboard.sessions.allClearedMessage",{defaultValue:"已清除 {{count}} 个会话",count:a.clearedCount}))}catch(a){console.error("Failed to clear all sessions:",a),S(s("dashboard.sessions.clearFailed",{defaultValue:"清除失败"}),a instanceof Error?a.message:s("dashboard.sessions.clearError",{defaultValue:"无法清除会话"}))}finally{v(!1)}}},R=[{icon:Z,label:s("dashboard.templates.organizeFiles",{defaultValue:"整理文件"}),prompt:"帮我整理一下当前目录下的文件。请先分析目录结构,然后提出整理方案让我确认,最后再执行。"},{icon:ee,label:s("dashboard.templates.analyzeFiles",{defaultValue:"文件分析"}),prompt:"帮我分析一下当前项目的文件结构和代码情况,给出概要报告。"},{icon:ae,label:s("dashboard.templates.writeDoc",{defaultValue:"写一份文档"}),prompt:"帮我为这个项目写一份 README 文档,包含项目介绍、安装步骤和使用说明。"},{icon:se,label:s("dashboard.templates.codeReview",{defaultValue:"代码审查"}),prompt:"帮我审查一下这个项目的代码质量,包括代码风格、潜在问题和改进建议。"},{icon:re,label:s("dashboard.templates.checkWeather",{defaultValue:"查深圳天气"}),prompt:"查一下深圳现在的天气情况。"},{icon:te,label:s("dashboard.templates.quickTask",{defaultValue:"自由提问"}),prompt:""}],z=[{icon:le,label:s("dashboard.quickLinks.projects",{defaultValue:"项目管理"}),path:"/projects",color:"text-blue-500 bg-blue-50 dark:bg-blue-900/30"},{icon:de,label:s("dashboard.quickLinks.modelSettings",{defaultValue:"模型供应商"}),path:"/settings/suppliers",color:"text-purple-500 bg-purple-50 dark:bg-purple-900/30"},{icon:oe,label:s("dashboard.quickLinks.scheduledTasks",{defaultValue:"定时任务"}),path:"/scheduled-tasks",color:"text-green-500 bg-green-50 dark:bg-green-900/30"},{icon:ne,label:s("dashboard.quickLinks.customAgents",{defaultValue:"自定义 Agent"}),path:"/agents",color:"text-orange-500 bg-orange-50 dark:bg-orange-900/30"}],U=a=>{if(a){const r=m(t);if(t&&r){const l=encodeURIComponent(a),P=`/chat/${r.id}?project=${encodeURIComponent(t.path)}&message=${l}`;window.open(P,"_blank")}else f(a)}},H=!$&&o.length===0,K=a=>{const r=Math.floor(a/1e3);if(r<60)return`${r}s`;const l=Math.floor(r/60);return l<60?`${l}m`:`${Math.floor(l/60)}h`};return e.jsx("div",{className:"h-full flex flex-col bg-gray-50 dark:bg-gray-900 overflow-auto",children:e.jsxs("div",{className:"flex-1 flex flex-col items-center px-6 py-8",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-900 dark:text-white",children:s("dashboard.welcome.title",{defaultValue:"让我们开始工作吧"})})}),e.jsxs("div",{className:"w-full max-w-2xl",children:[H&&e.jsxs("div",{className:"mb-6 p-6 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-2xl text-center",children:[e.jsx(h,{className:"w-12 h-12 text-amber-500 mx-auto mb-3"}),e.jsx("h3",{className:"text-lg font-medium text-amber-800 dark:text-amber-200 mb-2",children:s("dashboard.noProjectsHint.title",{defaultValue:"还没有项目"})}),e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-300 mb-4",children:s("dashboard.noProjectsHint.description",{defaultValue:"创建一个项目来开始与 AI 协作"})}),e.jsx("button",{onClick:q,disabled:y||n.length===0,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-amber-600 hover:bg-amber-700 disabled:bg-amber-400 text-white rounded-xl font-medium transition-colors",children:y?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:s("dashboard.noProjectsHint.creating",{defaultValue:"创建中..."})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{className:"w-4 h-4"}),e.jsx("span",{children:s("dashboard.noProjectsHint.createButton",{defaultValue:"一键创建默认项目"})})]})})]}),e.jsx("div",{className:"mb-6 grid grid-cols-2 md:grid-cols-3 gap-3",children:R.map((a,r)=>e.jsxs("button",{onClick:()=>U(a.prompt),className:"flex items-center gap-3 px-4 py-3.5 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-600/50 hover:border-gray-300 dark:hover:border-gray-500 hover:bg-gray-50 dark:hover:bg-gray-700 hover:shadow-md text-left transition-all group",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-gray-100 dark:bg-gray-700 rounded-lg",children:e.jsx(a.icon,{className:"w-5 h-5 text-gray-500 dark:text-gray-300"})}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:a.label})]},r))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("textarea",{value:i,onChange:a=>f(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),V())},placeholder:s("dashboard.inputPlaceholder",{defaultValue:"描述你想要完成的任务..."}),className:"w-full px-5 py-4 text-base bg-transparent border-none outline-none resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500",rows:3}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>g(!j),className:"flex items-center gap-2 px-3 py-1.5 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500 transition-colors",children:[e.jsx(h,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 max-w-[150px] truncate",children:t?.name||s("dashboard.selectProject",{defaultValue:"选择项目"})}),e.jsx(ce,{className:"w-3.5 h-3.5 text-gray-400"})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>g(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-2 w-72 bg-white dark:bg-gray-800 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 z-20 max-h-64 overflow-y-auto",children:[o.map(a=>e.jsxs("button",{onClick:()=>{u(a),g(!1)},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700/50 flex items-center gap-3 first:rounded-t-xl last:rounded-b-xl ${t?.id===a.id?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[e.jsx(h,{className:`w-4 h-4 flex-shrink-0 ${t?.id===a.id?"text-blue-500":"text-gray-400"}`}),e.jsx("span",{className:`text-sm truncate ${t?.id===a.id?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"}`,children:a.name})]},a.id)),o.length===0&&e.jsx("div",{className:"px-4 py-6 text-center text-gray-500 text-sm",children:s("dashboard.noProjects",{defaultValue:"暂无项目"})})]})]})]}),e.jsxs("button",{onClick:V,disabled:!i.trim()||!t||!m(t),className:"flex items-center gap-2 px-5 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 dark:disabled:bg-gray-600 text-white rounded-xl font-medium transition-colors disabled:cursor-not-allowed",children:[e.jsx("span",{children:s("dashboard.startChat",{defaultValue:"开始对话"})}),e.jsx(ue,{className:"w-4 h-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 text-sm text-gray-400 dark:text-gray-500",children:[e.jsx(ge,{className:"w-4 h-4 animate-bounce"}),e.jsx("span",{children:s("dashboard.welcome.subtitle",{defaultValue:"选择一个项目,开始与 AI 协作完成任务"})})]})]}),e.jsxs("div",{className:"mt-10",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-4 text-center",children:s("dashboard.quickLinks.title",{defaultValue:"快捷入口"})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:z.map((a,r)=>e.jsxs("button",{onClick:()=>A(a.path),className:"flex flex-col items-center gap-2 p-4 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:shadow-md transition-all group",children:[e.jsx("div",{className:`p-2.5 rounded-lg ${a.color}`,children:e.jsx(a.icon,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:a.label})]},r))})]}),c.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:[s("dashboard.sessions.title",{defaultValue:"活跃会话"})," (",c.length,")"]}),e.jsxs("button",{onClick:L,disabled:w,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",children:[w?e.jsx(b,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:s("dashboard.sessions.clearAll",{defaultValue:"清除全部"})})]})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 divide-y divide-gray-100 dark:divide-gray-700 max-h-64 overflow-y-auto",children:c.map(a=>{const r=a.projectPath?a.projectPath.split("/").pop()||a.projectPath:"-",l=a.sessionTitle||`${s("dashboard.sessions.session",{defaultValue:"会话"})} ${a.sessionId.slice(0,8)}`;return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.status==="confirmed"?"bg-green-500":"bg-amber-500"}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate font-medium",children:l}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 mt-0.5",children:[e.jsx("span",{className:"truncate max-w-[120px]",title:r,children:r}),e.jsx("span",{children:"•"}),e.jsx("span",{children:a.agentId}),a.modelId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded",children:a.modelId.replace("claude-","").replace(/-\d{8}$/,"")})]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:K(a.idleTimeMs)}),a.heartbeatTimedOut&&e.jsx("span",{className:"text-amber-500 flex items-center gap-1",children:e.jsx(xe,{className:"w-3 h-3"})})]})]})]}),e.jsx("button",{onClick:()=>E(a.sessionId),disabled:N===a.sessionId,className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",title:s("dashboard.sessions.close",{defaultValue:"关闭会话"}),children:N===a.sessionId?e.jsx(b,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"})})]},a.sessionId)})})]})]})]})})};export{Ve as DashboardPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{e as a}from"./index-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{e as a}from"./index-BIGPvi1D.js";function i({feature:t,description:s}){const{engineName:r}=a();return e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"text-gray-400 mb-4",children:e.jsx("svg",{className:"w-16 h-16 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"})})}),e.jsxs("h3",{className:"text-lg font-medium text-gray-700 dark:text-gray-300 mb-2",children:[t," 不可用"]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 max-w-md",children:s||`当前引擎 (${r}) 不支持此功能。`})]})}export{i as N};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as o}from"./monaco-editor-BWfQfpij.js";import{a as K,A as W}from"./agents-
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as o}from"./monaco-editor-BWfQfpij.js";import{a as K,A as W}from"./agents-DR9EZMs5.js";import{a as de}from"./index-BIGPvi1D.js";import{u as ee}from"./tools-crrPnehB.js";import{X as A,ay as te,az as X,S as q,aA as Y,l as _,aB as ae,aC as Z,_ as ce,I as xe,H as ge,k as he,aD as ye,x as me,am as be,a9 as ue,E as pe,u as re,d as fe,aE as we}from"./ui-components-D1pZO0y-.js";const ve=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,V]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,T]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(50),[z,H]=o.useState(""),O=c=>{const n=c.split(`
|
|
2
2
|
`).filter(x=>x.trim()),g=[];for(const x of n){const u=[];let S="",D=!1;for(let L=0;L<x.length;L++){const R=x[L];R==='"'?D&&x[L+1]==='"'?(S+='"',L++):D=!D:R===","&&!D?(u.push(S.trim()),S=""):S+=R}u.push(S.trim()),g.push(u)}return g};o.useEffect(()=>{(async()=>{try{U(!0),s(null);const n=F.split(/[/\\]/).pop()||"unknown.csv";H(n);const g=await K(`${W}/files/read?path=${encodeURIComponent(F)}`);if(!g.ok)throw new Error(t("csvPreview.errors.loadFailed"));const x=await g.json(),u=O(x.content);V(u)}catch(n){console.error("Failed to load CSV:",n),s(n instanceof Error?n.message:t("csvPreview.errors.unknownError"))}finally{U(!1)}})()},[F,t]);const j=o.useMemo(()=>{if(!d)return p;const c=d.toLowerCase();return p.filter(n=>n.some(g=>g.toLowerCase().includes(c)))},[p,d]),y=Math.ceil(j.length/v),f=(i-1)*v,C=f+v,m=j.slice(f,C);o.useEffect(()=>{b(1)},[d]),o.useEffect(()=>{const c=n=>{n.key==="Escape"?h():n.key==="ArrowLeft"&&i>1?b(i-1):n.key==="ArrowRight"&&i<y?b(i+1):n.ctrlKey&&n.key==="f"&&(n.preventDefault(),document.getElementById("csv-search")?.focus())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[h,i,y]);const k=()=>{const c=p.map(x=>x.map(u=>u.includes(",")||u.includes('"')||u.includes(`
|
|
3
3
|
`)?`"${u.replace(/"/g,'""')}"`:u).join(",")).join(`
|
|
4
4
|
`),n=new Blob([c],{type:"text/csv;charset=utf-8;"}),g=document.createElement("a");g.href=URL.createObjectURL(n),g.download=z,g.click(),URL.revokeObjectURL(g.href)};if(N)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 p-6 flex items-center space-x-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("csvPreview.loading")})]})});if(M)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 p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("csvPreview.errors.title")}),e.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(A,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-red-600 dark:text-red-400",children:M}),e.jsx("button",{onClick:h,className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:t("csvPreview.actions.close")})]})});const I=P?"fixed inset-4 bg-white dark:bg-gray-900 flex flex-col z-50":"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50";return e.jsx("div",{className:I,children:P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.minimize"),children:e.jsx(te,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(X,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(A,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>T(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-800 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(Y,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(_,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.maximize"),children:e.jsx(ae,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(X,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(A,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-100 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(q,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>T(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(Y,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(_,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 text-center border-t border-gray-100 dark:border-gray-700",children:t("csvPreview.instructions")})]})})},je=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,V]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,T]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(20),[z,H]=o.useState(""),[O,j]=o.useState(new Set),[y,f]=o.useState(null),C=a=>{const l=a.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Se}from"./syntax-highlighting-DGbNjS3S.js";import{j as e,T as He}from"./data-structures-ChC1tqVg.js";import{r as n,W as Fe}from"./monaco-editor-BWfQfpij.js";import{b as ue,a as I,A}from"./agents-KlPdWQ8K.js";import{aJ as u,E as Me,a9 as Te,V as De,aK as Ae,L as R,aL as Re,X as ie,aM as Ie,k as Oe,l as Ve}from"./ui-components-DjgDPiqV.js";import{u as fe}from"./tools-BZTR2NP1.js";function $e(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L192 480l157.1-52.2L384 32H0zm313.1 80l-4.8 47.3L193 208.6l-.3.1h111.5l-12.8 146.6-98.2 28.7-98.8-29.2-6.4-73.9h48.9l3.2 38.3 52.6 13.3 54.7-15.4 3.7-61.6-166.3-.5v-.1l-.2.1-3.6-46.3L193.1 162l6.5-2.7H76.7L70.9 112h242.2z"},child:[]}]})(r)}function le(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"},child:[]}]})(r)}function Be(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"},child:[]}]})(r)}function _e(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM243.8 381.4c0 43.6-25.6 63.5-62.9 63.5-33.7 0-53.2-17.4-63.2-38.5l34.3-20.7c6.6 11.7 12.6 21.6 27.1 21.6 13.8 0 22.6-5.4 22.6-26.5V237.7h42.1v143.7zm99.6 63.5c-39.1 0-64.4-18.6-76.7-43l34.3-19.8c9 14.7 20.8 25.6 41.5 25.6 17.4 0 28.6-8.7 28.6-20.8 0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5 0-31.6 24.1-55.6 61.6-55.6 26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18-12.3 0-20.1 7.8-20.1 18 0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2 0 37.8-29.8 58.6-69.7 58.6z"},child:[]}]})(r)}function Pe(r){return u({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"},child:[]}]})(r)}function Ue(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(r)}function qe(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M418.2 177.2c-5.4-1.8-10.8-3.5-16.2-5.1.9-3.7 1.7-7.4 2.5-11.1 12.3-59.6 4.2-107.5-23.1-123.3-26.3-15.1-69.2.6-112.6 38.4-4.3 3.7-8.5 7.6-12.5 11.5-2.7-2.6-5.5-5.2-8.3-7.7-45.5-40.4-91.1-57.4-118.4-41.5-26.2 15.2-34 60.3-23 116.7 1.1 5.6 2.3 11.1 3.7 16.7-6.4 1.8-12.7 3.8-18.6 5.9C38.3 196.2 0 225.4 0 255.6c0 31.2 40.8 62.5 96.3 81.5 4.5 1.5 9 3 13.6 4.3-1.5 6-2.8 11.9-4 18-10.5 55.5-2.3 99.5 23.9 114.6 27 15.6 72.4-.4 116.6-39.1 3.5-3.1 7-6.3 10.5-9.7 4.4 4.3 9 8.4 13.6 12.4 42.8 36.8 85.1 51.7 111.2 36.6 27-15.6 35.8-62.9 24.4-120.5-.9-4.4-1.9-8.9-3-13.5 3.2-.9 6.3-1.9 9.4-2.9 57.7-19.1 99.5-50 99.5-81.7 0-30.3-39.4-59.7-93.8-78.4zM282.9 92.3c37.2-32.4 71.9-45.1 87.7-36 16.9 9.7 23.4 48.9 12.8 100.4-.7 3.4-1.4 6.7-2.3 10-22.2-5-44.7-8.6-67.3-10.6-13-18.6-27.2-36.4-42.6-53.1 3.9-3.7 7.7-7.2 11.7-10.7zM167.2 307.5c5.1 8.7 10.3 17.4 15.8 25.9-15.6-1.7-31.1-4.2-46.4-7.5 4.4-14.4 9.9-29.3 16.3-44.5 4.6 8.8 9.3 17.5 14.3 26.1zm-30.3-120.3c14.4-3.2 29.7-5.8 45.6-7.8-5.3 8.3-10.5 16.8-15.4 25.4-4.9 8.5-9.7 17.2-14.2 26-6.3-14.9-11.6-29.5-16-43.6zm27.4 68.9c6.6-13.8 13.8-27.3 21.4-40.6s15.8-26.2 24.4-38.9c15-1.1 30.3-1.7 45.9-1.7s31 .6 45.9 1.7c8.5 12.6 16.6 25.5 24.3 38.7s14.9 26.7 21.7 40.4c-6.7 13.8-13.9 27.4-21.6 40.8-7.6 13.3-15.7 26.2-24.2 39-14.9 1.1-30.4 1.6-46.1 1.6s-30.9-.5-45.6-1.4c-8.7-12.7-16.9-25.7-24.6-39s-14.8-26.8-21.5-40.6zm180.6 51.2c5.1-8.8 9.9-17.7 14.6-26.7 6.4 14.5 12 29.2 16.9 44.3-15.5 3.5-31.2 6.2-47 8 5.4-8.4 10.5-17 15.5-25.6zm14.4-76.5c-4.7-8.8-9.5-17.6-14.5-26.2-4.9-8.5-10-16.9-15.3-25.2 16.1 2 31.5 4.7 45.9 8-4.6 14.8-10 29.2-16.1 43.4zM256.2 118.3c10.5 11.4 20.4 23.4 29.6 35.8-19.8-.9-39.7-.9-59.5 0 9.8-12.9 19.9-24.9 29.9-35.8zM140.2 57c16.8-9.8 54.1 4.2 93.4 39 2.5 2.2 5 4.6 7.6 7-15.5 16.7-29.8 34.5-42.9 53.1-22.6 2-45 5.5-67.2 10.4-1.3-5.1-2.4-10.3-3.5-15.5-9.4-48.4-3.2-84.9 12.6-94zm-24.5 263.6c-4.2-1.2-8.3-2.5-12.4-3.9-21.3-6.7-45.5-17.3-63-31.2-10.1-7-16.9-17.8-18.8-29.9 0-18.3 31.6-41.7 77.2-57.6 5.7-2 11.5-3.8 17.3-5.5 6.8 21.7 15 43 24.5 63.6-9.6 20.9-17.9 42.5-24.8 64.5zm116.6 98c-16.5 15.1-35.6 27.1-56.4 35.3-11.1 5.3-23.9 5.8-35.3 1.3-15.9-9.2-22.5-44.5-13.5-92 1.1-5.6 2.3-11.2 3.7-16.7 22.4 4.8 45 8.1 67.9 9.8 13.2 18.7 27.7 36.6 43.2 53.4-3.2 3.1-6.4 6.1-9.6 8.9zm24.5-24.3c-10.2-11-20.4-23.2-30.3-36.3 9.6.4 19.5.6 29.5.6 10.3 0 20.4-.2 30.4-.7-9.2 12.7-19.1 24.8-29.6 36.4zm130.7 30c-.9 12.2-6.9 23.6-16.5 31.3-15.9 9.2-49.8-2.8-86.4-34.2-4.2-3.6-8.4-7.5-12.7-11.5 15.3-16.9 29.4-34.8 42.2-53.6 22.9-1.9 45.7-5.4 68.2-10.5 1 4.1 1.9 8.2 2.7 12.2 4.9 21.6 5.7 44.1 2.5 66.3zm18.2-107.5c-2.8.9-5.6 1.8-8.5 2.6-7-21.8-15.6-43.1-25.5-63.8 9.6-20.4 17.7-41.4 24.5-62.9 5.2 1.5 10.2 3.1 15 4.7 46.6 16 79.3 39.8 79.3 58 0 19.6-34.9 44.9-84.8 61.4zm-149.7-15c25.3 0 45.8-20.5 45.8-45.8s-20.5-45.8-45.8-45.8c-25.3 0-45.8 20.5-45.8 45.8s20.5 45.8 45.8 45.8z"},child:[]}]})(r)}function We(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(r)}function oe(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm57.1 120H305c7.7 0 13.4 7.1 11.7 14.7l-38 168c-1.2 5.5-6.1 9.3-11.7 9.3h-38c-5.5 0-10.3-3.8-11.6-9.1-25.8-103.5-20.8-81.2-25.6-110.5h-.5c-1.1 14.3-2.4 17.4-25.6 110.5-1.3 5.3-6.1 9.1-11.6 9.1H117c-5.6 0-10.5-3.9-11.7-9.4l-37.8-168c-1.7-7.5 4-14.6 11.7-14.6h24.5c5.7 0 10.7 4 11.8 9.7 15.6 78 20.1 109.5 21 122.2 1.6-10.2 7.3-32.7 29.4-122.7 1.3-5.4 6.1-9.1 11.7-9.1h29.1c5.6 0 10.4 3.8 11.7 9.2 24 100.4 28.8 124 29.6 129.4-.2-11.2-2.6-17.8 21.6-129.2 1-5.6 5.9-9.5 11.5-9.5zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function W(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function Je(r){return u({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(r)}function Ke(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"},child:[]}]})(r)}function w(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(r)}function Ge(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4.708 5.578L2.061 8.224l2.647 2.646-.708.708-3-3V7.87l3-3 .708.708zm7-.708L11 5.578l2.647 2.646L11 10.87l.708.708 3-3V7.87l-3-3zM4.908 13l.894.448 5-10L9.908 3l-5 10z"},child:[]}]})(r)}function de(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(r)}function he(r){return u({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"},child:[]}]})(r)}const Xe=r=>{const l=r.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"].includes(l)},Qe=(r,l)=>{const d=r?Xe(r.split("/").pop()||""):!1;return ue({queryKey:["file-content",r,l],queryFn:async()=>{if(!r)throw new Error("File path is required");const h=new URLSearchParams;h.append("path",r),l&&h.append("projectPath",l);const a=await I(`${A}/files/read?${h.toString()}`);if(!a.ok)throw a.status===403?new Error("访问被拒绝:文件在项目目录之外"):a.status===404?new Error("文件不存在"):new Error(`读取文件失败 (${a.status})`);return a.json()},enabled:!!r&&!d,staleTime:6e4,retry:!1})},Ye=(r,l)=>ue({queryKey:["file-tree-lazy",r,l],queryFn:async()=>{if(!r)throw new Error("Project path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("showHiddenFiles","true");const h=await I(`${A}/files/browse?${d.toString()}`);if(!h.ok)throw new Error("Failed to browse directory");const a=await h.json(),x=[];for(const f of a.items)f.isDirectory?x.push({...f,children:[]}):x.push(f);return x},enabled:!!r,staleTime:3e4});class Ze{events=new Map;on(l,d){this.events.has(l)||this.events.set(l,[]),this.events.get(l).push(d)}off(l,d){const h=this.events.get(l);if(h){const a=h.indexOf(d);a>-1&&h.splice(a,1)}}emit(l,...d){const h=this.events.get(l);h&&h.forEach(a=>{try{a(...d)}catch(x){console.error(`Error in event handler for ${l}:`,x)}})}clear(){this.events.clear()}}const xe=new Ze,me={AI_RESPONSE_COMPLETE:"ai_response_complete",REFRESH_AGENT_CONTENT:"refresh_agent_content"},et=n.lazy(()=>Se(()=>import("./monaco-editor-BWfQfpij.js").then(r=>r.i),[])),tt=new Map([["js",e.jsx(_e,{color:"#f7df1e"},"js")],["jsx",e.jsx(qe,{color:"#61dafb"},"jsx")],["ts",e.jsx(he,{color:"#3178c6"},"ts")],["tsx",e.jsx(he,{color:"#3178c6"},"tsx")],["css",e.jsx($e,{color:"#1572b6"},"css")],["html",e.jsx(le,{color:"#e34f26"},"html")],["htm",e.jsx(le,{color:"#e34f26"},"htm")],["json",e.jsx(de,{color:"#f9d71c"},"json")],["jsonl",e.jsx(de,{color:"#e6a23c"},"jsonl")],["md",e.jsx(Pe,{color:"#083fa1"},"md")],["csv",e.jsx(W,{color:"#00a86b"},"csv")],["pdf",e.jsx(We,{color:"#d63031"},"pdf")],["ppt",e.jsx(oe,{color:"#d63031"},"ppt")],["pptx",e.jsx(oe,{color:"#d63031"},"pptx")],["ico",e.jsx(w,{color:"#a9a9a9"},"ico")],["png",e.jsx(w,{color:"#a9a9a9"},"png")],["jpg",e.jsx(w,{color:"#a9a9a9"},"jpg")],["jpeg",e.jsx(w,{color:"#a9a9a9"},"jpeg")],["gif",e.jsx(w,{color:"#a9a9a9"},"gif")],["svg",e.jsx(w,{color:"#a9a9a9"},"svg")],["webp",e.jsx(w,{color:"#a9a9a9"},"webp")],["py",e.jsx(Ue,{color:"#3776ab"},"py")],["java",e.jsx(Be,{color:"#007396"},"java")]]),q=({node:r})=>{const l=r.data.isHidden;if(r.data.isDirectory){const x=l?"#9ca3af":"#87b3d6";return r.isOpen?e.jsx(Je,{color:x}):e.jsx(Ke,{color:x})}const d=r.data.name.split(".").pop()?.toLowerCase()||"",h=l?"#9ca3af":"#6d8a9f",a=l?{opacity:.6}:{};return e.jsx("span",{style:a,children:tt.get(d)||e.jsx(W,{color:h})})},rt=(r="")=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"dockerfile";switch(r.split(".").pop()?.toLowerCase()||""){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"css":case"scss":case"sass":case"less":return"css";case"json":case"jsonl":return"json";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"csv":return"csv";case"py":return"python";case"java":return"java";case"xml":return"xml";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"conf":case"config":case"ini":return"ini";case"nginx":return"nginx";case"sql":return"sql";case"go":return"go";case"rs":return"rust";case"c":case"cpp":case"cc":case"cxx":return"cpp";case"h":case"hpp":return"cpp";case"cs":return"csharp";case"php":return"php";case"rb":return"ruby";case"swift":return"swift";case"kt":return"kotlin";case"dockerfile":return"dockerfile";default:return"plaintext"}},st=({imageUrl:r,fileName:l})=>{const{t:d}=fe("components"),[h,a]=n.useState(!0),[x,f]=n.useState(!1),[g,E]=n.useState(null);return n.useEffect(()=>{let C=null;return(async()=>{try{a(!0),f(!1);const p=await I(r);if(!p.ok)throw new Error(`Failed to load image: ${p.status}`);const z=await p.blob(),j=URL.createObjectURL(z);C=j,E(j),a(!1)}catch(p){console.error("Failed to load image:",p),a(!1),f(!0)}})(),()=>{C&&URL.revokeObjectURL(C)}},[r]),e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:x?e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(w,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:d("fileExplorer.imageLoadFailed")}),e.jsx("p",{className:"text-sm mt-2",children:l})]}):e.jsxs("div",{className:"relative max-w-full max-h-full",children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(R,{className:"w-8 h-8 animate-spin text-gray-400"})}),g&&e.jsx("img",{src:g,alt:l,className:"max-w-full max-h-full object-contain bg-white dark:bg-gray-900 rounded shadow-lg",onLoad:()=>a(!1),onError:()=>{a(!1),f(!0)},style:{display:x?"none":"block"}})]})})},at=r=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"text";const d=r.split(".").pop()?.toLowerCase()||"",h=["js","jsx","ts","tsx","css","scss","sass","less","html","htm","json","jsonl","md","markdown","txt","py","java","xml","yaml","yml","sh","bash","bat","cmd","php","rb","go","rs","cpp","c","h","hpp","cc","cxx","cs","swift","kt","scala","clj","sql","dockerfile","gitignore","env","csv","tsv","conf","config","ini","toml","nginx","apache","properties","cfg"],a=["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"];return h.includes(d)?"text":a.includes(d)?"image":"binary"},ct=({node:r,style:l,dragHandle:d,isLoading:h=!1,onDirectoryToggle:a,onFileSelect:x})=>{const f=n.useCallback(g=>{g.preventDefault(),g.stopPropagation(),r.data.isDirectory?a?.(r):x?.(r)},[r,a,x]);return e.jsxs("div",{style:l,ref:d,className:`flex items-center cursor-pointer px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 ${r.isSelected?"bg-blue-100 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,onClick:f,children:[r.data.isDirectory&&e.jsx("span",{className:"mr-1 flex items-center",children:h?e.jsx(R,{className:"w-3 h-3 animate-spin text-gray-400"}):e.jsx(Ve,{className:`w-3 h-3 transition-transform text-gray-400 ${r.isOpen?"rotate-90":""}`})}),e.jsx("span",{className:"mr-2 flex items-center",children:e.jsx(q,{node:r})}),e.jsx("span",{className:`text-sm truncate flex-1 ${r.data.isHidden?"text-gray-400 dark:text-gray-500 italic":"text-gray-700 dark:text-gray-300"}`,children:r.data.name}),!r.data.isDirectory&&r.data.size&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:[(r.data.size/1024).toFixed(1),"KB"]})]})},D=5,ut=({projectPath:r,onFileSelect:l,className:d="",height:h="100vh"})=>{const{t:a}=fe("components"),[x,f]=n.useState([]),[g,E]=n.useState(null),[C,O]=n.useState(600),[p,z]=n.useState(!1),j=n.useRef(null),V=n.useRef(null),$=n.useRef(null),[J,ge]=n.useState(0),[K,pe]=n.useState(""),[ye,ve]=n.useState(document.documentElement.classList.contains("dark")),[F,M]=n.useState(new Set),[L,G]=n.useState([]),[B,T]=n.useState(new Set),[y,je]=n.useState(!1),[X,Q]=n.useState(!1),{data:S,isLoading:_,error:Y,refetch:H}=Ye(r,y),v=n.useMemo(()=>x.find(t=>t.isActive)||null,[x]),{data:Z,isLoading:be,error:ee}=Qe(v?v.path:void 0,r);n.useEffect(()=>{const t=new MutationObserver(s=>{s.forEach(o=>{o.attributeName==="class"&&ve(document.documentElement.classList.contains("dark"))})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),n.useEffect(()=>{if(S){const t=m=>m.filter(c=>y||!c.isHidden).map(c=>({id:c.path,name:c.name,path:c.path,isDirectory:c.isDirectory,size:c.size,modified:c.modified,isHidden:c.isHidden,children:c.children?t(c.children):void 0})),s=(m,c=new Set)=>(m.forEach(i=>{i.isDirectory&&i.children&&i.children.length>0&&(c.add(i.path),s(i.children,c))}),c),o=s(S);M(o),G(t(S))}},[S,y]);const te=n.useCallback(async t=>{if(!(F.has(t)||B.has(t))){T(s=>new Set(s).add(t));try{const s=new URLSearchParams;s.append("path",t),y&&s.append("showHiddenFiles","true");const o=await I(`${A}/files/browse?${s.toString()}`);if(!o.ok)throw new Error("Failed to browse directory");const m=await o.json(),c=[];for(const i of m.items)i.isDirectory?c.push({...i,children:[]}):c.push(i);G(i=>{const k=Le=>Le.map(N=>N.path===t?{...N,children:c.map(b=>({id:b.path,name:b.name,path:b.path,isDirectory:b.isDirectory,size:b.size,modified:b.modified,isHidden:b.isHidden,children:b.isDirectory?[]:void 0}))}:N.children?{...N,children:k(N.children)}:N);return k(i)}),M(i=>new Set(i).add(t)),$.current&&c.length>0&&c.forEach(i=>{i.isDirectory&&$.current?.close(i.path)})}catch(s){throw console.error("Failed to load directory children:",s),s}finally{T(s=>{const o=new Set(s);return o.delete(t),o})}}},[F,B,y]),P=n.useCallback(()=>{M(new Set),T(new Set),H()},[H]),we=n.useCallback(()=>{je(t=>!t)},[]);n.useEffect(()=>{M(new Set),T(new Set),H()},[y,H]),n.useEffect(()=>{const t=()=>{if(j.current){const m=j.current.getBoundingClientRect(),c=m.height>0?m.height:600;O(c)}};let s=null;j.current&&(s=new ResizeObserver(m=>{for(const c of m){const{height:i}=c.contentRect;i>0&&O(i)}}),s.observe(j.current));const o=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(o),window.removeEventListener("resize",t),s&&s.disconnect()}},[S]),n.useEffect(()=>{const t=s=>{V.current&&!V.current.contains(s.target)&&z(!1)};if(p)return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[p]),n.useEffect(()=>{const t=s=>{console.log("🔄 Received AI_RESPONSE_COMPLETE event in FileExplorer:",s),s.projectPath===r&&(console.log("🔄 Auto-refreshing file tree after AI response completion"),P())};return xe.on(me.AI_RESPONSE_COMPLETE,t),()=>{xe.off(me.AI_RESPONSE_COMPLETE,t)}},[r,P]);const re=L,ke=n.useMemo(()=>{const t={},s=o=>{o.forEach(m=>{m.isDirectory&&(t[m.id]=!1,m.children&&s(m.children))})};return L&&L.length>0&&s(L),t},[L]),se=n.useCallback((t,s=!1)=>({id:`tab-${t.path}`,name:t.name,path:t.path,isPinned:s,isActive:!1}),[]),U=n.useCallback((t,s=!1)=>{f(o=>{const m=o.findIndex(c=>c.path===t.path);if(m!==-1)return o.map((c,i)=>({...c,isActive:i===m,isPinned:s||c.isPinned}));{const c=se(t,s);return!s&&g?(E(c.id),o.map(i=>i.id===g?{...c,isActive:!0}:{...i,isActive:!1})):(s||E(c.id),[...o.map(i=>({...i,isActive:!1})),{...c,isActive:!0}])}}),l?.(t.path)},[se,g,l]),ae=n.useCallback(t=>{f(s=>{const o=s.findIndex(i=>i.id===t);if(o===-1)return s;const m=s[o],c=s.filter(i=>i.id!==t);if(m.isActive&&c.length>0){const i=Math.min(o,c.length-1);c[i]={...c[i],isActive:!0}}return g===t&&E(null),c})},[g]),ce=n.useCallback(t=>{f(s=>s.map(o=>({...o,isActive:o.id===t})))},[]),[ne,Ne]=n.useState({}),Ee=n.useCallback(t=>{const s=Date.now(),o=ne[t.data.path]||0;if(s-o<300)return;Ne(k=>({...k,[t.data.path]:s}));const m=t.isOpen,c=t.data.children&&t.data.children.length>0,i=F.has(t.data.path);m?t.close():!c&&!i?(t.open(),te(t.data.path).catch(k=>{console.error("Failed to load directory children:",k),t.close()})):t.open()},[ne,F,te]),Ce=n.useCallback(t=>{t.select();const s=Date.now(),o=s-J<300&&K===t.data.path;ge(s),pe(t.data.path),o?U(t.data,!0):setTimeout(()=>{Date.now()-s>=300&&U(t.data,!1)},300)},[U,J,K]),ze=()=>{if(!v)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(W,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:a("fileExplorer.selectFile")})]})});if(be)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(R,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:a("fileExplorer.loading")})]})});if(ee)return e.jsx("div",{className:"flex items-center justify-center h-full text-red-500 dark:text-red-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:a("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:ee.message}),e.jsx("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:v.path})]})});switch(at(v.name)){case"image":const s=new URLSearchParams;s.append("path",v.path),r&&s.append("projectPath",r),s.append("binary","true");const o=`${A}/files/read?${s.toString()}`;return e.jsx(st,{imageUrl:o,fileName:v.name});case"text":return Z?e.jsx(Fe.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"})}),children:e.jsx(et,{height:"100%",theme:ye?"vs-dark":"vs-light",language:rt(v.name),value:Z.content,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1}})}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:a("fileExplorer.cannotReadFile")})});default:return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:a("fileExplorer.previewNotSupported")}),e.jsxs("p",{className:"text-sm mt-2",children:[a("fileExplorer.fileLabel"),": ",v.name]})]})})}};return Y?e.jsx("div",{className:`flex items-center justify-center h-full text-red-500 dark:text-red-400 ${d}`,style:{height:h},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:a("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Y.message}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:[a("fileExplorer.projectPath"),": ",r]}),e.jsx("button",{onClick:()=>H(),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:a("fileExplorer.retry")})]})}):e.jsxs("div",{className:`flex h-full bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${d}`,children:[!X&&e.jsxs("div",{className:"w-80 border-r border-gray-200 dark:border-gray-700 flex flex-col h-full",children:[e.jsx("div",{className:"h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("fileExplorer.title")}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:we,className:`p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors ${y?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"}`,title:y?"隐藏文件和文件夹":"显示隐藏文件和文件夹",children:y?e.jsx(Me,{className:"w-4 h-4"}):e.jsx(Te,{className:"w-4 h-4"})}),e.jsx("button",{onClick:P,className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("common:actions.refresh"),disabled:_,children:e.jsx(De,{className:`w-4 h-4 ${_?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Q(!0),className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("fileExplorer.collapsePanel"),children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})}),e.jsx("div",{ref:j,className:"flex-1 min-h-0 pl-2",children:_?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:a("fileExplorer.loading")})]})}):re.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:a("fileExplorer.emptyDirectory")})}):e.jsx(He,{data:re,width:320,height:C,indent:20,rowHeight:36,initialOpenState:ke,ref:$,children:t=>e.jsx(ct,{...t,isLoading:B.has(t.node.data.path),onDirectoryToggle:Ee,onFileSelect:Ce})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"h-12 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:[X&&e.jsx("button",{onClick:()=>Q(!1),className:"p-1.5 mx-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("fileExplorer.expandPanel"),children:e.jsx(Re,{className:"w-4 h-4"})}),x.length>0?e.jsxs("div",{className:"flex items-center h-full w-full",children:[e.jsx("div",{className:"flex items-center h-full flex-1",children:x.slice(0,Math.min(D,x.length)).map(t=>e.jsxs("div",{className:`group relative flex items-center h-full px-3 border-r border-gray-200 dark:border-gray-700 cursor-pointer transition-colors ${t.isActive?"bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"} ${t.isPinned?"":"italic"}`,onClick:()=>ce(t.id),title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,style:{minWidth:"120px",maxWidth:"180px"},children:[e.jsx(q,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 text-sm truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),ae(t.id)},title:a("common:actions.close"),children:e.jsx(ie,{className:"w-3 h-3"})})]},t.id))}),x.length>D&&e.jsxs("div",{className:"relative",ref:V,children:[e.jsxs("button",{className:"flex items-center h-full px-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-white transition-colors border-l border-gray-200 dark:border-gray-700",onClick:()=>z(!p),title:`${x.length-D} more tabs`,children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx(Oe,{className:"w-3 h-3 ml-1"})]}),p&&e.jsx("div",{className:"absolute top-full right-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-48 max-h-64 overflow-y-auto",children:x.slice(D).map(t=>e.jsxs("div",{className:`flex items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 ${t.isActive?"bg-blue-50 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"} ${t.isPinned?"":"italic"}`,onClick:()=>{ce(t.id),z(!1)},title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,children:[e.jsx(q,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),ae(t.id)},title:a("common:actions.close"),children:e.jsx(ie,{className:"w-3 h-3"})})]},t.id))})]})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-full text-gray-500 dark:text-gray-400",children:e.jsx("span",{className:"text-sm",children:a("fileExplorer.noFiles")})})]}),e.jsx("div",{className:"flex-1 bg-gray-50 dark:bg-gray-900 min-h-0",children:ze()})]})]})};export{me as E,ut as F,xe as e};
|
|
1
|
+
import{c as Se}from"./syntax-highlighting-DGbNjS3S.js";import{j as e,T as He}from"./data-structures-ChC1tqVg.js";import{r as n,W as Fe}from"./monaco-editor-BWfQfpij.js";import{b as ue,a as I,A}from"./agents-DR9EZMs5.js";import{aJ as u,E as Me,a9 as Te,V as De,aK as Ae,L as R,aL as Re,X as ie,aM as Ie,k as Oe,l as Ve}from"./ui-components-D1pZO0y-.js";import{u as fe}from"./tools-crrPnehB.js";function $e(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L192 480l157.1-52.2L384 32H0zm313.1 80l-4.8 47.3L193 208.6l-.3.1h111.5l-12.8 146.6-98.2 28.7-98.8-29.2-6.4-73.9h48.9l3.2 38.3 52.6 13.3 54.7-15.4 3.7-61.6-166.3-.5v-.1l-.2.1-3.6-46.3L193.1 162l6.5-2.7H76.7L70.9 112h242.2z"},child:[]}]})(r)}function le(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"},child:[]}]})(r)}function Be(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"},child:[]}]})(r)}function _e(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM243.8 381.4c0 43.6-25.6 63.5-62.9 63.5-33.7 0-53.2-17.4-63.2-38.5l34.3-20.7c6.6 11.7 12.6 21.6 27.1 21.6 13.8 0 22.6-5.4 22.6-26.5V237.7h42.1v143.7zm99.6 63.5c-39.1 0-64.4-18.6-76.7-43l34.3-19.8c9 14.7 20.8 25.6 41.5 25.6 17.4 0 28.6-8.7 28.6-20.8 0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5 0-31.6 24.1-55.6 61.6-55.6 26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18-12.3 0-20.1 7.8-20.1 18 0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2 0 37.8-29.8 58.6-69.7 58.6z"},child:[]}]})(r)}function Pe(r){return u({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"},child:[]}]})(r)}function Ue(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(r)}function qe(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M418.2 177.2c-5.4-1.8-10.8-3.5-16.2-5.1.9-3.7 1.7-7.4 2.5-11.1 12.3-59.6 4.2-107.5-23.1-123.3-26.3-15.1-69.2.6-112.6 38.4-4.3 3.7-8.5 7.6-12.5 11.5-2.7-2.6-5.5-5.2-8.3-7.7-45.5-40.4-91.1-57.4-118.4-41.5-26.2 15.2-34 60.3-23 116.7 1.1 5.6 2.3 11.1 3.7 16.7-6.4 1.8-12.7 3.8-18.6 5.9C38.3 196.2 0 225.4 0 255.6c0 31.2 40.8 62.5 96.3 81.5 4.5 1.5 9 3 13.6 4.3-1.5 6-2.8 11.9-4 18-10.5 55.5-2.3 99.5 23.9 114.6 27 15.6 72.4-.4 116.6-39.1 3.5-3.1 7-6.3 10.5-9.7 4.4 4.3 9 8.4 13.6 12.4 42.8 36.8 85.1 51.7 111.2 36.6 27-15.6 35.8-62.9 24.4-120.5-.9-4.4-1.9-8.9-3-13.5 3.2-.9 6.3-1.9 9.4-2.9 57.7-19.1 99.5-50 99.5-81.7 0-30.3-39.4-59.7-93.8-78.4zM282.9 92.3c37.2-32.4 71.9-45.1 87.7-36 16.9 9.7 23.4 48.9 12.8 100.4-.7 3.4-1.4 6.7-2.3 10-22.2-5-44.7-8.6-67.3-10.6-13-18.6-27.2-36.4-42.6-53.1 3.9-3.7 7.7-7.2 11.7-10.7zM167.2 307.5c5.1 8.7 10.3 17.4 15.8 25.9-15.6-1.7-31.1-4.2-46.4-7.5 4.4-14.4 9.9-29.3 16.3-44.5 4.6 8.8 9.3 17.5 14.3 26.1zm-30.3-120.3c14.4-3.2 29.7-5.8 45.6-7.8-5.3 8.3-10.5 16.8-15.4 25.4-4.9 8.5-9.7 17.2-14.2 26-6.3-14.9-11.6-29.5-16-43.6zm27.4 68.9c6.6-13.8 13.8-27.3 21.4-40.6s15.8-26.2 24.4-38.9c15-1.1 30.3-1.7 45.9-1.7s31 .6 45.9 1.7c8.5 12.6 16.6 25.5 24.3 38.7s14.9 26.7 21.7 40.4c-6.7 13.8-13.9 27.4-21.6 40.8-7.6 13.3-15.7 26.2-24.2 39-14.9 1.1-30.4 1.6-46.1 1.6s-30.9-.5-45.6-1.4c-8.7-12.7-16.9-25.7-24.6-39s-14.8-26.8-21.5-40.6zm180.6 51.2c5.1-8.8 9.9-17.7 14.6-26.7 6.4 14.5 12 29.2 16.9 44.3-15.5 3.5-31.2 6.2-47 8 5.4-8.4 10.5-17 15.5-25.6zm14.4-76.5c-4.7-8.8-9.5-17.6-14.5-26.2-4.9-8.5-10-16.9-15.3-25.2 16.1 2 31.5 4.7 45.9 8-4.6 14.8-10 29.2-16.1 43.4zM256.2 118.3c10.5 11.4 20.4 23.4 29.6 35.8-19.8-.9-39.7-.9-59.5 0 9.8-12.9 19.9-24.9 29.9-35.8zM140.2 57c16.8-9.8 54.1 4.2 93.4 39 2.5 2.2 5 4.6 7.6 7-15.5 16.7-29.8 34.5-42.9 53.1-22.6 2-45 5.5-67.2 10.4-1.3-5.1-2.4-10.3-3.5-15.5-9.4-48.4-3.2-84.9 12.6-94zm-24.5 263.6c-4.2-1.2-8.3-2.5-12.4-3.9-21.3-6.7-45.5-17.3-63-31.2-10.1-7-16.9-17.8-18.8-29.9 0-18.3 31.6-41.7 77.2-57.6 5.7-2 11.5-3.8 17.3-5.5 6.8 21.7 15 43 24.5 63.6-9.6 20.9-17.9 42.5-24.8 64.5zm116.6 98c-16.5 15.1-35.6 27.1-56.4 35.3-11.1 5.3-23.9 5.8-35.3 1.3-15.9-9.2-22.5-44.5-13.5-92 1.1-5.6 2.3-11.2 3.7-16.7 22.4 4.8 45 8.1 67.9 9.8 13.2 18.7 27.7 36.6 43.2 53.4-3.2 3.1-6.4 6.1-9.6 8.9zm24.5-24.3c-10.2-11-20.4-23.2-30.3-36.3 9.6.4 19.5.6 29.5.6 10.3 0 20.4-.2 30.4-.7-9.2 12.7-19.1 24.8-29.6 36.4zm130.7 30c-.9 12.2-6.9 23.6-16.5 31.3-15.9 9.2-49.8-2.8-86.4-34.2-4.2-3.6-8.4-7.5-12.7-11.5 15.3-16.9 29.4-34.8 42.2-53.6 22.9-1.9 45.7-5.4 68.2-10.5 1 4.1 1.9 8.2 2.7 12.2 4.9 21.6 5.7 44.1 2.5 66.3zm18.2-107.5c-2.8.9-5.6 1.8-8.5 2.6-7-21.8-15.6-43.1-25.5-63.8 9.6-20.4 17.7-41.4 24.5-62.9 5.2 1.5 10.2 3.1 15 4.7 46.6 16 79.3 39.8 79.3 58 0 19.6-34.9 44.9-84.8 61.4zm-149.7-15c25.3 0 45.8-20.5 45.8-45.8s-20.5-45.8-45.8-45.8c-25.3 0-45.8 20.5-45.8 45.8s20.5 45.8 45.8 45.8z"},child:[]}]})(r)}function We(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(r)}function oe(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm57.1 120H305c7.7 0 13.4 7.1 11.7 14.7l-38 168c-1.2 5.5-6.1 9.3-11.7 9.3h-38c-5.5 0-10.3-3.8-11.6-9.1-25.8-103.5-20.8-81.2-25.6-110.5h-.5c-1.1 14.3-2.4 17.4-25.6 110.5-1.3 5.3-6.1 9.1-11.6 9.1H117c-5.6 0-10.5-3.9-11.7-9.4l-37.8-168c-1.7-7.5 4-14.6 11.7-14.6h24.5c5.7 0 10.7 4 11.8 9.7 15.6 78 20.1 109.5 21 122.2 1.6-10.2 7.3-32.7 29.4-122.7 1.3-5.4 6.1-9.1 11.7-9.1h29.1c5.6 0 10.4 3.8 11.7 9.2 24 100.4 28.8 124 29.6 129.4-.2-11.2-2.6-17.8 21.6-129.2 1-5.6 5.9-9.5 11.5-9.5zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function W(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function Je(r){return u({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(r)}function Ke(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"},child:[]}]})(r)}function w(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(r)}function Ge(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4.708 5.578L2.061 8.224l2.647 2.646-.708.708-3-3V7.87l3-3 .708.708zm7-.708L11 5.578l2.647 2.646L11 10.87l.708.708 3-3V7.87l-3-3zM4.908 13l.894.448 5-10L9.908 3l-5 10z"},child:[]}]})(r)}function de(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(r)}function he(r){return u({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"},child:[]}]})(r)}const Xe=r=>{const l=r.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"].includes(l)},Qe=(r,l)=>{const d=r?Xe(r.split("/").pop()||""):!1;return ue({queryKey:["file-content",r,l],queryFn:async()=>{if(!r)throw new Error("File path is required");const h=new URLSearchParams;h.append("path",r),l&&h.append("projectPath",l);const a=await I(`${A}/files/read?${h.toString()}`);if(!a.ok)throw a.status===403?new Error("访问被拒绝:文件在项目目录之外"):a.status===404?new Error("文件不存在"):new Error(`读取文件失败 (${a.status})`);return a.json()},enabled:!!r&&!d,staleTime:6e4,retry:!1})},Ye=(r,l)=>ue({queryKey:["file-tree-lazy",r,l],queryFn:async()=>{if(!r)throw new Error("Project path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("showHiddenFiles","true");const h=await I(`${A}/files/browse?${d.toString()}`);if(!h.ok)throw new Error("Failed to browse directory");const a=await h.json(),x=[];for(const f of a.items)f.isDirectory?x.push({...f,children:[]}):x.push(f);return x},enabled:!!r,staleTime:3e4});class Ze{events=new Map;on(l,d){this.events.has(l)||this.events.set(l,[]),this.events.get(l).push(d)}off(l,d){const h=this.events.get(l);if(h){const a=h.indexOf(d);a>-1&&h.splice(a,1)}}emit(l,...d){const h=this.events.get(l);h&&h.forEach(a=>{try{a(...d)}catch(x){console.error(`Error in event handler for ${l}:`,x)}})}clear(){this.events.clear()}}const xe=new Ze,me={AI_RESPONSE_COMPLETE:"ai_response_complete",REFRESH_AGENT_CONTENT:"refresh_agent_content"},et=n.lazy(()=>Se(()=>import("./monaco-editor-BWfQfpij.js").then(r=>r.i),[])),tt=new Map([["js",e.jsx(_e,{color:"#f7df1e"},"js")],["jsx",e.jsx(qe,{color:"#61dafb"},"jsx")],["ts",e.jsx(he,{color:"#3178c6"},"ts")],["tsx",e.jsx(he,{color:"#3178c6"},"tsx")],["css",e.jsx($e,{color:"#1572b6"},"css")],["html",e.jsx(le,{color:"#e34f26"},"html")],["htm",e.jsx(le,{color:"#e34f26"},"htm")],["json",e.jsx(de,{color:"#f9d71c"},"json")],["jsonl",e.jsx(de,{color:"#e6a23c"},"jsonl")],["md",e.jsx(Pe,{color:"#083fa1"},"md")],["csv",e.jsx(W,{color:"#00a86b"},"csv")],["pdf",e.jsx(We,{color:"#d63031"},"pdf")],["ppt",e.jsx(oe,{color:"#d63031"},"ppt")],["pptx",e.jsx(oe,{color:"#d63031"},"pptx")],["ico",e.jsx(w,{color:"#a9a9a9"},"ico")],["png",e.jsx(w,{color:"#a9a9a9"},"png")],["jpg",e.jsx(w,{color:"#a9a9a9"},"jpg")],["jpeg",e.jsx(w,{color:"#a9a9a9"},"jpeg")],["gif",e.jsx(w,{color:"#a9a9a9"},"gif")],["svg",e.jsx(w,{color:"#a9a9a9"},"svg")],["webp",e.jsx(w,{color:"#a9a9a9"},"webp")],["py",e.jsx(Ue,{color:"#3776ab"},"py")],["java",e.jsx(Be,{color:"#007396"},"java")]]),q=({node:r})=>{const l=r.data.isHidden;if(r.data.isDirectory){const x=l?"#9ca3af":"#87b3d6";return r.isOpen?e.jsx(Je,{color:x}):e.jsx(Ke,{color:x})}const d=r.data.name.split(".").pop()?.toLowerCase()||"",h=l?"#9ca3af":"#6d8a9f",a=l?{opacity:.6}:{};return e.jsx("span",{style:a,children:tt.get(d)||e.jsx(W,{color:h})})},rt=(r="")=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"dockerfile";switch(r.split(".").pop()?.toLowerCase()||""){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"css":case"scss":case"sass":case"less":return"css";case"json":case"jsonl":return"json";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"csv":return"csv";case"py":return"python";case"java":return"java";case"xml":return"xml";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"conf":case"config":case"ini":return"ini";case"nginx":return"nginx";case"sql":return"sql";case"go":return"go";case"rs":return"rust";case"c":case"cpp":case"cc":case"cxx":return"cpp";case"h":case"hpp":return"cpp";case"cs":return"csharp";case"php":return"php";case"rb":return"ruby";case"swift":return"swift";case"kt":return"kotlin";case"dockerfile":return"dockerfile";default:return"plaintext"}},st=({imageUrl:r,fileName:l})=>{const{t:d}=fe("components"),[h,a]=n.useState(!0),[x,f]=n.useState(!1),[g,E]=n.useState(null);return n.useEffect(()=>{let C=null;return(async()=>{try{a(!0),f(!1);const p=await I(r);if(!p.ok)throw new Error(`Failed to load image: ${p.status}`);const z=await p.blob(),j=URL.createObjectURL(z);C=j,E(j),a(!1)}catch(p){console.error("Failed to load image:",p),a(!1),f(!0)}})(),()=>{C&&URL.revokeObjectURL(C)}},[r]),e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:x?e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(w,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:d("fileExplorer.imageLoadFailed")}),e.jsx("p",{className:"text-sm mt-2",children:l})]}):e.jsxs("div",{className:"relative max-w-full max-h-full",children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(R,{className:"w-8 h-8 animate-spin text-gray-400"})}),g&&e.jsx("img",{src:g,alt:l,className:"max-w-full max-h-full object-contain bg-white dark:bg-gray-900 rounded shadow-lg",onLoad:()=>a(!1),onError:()=>{a(!1),f(!0)},style:{display:x?"none":"block"}})]})})},at=r=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"text";const d=r.split(".").pop()?.toLowerCase()||"",h=["js","jsx","ts","tsx","css","scss","sass","less","html","htm","json","jsonl","md","markdown","txt","py","java","xml","yaml","yml","sh","bash","bat","cmd","php","rb","go","rs","cpp","c","h","hpp","cc","cxx","cs","swift","kt","scala","clj","sql","dockerfile","gitignore","env","csv","tsv","conf","config","ini","toml","nginx","apache","properties","cfg"],a=["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"];return h.includes(d)?"text":a.includes(d)?"image":"binary"},ct=({node:r,style:l,dragHandle:d,isLoading:h=!1,onDirectoryToggle:a,onFileSelect:x})=>{const f=n.useCallback(g=>{g.preventDefault(),g.stopPropagation(),r.data.isDirectory?a?.(r):x?.(r)},[r,a,x]);return e.jsxs("div",{style:l,ref:d,className:`flex items-center cursor-pointer px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 ${r.isSelected?"bg-blue-100 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,onClick:f,children:[r.data.isDirectory&&e.jsx("span",{className:"mr-1 flex items-center",children:h?e.jsx(R,{className:"w-3 h-3 animate-spin text-gray-400"}):e.jsx(Ve,{className:`w-3 h-3 transition-transform text-gray-400 ${r.isOpen?"rotate-90":""}`})}),e.jsx("span",{className:"mr-2 flex items-center",children:e.jsx(q,{node:r})}),e.jsx("span",{className:`text-sm truncate flex-1 ${r.data.isHidden?"text-gray-400 dark:text-gray-500 italic":"text-gray-700 dark:text-gray-300"}`,children:r.data.name}),!r.data.isDirectory&&r.data.size&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:[(r.data.size/1024).toFixed(1),"KB"]})]})},D=5,ut=({projectPath:r,onFileSelect:l,className:d="",height:h="100vh"})=>{const{t:a}=fe("components"),[x,f]=n.useState([]),[g,E]=n.useState(null),[C,O]=n.useState(600),[p,z]=n.useState(!1),j=n.useRef(null),V=n.useRef(null),$=n.useRef(null),[J,ge]=n.useState(0),[K,pe]=n.useState(""),[ye,ve]=n.useState(document.documentElement.classList.contains("dark")),[F,M]=n.useState(new Set),[L,G]=n.useState([]),[B,T]=n.useState(new Set),[y,je]=n.useState(!1),[X,Q]=n.useState(!1),{data:S,isLoading:_,error:Y,refetch:H}=Ye(r,y),v=n.useMemo(()=>x.find(t=>t.isActive)||null,[x]),{data:Z,isLoading:be,error:ee}=Qe(v?v.path:void 0,r);n.useEffect(()=>{const t=new MutationObserver(s=>{s.forEach(o=>{o.attributeName==="class"&&ve(document.documentElement.classList.contains("dark"))})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),n.useEffect(()=>{if(S){const t=m=>m.filter(c=>y||!c.isHidden).map(c=>({id:c.path,name:c.name,path:c.path,isDirectory:c.isDirectory,size:c.size,modified:c.modified,isHidden:c.isHidden,children:c.children?t(c.children):void 0})),s=(m,c=new Set)=>(m.forEach(i=>{i.isDirectory&&i.children&&i.children.length>0&&(c.add(i.path),s(i.children,c))}),c),o=s(S);M(o),G(t(S))}},[S,y]);const te=n.useCallback(async t=>{if(!(F.has(t)||B.has(t))){T(s=>new Set(s).add(t));try{const s=new URLSearchParams;s.append("path",t),y&&s.append("showHiddenFiles","true");const o=await I(`${A}/files/browse?${s.toString()}`);if(!o.ok)throw new Error("Failed to browse directory");const m=await o.json(),c=[];for(const i of m.items)i.isDirectory?c.push({...i,children:[]}):c.push(i);G(i=>{const k=Le=>Le.map(N=>N.path===t?{...N,children:c.map(b=>({id:b.path,name:b.name,path:b.path,isDirectory:b.isDirectory,size:b.size,modified:b.modified,isHidden:b.isHidden,children:b.isDirectory?[]:void 0}))}:N.children?{...N,children:k(N.children)}:N);return k(i)}),M(i=>new Set(i).add(t)),$.current&&c.length>0&&c.forEach(i=>{i.isDirectory&&$.current?.close(i.path)})}catch(s){throw console.error("Failed to load directory children:",s),s}finally{T(s=>{const o=new Set(s);return o.delete(t),o})}}},[F,B,y]),P=n.useCallback(()=>{M(new Set),T(new Set),H()},[H]),we=n.useCallback(()=>{je(t=>!t)},[]);n.useEffect(()=>{M(new Set),T(new Set),H()},[y,H]),n.useEffect(()=>{const t=()=>{if(j.current){const m=j.current.getBoundingClientRect(),c=m.height>0?m.height:600;O(c)}};let s=null;j.current&&(s=new ResizeObserver(m=>{for(const c of m){const{height:i}=c.contentRect;i>0&&O(i)}}),s.observe(j.current));const o=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(o),window.removeEventListener("resize",t),s&&s.disconnect()}},[S]),n.useEffect(()=>{const t=s=>{V.current&&!V.current.contains(s.target)&&z(!1)};if(p)return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[p]),n.useEffect(()=>{const t=s=>{console.log("🔄 Received AI_RESPONSE_COMPLETE event in FileExplorer:",s),s.projectPath===r&&(console.log("🔄 Auto-refreshing file tree after AI response completion"),P())};return xe.on(me.AI_RESPONSE_COMPLETE,t),()=>{xe.off(me.AI_RESPONSE_COMPLETE,t)}},[r,P]);const re=L,ke=n.useMemo(()=>{const t={},s=o=>{o.forEach(m=>{m.isDirectory&&(t[m.id]=!1,m.children&&s(m.children))})};return L&&L.length>0&&s(L),t},[L]),se=n.useCallback((t,s=!1)=>({id:`tab-${t.path}`,name:t.name,path:t.path,isPinned:s,isActive:!1}),[]),U=n.useCallback((t,s=!1)=>{f(o=>{const m=o.findIndex(c=>c.path===t.path);if(m!==-1)return o.map((c,i)=>({...c,isActive:i===m,isPinned:s||c.isPinned}));{const c=se(t,s);return!s&&g?(E(c.id),o.map(i=>i.id===g?{...c,isActive:!0}:{...i,isActive:!1})):(s||E(c.id),[...o.map(i=>({...i,isActive:!1})),{...c,isActive:!0}])}}),l?.(t.path)},[se,g,l]),ae=n.useCallback(t=>{f(s=>{const o=s.findIndex(i=>i.id===t);if(o===-1)return s;const m=s[o],c=s.filter(i=>i.id!==t);if(m.isActive&&c.length>0){const i=Math.min(o,c.length-1);c[i]={...c[i],isActive:!0}}return g===t&&E(null),c})},[g]),ce=n.useCallback(t=>{f(s=>s.map(o=>({...o,isActive:o.id===t})))},[]),[ne,Ne]=n.useState({}),Ee=n.useCallback(t=>{const s=Date.now(),o=ne[t.data.path]||0;if(s-o<300)return;Ne(k=>({...k,[t.data.path]:s}));const m=t.isOpen,c=t.data.children&&t.data.children.length>0,i=F.has(t.data.path);m?t.close():!c&&!i?(t.open(),te(t.data.path).catch(k=>{console.error("Failed to load directory children:",k),t.close()})):t.open()},[ne,F,te]),Ce=n.useCallback(t=>{t.select();const s=Date.now(),o=s-J<300&&K===t.data.path;ge(s),pe(t.data.path),o?U(t.data,!0):setTimeout(()=>{Date.now()-s>=300&&U(t.data,!1)},300)},[U,J,K]),ze=()=>{if(!v)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(W,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:a("fileExplorer.selectFile")})]})});if(be)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(R,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:a("fileExplorer.loading")})]})});if(ee)return e.jsx("div",{className:"flex items-center justify-center h-full text-red-500 dark:text-red-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:a("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:ee.message}),e.jsx("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:v.path})]})});switch(at(v.name)){case"image":const s=new URLSearchParams;s.append("path",v.path),r&&s.append("projectPath",r),s.append("binary","true");const o=`${A}/files/read?${s.toString()}`;return e.jsx(st,{imageUrl:o,fileName:v.name});case"text":return Z?e.jsx(Fe.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"})}),children:e.jsx(et,{height:"100%",theme:ye?"vs-dark":"vs-light",language:rt(v.name),value:Z.content,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1}})}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:a("fileExplorer.cannotReadFile")})});default:return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:a("fileExplorer.previewNotSupported")}),e.jsxs("p",{className:"text-sm mt-2",children:[a("fileExplorer.fileLabel"),": ",v.name]})]})})}};return Y?e.jsx("div",{className:`flex items-center justify-center h-full text-red-500 dark:text-red-400 ${d}`,style:{height:h},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:a("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Y.message}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:[a("fileExplorer.projectPath"),": ",r]}),e.jsx("button",{onClick:()=>H(),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:a("fileExplorer.retry")})]})}):e.jsxs("div",{className:`flex h-full bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${d}`,children:[!X&&e.jsxs("div",{className:"w-80 border-r border-gray-200 dark:border-gray-700 flex flex-col h-full",children:[e.jsx("div",{className:"h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:a("fileExplorer.title")}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:we,className:`p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors ${y?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"}`,title:y?"隐藏文件和文件夹":"显示隐藏文件和文件夹",children:y?e.jsx(Me,{className:"w-4 h-4"}):e.jsx(Te,{className:"w-4 h-4"})}),e.jsx("button",{onClick:P,className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("common:actions.refresh"),disabled:_,children:e.jsx(De,{className:`w-4 h-4 ${_?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>Q(!0),className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("fileExplorer.collapsePanel"),children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})}),e.jsx("div",{ref:j,className:"flex-1 min-h-0 pl-2",children:_?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(R,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:a("fileExplorer.loading")})]})}):re.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:a("fileExplorer.emptyDirectory")})}):e.jsx(He,{data:re,width:320,height:C,indent:20,rowHeight:36,initialOpenState:ke,ref:$,children:t=>e.jsx(ct,{...t,isLoading:B.has(t.node.data.path),onDirectoryToggle:Ee,onFileSelect:Ce})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"h-12 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:[X&&e.jsx("button",{onClick:()=>Q(!1),className:"p-1.5 mx-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:a("fileExplorer.expandPanel"),children:e.jsx(Re,{className:"w-4 h-4"})}),x.length>0?e.jsxs("div",{className:"flex items-center h-full w-full",children:[e.jsx("div",{className:"flex items-center h-full flex-1",children:x.slice(0,Math.min(D,x.length)).map(t=>e.jsxs("div",{className:`group relative flex items-center h-full px-3 border-r border-gray-200 dark:border-gray-700 cursor-pointer transition-colors ${t.isActive?"bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"} ${t.isPinned?"":"italic"}`,onClick:()=>ce(t.id),title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,style:{minWidth:"120px",maxWidth:"180px"},children:[e.jsx(q,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 text-sm truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),ae(t.id)},title:a("common:actions.close"),children:e.jsx(ie,{className:"w-3 h-3"})})]},t.id))}),x.length>D&&e.jsxs("div",{className:"relative",ref:V,children:[e.jsxs("button",{className:"flex items-center h-full px-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-white transition-colors border-l border-gray-200 dark:border-gray-700",onClick:()=>z(!p),title:`${x.length-D} more tabs`,children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx(Oe,{className:"w-3 h-3 ml-1"})]}),p&&e.jsx("div",{className:"absolute top-full right-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-48 max-h-64 overflow-y-auto",children:x.slice(D).map(t=>e.jsxs("div",{className:`flex items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 ${t.isActive?"bg-blue-50 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"} ${t.isPinned?"":"italic"}`,onClick:()=>{ce(t.id),z(!1)},title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,children:[e.jsx(q,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),ae(t.id)},title:a("common:actions.close"),children:e.jsx(ie,{className:"w-3 h-3"})})]},t.id))})]})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-full text-gray-500 dark:text-gray-400",children:e.jsx("span",{className:"text-sm",children:a("fileExplorer.noFiles")})})]}),e.jsx("div",{className:"flex-1 bg-gray-50 dark:bg-gray-900 min-h-0",children:ze()})]})]})};export{me as E,ut as F,xe as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as n}from"./monaco-editor-BWfQfpij.js";import{b as G,e as M,f as O,g as P,i as R,h as W}from"./index-BIGPvi1D.js";import{u as _}from"./tools-crrPnehB.js";import{r as p,K as F,N as K,M as k,O as H,Q,G as z,R as q,U as B,V as Y,Y as c,_ as J,$ as X,a0 as Z,d as ee,a1 as j,a2 as f,a3 as se,j as N}from"./ui-components-D1pZO0y-.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-DR9EZMs5.js";const ce=()=>{const{t:s,i18n:d}=_("pages"),{isMobile:a}=G(),{isCursorEngine:g,isLoading:o}=M(),[i,v]=n.useState(()=>localStorage.getItem("theme")||"auto"),[w,x]=n.useState(d.language),[C,m]=n.useState(()=>{const t=localStorage.getItem("agentstudio:chat-version");return t||(localStorage.getItem("agentstudio:engine-type")==="cursor"?"agui":"original")});n.useEffect(()=>{o||localStorage.getItem("agentstudio:chat-version")||m(g?"agui":"original")},[o,g]);const{currentVersion:h,latestVersion:b,hasUpdate:$,forceCheck:S,isChecking:u,dismissUpdate:E,showUpdateNotification:I}=O(),{systemInfo:r,refetch:V}=P(),[l,T]=n.useState(R());n.useEffect(()=>{x(d.language)},[d.language]),n.useEffect(()=>{(()=>{i==="dark"?document.documentElement.classList.add("dark"):i==="light"?document.documentElement.classList.remove("dark"):window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")})(),localStorage.setItem("theme",i),window.dispatchEvent(new Event("themechange"))},[i]);const A=t=>{x(t),d.changeLanguage(t)},D=t=>{m(t),localStorage.setItem("agentstudio:chat-version",t)},U=()=>{S(),V()},L=()=>{const t=!l;W(t),T(t)};return e.jsxs("div",{className:`${a?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsxs("h1",{className:`${a?"text-xl":"text-2xl"} font-bold text-gray-900 dark:text-white mb-2 flex items-center gap-2`,children:[e.jsx(p,{className:"w-6 h-6"}),s("settings.general.title")]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.general.description")})]}),I&&b&&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-4",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-800 rounded-full",children:e.jsx(F,{className:"w-6 h-6 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100",children:s("settings.systemInfo.updateAvailable")}),e.jsx("p",{className:"text-sm text-blue-700 dark:text-blue-300 mt-1",children:s("version.newVersionAvailable",{version:b})}),e.jsxs("div",{className:"mt-3 flex space-x-2",children:[e.jsxs("a",{href:"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center px-3 py-1.5 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),s("settings.systemInfo.viewReleases")]}),e.jsx("button",{onClick:E,className:"px-3 py-1.5 text-blue-700 dark:text-blue-300 text-sm bg-blue-100 dark:bg-blue-800 hover:bg-blue-200 dark:hover:bg-blue-700 rounded-lg",children:s("version.dismiss")})]})]})]})})}),e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 ${a?"p-4":"p-6"}`,children:[e.jsxs("h2",{className:`${a?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2`,children:[e.jsx(k,{className:"w-5 h-5"}),s("settings.general.interfaceSettings")]}),e.jsxs("div",{className:`${a?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block font-medium text-gray-900 dark:text-white mb-2",children:s("settings.general.theme.label")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-3",children:s("settings.general.theme.description")}),e.jsx("div",{className:`${a?"grid grid-cols-1 gap-2":"grid grid-cols-3 gap-3"}`,children:[{value:"auto",label:s("settings.general.theme.auto"),icon:k},{value:"light",label:s("settings.general.theme.light"),icon:H},{value:"dark",label:s("settings.general.theme.dark"),icon:Q}].map(t=>e.jsxs("button",{onClick:()=>v(t.value),className:`${a?"p-3":"p-4"} border-2 rounded-lg flex items-center ${a?"flex-row space-x-3":"flex-col space-y-2"} transition-all ${i===t.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx(t.icon,{className:`${a?"w-5 h-5":"w-6 h-6"}`}),e.jsx("span",{className:"text-sm font-medium",children:t.label})]},t.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block font-medium text-gray-900 dark:text-white mb-2 flex items-center space-x-2",children:[e.jsx(z,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:s("settings.general.language.label")})]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-3",children:s("settings.general.language.description")}),e.jsx("div",{className:`${a?"grid grid-cols-1 gap-2":"grid grid-cols-2 gap-3"}`,children:[{value:"zh-CN",label:"中文简体",flag:"🇨🇳"},{value:"en-US",label:"English",flag:"🇺🇸"}].map(t=>e.jsxs("button",{onClick:()=>A(t.value),className:`${a?"p-3":"p-4"} border-2 rounded-lg flex items-center space-x-3 transition-all ${w===t.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx("span",{className:`${a?"text-xl":"text-2xl"}`,children:t.flag}),e.jsx("span",{className:"text-sm font-medium",children:t.label})]},t.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block font-medium text-gray-900 dark:text-white mb-2 flex items-center space-x-2",children:[e.jsx(q,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:s("settings.general.chatVersion.label","Chat Panel Version")})]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-3",children:s("settings.general.chatVersion.description","Choose which chat panel implementation to use")}),e.jsx("div",{className:`${a?"grid grid-cols-1 gap-2":"grid grid-cols-2 gap-3"}`,children:[{value:"original",label:s("settings.general.chatVersion.original","Original"),icon:"💬",description:s("settings.general.chatVersion.originalDesc","Classic chat interface")},{value:"agui",label:s("settings.general.chatVersion.agui","AGUI (Experimental)"),icon:"🚀",description:s("settings.general.chatVersion.aguiDesc","TDesign-based with AGUI protocol")}].map(t=>e.jsxs("button",{onClick:()=>D(t.value),className:`${a?"p-3":"p-4"} border-2 rounded-lg flex items-start space-x-3 transition-all text-left ${C===t.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx("span",{className:`${a?"text-xl":"text-2xl"}`,children:t.icon}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium block",children:t.label}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.description})]})]},t.value))})]})]})]}),e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 ${a?"p-4":"p-6"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:`${a?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white flex items-center gap-2`,children:[e.jsx(B,{className:"w-5 h-5"}),s("settings.systemInfo.title")]}),e.jsxs("button",{onClick:U,disabled:u,className:"inline-flex items-center px-3 py-1.5 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 disabled:opacity-50",children:[e.jsx(Y,{className:`w-3 h-3 mr-1 ${u?"animate-spin":""}`}),s("settings.systemInfo.checkUpdate")]})]}),e.jsxs("div",{className:"space-y-4",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.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(c,{className:"w-4 h-4"}),s("settings.systemInfo.currentVersion")]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"font-mono text-gray-900 dark:text-white",children:["v",h||r?.app.version||"-"]}),!$&&h&&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(J,{className:"w-3 h-3 mr-1"}),s("settings.systemInfo.upToDate")]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(X,{className:"w-4 h-4"}),"Node.js"]}),e.jsx("p",{className:"font-mono text-gray-900 dark:text-white",children:r?.runtime.nodeVersion||"-"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-1",children:s("settings.systemInfo.platform")}),e.jsxs("p",{className:"text-gray-900 dark:text-white capitalize",children:[r?.runtime.platform||"-"," (",r?.runtime.arch||"-",")"]})]})]}),r?.sdk&&e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-indigo-50 dark:from-blue-900/20 dark:to-indigo-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3 flex items-center gap-2",children:[e.jsx(p,{className:"w-4 h-4"}),"Agent SDK Configuration"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-blue-700 dark:text-blue-300 mb-1",children:"SDK Engine"}),e.jsxs("div",{className:"font-mono text-sm text-blue-900 dark:text-blue-100 font-medium",children:[r.sdk.engine==="claude-code"&&"🤖 Claude Code (Default)",r.sdk.engine==="claude-internal"&&"🔒 Claude Internal",r.sdk.engine==="code-buddy"&&"🤝 Code Buddy (Coming Soon)",!["claude-code","claude-internal","code-buddy"].includes(r.sdk.engine)&&r.sdk.engine]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-blue-700 dark:text-blue-300 mb-1",children:"SDK Directory"}),e.jsx("div",{className:"font-mono text-xs text-blue-900 dark:text-blue-100 break-all",children:r.sdk.directory})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:[e.jsxs("a",{href:r?.links.github||"https://github.com/okguitar/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-sm",children:[e.jsx(Z,{className:"w-4 h-4 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"GitHub"})]}),e.jsxs("a",{href:r?.links.releases||"https://github.com/okguitar/agentstudio/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-sm",children:[e.jsx(c,{className:"w-4 h-4 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Releases"})]}),e.jsxs("a",{href:r?.links.changelog||"https://github.com/okguitar/agentstudio/blob/main/CHANGELOG.md",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-sm",children:[e.jsx(ee,{className:"w-4 h-4 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Changelog"})]}),e.jsxs("a",{href:r?.links.npm||"https://www.npmjs.com/package/agentstudio",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-sm",children:[e.jsx(c,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"npm"})]})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:`${a?"p-4":"p-6"}`,children:[e.jsxs("h2",{className:`${a?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2`,children:[e.jsx(j,{className:"w-5 h-5"}),s("settings.telemetry.title","Telemetry & Analytics")]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${l?"bg-blue-100 dark:bg-blue-900/30":"bg-gray-100 dark:bg-gray-700"}`,children:e.jsx(j,{className:`w-5 h-5 ${l?"text-blue-600 dark:text-blue-400":"text-gray-500"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium 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",children:s("settings.telemetry.enableDescription","Help improve AgentStudio by sharing anonymous usage data")})]})]}),e.jsx("button",{onClick:L,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${l?"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 ${l?"translate-x-6":"translate-x-1"}`})})]})]}),e.jsx("div",{className:`px-4 py-2 border-t ${l?"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:l?e.jsxs(e.Fragment,{children:[e.jsx(f,{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(se,{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("details",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("summary",{className:"px-4 py-3 cursor-pointer text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 flex items-center gap-2",children:[e.jsx(N,{className:"w-4 h-4"}),s("settings.telemetry.privacyDetails","Privacy & Data Collection Details")]}),e.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium text-gray-900 dark:text-white mb-2 flex items-center gap-2 text-sm",children:[e.jsx(f,{className:"w-4 h-4 text-green-500"}),s("settings.telemetry.whatWeCollect","What We Collect")]}),e.jsxs("ul",{className:"space-y-1 text-xs text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"✓"}),s("settings.telemetry.collect.installId","Anonymous Installation ID")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"✓"}),s("settings.telemetry.collect.version","App Version & OS")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"✓"}),s("settings.telemetry.collect.features","Feature Usage")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-green-500",children:"✓"}),s("settings.telemetry.collect.errors","Error Reports")]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium text-gray-900 dark:text-white mb-2 flex items-center gap-2 text-sm",children:[e.jsx(N,{className:"w-4 h-4 text-red-500"}),s("settings.telemetry.whatWeNeverCollect","What We Never Collect")]}),e.jsxs("ul",{className:"space-y-1 text-xs text-gray-600 dark:text-gray-300",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-red-500",children:"✗"}),s("settings.telemetry.neverCollect.files","File contents, code, or project data")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-red-500",children:"✗"}),s("settings.telemetry.neverCollect.keys","API keys, passwords, or credentials")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-red-500",children:"✗"}),s("settings.telemetry.neverCollect.pii","Personal identifying information")]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-red-500",children:"✗"}),s("settings.telemetry.neverCollect.conversations","Chat conversations or AI responses")]})]})]})]})]})]})]})};export{ce as GeneralSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as h}from"./monaco-editor-BWfQfpij.js";import{u as O,b as Q,c as b,a as p,A as y}from"./agents-KlPdWQ8K.js";import{T as K,a as A,b as T,c,d as B,e as m}from"./table-Clz57edU.js";import{e as J}from"./index-f67nhEoX.js";import{N as z}from"./EngineGate-BjHJu955.js";import{V as G,j as L,v as V,al as W,ag as X,G as Y,e as F,T as E,m as Z,C as ee,n as te,J as re,y as ae}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./tools-BZTR2NP1.js";const _={PreToolUse:"工具执行前",PostToolUse:"工具成功执行后",PostToolUseFailure:"工具执行失败后",PermissionRequest:"请求权限时",SessionStart:"会话开始时",UserPromptSubmit:"用户提交提示时",Notification:"显示通知时"};async function se(l){const a=await p(`${y}/hooks`);if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to fetch hooks")}return a.json()}async function ne(l,n){const a=await p(`${y}/hooks?scope=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to create hook")}return a.json()}async function q(l,n){const a=await p(`${y}/hooks/${encodeURIComponent(l)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to update hook")}return a.json()}async function oe(l){const n=await p(`${y}/hooks/${encodeURIComponent(l)}`,{method:"DELETE"});if(!n.ok){const a=await n.json();throw new Error(a.error||"Failed to delete hook")}}const be=()=>{const{isCursorEngine:l,isFeatureSupported:n}=J(),a=O(),[d,i]=h.useState(!1),[u,x]=h.useState(null),[w,j]=h.useState(null),[r,o]=h.useState({event:"PreToolUse",command:"",scope:"global",toolName:"",pathPattern:"",enabled:!0,timeout:""}),C=n("hooks"),{data:$,isLoading:U,error:f,refetch:D}=Q({queryKey:["hooks"],queryFn:()=>se(),enabled:C}),P=$?.hooks||[],k=b({mutationFn:t=>ne(t,r.scope),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),i(!1),g()}}),N=b({mutationFn:({id:t,data:s})=>q(t,s),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),i(!1),x(null),g()}}),v=b({mutationFn:oe,onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),j(null)}}),S=b({mutationFn:({id:t,enabled:s})=>q(t,{enabled:s}),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]})}}),g=()=>{o({event:"PreToolUse",command:"",scope:"global",toolName:"",pathPattern:"",enabled:!0,timeout:""})},R=t=>{x(t);const[s]=t.id.split(":");o({event:t.event,command:t.command,scope:s,toolName:t.matcher?.tool_name||t.matcher?.tool_names?.join(", ")||"",pathPattern:t.matcher?.path_pattern||"",enabled:t.enabled,timeout:t.timeout?.toString()||""}),i(!0)},I=t=>{t.preventDefault();const s=r.toolName||r.pathPattern?{...r.toolName&&{tool_names:r.toolName.split(",").map(M=>M.trim()).filter(Boolean)},...r.pathPattern&&{path_pattern:r.pathPattern}}:void 0,H={event:r.event,command:r.command,matcher:s,enabled:r.enabled,timeout:r.timeout?parseInt(r.timeout,10):void 0};u?N.mutate({id:u.id,data:H}):k.mutate(H)};return l||!C?e.jsx("div",{className:"p-6",children:e.jsx(z,{feature:"Hooks",description:"Hooks 是 Claude Code 特有的功能,Cursor 不支持此功能。"})}):U?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx(G,{className:"w-8 h-8 animate-spin text-blue-500"})}):f?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-700 dark:text-red-400",children:[e.jsx(L,{className:"w-5 h-5"}),e.jsxs("span",{children:["加载失败: ",f instanceof Error?f.message:"未知错误"]})]}),e.jsx("button",{onClick:()=>D(),className:"mt-2 text-sm text-red-600 hover:text-red-700 dark:text-red-400",children:"重试"})]})}):e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Hooks"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"管理 Claude Code 钩子 - 在特定事件触发时自动执行的命令"})]}),e.jsxs("button",{onClick:()=>{x(null),g(),i(!0)},className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(V,{className:"w-4 h-4"}),e.jsx("span",{children:"添加 Hook"})]})]})}),P.length===0?e.jsxs("div",{className:"text-center py-12 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx(W,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"暂无 Hooks"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:"创建第一个 Hook 开始自动化工作流"}),e.jsx("button",{onClick:()=>{x(null),g(),i(!0)},className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"添加 Hook"})]}):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(K,{children:[e.jsx(A,{children:e.jsxs(T,{children:[e.jsx(c,{children:"事件"}),e.jsx(c,{children:"范围"}),e.jsx(c,{children:"命令"}),e.jsx(c,{children:"匹配器"}),e.jsx(c,{children:"状态"}),e.jsx(c,{className:"text-right",children:"操作"})]})}),e.jsx(B,{children:P.map(t=>{const[s]=t.id.split(":");return e.jsxs(T,{children:[e.jsx(m,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.event}),e.jsx("div",{className:"text-xs text-gray-500",children:_[t.event]})]})]})}),e.jsx(m,{children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs ${s==="global"?"bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300":"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300"}`,children:[s==="global"?e.jsx(Y,{className:"w-3 h-3"}):e.jsx(F,{className:"w-3 h-3"}),s==="global"?"全局":"本地"]})}),e.jsx(m,{children:e.jsx("code",{className:"text-sm bg-gray-100 dark:bg-gray-700 px-2 py-1 rounded max-w-xs truncate block",children:t.command})}),e.jsxs(m,{className:"text-sm text-gray-500 dark:text-gray-400",children:[t.matcher?e.jsxs("div",{className:"space-y-1",children:[t.matcher.tool_name&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(E,{className:"w-3 h-3"}),t.matcher.tool_name]}),t.matcher.tool_names&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(E,{className:"w-3 h-3"}),t.matcher.tool_names.join(", ")]}),t.matcher.path_pattern&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.matcher.path_pattern]})]}):"-",t.timeout&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(Z,{className:"w-3 h-3"}),t.timeout,"ms"]})]}),e.jsx(m,{children:e.jsx("button",{onClick:()=>S.mutate({id:t.id,enabled:!t.enabled}),disabled:S.isPending,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs transition-colors ${t.enabled?"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/50 dark:text-green-300":"bg-gray-100 text-gray-500 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-400"}`,children:t.enabled?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-3 h-3"}),"启用"]}):e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-3 h-3"}),"禁用"]})})}),e.jsx(m,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>R(t),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:"编辑",children:e.jsx(re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>j(t),className:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded transition-colors",title:"删除",children:e.jsx(ae,{className:"w-4 h-4"})})]})})]},t.id)})})]})}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx("div",{className:"p-6 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white",children:u?"编辑 Hook":"创建 Hook"})}),e.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"事件类型"}),e.jsx("select",{value:r.event,onChange:t=>o({...r,event:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",children:Object.entries(_).map(([t,s])=>e.jsxs("option",{value:t,children:[t," - ",s]},t))})]}),!u&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"范围"}),e.jsxs("select",{value:r.scope,onChange:t=>o({...r,scope:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"global",children:"全局 (~/.claude/settings.json)"}),e.jsx("option",{value:"local",children:"本地 (.claude/settings.local.json)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"命令"}),e.jsx("input",{type:"text",value:r.command,onChange:t=>o({...r,command:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white font-mono",placeholder:"echo 'Hook triggered!'",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"将在事件触发时执行的 shell 命令"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"工具匹配 (可选)"}),e.jsx("input",{type:"text",value:r.toolName,onChange:t=>o({...r,toolName:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"Read, Write, Shell"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"多个工具用逗号分隔"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"路径匹配 (可选)"}),e.jsx("input",{type:"text",value:r.pathPattern,onChange:t=>o({...r,pathPattern:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"**/*.ts"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"超时 (毫秒, 可选)"}),e.jsx("input",{type:"number",value:r.timeout,onChange:t=>o({...r,timeout:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"5000",min:"0"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:r.enabled,onChange:t=>o({...r,enabled:t.target.checked}),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("label",{htmlFor:"enabled",className:"text-sm text-gray-700 dark:text-gray-300",children:"启用此 Hook"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>{i(!1),x(null),g()},className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:"取消"}),e.jsx("button",{type:"submit",disabled:k.isPending||N.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:k.isPending||N.isPending?"保存中...":"保存"})]})]})]})}),w&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-4",children:"确认删除"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"确定要删除此 Hook 吗?此操作无法撤销。"}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>j(null),className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:"取消"}),e.jsx("button",{onClick:()=>v.mutate(w.id),disabled:v.isPending,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50",children:v.isPending?"删除中...":"删除"})]})]})})]})};export{be as HooksPage};
|
|
1
|
+
import{j as e}from"./data-structures-ChC1tqVg.js";import{r as h}from"./monaco-editor-BWfQfpij.js";import{u as O,b as Q,c as b,a as p,A as y}from"./agents-DR9EZMs5.js";import{T as K,a as A,b as T,c,d as B,e as m}from"./table-BgVewkB5.js";import{e as J}from"./index-BIGPvi1D.js";import{N as z}from"./EngineGate-DYNvEEbW.js";import{V as G,j as L,v as V,al as W,ag as X,G as Y,e as F,T as E,m as Z,C as ee,n as te,J as re,y as ae}from"./ui-components-D1pZO0y-.js";import"./syntax-highlighting-DGbNjS3S.js";import"./tools-crrPnehB.js";const _={PreToolUse:"工具执行前",PostToolUse:"工具成功执行后",PostToolUseFailure:"工具执行失败后",PermissionRequest:"请求权限时",SessionStart:"会话开始时",UserPromptSubmit:"用户提交提示时",Notification:"显示通知时"};async function se(l){const a=await p(`${y}/hooks`);if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to fetch hooks")}return a.json()}async function ne(l,n){const a=await p(`${y}/hooks?scope=${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to create hook")}return a.json()}async function q(l,n){const a=await p(`${y}/hooks/${encodeURIComponent(l)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok){const d=await a.json();throw new Error(d.error||"Failed to update hook")}return a.json()}async function oe(l){const n=await p(`${y}/hooks/${encodeURIComponent(l)}`,{method:"DELETE"});if(!n.ok){const a=await n.json();throw new Error(a.error||"Failed to delete hook")}}const be=()=>{const{isCursorEngine:l,isFeatureSupported:n}=J(),a=O(),[d,i]=h.useState(!1),[u,x]=h.useState(null),[w,j]=h.useState(null),[r,o]=h.useState({event:"PreToolUse",command:"",scope:"global",toolName:"",pathPattern:"",enabled:!0,timeout:""}),C=n("hooks"),{data:$,isLoading:U,error:f,refetch:D}=Q({queryKey:["hooks"],queryFn:()=>se(),enabled:C}),P=$?.hooks||[],k=b({mutationFn:t=>ne(t,r.scope),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),i(!1),g()}}),N=b({mutationFn:({id:t,data:s})=>q(t,s),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),i(!1),x(null),g()}}),v=b({mutationFn:oe,onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]}),j(null)}}),S=b({mutationFn:({id:t,enabled:s})=>q(t,{enabled:s}),onSuccess:()=>{a.invalidateQueries({queryKey:["hooks"]})}}),g=()=>{o({event:"PreToolUse",command:"",scope:"global",toolName:"",pathPattern:"",enabled:!0,timeout:""})},R=t=>{x(t);const[s]=t.id.split(":");o({event:t.event,command:t.command,scope:s,toolName:t.matcher?.tool_name||t.matcher?.tool_names?.join(", ")||"",pathPattern:t.matcher?.path_pattern||"",enabled:t.enabled,timeout:t.timeout?.toString()||""}),i(!0)},I=t=>{t.preventDefault();const s=r.toolName||r.pathPattern?{...r.toolName&&{tool_names:r.toolName.split(",").map(M=>M.trim()).filter(Boolean)},...r.pathPattern&&{path_pattern:r.pathPattern}}:void 0,H={event:r.event,command:r.command,matcher:s,enabled:r.enabled,timeout:r.timeout?parseInt(r.timeout,10):void 0};u?N.mutate({id:u.id,data:H}):k.mutate(H)};return l||!C?e.jsx("div",{className:"p-6",children:e.jsx(z,{feature:"Hooks",description:"Hooks 是 Claude Code 特有的功能,Cursor 不支持此功能。"})}):U?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx(G,{className:"w-8 h-8 animate-spin text-blue-500"})}):f?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-700 dark:text-red-400",children:[e.jsx(L,{className:"w-5 h-5"}),e.jsxs("span",{children:["加载失败: ",f instanceof Error?f.message:"未知错误"]})]}),e.jsx("button",{onClick:()=>D(),className:"mt-2 text-sm text-red-600 hover:text-red-700 dark:text-red-400",children:"重试"})]})}):e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Hooks"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"管理 Claude Code 钩子 - 在特定事件触发时自动执行的命令"})]}),e.jsxs("button",{onClick:()=>{x(null),g(),i(!0)},className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[e.jsx(V,{className:"w-4 h-4"}),e.jsx("span",{children:"添加 Hook"})]})]})}),P.length===0?e.jsxs("div",{className:"text-center py-12 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx(W,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"暂无 Hooks"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-4",children:"创建第一个 Hook 开始自动化工作流"}),e.jsx("button",{onClick:()=>{x(null),g(),i(!0)},className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"添加 Hook"})]}):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(K,{children:[e.jsx(A,{children:e.jsxs(T,{children:[e.jsx(c,{children:"事件"}),e.jsx(c,{children:"范围"}),e.jsx(c,{children:"命令"}),e.jsx(c,{children:"匹配器"}),e.jsx(c,{children:"状态"}),e.jsx(c,{className:"text-right",children:"操作"})]})}),e.jsx(B,{children:P.map(t=>{const[s]=t.id.split(":");return e.jsxs(T,{children:[e.jsx(m,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-4 h-4 text-blue-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.event}),e.jsx("div",{className:"text-xs text-gray-500",children:_[t.event]})]})]})}),e.jsx(m,{children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs ${s==="global"?"bg-purple-100 text-purple-700 dark:bg-purple-900/50 dark:text-purple-300":"bg-green-100 text-green-700 dark:bg-green-900/50 dark:text-green-300"}`,children:[s==="global"?e.jsx(Y,{className:"w-3 h-3"}):e.jsx(F,{className:"w-3 h-3"}),s==="global"?"全局":"本地"]})}),e.jsx(m,{children:e.jsx("code",{className:"text-sm bg-gray-100 dark:bg-gray-700 px-2 py-1 rounded max-w-xs truncate block",children:t.command})}),e.jsxs(m,{className:"text-sm text-gray-500 dark:text-gray-400",children:[t.matcher?e.jsxs("div",{className:"space-y-1",children:[t.matcher.tool_name&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(E,{className:"w-3 h-3"}),t.matcher.tool_name]}),t.matcher.tool_names&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(E,{className:"w-3 h-3"}),t.matcher.tool_names.join(", ")]}),t.matcher.path_pattern&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),t.matcher.path_pattern]})]}):"-",t.timeout&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(Z,{className:"w-3 h-3"}),t.timeout,"ms"]})]}),e.jsx(m,{children:e.jsx("button",{onClick:()=>S.mutate({id:t.id,enabled:!t.enabled}),disabled:S.isPending,className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs transition-colors ${t.enabled?"bg-green-100 text-green-700 hover:bg-green-200 dark:bg-green-900/50 dark:text-green-300":"bg-gray-100 text-gray-500 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-400"}`,children:t.enabled?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-3 h-3"}),"启用"]}):e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"w-3 h-3"}),"禁用"]})})}),e.jsx(m,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>R(t),className:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded transition-colors",title:"编辑",children:e.jsx(re,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>j(t),className:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded transition-colors",title:"删除",children:e.jsx(ae,{className:"w-4 h-4"})})]})})]},t.id)})})]})}),d&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx("div",{className:"p-6 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white",children:u?"编辑 Hook":"创建 Hook"})}),e.jsxs("form",{onSubmit:I,className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"事件类型"}),e.jsx("select",{value:r.event,onChange:t=>o({...r,event:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",children:Object.entries(_).map(([t,s])=>e.jsxs("option",{value:t,children:[t," - ",s]},t))})]}),!u&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"范围"}),e.jsxs("select",{value:r.scope,onChange:t=>o({...r,scope:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"global",children:"全局 (~/.claude/settings.json)"}),e.jsx("option",{value:"local",children:"本地 (.claude/settings.local.json)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"命令"}),e.jsx("input",{type:"text",value:r.command,onChange:t=>o({...r,command:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white font-mono",placeholder:"echo 'Hook triggered!'",required:!0}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"将在事件触发时执行的 shell 命令"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"工具匹配 (可选)"}),e.jsx("input",{type:"text",value:r.toolName,onChange:t=>o({...r,toolName:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"Read, Write, Shell"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"多个工具用逗号分隔"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"路径匹配 (可选)"}),e.jsx("input",{type:"text",value:r.pathPattern,onChange:t=>o({...r,pathPattern:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"**/*.ts"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"超时 (毫秒, 可选)"}),e.jsx("input",{type:"number",value:r.timeout,onChange:t=>o({...r,timeout:t.target.value}),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white",placeholder:"5000",min:"0"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"enabled",checked:r.enabled,onChange:t=>o({...r,enabled:t.target.checked}),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("label",{htmlFor:"enabled",className:"text-sm text-gray-700 dark:text-gray-300",children:"启用此 Hook"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:()=>{i(!1),x(null),g()},className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:"取消"}),e.jsx("button",{type:"submit",disabled:k.isPending||N.isPending,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50",children:k.isPending||N.isPending?"保存中...":"保存"})]})]})]})}),w&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900 dark:text-white mb-4",children:"确认删除"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:"确定要删除此 Hook 吗?此操作无法撤销。"}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx("button",{onClick:()=>j(null),className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:"取消"}),e.jsx("button",{onClick:()=>v.mutate(w.id),disabled:v.isPending,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50",children:v.isPending?"删除中...":"删除"})]})]})})]})};export{be as HooksPage};
|