agent-tower 0.6.0-beta.0 → 0.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/executors/__tests__/providers-availability.test.js +18 -1
- package/dist/executors/__tests__/providers-availability.test.js.map +1 -1
- package/dist/executors/index.js +2 -2
- package/dist/executors/index.js.map +1 -1
- package/dist/routes/__tests__/providers.test.js +16 -0
- package/dist/routes/__tests__/providers.test.js.map +1 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +12 -5
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/system.d.ts.map +1 -1
- package/dist/routes/system.js +1 -7
- package/dist/routes/system.js.map +1 -1
- package/dist/runtime/__tests__/acp-agent-definitions.test.js +7 -0
- package/dist/runtime/__tests__/acp-agent-definitions.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-driver-cleanup.test.js +3 -1
- package/dist/runtime/__tests__/acp-driver-cleanup.test.js.map +1 -1
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.js +241 -0
- package/dist/runtime/__tests__/acp-driver-lifecycle.test.js.map +1 -0
- package/dist/runtime/__tests__/acp-history-reconciler.test.d.ts +2 -0
- package/dist/runtime/__tests__/acp-history-reconciler.test.d.ts.map +1 -0
- package/dist/runtime/__tests__/acp-history-reconciler.test.js +69 -0
- package/dist/runtime/__tests__/acp-history-reconciler.test.js.map +1 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.js +41 -0
- package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
- package/dist/runtime/acp/acp-driver.d.ts.map +1 -1
- package/dist/runtime/acp/acp-driver.js +61 -26
- package/dist/runtime/acp/acp-driver.js.map +1 -1
- package/dist/runtime/acp/agents/codex.d.ts.map +1 -1
- package/dist/runtime/acp/agents/codex.js +2 -0
- package/dist/runtime/acp/agents/codex.js.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.d.ts.map +1 -1
- package/dist/runtime/acp/agents/pi-coding-agent.js +6 -4
- package/dist/runtime/acp/agents/pi-coding-agent.js.map +1 -1
- package/dist/runtime/acp/history-reconciler.d.ts +8 -0
- package/dist/runtime/acp/history-reconciler.d.ts.map +1 -0
- package/dist/runtime/acp/history-reconciler.js +82 -0
- package/dist/runtime/acp/history-reconciler.js.map +1 -0
- package/dist/runtime/contracts.d.ts +4 -0
- package/dist/runtime/contracts.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.d.ts +2 -1
- package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
- package/dist/runtime/runtime-coordinator.js +27 -7
- package/dist/runtime/runtime-coordinator.js.map +1 -1
- package/dist/services/__tests__/session-manager.lifecycle.test.js +4 -2
- package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
- package/dist/services/__tests__/session-manager.team-run.test.js +6 -0
- package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
- package/dist/services/mcp-config.integration.test.d.ts +2 -0
- package/dist/services/mcp-config.integration.test.d.ts.map +1 -0
- package/dist/services/mcp-config.integration.test.js +75 -0
- package/dist/services/mcp-config.integration.test.js.map +1 -0
- package/dist/services/mcp-config.service.d.ts +10 -3
- package/dist/services/mcp-config.service.d.ts.map +1 -1
- package/dist/services/mcp-config.service.js +70 -18
- package/dist/services/mcp-config.service.js.map +1 -1
- package/dist/services/mcp-config.service.test.js +44 -13
- package/dist/services/mcp-config.service.test.js.map +1 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +27 -9
- package/dist/services/session-manager.js.map +1 -1
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +1 -3
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +2 -17
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/agent-icons/codex.svg +4 -1
- package/dist/web/agent-icons/grok-build.svg +5 -0
- package/dist/web/agent-icons/kiro-cli.svg +6 -0
- package/dist/web/agent-icons/opencode.svg +5 -0
- package/dist/web/agent-icons/pi-coding-agent.svg +5 -0
- package/dist/web/agent-icons/qwen-code.svg +13 -0
- package/dist/web/assets/{AgentDemoPage-BpUO2gR6.js → AgentDemoPage-XrttOpQW.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-CSBMaAvL.js → AgentEnvironmentSettingsPage-CAo0bCpZ.js} +1 -1
- package/dist/web/assets/{AgentLogo-C190Z6bw.js → AgentLogo-BCwbooTN.js} +1 -1
- package/dist/web/assets/{ConversationPage-Cer_WtdC.js → ConversationPage-kyHuICil.js} +1 -1
- package/dist/web/assets/{CreateTaskInput-ByeWDjc8.js → CreateTaskInput-B67vzMJD.js} +1 -1
- package/dist/web/assets/{DemoPage-Dpb9aAKX.js → DemoPage-DHMh9-zU.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-TqbAsCZM.js → GeneralSettingsPage-DvWaqR9O.js} +1 -1
- package/dist/web/assets/{Icons-CyNNz4Z5.js → Icons-DADUmnB1.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-DmH1TGln.js → LoadingPreviewPage-Dk91Ua1W.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-z1_NcsMR.js → McpSettingsPage-CH8jFyxp.js} +1 -1
- package/dist/web/assets/{MemberAvatar-BPoYS6Il.js → MemberAvatar-l-WCdlLA.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-CNsRJ6nN.js → NotificationSettingsPage-Byu8b9X3.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-g1RKcEbo.js → ProfileSettingsPage-BdylqWUj.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-j2v5fLfg.js → ProjectKanbanPage--cx6wNDR.js} +3 -3
- package/dist/web/assets/{ProjectSettingsPage-Cp89NvwE.js → ProjectSettingsPage-6psG0Vfc.js} +1 -1
- package/dist/web/assets/ProviderSettingsPage-BPEEkhtA.js +93 -0
- package/dist/web/assets/{SettingsMasterDetail-BYB-1oyf.js → SettingsMasterDetail-DTGIIGdI.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-Y2zCVbVD.js → TeamSettingsPage-BXuG4Bou.js} +1 -1
- package/dist/web/assets/{arc-BmDnqN7Q.js → arc-DrcjdWTE.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BIG4K9gT.js → architectureDiagram-3BPJPVTR-CAoBhXSL.js} +1 -1
- package/dist/web/assets/{arrow-left-CB4qTjQs.js → arrow-left-CCWDjOmp.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-CowveYw0.js → blockDiagram-GPEHLZMM-CcTSBbUq.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-CLjbYgNG.js → c4Diagram-AAUBKEIU-BuUKdgUg.js} +1 -1
- package/dist/web/assets/channel-Bh_PCZNP.js +1 -0
- package/dist/web/assets/check-BN_PVKzE.js +1 -0
- package/dist/web/assets/{chevron-down-BXYCSpWd.js → chevron-down-BQcW9sFf.js} +1 -1
- package/dist/web/assets/{chevron-right-CkcSaX8x.js → chevron-right-pH923eYp.js} +1 -1
- package/dist/web/assets/{chevron-up-Y8L6pbzc.js → chevron-up-DyQW115F.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DRf_miP4.js → chunk-2J33WTMH-BWNSmQa8.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-C6Ne_vwR.js → chunk-4BX2VUAB-Blldhw0k.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-DejCglMr.js → chunk-55IACEB6-hTffyPXL.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-B0MC9Ojc.js → chunk-727SXJPM-Cd48r7c-.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-D9f4hbMX.js → chunk-AQP2D5EJ-BdDrOIL7.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-k90hkOQq.js → chunk-FMBD7UC4-6XIvQYVJ.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-CX2-qxPx.js → chunk-ND2GUHAM-BJlcb_pB.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-CpFs7UD0.js → chunk-QZHKN3VN-3TZzFkxK.js} +1 -1
- package/dist/web/assets/{circle-alert-ClX4sQ2K.js → circle-alert-oa-BQ5e7.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-B0lQFDoP.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-B0lQFDoP.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-_lkU1VUC.js → code-block-OCS4YCEC-xJQWFyR7.js} +1 -1
- package/dist/web/assets/{confirm-dialog-BJwzwwOk.js → confirm-dialog-CRiC3xBd.js} +1 -1
- package/dist/web/assets/{copy-jQAntc98.js → copy-DaoAUKTO.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-CLWAfEVg.js → cose-bilkent-S5V4N54A-Cjcm-rW_.js} +1 -1
- package/dist/web/assets/{cssMode-q0rL0Hjc.js → cssMode-_D6u4YDd.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-DKviWU-X.js → dagre-BM42HDAG-YqubcAJi.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-L6emXRJ1.js → diagram-2AECGRRQ-Dk4ayFqg.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-CXGUerks.js → diagram-5GNKFQAL-CQ0joYfB.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-C8FHXqeH.js → diagram-KO2AKTUF-DmuZzIdW.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-Cng_aa5j.js → diagram-LMA3HP47-YTPEfEZy.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-BEC6IDf4.js → diagram-OG6HWLK6-DmwRuz8-.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-BWMCTdYK.js → erDiagram-TEJ5UH35-LRL_DMXa.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-aAEYIyx2.js → flowDiagram-I6XJVG4X-ELBDyOvk.js} +1 -1
- package/dist/web/assets/{folder-picker-CioQjSzV.js → folder-picker-WUhXxIM5.js} +1 -1
- package/dist/web/assets/{freemarker2-DZgAIr6s.js → freemarker2-DxJFkRz5.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-DVqWnwcH.js → ganttDiagram-6RSMTGT7-D0e9ILuF.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-BVWrTXBv.js → gitGraphDiagram-PVQCEYII-Ck6OXXw0.js} +1 -1
- package/dist/web/assets/{handlebars-9RRQrLUb.js → handlebars-djdO6ZKR.js} +1 -1
- package/dist/web/assets/{html-BVI4F9TT.js → html-CHeBxmFi.js} +1 -1
- package/dist/web/assets/{htmlMode-t0djrjSv.js → htmlMode-SZh8FaPi.js} +1 -1
- package/dist/web/assets/{index-Da9mzleR.js → index-CjdqAcbu.js} +4 -4
- package/dist/web/assets/{index-RYlllU6n.js → index-D9kBRMR0.js} +3 -3
- package/dist/web/assets/{infoDiagram-5YYISTIA-DYG1ew4x.js → infoDiagram-5YYISTIA-Cx8be-MV.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-COBW1j3-.js → ishikawaDiagram-YF4QCWOH-Dlc7akl7.js} +1 -1
- package/dist/web/assets/javascript-l6fV6hf7.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-BI_FlncW.js → journeyDiagram-JHISSGLW-BVDSbS9-.js} +1 -1
- package/dist/web/assets/{jsonMode-A5wuW-PC.js → jsonMode-B5CJhoWd.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-BKrHEd7r.js → kanban-definition-UN3LZRKU-nFR0zB7B.js} +1 -1
- package/dist/web/assets/{layers-BZMh9pqm.js → layers-Bo4aml98.js} +1 -1
- package/dist/web/assets/{linear-DyoMQJGq.js → linear-BCWZjcpP.js} +1 -1
- package/dist/web/assets/{liquid-HXqG_RIQ.js → liquid-DkFOeJ6J.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-s3xWnrXc.js → lspLanguageFeatures-Cbk7wEkj.js} +1 -1
- package/dist/web/assets/{mdx-k_7JTYp2.js → mdx-BOPNdexu.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-orMHhlAj.js → mermaid-NOHMQCX5-DWQaYVL0.js} +45 -45
- package/dist/web/assets/{message-square-CStQg7sr.js → message-square-DxbkpGqF.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CKOIIjUJ.js → mindmap-definition-RKZ34NQL-LI7W1FIX.js} +1 -1
- package/dist/web/assets/{modal-ZYdX5Krr.js → modal-Cymk-6Df.js} +1 -1
- package/dist/web/assets/{monaco-DX9iObLO.js → monaco-Bc-Z2u8N.js} +3 -3
- package/dist/web/assets/{pencil-DoB4p30x.js → pencil-DOL2nlgg.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-BW18kL8l.js → pieDiagram-4H26LBE5-mgUzAFkk.js} +1 -1
- package/dist/web/assets/{python-abx8p9WS.js → python-D_wlYLCL.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-Df_F1INR.js → quadrantDiagram-W4KKPZXB-CaDF2kqA.js} +1 -1
- package/dist/web/assets/{razor-DGdDlX86.js → razor-DBFVg4JU.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-De6R8t8O.js → requirementDiagram-4Y6WPE33-DhmHdr_0.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-ChlLeN5m.js → sankeyDiagram-5OEKKPKP-B7qnGfue.js} +1 -1
- package/dist/web/assets/{select-B9kjO67b.js → select-BpKQyMvD.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CPVnbcvz.js → sequenceDiagram-3UESZ5HK-D2LhPgpM.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-BFS1G-aJ.js → stateDiagram-AJRCARHV-ClkO4Gu5.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-YnSeSD_N.js +1 -0
- package/dist/web/assets/{switch-C2r5pofB.js → switch-BJ4Ar_OA.js} +1 -1
- package/dist/web/assets/{textarea-BB3UoYxg.js → textarea-DjwjAAG8.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-C1Rgs32y.js → timeline-definition-PNZ67QCA-DhGIG-GC.js} +1 -1
- package/dist/web/assets/{trash-2-BNiAEW-6.js → trash-2-R46i6Uus.js} +1 -1
- package/dist/web/assets/{tsMode-DHruHjGh.js → tsMode-CKaqpIrz.js} +1 -1
- package/dist/web/assets/{typescript-SLYiKRhJ.js → typescript-DsixnGVt.js} +1 -1
- package/dist/web/assets/{upload-BLLmywZY.js → upload-CgWqsmdI.js} +1 -1
- package/dist/web/assets/{use-profiles-OJaV4lOv.js → use-profiles-BlGgvdYm.js} +1 -1
- package/dist/web/assets/{use-projects-D_Sq7ahS.js → use-projects-Cuv0A0RC.js} +1 -1
- package/dist/web/assets/{use-providers-SSHcslI-.js → use-providers-DLcAY6E1.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-DeA-fso_.js → useNormalizedLogs-tfxFAJOF.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-DLGPZTKg.js → vennDiagram-CIIHVFJN-BngQhsYJ.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-BVMPWfq9.js → wardley-L42UT6IY-BEY6sftT.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-_KXuEg6G.js → wardleyDiagram-YWT4CUSO-IH_Yh-cw.js} +1 -1
- package/dist/web/assets/{xml-BmreQojr.js → xml-dEcQ1gzo.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-a-Do3v5G.js → xychartDiagram-2RQKCTM6-BdrGFDsr.js} +1 -1
- package/dist/web/assets/{yaml-CJoLHuqv.js → yaml-BfGVqGj4.js} +1 -1
- package/dist/web/index.html +1 -1
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.d.ts +2 -0
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.js +5 -0
- package/node_modules/@agent-tower/shared/dist/agent-runtime-support.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/assets/ProviderSettingsPage-B-bBs2qN.js +0 -93
- package/dist/web/assets/channel-BsOpjSZw.js +0 -1
- package/dist/web/assets/check-BVOtZt28.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-KkLqUSdB.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-KkLqUSdB.js +0 -1
- package/dist/web/assets/javascript-DaUCpDvL.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DSxC8AfE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as X,o as he,n as ke,q as W,p as ce,m as Je,r,P as gt,Q as ae,u as ge,j as e,a3 as xe,l as k,ae as He,V as bt,D as vt,E as yt,W as Qe,X as Nt,z as wt,af as kt,ag as Ct}from"./index-RYlllU6n.js";import{S as Ve,T as Ae,R as ie,h as ye,W as L,u as jt,A as St}from"./mermaid-NOHMQCX5-orMHhlAj.js";import{A as pe}from"./AgentLogo-C190Z6bw.js";import{C as fe}from"./chevron-down-BXYCSpWd.js";import{C as se}from"./check-BVOtZt28.js";import{d as Tt,F as Et}from"./use-projects-D_Sq7ahS.js";import{M as Ye}from"./MemberAvatar-BPoYS6Il.js";import{u as Mt}from"./use-providers-SSHcslI-.js";import{P as It}from"./trash-2-BNiAEW-6.js";import{P as Rt}from"./useNormalizedLogs-DeA-fso_.js";const At=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_n=X("arrow-down",At);const Lt=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_t=X("arrow-up",Lt);const Dt=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ot=X("gauge",Dt);const Pt=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],zt=X("git-branch",Pt);const $t=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Dn=X("search",$t);const Ft=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],qt=X("shield-alert",Ft);const Gt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Wt=X("shield",Gt);const Bt=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],On=X("square-pen",Bt);const Ut=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Kt=X("zap",Ut);function et(t){const s=he(),a=Je({queryKey:W.sessions.runtime(t),queryFn:()=>ce.get(`/sessions/${t}/runtime`),enabled:!!t});return r.useEffect(()=>{if(!t)return;const o=gt.connect(),l=g=>{g.sessionId===t&&s.invalidateQueries({queryKey:W.sessions.runtime(t)})},u=g=>{g.sessionId===t&&s.setQueryData(W.sessions.runtime(t),g.state)},f=()=>{s.invalidateQueries({queryKey:W.sessions.runtime(t)})};return o.on(ae.SESSION_PERMISSION_REQUESTED,l),o.on(ae.SESSION_PERMISSION_INVALIDATED,l),o.on(ae.SESSION_RUNTIME_STATE_CHANGED,u),o.on("connect",f),()=>{o.off(ae.SESSION_PERMISSION_REQUESTED,l),o.off(ae.SESSION_PERMISSION_INVALIDATED,l),o.off(ae.SESSION_RUNTIME_STATE_CHANGED,u),o.off("connect",f)}},[t,s]),a}function Ht(t){return t==="RUNNING"||t==="AWAITING_PERMISSION"||t==="CANCELLING"}function Qt(t){return t===Ve.RUNNING||t===Ve.PENDING}function Pn(t,s){const{data:a}=et(t);return{runtimeState:a,isActive:Qt(s)||Ht(a?.turnState),isCancelling:a?.turnState==="CANCELLING"}}function Vt(){const t=he();return ke({mutationFn:({sessionId:s,requestId:a,optionId:o})=>ce.post(`/sessions/${s}/permissions/${a}/resolve`,{optionId:o}),onSettled:(s,a,o)=>{t.invalidateQueries({queryKey:W.sessions.runtime(o.sessionId)})}})}function zn(){const t=he();return ke({mutationFn:s=>ce.post(`/sessions/${s}/start`),onSuccess:(s,a)=>{t.invalidateQueries({queryKey:W.sessions.detail(a)}),t.invalidateQueries({queryKey:W.tasks.all})}})}function $n(){const t=he();return ke({mutationFn:s=>ce.post(`/sessions/${s}/stop`),onSuccess:(s,a)=>{t.invalidateQueries({queryKey:W.sessions.detail(a)})}})}function Fn(){const t=he();return ke({mutationFn:({id:s,message:a,providerId:o})=>ce.post(`/sessions/${s}/message`,{message:a,providerId:o}),onSuccess:()=>{t.invalidateQueries({queryKey:W.workspaces.all}),t.invalidateQueries({queryKey:W.tasks.all})}})}function qn({sessionId:t,compact:s=!1}){const{t:a}=ge(),{data:o}=et(t),l=Vt(),u=o?.pendingPermissions[0],f=u?.requestId,g=l.reset;return r.useEffect(()=>{g()},[f,g]),u?e.jsx("div",{className:k("mb-2 border-l-2 border-warning bg-warning/5 px-3 py-2.5",s&&"px-2.5 py-2"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(qt,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:a("Permission required")}),e.jsx("div",{className:"mt-0.5 break-words text-xs text-muted-foreground",children:u.toolSummary||u.toolName||a("The agent needs approval to continue.")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:u.options.map(x=>e.jsxs("button",{type:"button",disabled:l.isPending,onClick:()=>l.mutate({sessionId:t,requestId:u.requestId,optionId:x.optionId}),className:k("inline-flex min-h-8 items-center gap-1.5 border px-3 text-xs font-medium transition-colors disabled:opacity-50",x.kind.startsWith("reject")?"border-destructive/30 text-destructive hover:bg-destructive/10":"border-border bg-background text-foreground hover:bg-muted"),children:[l.isPending&&l.variables?.requestId===u.requestId&&l.variables.optionId===x.optionId?e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):null,x.name]},x.optionId))}),l.error?e.jsx("div",{className:"mt-1.5 text-xs text-destructive",role:"alert",children:l.error.message}):null]})]})}):null}function Ne(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Yt(t){return t>=.9?"text-red-500":t>=.7?"text-amber-500":"text-neutral-400"}function Gn({usage:t,tooltipSide:s="top"}){const{t:a}=ge();if(!t)return null;const o=t.modelContextWindow,l=o?t.totalTokens/o:0,u=o?Math.min(Math.round(l*100),100):null,f=o?Yt(l):"text-neutral-400",g=o?e.jsx("span",{children:a("上下文: {used} / {max} tokens",{used:Ne(t.totalTokens),max:Ne(o)})}):e.jsx("span",{children:a("已使用: {used} tokens",{used:Ne(t.totalTokens)})});return e.jsx(Ae,{content:g,side:s,children:e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[e.jsx(Ot,{size:14,className:f}),e.jsxs("span",{className:`tabular-nums ${f}`,children:[Ne(t.totalTokens),u!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",u,"%"]})]})]})})}const Xt={damping:.7,stiffness:.05,mass:1.25},Zt=70,Jt=1e3/60,en=350;let Ce=!1;globalThis.document?.addEventListener("mousedown",()=>{Ce=!0});globalThis.document?.addEventListener("mouseup",()=>{Ce=!1});globalThis.document?.addEventListener("click",()=>{Ce=!1});const Wn=(t={})=>{const[s,a]=r.useState(!1),[o,l]=r.useState(t.initial!==!1),[u,f]=r.useState(!1),g=r.useRef(null);g.current=t;const x=r.useCallback(()=>{if(!Ce)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const h=d.getRangeAt(0);return h.commonAncestorContainer.contains(p.current)||p.current?.contains(h.commonAncestorContainer)},[]),y=r.useCallback(d=>{n.isAtBottom=d,l(d)},[]),C=r.useCallback(d=>{n.escapedFromLock=d,a(d)},[]),n=r.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return p.current?.scrollTop??0},set scrollTop(h){p.current&&(p.current.scrollTop=h,n.ignoreScrollToTop=p.current.scrollTop)},get targetScrollTop(){return!p.current||!I.current?0:p.current.scrollHeight-1-p.current.clientHeight},get calculatedTargetScrollTop(){if(!p.current||!I.current)return 0;const{targetScrollTop:h}=this;if(!t.targetScrollTop)return h;if(d?.targetScrollTop===h)return d.calculatedScrollTop;const v=Math.max(Math.min(t.targetScrollTop(h,{scrollElement:p.current,contentElement:I.current}),h),0);return d={targetScrollTop:h,calculatedScrollTop:v},requestAnimationFrame(()=>{d=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Zt}}},[]),b=r.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||y(!0);const h=Date.now()+(Number(d.wait)||0),v=Re(g.current,d.animation),{ignoreEscapes:j=!1}=d;let S,M=n.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{S=Date.now()}):S=h+(d.duration??0);const A=async()=>{const B=new Promise(requestAnimationFrame).then(()=>{if(!n.isAtBottom)return n.animation=void 0,!1;const{scrollTop:D}=n,U=performance.now(),K=(U-(n.lastTick??U))/Jt;if(n.animation||(n.animation={behavior:v,promise:B,ignoreEscapes:j}),n.animation.behavior===v&&(n.lastTick=U),x()||h>Date.now())return A();if(D<Math.min(M,n.calculatedTargetScrollTop)){if(n.animation?.behavior===v){if(v==="instant")return n.scrollTop=n.calculatedTargetScrollTop,A();n.velocity=(v.damping*n.velocity+v.stiffness*n.scrollDifference)/v.mass,n.accumulated+=n.velocity*K,n.scrollTop+=n.accumulated,n.scrollTop!==D&&(n.accumulated=0)}return A()}return S>Date.now()?(M=n.calculatedTargetScrollTop,A()):(n.animation=void 0,n.scrollTop<n.calculatedTargetScrollTop?b({animation:Re(g.current,g.current.resize),ignoreEscapes:j,duration:Math.max(0,S-Date.now())||void 0}):n.isAtBottom)});return B.then(D=>(requestAnimationFrame(()=>{n.animation||(n.lastTick=void 0,n.velocity=0)}),D))};return d.wait!==!0&&(n.animation=void 0),n.animation?.behavior===v?n.animation.promise:A()},[y,x,n]),m=r.useCallback(()=>{C(!0),y(!1)},[C,y]),N=r.useCallback(({target:d})=>{if(d!==p.current)return;const{scrollTop:h,ignoreScrollToTop:v}=n;let{lastScrollTop:j=h}=n;n.lastScrollTop=h,n.ignoreScrollToTop=void 0,v&&v>h&&(j=v),f(n.isNearBottom),setTimeout(()=>{if(n.resizeDifference||h===v)return;if(x()){C(!0),y(!1);return}const S=h>j,M=h<j;if(n.animation?.ignoreEscapes){n.scrollTop=j;return}M&&(C(!0),y(!1)),S&&C(!1),!n.escapedFromLock&&n.isNearBottom&&y(!0)},1)},[C,y,x,n]),_=r.useCallback(({target:d,deltaY:h})=>{let v=d;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===p.current&&h<0&&p.current.scrollHeight>p.current.clientHeight&&!n.animation?.ignoreEscapes&&(C(!0),y(!1))},[C,y,n]),p=Xe(d=>{p.current?.removeEventListener("scroll",N),p.current?.removeEventListener("wheel",_),d?.addEventListener("scroll",N,{passive:!0}),d?.addEventListener("wheel",_,{passive:!0})},[]),I=Xe(d=>{if(n.resizeObserver?.disconnect(),!d)return;let h;n.resizeObserver=new ResizeObserver(([v])=>{const{height:j}=v.contentRect,S=j-(h??j);if(n.resizeDifference=S,n.scrollTop>n.targetScrollTop&&(n.scrollTop=n.targetScrollTop),f(n.isNearBottom),S>=0){const M=Re(g.current,h?g.current.resize:g.current.initial);b({animation:M,wait:!0,preserveScrollPosition:!0,duration:M==="instant"?void 0:en})}else n.isNearBottom&&(C(!1),y(!0));h=j,requestAnimationFrame(()=>{setTimeout(()=>{n.resizeDifference===S&&(n.resizeDifference=0)},1)})}),n.resizeObserver?.observe(d)},[]);return{contentRef:I,scrollRef:p,scrollToBottom:b,stopScroll:m,isAtBottom:o||u,isNearBottom:u,escapedFromLock:s,state:n}};function Xe(t,s){const a=r.useCallback(o=>(a.current=o,t(o)),s);return a}const Ie=new Map;function Re(...t){const s={...Xt};let a=!1;for(const l of t){if(l==="instant"){a=!0;continue}typeof l=="object"&&(a=!1,s.damping=l.damping??s.damping,s.stiffness=l.stiffness??s.stiffness,s.mass=l.mass??s.mass)}const o=JSON.stringify(s);return Ie.has(o)||Ie.set(o,Object.freeze(s)),a?"instant":Ie.get(o)}function Bn({providers:t,currentProviderId:s,agentType:a,runtimeType:o,onSelect:l}){const{t:u}=ge(),[f,g]=r.useState(!1),x=r.useRef(null),y=o===ie.ACP?ie.ACP:ie.CLI,C=t.filter(b=>String(b.provider.agentType)===a&&(b.provider.runtimeType===ie.ACP?ie.ACP:ie.CLI)===y),n=t.find(b=>b.provider.id===s);return r.useEffect(()=>{function b(m){x.current&&!x.current.contains(m.target)&&g(!1)}if(f)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[f]),C.length<=1?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[e.jsx(pe,{agentType:n?.provider.agentType??a,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?He(n.provider.name,12):a})]}):e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>g(!f),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${n?.provider.name??a} (click to change)`,children:[e.jsx(pe,{agentType:n?.provider.agentType??a,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?He(n.provider.name,12):a}),e.jsx(fe,{size:12,className:`shrink-0 transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:u("切换渠道")}),C.map(b=>e.jsxs("button",{onClick:()=>{l(b.provider.id),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${b.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(pe,{agentType:b.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:b.provider.name}),b.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:u("(默认)")})]}),b.provider.id===s&&e.jsx(se,{size:14,className:"shrink-0"})]},b.provider.id))]})]})}function Un(t,s){return r.useMemo(()=>{for(let a=t.length-1;a>=0;a--){const o=t[a];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[t,s])}function Ze(t,s,a,o){if(a.filter(f=>f===o).length<=1)return t;const u=a.slice(0,s+1).filter(f=>f===o).length;return`${t} #${u}`}function tn(t){return Object.values(t).filter(Boolean).length}function nn({mode:t,setMode:s,selectedTemplateId:a,setSelectedTemplateId:o,selectedMemberPresetIds:l,setSelectedMemberPresetIds:u,disabled:f=!1,compact:g=!1}){const{t:x}=ge(),{preserveDesktopSearch:y}=bt(),[C,n]=r.useState(!1),{data:b}=Mt(),{data:m,isError:N,isFetching:_,isLoading:p,refetch:I}=vt(),{data:d,isError:h,isFetching:v,isLoading:j,refetch:S}=yt(),M=r.useMemo(()=>new Map((b??[]).map(({provider:c,availability:w})=>[c.id,c.name+(w.type==="NOT_FOUND"?x(" (不可用)"):"")])),[b,x]),A=r.useMemo(()=>new Map((m??[]).map(c=>[c.id,c])),[m]),B=r.useMemo(()=>new Map((d??[]).map(c=>[c.id,c])),[d]),D=r.useMemo(()=>l.map(c=>A.get(c)).filter(c=>!!c),[A,l]);r.useEffect(()=>{m!==void 0&&u(c=>{const w=c.filter(z=>A.has(z));return w.length===c.length&&w.every((z,F)=>z===c[F])?c:w})},[m,A,u]),r.useEffect(()=>{d!==void 0&&o(c=>!c||B.has(c)?c:null)},[o,B,d]);const U=c=>{f||o(w=>w===c?null:c)},K=c=>{f||u(w=>[...w,c])},te=c=>{f||u(w=>w.filter((z,F)=>F!==c))},H=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:x("团队模板")}),h?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{S()},disabled:f||v,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):j?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(xe,{size:12,className:"animate-spin"}),x("加载中...")]}):(d??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[x("当前没有团队模板"),e.jsx(Qe,{to:y("/settings/team"),className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:k("space-y-1.5",g&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(d??[]).map(c=>{const w=c.id===a,z=c.members?.length??0,F=c.members?.map(V=>V.memberPresetId)??[],q=c.members?.slice(0,3).map((V,le)=>Ze(V.memberPreset?.name??V.memberPresetId,le,F,V.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>U(c.id),disabled:f,className:k("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",w?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:k("text-xs truncate",w?"font-medium text-foreground":"text-foreground"),children:c.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[z,x("人")]})]}),q&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:q})]}),w&&e.jsx(se,{size:13,className:"shrink-0 text-foreground"})]})},c.id)})})]}),ne=D.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:D.map((c,w)=>{const z=Ze(c.name,w,l,c.id);return e.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded-md border border-border/60 bg-background text-[10px] text-foreground",children:[e.jsx(Ye,{name:c.name,avatar:c.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:z}),e.jsx("button",{type:"button",onClick:()=>te(w),disabled:f,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Nt,{size:9})})]},`${c.id}-${w}`)})}),re=N?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{I()},disabled:f||_,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(xe,{size:12,className:"animate-spin"}),x("加载中...")]}):(m??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[x("当前没有成员预设"),e.jsx(Qe,{to:y("/settings/team"),className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(m??[]).map(c=>{const w=l.filter(q=>q===c.id).length,z=M.get(c.providerId)??c.providerId,F=tn(c.capabilities);return e.jsxs("button",{type:"button",onClick:()=>K(c.id),disabled:f,className:k("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",f&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(Ye,{name:c.name,avatar:c.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:c.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[z," · ",F,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[w>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",w]}),e.jsx(It,{size:12,className:"text-muted-foreground"})]})]},c.id)})}),Q=D.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-primary text-[10px] font-semibold text-primary-foreground px-1.5",children:D.length}),Z=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:x("执行模式")}),e.jsxs("div",{className:"inline-flex items-center h-7 rounded-md border border-border/70 bg-background p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&s("AUTO"),disabled:f,className:k("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Kt,{size:11}),x("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!f&&s("CONFIRM"),disabled:f,className:k("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Wt,{size:11}),x("确认模式")]})]})]});return g?e.jsxs("div",{className:"space-y-3",children:[Z,H,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&n(c=>!c),disabled:f,"aria-expanded":C,className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(fe,{size:12,className:k("transition-transform",C?"":"-rotate-90")}),x("追加独立成员"),Q]}),C&&e.jsxs("div",{className:"mt-2",children:[ne,re]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[Z,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[H,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:x("追加成员")}),Q]}),ne,re]})]})]})}function sn({commands:t,selectedIndex:s,query:a,hasCatalog:o,title:l="Slash Commands",queryPrefix:u="/",emptyCatalogMessage:f="No slash commands catalog for this agent yet.",emptyQueryMessage:g,insertionHint:x="Enter / Tab to insert",compact:y=!1,onSelect:C}){const n=y?"px-1.5 pb-1.5":"px-2 pb-2",b=y?"px-2 py-1.5":"px-2.5 py-2",m=y?"max-h-36":"max-h-48";return e.jsxs("div",{className:y?"pt-1.5":"pt-2",children:[e.jsxs("div",{className:`mb-1 flex items-center justify-between ${y?"px-2 pt-0.5":"px-3 pt-1"}`,children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:l}),e.jsx("span",{className:"text-[10px] text-neutral-400",children:x})]}),t.length===0?e.jsx("div",{className:`${y?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?g??`No matches for ${u}${a}`:f}):e.jsx("div",{className:`${n} ${m} overflow-y-auto`,children:t.map((N,_)=>e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>C(N),className:`w-full rounded-lg border text-left transition-colors ${_===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${b}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:N.command}),N.kind&&N.kind!=="builtin"?e.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:N.scope?`${N.scope} ${N.kind}`:N.kind}):null]}),e.jsx("div",{className:`${y?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:N.description})]},N.command))})]})}const ee=12,we=8;function rn({open:t,anchorRef:s,commands:a,selectedIndex:o,query:l,hasCatalog:u,title:f,queryPrefix:g,emptyCatalogMessage:x,emptyQueryMessage:y,insertionHint:C,compact:n=!1,onSelect:b}){const m=r.useRef(null),[N,_]=r.useState(null);return r.useLayoutEffect(()=>{if(!t){_(null);return}const p=s.current;if(!p)return;let I=0;const d=()=>{const j=s.current;if(!j)return;const S=j.getBoundingClientRect(),M=window.innerWidth,A=window.innerHeight,B=n?260:320,D=n?M-ee*2:560,U=Math.min(Math.max(S.width,B),Math.max(B,D)),K=Math.min(Math.max(ee,S.left),Math.max(ee,M-ee-U)),te=A-S.bottom-we-ee,H=S.top-we-ee,ne=m.current?.offsetHeight??(n?220:280),re=n?240:320,Q=te<180&&H>te,c=Math.max(120,Math.min(re,Q?H:te)),w=Q?Math.max(ee,S.top-we-Math.min(ne,c)):Math.min(A-ee-Math.min(ne,c),S.bottom+we);_({top:w,left:K,width:U,maxHeight:c})},h=()=>{cancelAnimationFrame(I),I=requestAnimationFrame(d)};h();const v=new ResizeObserver(h);return v.observe(p),m.current&&v.observe(m.current),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),window.visualViewport?.addEventListener("resize",h),window.visualViewport?.addEventListener("scroll",h),()=>{cancelAnimationFrame(I),v.disconnect(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),window.visualViewport?.removeEventListener("resize",h),window.visualViewport?.removeEventListener("scroll",h)}},[s,a.length,n,t,l,o]),!t||!N||typeof document>"u"?null:wt.createPortal(e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:e.jsx("div",{ref:m,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:N.top,left:N.left,width:N.width,maxHeight:N.maxHeight},children:e.jsx(sn,{commands:a,selectedIndex:o,query:l,hasCatalog:u,title:f,queryPrefix:g,emptyCatalogMessage:x,emptyQueryMessage:y,insertionHint:C,compact:n,onSelect:b})})}),document.body)}function on({agentType:t,workingDir:s}){return Je({queryKey:W.system.slashCommandCatalog(t,s),queryFn:async()=>(await ce.get("/system/slash-command-catalog",{params:{agentType:String(t),...s?{workingDir:s}:{}}})).commands,enabled:!!t,staleTime:3e4})}function an(t,s){const a=new Set,o=[];for(const l of[...t,...s]){const u=l.command.trim().toLowerCase();!u||a.has(u)||(a.add(u),o.push(l.kind?l:{...l,kind:"builtin"}))}return o}function je(t){return t.trim().toLowerCase().replace(/^[/$]/,"")}function cn(t){return je(t.command)}function ln(t,s){if(!s)return 1e3;const a=cn(t),o=t.aliases?.map(je)??[],l=[a,...o];let u=0;for(const g of l)g===s?u=Math.max(u,500):g.startsWith(s)?u=Math.max(u,400-(g.length-s.length)):g.includes(s)&&(u=Math.max(u,250-g.indexOf(s)));return u>0?u:`${a} ${o.join(" ")} ${t.description}`.toLowerCase().includes(s)?100:0}function Kn(t){const s=/(^|[\s])\$([^\s]*)$/.exec(t);if(!s||s.index===void 0)return null;const a=s.index+s[1].length;return{query:je(s[2]),replaceStart:a}}function dn(t,s){const a=je(s);return a?t.map((o,l)=>({command:o,index:l,score:ln(o,a)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.index-l.index||o.command.command.localeCompare(l.command.command)).map(o=>o.command):t.slice()}const mn=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],un=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],pn=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],fn=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],xn={[ye.CODEX]:mn,[ye.CLAUDE_CODE]:un,[ye.GEMINI_CLI]:pn,[ye.CURSOR_AGENT]:fn};function tt(t){return t.trim().toLowerCase().replace(/^\//,"")}function hn(t){return t?(xn[t]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function gn(t){const s=t.match(/^\s*\/([^\s]*)$/);return s?tt(s[1]):null}function bn(t,s){return dn(t,tt(s))}function vn(t){const s=t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229,a=t.key==="Tab"&&!t.shiftKey;return s||a}function yn({agentType:t,workingDir:s,input:a,setInput:o,textareaRef:l,minHeight:u,maxHeight:f}){const[g,x]=r.useState(0),{data:y=[]}=on({agentType:t,workingDir:s}),C=r.useMemo(()=>an(hn(t),y),[t,y]),n=r.useMemo(()=>gn(a),[a]),b=r.useMemo(()=>n===null?[]:bn(C,n),[C,n]),m=r.useCallback(()=>{const p=l.current;p&&(p.style.height="auto",p.style.height=`${Math.max(u,Math.min(p.scrollHeight,f))}px`)},[f,u,l]);r.useEffect(()=>{x(0)},[t,n]),r.useEffect(()=>{g<b.length||x(0)},[b.length,g]);const N=r.useCallback(p=>{const d=`${a.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${p.command} `;o(d),requestAnimationFrame(()=>{const h=l.current;h&&(m(),h.focus(),h.setSelectionRange(d.length,d.length))})},[a,m,o,l]),_=r.useCallback(p=>n===null||b.length===0?!1:p.key==="ArrowDown"?(p.preventDefault(),x(I=>(I+1)%b.length),!0):p.key==="ArrowUp"?(p.preventDefault(),x(I=>(I-1+b.length)%b.length),!0):vn(p)?(p.preventDefault(),N(b[g]??b[0]),!0):!1,[N,b,n,g]);return{allCommands:C,query:n,filteredCommands:b,selectedIndex:g,setSelectedIndex:x,applyCommand:N,handleKeyDown:_}}const Nn="/assets/agent-tower-lockup-DPAcheCt.png";function Hn({className:t="h-6 w-auto max-[359px]:h-[22px]"}){return e.jsx("img",{src:Nn,alt:"Agent Tower",className:`block shrink-0 select-none object-contain ${t}`})}const wn={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Qn({variant:t="task",projects:s,providers:a,isProvidersLoading:o,onSubmit:l,defaultProjectId:u="",defaultProviderId:f="",onProjectChange:g,createStep:x,placeholder:y,submitLabel:C,pendingLabel:n,submitTitle:b}){const{t:m}=ge(),[N,_]=r.useState(""),[p,I]=r.useState(u),[d,h]=r.useState(f),[v,j]=r.useState("SOLO"),[S,M]=r.useState(L.WORKTREE),[A,B]=r.useState({}),[D,U]=r.useState("AUTO"),[K,te]=r.useState(null),[H,ne]=r.useState([]),[re,Q]=r.useState(!1),[Z,c]=r.useState(!1),[w,z]=r.useState(!1),[F,q]=r.useState(!1),V=r.useRef(null),le=r.useRef(null),Se=r.useRef(null),Le=r.useRef(null),_e=r.useRef(null),De=r.useRef(null),{files:Oe,addFiles:oe,removeFile:nt,clear:Pe,buildMarkdownLinks:ze,getDoneAttachments:$e,isUploading:be}=jt(),de=Tt(),T=t==="conversation",E=t==="task"||t==="conversation",st=C??m(T?"开始":"创建");r.useEffect(()=>{I(u),g?.(u)},[u,g]),r.useEffect(()=>{h(f)},[f]),r.useEffect(()=>{if(!Z)return;const i=R=>{V.current&&!V.current.contains(R.target)&&c(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[Z]),r.useEffect(()=>{if(!w)return;const i=R=>{le.current&&!le.current.contains(R.target)&&z(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[w]),r.useEffect(()=>{if(!F)return;const i=R=>{Se.current&&!Se.current.contains(R.target)&&q(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[F]);const G=r.useMemo(()=>s.find(i=>i.id===p),[s,p]),ve=r.useMemo(()=>a.find(i=>i.id===d),[a,d]),Te=p?A[p]:void 0,rt=(Te?.isGitRepo??G?.isGitRepo)!==!1,ot=(Te?.worktreeReady??G?.worktreeReady)!==!1,$=!T&&!(rt&&ot),O=$?"SOLO":v,Y=$?L.MAIN_DIRECTORY:S,at=Y===L.MAIN_DIRECTORY?m("本地模式"):m("工作树模式"),Fe=m("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),it=m("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),ct=Te?.reason??G?.reason,qe=m(ct==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"初始化 Git 后可使用工作树模式。"),Ge=T||O==="SOLO"?ve?.agentType:null,J=yn({agentType:Ge,workingDir:T?void 0:G?.repoPath,input:N,setInput:_,textareaRef:_e,minHeight:76,maxHeight:220}),P=x!=="idle",We=!!K||H.length>0,me=!P&&!be&&N.trim().length>0&&(T?!!d:!!p&&(O==="SOLO"?!!d:We));r.useEffect(()=>{$&&(j("SOLO"),M(L.MAIN_DIRECTORY),Q(!1),q(!1))},[$]),r.useEffect(()=>{$||T||M(L.WORKTREE)},[T,$,G?.id]);const lt=r.useCallback(async()=>{if(!G||de.isPending)return;const i=await de.mutateAsync({id:G.id});B(R=>({...R,[G.id]:i})),i.worktreeReady&&(j("SOLO"),M(L.WORKTREE),q(!1))},[de,G]),Ee=r.useCallback(async()=>{if(!me)return;const i=E?ze():"",R=E?$e().map(ue=>ue.id):[];try{await l({title:N.trim(),description:"",projectId:T?"":p,providerId:d,mode:T?"SOLO":O,workspaceMode:!T&&O==="SOLO"?Y:L.WORKTREE,teamRunMode:T?"AUTO":D,teamTemplateId:T||$?null:K,memberPresetIds:T||$?[]:H,attachmentLinks:i,attachmentIds:R}),_(""),E&&Pe()}catch{}},[me,E,ze,$e,l,N,T,p,d,O,Y,D,$,K,H,Pe]),dt=r.useCallback(i=>{J.handleKeyDown(i)||i.key==="Enter"&&!i.shiftKey&&!i.nativeEvent.isComposing&&i.nativeEvent.keyCode!==229&&(i.preventDefault(),Ee())},[Ee,J]),mt=r.useCallback(i=>{const R=i.target.files;R&&R.length>0&&oe(Array.from(R)),i.target.value=""},[oe]),ut=r.useCallback(i=>{I(i),g?.(i),c(!1)},[g]),pt=r.useCallback(i=>{if(!E)return;const R=i.clipboardData.items,ue=[];for(const Ue of R)if(Ue.kind==="file"){const Ke=Ue.getAsFile();Ke&&ue.push(Ke)}ue.length>0&&(i.preventDefault(),oe(ue))},[oe,E]),[Be,Me]=r.useState(!1),ft=r.useCallback(i=>{E&&(i.preventDefault(),Me(!0))},[E]),xt=r.useCallback(i=>{E&&(i.preventDefault(),Me(!1))},[E]),ht=r.useCallback(i=>{if(!E)return;i.preventDefault(),Me(!1);const R=i.dataTransfer.files;R.length>0&&oe(Array.from(R))},[oe,E]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{ref:Le,className:k("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Be?"border-info bg-info/5":"border-border",P&&"opacity-80"),onDragOver:E?ft:void 0,onDragLeave:E?xt:void 0,onDrop:E?ht:void 0,children:[E&&Oe.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(St,{files:Oe,onRemove:nt})}),e.jsx("textarea",{ref:_e,value:N,onChange:i=>_(i.target.value),onKeyDown:dt,onPaste:E?pt:void 0,placeholder:m(y||"Describe your task..."),disabled:P,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-[15px] text-foreground placeholder:text-muted-foreground/80 leading-relaxed",style:{minHeight:"76px",maxHeight:"220px",fieldSizing:"content"}}),E&&Be&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-center py-3 border border-dashed border-info/40 rounded-lg text-xs font-medium text-info",children:m("Drop files here")})}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:E?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>De.current?.click(),disabled:P||be,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:m("Attach files"),children:e.jsx(Rt,{size:18})}),e.jsx("input",{ref:De,type:"file",multiple:!0,onChange:mt,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&be&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(xe,{size:14,className:"animate-spin"}),m("Uploading...")]}),P&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(xe,{size:14,className:"animate-spin"}),m(n??wn[x])]}),!T&&!P&&!be&&O==="TEAM"&&!We&&N.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:m("请选择团队模板或追加成员")}),me&&e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[11px] text-muted-foreground/80 select-none",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-border bg-muted/60 text-[10px] font-medium text-muted-foreground leading-none",children:"⏎"}),st]}),e.jsx("button",{type:"button",onClick:Ee,disabled:!me,className:k("flex items-center justify-center size-8 rounded-lg transition-all duration-200",me?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:m(b||"Create & Start"),children:e.jsx(_t,{size:16,strokeWidth:2.5})})]})]})]}),e.jsx(rn,{open:!!Ge&&J.query!==null,anchorRef:Le,commands:J.filteredCommands,selectedIndex:J.selectedIndex,query:J.query??"",hasCatalog:J.allCommands.length>0,compact:!0,onSelect:J.applyCommand}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!T&&e.jsxs("div",{className:"relative",ref:V,children:[e.jsxs("button",{type:"button",onClick:()=>{P||c(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",G?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Et,{size:14,className:"shrink-0",style:{color:G?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:G?.name??m("Project")}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",Z&&"rotate-180")})]}),Z&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(i=>e.jsxs("button",{type:"button",onClick:()=>ut(i.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:i.color??"var(--muted-foreground)"}}),e.jsx("span",{className:k("truncate flex-1",i.id===p?"text-foreground font-medium":"text-muted-foreground"),children:i.name}),e.jsx(se,{size:14,className:k("ml-2 shrink-0 text-foreground",i.id===p?"opacity-100":"opacity-0")})]},i.id))})]}),(T||O==="SOLO")&&e.jsxs("div",{className:"relative",ref:le,children:[e.jsxs("button",{type:"button",onClick:()=>{P||z(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",ve?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(pe,{agentType:ve?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:ve?.name??m(o?"Loading...":"Agent")}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",w&&"rotate-180")})]}),w&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:a.map(i=>e.jsxs("button",{type:"button",disabled:!i.available,onClick:()=>{h(i.id),z(!1)},className:k("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!i.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(se,{size:14,className:k("mr-2 shrink-0 text-foreground",i.id===d?"opacity-100":"opacity-0")}),e.jsx(pe,{agentType:i.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:k("min-w-0 truncate",i.id===d?"text-foreground font-medium":"text-muted-foreground"),children:[i.name,i.available?"":m(" (unavailable)")]})]},i.id))})]}),!T&&O==="SOLO"&&e.jsxs("div",{className:"relative",ref:Se,children:[e.jsxs("button",{type:"button",onClick:()=>{P||q(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(zt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:at}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[$?e.jsx(Ae,{side:"bottom",className:"block w-full",content:qe,children:e.jsxs("div",{tabIndex:0,"aria-label":qe,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(se,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:m("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]}),e.jsx("button",{type:"button",onClick:lt,disabled:de.isPending,className:"flex w-full items-center px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:de.isPending?m("检测中..."):m("重新检测 Git 状态")})]})}):e.jsxs("button",{type:"button",onClick:()=>{M(L.WORKTREE),q(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(se,{size:14,className:k("mr-2 mt-0.5 shrink-0 text-foreground",Y===L.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:k("block truncate",Y===L.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:m("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]}),e.jsxs("button",{type:"button",onClick:()=>{M(L.MAIN_DIRECTORY),q(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(se,{size:14,className:k("mr-2 mt-0.5 shrink-0 text-foreground",Y===L.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:k("block truncate",Y===L.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:m("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:it})]})]})]})]}),!T&&e.jsx(Ae,{side:"bottom",className:"ml-auto",content:$?m("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):Y===L.MAIN_DIRECTORY?m("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):m("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":O==="TEAM",onClick:()=>{P||$||(v==="TEAM"?(j("SOLO"),Q(!1)):(j("TEAM"),q(!1),M(L.WORKTREE),Q(!0)))},disabled:P||$,className:k("flex items-center gap-2 h-7 pl-2 pr-2 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",O==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":m("启用团队模式"),children:[e.jsx(kt,{size:14,className:O==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:m("团队模式")}),($||Y===L.MAIN_DIRECTORY)&&O!=="TEAM"?e.jsx(Ct,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:k("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",O==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:k("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",O==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),!T&&O==="TEAM"&&re&&e.jsx("div",{className:"mt-2.5 rounded-xl border border-border/60 bg-muted/40 p-3 animate-[fadeInUp_0.25s_cubic-bezier(0.16,1,0.3,1)]",children:e.jsx(nn,{mode:D,setMode:U,selectedTemplateId:K,setSelectedTemplateId:te,selectedMemberPresetIds:H,setSelectedMemberPresetIds:ne,disabled:P,compact:!0})})]})}export{_n as A,Hn as B,Qn as C,zt as G,Bn as P,qn as R,On as S,Gn as T,Kt as Z,Un as a,Pn as b,_t as c,Dn as d,zn as e,nn as f,Fn as g,Kn as h,dn as i,yn as j,$n as k,rn as l,Wt as m,Wn as u};
|
|
1
|
+
import{k as X,o as he,n as ke,q as W,p as ce,m as Je,r,P as gt,Q as ae,u as ge,j as e,a3 as xe,l as k,ae as He,V as bt,D as vt,E as yt,W as Qe,X as Nt,z as wt,af as kt,ag as Ct}from"./index-D9kBRMR0.js";import{S as Ve,T as Ae,R as ie,h as ye,W as L,u as jt,A as St}from"./mermaid-NOHMQCX5-DWQaYVL0.js";import{A as pe}from"./AgentLogo-BCwbooTN.js";import{C as fe}from"./chevron-down-BQcW9sFf.js";import{C as se}from"./check-BN_PVKzE.js";import{d as Tt,F as Et}from"./use-projects-Cuv0A0RC.js";import{M as Ye}from"./MemberAvatar-l-WCdlLA.js";import{u as Mt}from"./use-providers-DLcAY6E1.js";import{P as It}from"./trash-2-R46i6Uus.js";import{P as Rt}from"./useNormalizedLogs-tfxFAJOF.js";const At=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_n=X("arrow-down",At);const Lt=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],_t=X("arrow-up",Lt);const Dt=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ot=X("gauge",Dt);const Pt=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],zt=X("git-branch",Pt);const $t=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Dn=X("search",$t);const Ft=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],qt=X("shield-alert",Ft);const Gt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Wt=X("shield",Gt);const Bt=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],On=X("square-pen",Bt);const Ut=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Kt=X("zap",Ut);function et(t){const s=he(),a=Je({queryKey:W.sessions.runtime(t),queryFn:()=>ce.get(`/sessions/${t}/runtime`),enabled:!!t});return r.useEffect(()=>{if(!t)return;const o=gt.connect(),l=g=>{g.sessionId===t&&s.invalidateQueries({queryKey:W.sessions.runtime(t)})},u=g=>{g.sessionId===t&&s.setQueryData(W.sessions.runtime(t),g.state)},f=()=>{s.invalidateQueries({queryKey:W.sessions.runtime(t)})};return o.on(ae.SESSION_PERMISSION_REQUESTED,l),o.on(ae.SESSION_PERMISSION_INVALIDATED,l),o.on(ae.SESSION_RUNTIME_STATE_CHANGED,u),o.on("connect",f),()=>{o.off(ae.SESSION_PERMISSION_REQUESTED,l),o.off(ae.SESSION_PERMISSION_INVALIDATED,l),o.off(ae.SESSION_RUNTIME_STATE_CHANGED,u),o.off("connect",f)}},[t,s]),a}function Ht(t){return t==="RUNNING"||t==="AWAITING_PERMISSION"||t==="CANCELLING"}function Qt(t){return t===Ve.RUNNING||t===Ve.PENDING}function Pn(t,s){const{data:a}=et(t);return{runtimeState:a,isActive:Qt(s)||Ht(a?.turnState),isCancelling:a?.turnState==="CANCELLING"}}function Vt(){const t=he();return ke({mutationFn:({sessionId:s,requestId:a,optionId:o})=>ce.post(`/sessions/${s}/permissions/${a}/resolve`,{optionId:o}),onSettled:(s,a,o)=>{t.invalidateQueries({queryKey:W.sessions.runtime(o.sessionId)})}})}function zn(){const t=he();return ke({mutationFn:s=>ce.post(`/sessions/${s}/start`),onSuccess:(s,a)=>{t.invalidateQueries({queryKey:W.sessions.detail(a)}),t.invalidateQueries({queryKey:W.tasks.all})}})}function $n(){const t=he();return ke({mutationFn:s=>ce.post(`/sessions/${s}/stop`),onSuccess:(s,a)=>{t.invalidateQueries({queryKey:W.sessions.detail(a)})}})}function Fn(){const t=he();return ke({mutationFn:({id:s,message:a,providerId:o})=>ce.post(`/sessions/${s}/message`,{message:a,providerId:o}),onSuccess:()=>{t.invalidateQueries({queryKey:W.workspaces.all}),t.invalidateQueries({queryKey:W.tasks.all})}})}function qn({sessionId:t,compact:s=!1}){const{t:a}=ge(),{data:o}=et(t),l=Vt(),u=o?.pendingPermissions[0],f=u?.requestId,g=l.reset;return r.useEffect(()=>{g()},[f,g]),u?e.jsx("div",{className:k("mb-2 border-l-2 border-warning bg-warning/5 px-3 py-2.5",s&&"px-2.5 py-2"),children:e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx(qt,{className:"mt-0.5 h-4 w-4 shrink-0 text-warning","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:a("Permission required")}),e.jsx("div",{className:"mt-0.5 break-words text-xs text-muted-foreground",children:u.toolSummary||u.toolName||a("The agent needs approval to continue.")}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:u.options.map(x=>e.jsxs("button",{type:"button",disabled:l.isPending,onClick:()=>l.mutate({sessionId:t,requestId:u.requestId,optionId:x.optionId}),className:k("inline-flex min-h-8 items-center gap-1.5 border px-3 text-xs font-medium transition-colors disabled:opacity-50",x.kind.startsWith("reject")?"border-destructive/30 text-destructive hover:bg-destructive/10":"border-border bg-background text-foreground hover:bg-muted"),children:[l.isPending&&l.variables?.requestId===u.requestId&&l.variables.optionId===x.optionId?e.jsx(xe,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):null,x.name]},x.optionId))}),l.error?e.jsx("div",{className:"mt-1.5 text-xs text-destructive",role:"alert",children:l.error.message}):null]})]})}):null}function Ne(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Yt(t){return t>=.9?"text-red-500":t>=.7?"text-amber-500":"text-neutral-400"}function Gn({usage:t,tooltipSide:s="top"}){const{t:a}=ge();if(!t)return null;const o=t.modelContextWindow,l=o?t.totalTokens/o:0,u=o?Math.min(Math.round(l*100),100):null,f=o?Yt(l):"text-neutral-400",g=o?e.jsx("span",{children:a("上下文: {used} / {max} tokens",{used:Ne(t.totalTokens),max:Ne(o)})}):e.jsx("span",{children:a("已使用: {used} tokens",{used:Ne(t.totalTokens)})});return e.jsx(Ae,{content:g,side:s,children:e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[e.jsx(Ot,{size:14,className:f}),e.jsxs("span",{className:`tabular-nums ${f}`,children:[Ne(t.totalTokens),u!==null&&e.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",u,"%"]})]})]})})}const Xt={damping:.7,stiffness:.05,mass:1.25},Zt=70,Jt=1e3/60,en=350;let Ce=!1;globalThis.document?.addEventListener("mousedown",()=>{Ce=!0});globalThis.document?.addEventListener("mouseup",()=>{Ce=!1});globalThis.document?.addEventListener("click",()=>{Ce=!1});const Wn=(t={})=>{const[s,a]=r.useState(!1),[o,l]=r.useState(t.initial!==!1),[u,f]=r.useState(!1),g=r.useRef(null);g.current=t;const x=r.useCallback(()=>{if(!Ce)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const h=d.getRangeAt(0);return h.commonAncestorContainer.contains(p.current)||p.current?.contains(h.commonAncestorContainer)},[]),y=r.useCallback(d=>{n.isAtBottom=d,l(d)},[]),C=r.useCallback(d=>{n.escapedFromLock=d,a(d)},[]),n=r.useMemo(()=>{let d;return{escapedFromLock:s,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return p.current?.scrollTop??0},set scrollTop(h){p.current&&(p.current.scrollTop=h,n.ignoreScrollToTop=p.current.scrollTop)},get targetScrollTop(){return!p.current||!I.current?0:p.current.scrollHeight-1-p.current.clientHeight},get calculatedTargetScrollTop(){if(!p.current||!I.current)return 0;const{targetScrollTop:h}=this;if(!t.targetScrollTop)return h;if(d?.targetScrollTop===h)return d.calculatedScrollTop;const v=Math.max(Math.min(t.targetScrollTop(h,{scrollElement:p.current,contentElement:I.current}),h),0);return d={targetScrollTop:h,calculatedScrollTop:v},requestAnimationFrame(()=>{d=void 0}),v},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Zt}}},[]),b=r.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||y(!0);const h=Date.now()+(Number(d.wait)||0),v=Re(g.current,d.animation),{ignoreEscapes:j=!1}=d;let S,M=n.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{S=Date.now()}):S=h+(d.duration??0);const A=async()=>{const B=new Promise(requestAnimationFrame).then(()=>{if(!n.isAtBottom)return n.animation=void 0,!1;const{scrollTop:D}=n,U=performance.now(),K=(U-(n.lastTick??U))/Jt;if(n.animation||(n.animation={behavior:v,promise:B,ignoreEscapes:j}),n.animation.behavior===v&&(n.lastTick=U),x()||h>Date.now())return A();if(D<Math.min(M,n.calculatedTargetScrollTop)){if(n.animation?.behavior===v){if(v==="instant")return n.scrollTop=n.calculatedTargetScrollTop,A();n.velocity=(v.damping*n.velocity+v.stiffness*n.scrollDifference)/v.mass,n.accumulated+=n.velocity*K,n.scrollTop+=n.accumulated,n.scrollTop!==D&&(n.accumulated=0)}return A()}return S>Date.now()?(M=n.calculatedTargetScrollTop,A()):(n.animation=void 0,n.scrollTop<n.calculatedTargetScrollTop?b({animation:Re(g.current,g.current.resize),ignoreEscapes:j,duration:Math.max(0,S-Date.now())||void 0}):n.isAtBottom)});return B.then(D=>(requestAnimationFrame(()=>{n.animation||(n.lastTick=void 0,n.velocity=0)}),D))};return d.wait!==!0&&(n.animation=void 0),n.animation?.behavior===v?n.animation.promise:A()},[y,x,n]),m=r.useCallback(()=>{C(!0),y(!1)},[C,y]),N=r.useCallback(({target:d})=>{if(d!==p.current)return;const{scrollTop:h,ignoreScrollToTop:v}=n;let{lastScrollTop:j=h}=n;n.lastScrollTop=h,n.ignoreScrollToTop=void 0,v&&v>h&&(j=v),f(n.isNearBottom),setTimeout(()=>{if(n.resizeDifference||h===v)return;if(x()){C(!0),y(!1);return}const S=h>j,M=h<j;if(n.animation?.ignoreEscapes){n.scrollTop=j;return}M&&(C(!0),y(!1)),S&&C(!1),!n.escapedFromLock&&n.isNearBottom&&y(!0)},1)},[C,y,x,n]),_=r.useCallback(({target:d,deltaY:h})=>{let v=d;for(;!["scroll","auto"].includes(getComputedStyle(v).overflow);){if(!v.parentElement)return;v=v.parentElement}v===p.current&&h<0&&p.current.scrollHeight>p.current.clientHeight&&!n.animation?.ignoreEscapes&&(C(!0),y(!1))},[C,y,n]),p=Xe(d=>{p.current?.removeEventListener("scroll",N),p.current?.removeEventListener("wheel",_),d?.addEventListener("scroll",N,{passive:!0}),d?.addEventListener("wheel",_,{passive:!0})},[]),I=Xe(d=>{if(n.resizeObserver?.disconnect(),!d)return;let h;n.resizeObserver=new ResizeObserver(([v])=>{const{height:j}=v.contentRect,S=j-(h??j);if(n.resizeDifference=S,n.scrollTop>n.targetScrollTop&&(n.scrollTop=n.targetScrollTop),f(n.isNearBottom),S>=0){const M=Re(g.current,h?g.current.resize:g.current.initial);b({animation:M,wait:!0,preserveScrollPosition:!0,duration:M==="instant"?void 0:en})}else n.isNearBottom&&(C(!1),y(!0));h=j,requestAnimationFrame(()=>{setTimeout(()=>{n.resizeDifference===S&&(n.resizeDifference=0)},1)})}),n.resizeObserver?.observe(d)},[]);return{contentRef:I,scrollRef:p,scrollToBottom:b,stopScroll:m,isAtBottom:o||u,isNearBottom:u,escapedFromLock:s,state:n}};function Xe(t,s){const a=r.useCallback(o=>(a.current=o,t(o)),s);return a}const Ie=new Map;function Re(...t){const s={...Xt};let a=!1;for(const l of t){if(l==="instant"){a=!0;continue}typeof l=="object"&&(a=!1,s.damping=l.damping??s.damping,s.stiffness=l.stiffness??s.stiffness,s.mass=l.mass??s.mass)}const o=JSON.stringify(s);return Ie.has(o)||Ie.set(o,Object.freeze(s)),a?"instant":Ie.get(o)}function Bn({providers:t,currentProviderId:s,agentType:a,runtimeType:o,onSelect:l}){const{t:u}=ge(),[f,g]=r.useState(!1),x=r.useRef(null),y=o===ie.ACP?ie.ACP:ie.CLI,C=t.filter(b=>String(b.provider.agentType)===a&&(b.provider.runtimeType===ie.ACP?ie.ACP:ie.CLI)===y),n=t.find(b=>b.provider.id===s);return r.useEffect(()=>{function b(m){x.current&&!x.current.contains(m.target)&&g(!1)}if(f)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[f]),C.length<=1?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[e.jsx(pe,{agentType:n?.provider.agentType??a,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?He(n.provider.name,12):a})]}):e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>g(!f),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${n?.provider.name??a} (click to change)`,children:[e.jsx(pe,{agentType:n?.provider.agentType??a,className:"size-3.5"}),e.jsx("span",{className:"min-w-0 truncate",children:n?.provider.name?He(n.provider.name,12):a}),e.jsx(fe,{size:12,className:`shrink-0 transition-transform ${f?"rotate-180":""}`})]}),f&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[e.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:u("切换渠道")}),C.map(b=>e.jsxs("button",{onClick:()=>{l(b.provider.id),g(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${b.provider.id===s?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(pe,{agentType:b.provider.agentType,className:"size-4"}),e.jsx("span",{className:"truncate max-w-[120px]",children:b.provider.name}),b.provider.isDefault&&e.jsx("span",{className:"text-xs text-neutral-400",children:u("(默认)")})]}),b.provider.id===s&&e.jsx(se,{size:14,className:"shrink-0"})]},b.provider.id))]})]})}function Un(t,s){return r.useMemo(()=>{for(let a=t.length-1;a>=0;a--){const o=t[a];if(o.tokenUsage&&typeof o.tokenUsage.totalTokens=="number"&&o.tokenUsage.totalTokens>0)return{totalTokens:o.tokenUsage.totalTokens,modelContextWindow:o.tokenUsage.modelContextWindow}}return s??null},[t,s])}function Ze(t,s,a,o){if(a.filter(f=>f===o).length<=1)return t;const u=a.slice(0,s+1).filter(f=>f===o).length;return`${t} #${u}`}function tn(t){return Object.values(t).filter(Boolean).length}function nn({mode:t,setMode:s,selectedTemplateId:a,setSelectedTemplateId:o,selectedMemberPresetIds:l,setSelectedMemberPresetIds:u,disabled:f=!1,compact:g=!1}){const{t:x}=ge(),{preserveDesktopSearch:y}=bt(),[C,n]=r.useState(!1),{data:b}=Mt(),{data:m,isError:N,isFetching:_,isLoading:p,refetch:I}=vt(),{data:d,isError:h,isFetching:v,isLoading:j,refetch:S}=yt(),M=r.useMemo(()=>new Map((b??[]).map(({provider:c,availability:w})=>[c.id,c.name+(w.type==="NOT_FOUND"?x(" (不可用)"):"")])),[b,x]),A=r.useMemo(()=>new Map((m??[]).map(c=>[c.id,c])),[m]),B=r.useMemo(()=>new Map((d??[]).map(c=>[c.id,c])),[d]),D=r.useMemo(()=>l.map(c=>A.get(c)).filter(c=>!!c),[A,l]);r.useEffect(()=>{m!==void 0&&u(c=>{const w=c.filter(z=>A.has(z));return w.length===c.length&&w.every((z,F)=>z===c[F])?c:w})},[m,A,u]),r.useEffect(()=>{d!==void 0&&o(c=>!c||B.has(c)?c:null)},[o,B,d]);const U=c=>{f||o(w=>w===c?null:c)},K=c=>{f||u(w=>[...w,c])},te=c=>{f||u(w=>w.filter((z,F)=>F!==c))},H=e.jsxs("section",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-medium text-muted-foreground mb-1.5",children:x("团队模板")}),h?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("团队模板加载失败")}),e.jsx("button",{type:"button",onClick:()=>{S()},disabled:f||v,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):j?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(xe,{size:12,className:"animate-spin"}),x("加载中...")]}):(d??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[x("当前没有团队模板"),e.jsx(Qe,{to:y("/settings/team"),className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:k("space-y-1.5",g&&"sm:grid sm:grid-cols-2 sm:gap-1.5 sm:space-y-0"),children:(d??[]).map(c=>{const w=c.id===a,z=c.members?.length??0,F=c.members?.map(V=>V.memberPresetId)??[],q=c.members?.slice(0,3).map((V,le)=>Ze(V.memberPreset?.name??V.memberPresetId,le,F,V.memberPresetId)).join(", ");return e.jsx("button",{type:"button",onClick:()=>U(c.id),disabled:f,className:k("w-full rounded-lg px-3 py-2 text-left border transition-all disabled:cursor-not-allowed disabled:opacity-60",w?"bg-background border-foreground/20 shadow-sm":"bg-background border-border/60 hover:border-border hover:bg-accent"),children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:k("text-xs truncate",w?"font-medium text-foreground":"text-foreground"),children:c.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:[z,x("人")]})]}),q&&e.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground truncate",children:q})]}),w&&e.jsx(se,{size:13,className:"shrink-0 text-foreground"})]})},c.id)})})]}),ne=D.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:D.map((c,w)=>{const z=Ze(c.name,w,l,c.id);return e.jsxs("div",{className:"inline-flex items-center gap-1 pl-1 pr-0.5 py-0.5 rounded-md border border-border/60 bg-background text-[10px] text-foreground",children:[e.jsx(Ye,{name:c.name,avatar:c.avatar,className:"h-3.5 w-3.5 text-[7px]"}),e.jsx("span",{className:"max-w-[80px] truncate",children:z}),e.jsx("button",{type:"button",onClick:()=>te(w),disabled:f,className:"p-0.5 text-muted-foreground hover:text-destructive disabled:opacity-30 rounded transition-colors",children:e.jsx(Nt,{size:9})})]},`${c.id}-${w}`)})}),re=N?e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2.5 text-xs text-destructive",children:[e.jsx("span",{children:x("成员预设加载失败")}),e.jsx("button",{type:"button",onClick:()=>{I()},disabled:f||_,className:"ml-2 underline hover:no-underline",children:x("重试")})]}):p?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-xs text-muted-foreground",children:[e.jsx(xe,{size:12,className:"animate-spin"}),x("加载中...")]}):(m??[]).length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-border bg-background px-3 py-3 text-xs text-muted-foreground",children:[x("当前没有成员预设"),e.jsx(Qe,{to:y("/settings/team"),className:"ml-1.5 text-info hover:underline",children:x("去创建")})]}):e.jsx("div",{className:"space-y-1 max-h-[180px] overflow-y-auto pr-1",children:(m??[]).map(c=>{const w=l.filter(q=>q===c.id).length,z=M.get(c.providerId)??c.providerId,F=tn(c.capabilities);return e.jsxs("button",{type:"button",onClick:()=>K(c.id),disabled:f,className:k("flex items-center gap-2 w-full px-2 py-1.5 rounded-lg text-left border border-transparent transition-all",f&&"cursor-not-allowed opacity-60","bg-background hover:bg-accent hover:border-border/60"),children:[e.jsx(Ye,{name:c.name,avatar:c.avatar,className:"h-6 w-6 text-[9px] shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-foreground truncate",children:c.name}),e.jsxs("div",{className:"text-[10px] text-muted-foreground truncate",children:[z," · ",F,"/10"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[w>0&&e.jsxs("span",{className:"text-[10px] text-foreground font-semibold",children:["×",w]}),e.jsx(It,{size:12,className:"text-muted-foreground"})]})]},c.id)})}),Q=D.length>0&&e.jsx("span",{className:"inline-flex items-center justify-center min-w-[16px] h-4 rounded-full bg-primary text-[10px] font-semibold text-primary-foreground px-1.5",children:D.length}),Z=e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground shrink-0",children:x("执行模式")}),e.jsxs("div",{className:"inline-flex items-center h-7 rounded-md border border-border/70 bg-background p-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&s("AUTO"),disabled:f,className:k("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="AUTO"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Kt,{size:11}),x("自动模式")]}),e.jsxs("button",{type:"button",onClick:()=>!f&&s("CONFIRM"),disabled:f,className:k("flex items-center gap-1.5 rounded h-full px-2.5 text-xs transition-all disabled:cursor-not-allowed disabled:opacity-50",t==="CONFIRM"?"bg-primary text-primary-foreground font-medium shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Wt,{size:11}),x("确认模式")]})]})]});return g?e.jsxs("div",{className:"space-y-3",children:[Z,H,e.jsxs("div",{className:"border-t border-border/50 pt-2.5",children:[e.jsxs("button",{type:"button",onClick:()=>!f&&n(c=>!c),disabled:f,"aria-expanded":C,className:"flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(fe,{size:12,className:k("transition-transform",C?"":"-rotate-90")}),x("追加独立成员"),Q]}),C&&e.jsxs("div",{className:"mt-2",children:[ne,re]})]})]}):e.jsxs("div",{className:"space-y-3.5",children:[Z,e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[H,e.jsxs("section",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:x("追加成员")}),Q]}),ne,re]})]})]})}function sn({commands:t,selectedIndex:s,query:a,hasCatalog:o,title:l="Slash Commands",queryPrefix:u="/",emptyCatalogMessage:f="No slash commands catalog for this agent yet.",emptyQueryMessage:g,insertionHint:x="Enter / Tab to insert",compact:y=!1,onSelect:C}){const n=y?"px-1.5 pb-1.5":"px-2 pb-2",b=y?"px-2 py-1.5":"px-2.5 py-2",m=y?"max-h-36":"max-h-48";return e.jsxs("div",{className:y?"pt-1.5":"pt-2",children:[e.jsxs("div",{className:`mb-1 flex items-center justify-between ${y?"px-2 pt-0.5":"px-3 pt-1"}`,children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:l}),e.jsx("span",{className:"text-[10px] text-neutral-400",children:x})]}),t.length===0?e.jsx("div",{className:`${y?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:o?g??`No matches for ${u}${a}`:f}):e.jsx("div",{className:`${n} ${m} overflow-y-auto`,children:t.map((N,_)=>e.jsxs("button",{type:"button",onMouseDown:p=>p.preventDefault(),onClick:()=>C(N),className:`w-full rounded-lg border text-left transition-colors ${_===s?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${b}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:N.command}),N.kind&&N.kind!=="builtin"?e.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:N.scope?`${N.scope} ${N.kind}`:N.kind}):null]}),e.jsx("div",{className:`${y?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:N.description})]},N.command))})]})}const ee=12,we=8;function rn({open:t,anchorRef:s,commands:a,selectedIndex:o,query:l,hasCatalog:u,title:f,queryPrefix:g,emptyCatalogMessage:x,emptyQueryMessage:y,insertionHint:C,compact:n=!1,onSelect:b}){const m=r.useRef(null),[N,_]=r.useState(null);return r.useLayoutEffect(()=>{if(!t){_(null);return}const p=s.current;if(!p)return;let I=0;const d=()=>{const j=s.current;if(!j)return;const S=j.getBoundingClientRect(),M=window.innerWidth,A=window.innerHeight,B=n?260:320,D=n?M-ee*2:560,U=Math.min(Math.max(S.width,B),Math.max(B,D)),K=Math.min(Math.max(ee,S.left),Math.max(ee,M-ee-U)),te=A-S.bottom-we-ee,H=S.top-we-ee,ne=m.current?.offsetHeight??(n?220:280),re=n?240:320,Q=te<180&&H>te,c=Math.max(120,Math.min(re,Q?H:te)),w=Q?Math.max(ee,S.top-we-Math.min(ne,c)):Math.min(A-ee-Math.min(ne,c),S.bottom+we);_({top:w,left:K,width:U,maxHeight:c})},h=()=>{cancelAnimationFrame(I),I=requestAnimationFrame(d)};h();const v=new ResizeObserver(h);return v.observe(p),m.current&&v.observe(m.current),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),window.visualViewport?.addEventListener("resize",h),window.visualViewport?.addEventListener("scroll",h),()=>{cancelAnimationFrame(I),v.disconnect(),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),window.visualViewport?.removeEventListener("resize",h),window.visualViewport?.removeEventListener("scroll",h)}},[s,a.length,n,t,l,o]),!t||!N||typeof document>"u"?null:wt.createPortal(e.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:e.jsx("div",{ref:m,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:N.top,left:N.left,width:N.width,maxHeight:N.maxHeight},children:e.jsx(sn,{commands:a,selectedIndex:o,query:l,hasCatalog:u,title:f,queryPrefix:g,emptyCatalogMessage:x,emptyQueryMessage:y,insertionHint:C,compact:n,onSelect:b})})}),document.body)}function on({agentType:t,workingDir:s}){return Je({queryKey:W.system.slashCommandCatalog(t,s),queryFn:async()=>(await ce.get("/system/slash-command-catalog",{params:{agentType:String(t),...s?{workingDir:s}:{}}})).commands,enabled:!!t,staleTime:3e4})}function an(t,s){const a=new Set,o=[];for(const l of[...t,...s]){const u=l.command.trim().toLowerCase();!u||a.has(u)||(a.add(u),o.push(l.kind?l:{...l,kind:"builtin"}))}return o}function je(t){return t.trim().toLowerCase().replace(/^[/$]/,"")}function cn(t){return je(t.command)}function ln(t,s){if(!s)return 1e3;const a=cn(t),o=t.aliases?.map(je)??[],l=[a,...o];let u=0;for(const g of l)g===s?u=Math.max(u,500):g.startsWith(s)?u=Math.max(u,400-(g.length-s.length)):g.includes(s)&&(u=Math.max(u,250-g.indexOf(s)));return u>0?u:`${a} ${o.join(" ")} ${t.description}`.toLowerCase().includes(s)?100:0}function Kn(t){const s=/(^|[\s])\$([^\s]*)$/.exec(t);if(!s||s.index===void 0)return null;const a=s.index+s[1].length;return{query:je(s[2]),replaceStart:a}}function dn(t,s){const a=je(s);return a?t.map((o,l)=>({command:o,index:l,score:ln(o,a)})).filter(o=>o.score>0).sort((o,l)=>l.score-o.score||o.index-l.index||o.command.command.localeCompare(l.command.command)).map(o=>o.command):t.slice()}const mn=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],un=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],pn=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],fn=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],xn={[ye.CODEX]:mn,[ye.CLAUDE_CODE]:un,[ye.GEMINI_CLI]:pn,[ye.CURSOR_AGENT]:fn};function tt(t){return t.trim().toLowerCase().replace(/^\//,"")}function hn(t){return t?(xn[t]??[]).map(s=>({...s,kind:s.kind??"builtin"})):[]}function gn(t){const s=t.match(/^\s*\/([^\s]*)$/);return s?tt(s[1]):null}function bn(t,s){return dn(t,tt(s))}function vn(t){const s=t.key==="Enter"&&!t.shiftKey&&!t.repeat&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229,a=t.key==="Tab"&&!t.shiftKey;return s||a}function yn({agentType:t,workingDir:s,input:a,setInput:o,textareaRef:l,minHeight:u,maxHeight:f}){const[g,x]=r.useState(0),{data:y=[]}=on({agentType:t,workingDir:s}),C=r.useMemo(()=>an(hn(t),y),[t,y]),n=r.useMemo(()=>gn(a),[a]),b=r.useMemo(()=>n===null?[]:bn(C,n),[C,n]),m=r.useCallback(()=>{const p=l.current;p&&(p.style.height="auto",p.style.height=`${Math.max(u,Math.min(p.scrollHeight,f))}px`)},[f,u,l]);r.useEffect(()=>{x(0)},[t,n]),r.useEffect(()=>{g<b.length||x(0)},[b.length,g]);const N=r.useCallback(p=>{const d=`${a.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${p.command} `;o(d),requestAnimationFrame(()=>{const h=l.current;h&&(m(),h.focus(),h.setSelectionRange(d.length,d.length))})},[a,m,o,l]),_=r.useCallback(p=>n===null||b.length===0?!1:p.key==="ArrowDown"?(p.preventDefault(),x(I=>(I+1)%b.length),!0):p.key==="ArrowUp"?(p.preventDefault(),x(I=>(I-1+b.length)%b.length),!0):vn(p)?(p.preventDefault(),N(b[g]??b[0]),!0):!1,[N,b,n,g]);return{allCommands:C,query:n,filteredCommands:b,selectedIndex:g,setSelectedIndex:x,applyCommand:N,handleKeyDown:_}}const Nn="/assets/agent-tower-lockup-DPAcheCt.png";function Hn({className:t="h-6 w-auto max-[359px]:h-[22px]"}){return e.jsx("img",{src:Nn,alt:"Agent Tower",className:`block shrink-0 select-none object-contain ${t}`})}const wn={idle:"","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."};function Qn({variant:t="task",projects:s,providers:a,isProvidersLoading:o,onSubmit:l,defaultProjectId:u="",defaultProviderId:f="",onProjectChange:g,createStep:x,placeholder:y,submitLabel:C,pendingLabel:n,submitTitle:b}){const{t:m}=ge(),[N,_]=r.useState(""),[p,I]=r.useState(u),[d,h]=r.useState(f),[v,j]=r.useState("SOLO"),[S,M]=r.useState(L.WORKTREE),[A,B]=r.useState({}),[D,U]=r.useState("AUTO"),[K,te]=r.useState(null),[H,ne]=r.useState([]),[re,Q]=r.useState(!1),[Z,c]=r.useState(!1),[w,z]=r.useState(!1),[F,q]=r.useState(!1),V=r.useRef(null),le=r.useRef(null),Se=r.useRef(null),Le=r.useRef(null),_e=r.useRef(null),De=r.useRef(null),{files:Oe,addFiles:oe,removeFile:nt,clear:Pe,buildMarkdownLinks:ze,getDoneAttachments:$e,isUploading:be}=jt(),de=Tt(),T=t==="conversation",E=t==="task"||t==="conversation",st=C??m(T?"开始":"创建");r.useEffect(()=>{I(u),g?.(u)},[u,g]),r.useEffect(()=>{h(f)},[f]),r.useEffect(()=>{if(!Z)return;const i=R=>{V.current&&!V.current.contains(R.target)&&c(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[Z]),r.useEffect(()=>{if(!w)return;const i=R=>{le.current&&!le.current.contains(R.target)&&z(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[w]),r.useEffect(()=>{if(!F)return;const i=R=>{Se.current&&!Se.current.contains(R.target)&&q(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[F]);const G=r.useMemo(()=>s.find(i=>i.id===p),[s,p]),ve=r.useMemo(()=>a.find(i=>i.id===d),[a,d]),Te=p?A[p]:void 0,rt=(Te?.isGitRepo??G?.isGitRepo)!==!1,ot=(Te?.worktreeReady??G?.worktreeReady)!==!1,$=!T&&!(rt&&ot),O=$?"SOLO":v,Y=$?L.MAIN_DIRECTORY:S,at=Y===L.MAIN_DIRECTORY?m("本地模式"):m("工作树模式"),Fe=m("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),it=m("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),ct=Te?.reason??G?.reason,qe=m(ct==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"初始化 Git 后可使用工作树模式。"),Ge=T||O==="SOLO"?ve?.agentType:null,J=yn({agentType:Ge,workingDir:T?void 0:G?.repoPath,input:N,setInput:_,textareaRef:_e,minHeight:76,maxHeight:220}),P=x!=="idle",We=!!K||H.length>0,me=!P&&!be&&N.trim().length>0&&(T?!!d:!!p&&(O==="SOLO"?!!d:We));r.useEffect(()=>{$&&(j("SOLO"),M(L.MAIN_DIRECTORY),Q(!1),q(!1))},[$]),r.useEffect(()=>{$||T||M(L.WORKTREE)},[T,$,G?.id]);const lt=r.useCallback(async()=>{if(!G||de.isPending)return;const i=await de.mutateAsync({id:G.id});B(R=>({...R,[G.id]:i})),i.worktreeReady&&(j("SOLO"),M(L.WORKTREE),q(!1))},[de,G]),Ee=r.useCallback(async()=>{if(!me)return;const i=E?ze():"",R=E?$e().map(ue=>ue.id):[];try{await l({title:N.trim(),description:"",projectId:T?"":p,providerId:d,mode:T?"SOLO":O,workspaceMode:!T&&O==="SOLO"?Y:L.WORKTREE,teamRunMode:T?"AUTO":D,teamTemplateId:T||$?null:K,memberPresetIds:T||$?[]:H,attachmentLinks:i,attachmentIds:R}),_(""),E&&Pe()}catch{}},[me,E,ze,$e,l,N,T,p,d,O,Y,D,$,K,H,Pe]),dt=r.useCallback(i=>{J.handleKeyDown(i)||i.key==="Enter"&&!i.shiftKey&&!i.nativeEvent.isComposing&&i.nativeEvent.keyCode!==229&&(i.preventDefault(),Ee())},[Ee,J]),mt=r.useCallback(i=>{const R=i.target.files;R&&R.length>0&&oe(Array.from(R)),i.target.value=""},[oe]),ut=r.useCallback(i=>{I(i),g?.(i),c(!1)},[g]),pt=r.useCallback(i=>{if(!E)return;const R=i.clipboardData.items,ue=[];for(const Ue of R)if(Ue.kind==="file"){const Ke=Ue.getAsFile();Ke&&ue.push(Ke)}ue.length>0&&(i.preventDefault(),oe(ue))},[oe,E]),[Be,Me]=r.useState(!1),ft=r.useCallback(i=>{E&&(i.preventDefault(),Me(!0))},[E]),xt=r.useCallback(i=>{E&&(i.preventDefault(),Me(!1))},[E]),ht=r.useCallback(i=>{if(!E)return;i.preventDefault(),Me(!1);const R=i.dataTransfer.files;R.length>0&&oe(Array.from(R))},[oe,E]);return e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{ref:Le,className:k("relative bg-background rounded-xl border transition-colors duration-200","shadow-[0_1px_2px_rgba(0,0,0,0.05)]","hover:border-ring/40 focus-within:border-ring/60",Be?"border-info bg-info/5":"border-border",P&&"opacity-80"),onDragOver:E?ft:void 0,onDragLeave:E?xt:void 0,onDrop:E?ht:void 0,children:[E&&Oe.length>0&&e.jsx("div",{className:"px-4 pt-3",children:e.jsx(St,{files:Oe,onRemove:nt})}),e.jsx("textarea",{ref:_e,value:N,onChange:i=>_(i.target.value),onKeyDown:dt,onPaste:E?pt:void 0,placeholder:m(y||"Describe your task..."),disabled:P,autoFocus:!0,rows:1,className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-[15px] text-foreground placeholder:text-muted-foreground/80 leading-relaxed",style:{minHeight:"76px",maxHeight:"220px",fieldSizing:"content"}}),E&&Be&&e.jsx("div",{className:"px-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-center py-3 border border-dashed border-info/40 rounded-lg text-xs font-medium text-info",children:m("Drop files here")})}),e.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:E?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>De.current?.click(),disabled:P||be,className:"p-2 text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:m("Attach files"),children:e.jsx(Rt,{size:18})}),e.jsx("input",{ref:De,type:"file",multiple:!0,onChange:mt,className:"hidden"})]}):null}),e.jsxs("div",{className:"flex items-center gap-2",children:[E&&be&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(xe,{size:14,className:"animate-spin"}),m("Uploading...")]}),P&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(xe,{size:14,className:"animate-spin"}),m(n??wn[x])]}),!T&&!P&&!be&&O==="TEAM"&&!We&&N.trim().length>0&&e.jsx("span",{className:"text-[11px] text-warning",children:m("请选择团队模板或追加成员")}),me&&e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[11px] text-muted-foreground/80 select-none",children:[e.jsx("kbd",{className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded border border-border bg-muted/60 text-[10px] font-medium text-muted-foreground leading-none",children:"⏎"}),st]}),e.jsx("button",{type:"button",onClick:Ee,disabled:!me,className:k("flex items-center justify-center size-8 rounded-lg transition-all duration-200",me?"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm":"bg-muted text-muted-foreground/40 cursor-not-allowed"),title:m(b||"Create & Start"),children:e.jsx(_t,{size:16,strokeWidth:2.5})})]})]})]}),e.jsx(rn,{open:!!Ge&&J.query!==null,anchorRef:Le,commands:J.filteredCommands,selectedIndex:J.selectedIndex,query:J.query??"",hasCatalog:J.allCommands.length>0,compact:!0,onSelect:J.applyCommand}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-2.5 px-0.5",children:[!T&&e.jsxs("div",{className:"relative",ref:V,children:[e.jsxs("button",{type:"button",onClick:()=>{P||c(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",G?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(Et,{size:14,className:"shrink-0",style:{color:G?.color??"var(--muted-foreground)"}}),e.jsx("span",{className:"max-w-[120px] truncate",children:G?.name??m("Project")}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",Z&&"rotate-180")})]}),Z&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:s.map(i=>e.jsxs("button",{type:"button",onClick:()=>ut(i.id),className:"flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx("span",{className:"size-2 rounded-full shrink-0 mr-2",style:{backgroundColor:i.color??"var(--muted-foreground)"}}),e.jsx("span",{className:k("truncate flex-1",i.id===p?"text-foreground font-medium":"text-muted-foreground"),children:i.name}),e.jsx(se,{size:14,className:k("ml-2 shrink-0 text-foreground",i.id===p?"opacity-100":"opacity-0")})]},i.id))})]}),(T||O==="SOLO")&&e.jsxs("div",{className:"relative",ref:le,children:[e.jsxs("button",{type:"button",onClick:()=>{P||z(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed",ve?"text-foreground/80":"text-muted-foreground"),children:[e.jsx(pe,{agentType:ve?.agentType,className:"size-3.5"}),e.jsx("span",{className:"max-w-[120px] truncate",children:ve?.name??m(o?"Loading...":"Agent")}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",w&&"rotate-180")})]}),w&&e.jsx("div",{className:"absolute top-full left-0 mt-1.5 w-56 bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 max-h-[240px] overflow-y-auto z-50",children:a.map(i=>e.jsxs("button",{type:"button",disabled:!i.available,onClick:()=>{h(i.id),z(!1)},className:k("flex items-center w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",!i.available&&"opacity-40 cursor-not-allowed"),children:[e.jsx(se,{size:14,className:k("mr-2 shrink-0 text-foreground",i.id===d?"opacity-100":"opacity-0")}),e.jsx(pe,{agentType:i.agentType,className:"mr-2 size-3.5"}),e.jsxs("span",{className:k("min-w-0 truncate",i.id===d?"text-foreground font-medium":"text-muted-foreground"),children:[i.name,i.available?"":m(" (unavailable)")]})]},i.id))})]}),!T&&O==="SOLO"&&e.jsxs("div",{className:"relative",ref:Se,children:[e.jsxs("button",{type:"button",onClick:()=>{P||q(i=>!i)},disabled:P,className:k("flex items-center gap-1.5 px-2 h-7 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed text-foreground/80"),children:[e.jsx(zt,{size:14,className:"text-muted-foreground"}),e.jsx("span",{className:"max-w-[96px] truncate",children:at}),e.jsx(fe,{size:12,className:k("text-muted-foreground transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{className:"absolute top-full left-0 mt-1.5 w-72 max-w-[calc(100vw-2rem)] bg-popover border border-border rounded-lg shadow-[0_4px_12px_rgba(0,0,0,0.06)] py-1 z-50",children:[$?e.jsx(Ae,{side:"bottom",className:"block w-full",content:qe,children:e.jsxs("div",{tabIndex:0,"aria-label":qe,className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsxs("button",{type:"button",disabled:!0,className:"flex w-full cursor-not-allowed items-center px-3 py-2 text-left text-xs opacity-40 transition-colors",children:[e.jsx(se,{size:14,className:"mr-2 mt-0.5 shrink-0 text-foreground opacity-0"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-muted-foreground",children:m("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]}),e.jsx("button",{type:"button",onClick:lt,disabled:de.isPending,className:"flex w-full items-center px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:de.isPending?m("检测中..."):m("重新检测 Git 状态")})]})}):e.jsxs("button",{type:"button",onClick:()=>{M(L.WORKTREE),q(!1)},className:"flex w-full items-center px-3 py-2 text-left text-xs transition-colors hover:bg-accent",children:[e.jsx(se,{size:14,className:k("mr-2 mt-0.5 shrink-0 text-foreground",Y===L.WORKTREE?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:k("block truncate",Y===L.WORKTREE?"text-foreground font-medium":"text-muted-foreground"),children:m("工作树模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:Fe})]})]}),e.jsxs("button",{type:"button",onClick:()=>{M(L.MAIN_DIRECTORY),q(!1)},className:"flex items-start w-full px-3 py-2 text-xs text-left hover:bg-accent transition-colors",children:[e.jsx(se,{size:14,className:k("mr-2 mt-0.5 shrink-0 text-foreground",Y===L.MAIN_DIRECTORY?"opacity-100":"opacity-0")}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:k("block truncate",Y===L.MAIN_DIRECTORY?"text-foreground font-medium":"text-muted-foreground"),children:m("本地模式")}),e.jsx("span",{className:"mt-0.5 block whitespace-normal text-[11px] leading-snug text-muted-foreground/80",children:it})]})]})]})]}),!T&&e.jsx(Ae,{side:"bottom",className:"ml-auto",content:$?m("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun."):Y===L.MAIN_DIRECTORY?m("TeamRun 需要工作树模式。开启团队模式时会自动切换为工作树模式。"):m("启用 TeamRun 后可选择团队模板或成员。"),children:e.jsxs("button",{type:"button",role:"switch","aria-checked":O==="TEAM",onClick:()=>{P||$||(v==="TEAM"?(j("SOLO"),Q(!1)):(j("TEAM"),q(!1),M(L.WORKTREE),Q(!0)))},disabled:P||$,className:k("flex items-center gap-2 h-7 pl-2 pr-2 rounded-md text-xs font-medium transition-colors","hover:bg-accent disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",O==="TEAM"?"text-foreground/80":"text-muted-foreground"),"aria-label":m("启用团队模式"),children:[e.jsx(kt,{size:14,className:O==="TEAM"?"text-foreground/80":"text-muted-foreground"}),e.jsx("span",{children:m("团队模式")}),($||Y===L.MAIN_DIRECTORY)&&O!=="TEAM"?e.jsx(Ct,{size:12,className:"text-muted-foreground/70","aria-hidden":"true"}):null,e.jsx("span",{className:k("relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",O==="TEAM"?"bg-primary":"bg-border"),children:e.jsx("span",{className:k("inline-block size-3 rounded-full bg-background shadow-sm transition-transform",O==="TEAM"?"translate-x-3.5":"translate-x-0.5")})})]})})]}),!T&&O==="TEAM"&&re&&e.jsx("div",{className:"mt-2.5 rounded-xl border border-border/60 bg-muted/40 p-3 animate-[fadeInUp_0.25s_cubic-bezier(0.16,1,0.3,1)]",children:e.jsx(nn,{mode:D,setMode:U,selectedTemplateId:K,setSelectedTemplateId:te,selectedMemberPresetIds:H,setSelectedMemberPresetIds:ne,disabled:P,compact:!0})})]})}export{_n as A,Hn as B,Qn as C,zt as G,Bn as P,qn as R,On as S,Gn as T,Kt as Z,Un as a,Pn as b,_t as c,Dn as d,zn as e,nn as f,Fn as g,Kn as h,dn as i,yn as j,$n as k,rn as l,Wt as m,Wn as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as a,P as j,Q as E,U as T,j as s,l as U,u as _,p as I,B as O}from"./index-
|
|
1
|
+
import{r as a,P as j,Q as E,U as T,j as s,l as U,u as _,p as I,B as O}from"./index-D9kBRMR0.js";function M(t){const{sessionId:c,onOutput:k,onExit:x,onError:b}=t,[p,g]=a.useState(()=>j.isConnected()),[r,d]=a.useState(!1),m=a.useRef({onOutput:k,onExit:x,onError:b});m.current={onOutput:k,onExit:x,onError:b},a.useEffect(()=>{const n=j.getSocket();g(n.connected);const u=()=>g(!0),v=()=>{g(!1),d(!1)},w=l=>{l.sessionId===c&&m.current.onOutput?.(l.data)},C=l=>{l.sessionId===c&&(d(!1),m.current.onExit?.(l.exitCode))},S=l=>{l.sessionId===c&&m.current.onError?.(l.message)};return n.on("connect",u),n.on("disconnect",v),n.on(E.SESSION_STDOUT,w),n.on(E.SESSION_EXIT,C),n.on(E.SESSION_ERROR,S),g(n.connected),()=>{n.off("connect",u),n.off("disconnect",v),n.off(E.SESSION_STDOUT,w),n.off(E.SESSION_EXIT,C),n.off(E.SESSION_ERROR,S),d(!1)}},[c]);const i=a.useCallback(()=>new Promise(n=>{if(!j.getSocket().connected){n(!1);return}d(!0),n(!0)}),[]),y=a.useCallback(()=>{d(!1)},[]),N=a.useCallback(n=>{j.getSocket().emit(T.INPUT,{sessionId:c,data:n})},[c]),h=a.useCallback((n,u)=>{j.getSocket().emit(T.RESIZE,{sessionId:c,cols:n,rows:u})},[c]);return{isConnected:p,isAttached:r,attach:i,detach:y,sendInput:N,resize:h}}function $({className:t,...c}){return s.jsx("div",{"data-slot":"card",className:U("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...c})}function B(){const{t}=_(),[c,k]=a.useState([]),[x,b]=a.useState(""),[p,g]=a.useState(""),[r,d]=a.useState(null),[m,i]=a.useState([]),[y,N]=a.useState(!1),[h,n]=a.useState(""),u=a.useRef(null),v=a.useCallback(e=>{i(o=>{const f=o[o.length-1];return f&&f.role==="agent"?[...o.slice(0,-1),{...f,content:f.content+e}]:[...o,{role:"agent",content:e,timestamp:new Date}]})},[]),w=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
2
2
|
[${t("Process exited with code {code}",{code:e})}]`,timestamp:new Date}]),d(null)},[t]),C=a.useCallback(e=>{i(o=>[...o,{role:"agent",content:`
|
|
3
3
|
[${t("Error: {message}",{message:e})}]`,timestamp:new Date}])},[t]),{isConnected:S,isAttached:l,attach:D}=M({sessionId:r||"",onOutput:v,onExit:w,onError:C});a.useEffect(()=>{I.get("/demo/agents").then(e=>{k(e.agents);const o=e.agents.find(f=>f.available);o&&b(o.type)})},[]),a.useEffect(()=>{u.current?.scrollIntoView({behavior:"smooth"})},[m]),a.useEffect(()=>{r&&S&&!l&&D()},[r,S,l,D]);const R=async()=>{if(!(!x||!p.trim())){N(!0),i([{role:"user",content:p,timestamp:new Date}]);try{const e=await I.post("/demo/start",{agentType:x,prompt:p.trim()});d(e.sessionId),g("")}catch(e){i(o=>[...o,{role:"agent",content:t("启动失败: {message}",{message:e instanceof Error?e.message:t("未知错误")}),timestamp:new Date}])}finally{N(!1)}}},A=async()=>{if(!r||!h.trim())return;const e=h.trim();i(o=>[...o,{role:"user",content:e,timestamp:new Date}]),n("");try{await I.post(`/demo/${r}/message`,{message:e})}catch(o){i(f=>[...f,{role:"agent",content:t("发送失败: {message}",{message:o instanceof Error?o.message:t("未知错误")}),timestamp:new Date}])}},P=async()=>{if(r)try{await I.post(`/demo/${r}/stop`),i(e=>[...e,{role:"agent",content:`
|
|
4
4
|
[${t("会话已停止")}]`,timestamp:new Date}]),d(null)}catch(e){console.error("Stop failed:",e)}};return s.jsxs("div",{className:"flex flex-col h-full max-w-4xl mx-auto p-4 gap-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:t("Agent 交互演示")}),!r&&s.jsxs($,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold mb-3",children:t("选择 Agent")}),s.jsx("div",{className:"flex gap-2 flex-wrap mb-4",children:c.map(e=>s.jsxs(O,{variant:x===e.type?"default":"outline",disabled:!e.available,onClick:()=>b(e.type),children:[e.name,e.available&&e.version&&` (${e.version})`,!e.available&&t(" (不可用)")]},e.type))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&R(),placeholder:t("输入你的问题或任务..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(O,{onClick:R,disabled:y||!x||!p.trim(),children:t(y?"启动中...":"开始")})]})]}),s.jsxs($,{className:"flex-1 p-4 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:t("对话")}),r&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-gray-500",children:t(S?l?"已连接":"连接中...":"未连接")}),s.jsx(O,{variant:"outline",size:"sm",onClick:P,children:t("停止")})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[m.length===0?s.jsx("div",{className:"text-gray-400 text-center py-8",children:t("选择 Agent 并输入问题开始对话")}):m.map((e,o)=>s.jsxs("div",{className:`p-3 rounded-lg ${e.role==="user"?"bg-blue-100 ml-8":"bg-gray-100 mr-8"}`,children:[s.jsx("div",{className:"text-xs text-gray-500 mb-1",children:e.role==="user"?t("你"):"Agent"}),s.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:e.content})]},o)),s.jsx("div",{ref:u})]}),r&&s.jsxs("div",{className:"flex gap-2 mt-3 pt-3 border-t",children:[s.jsx("input",{type:"text",value:h,onChange:e=>n(e.target.value),onKeyDown:e=>e.key==="Enter"&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229&&A(),placeholder:t("发送后续消息..."),className:"flex-1 px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"}),s.jsx(O,{onClick:A,disabled:!h.trim(),children:t("发送")})]})]})]})}export{B as DemoPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as te,a as ne,b as le,c as ie,d as re,e as oe,f as ce,r as t,t as m,j as s,S as de,g as ue,h as A,i as G,B as g,I as z}from"./index-
|
|
1
|
+
import{u as te,a as ne,b as le,c as ie,d as re,e as oe,f as ce,r as t,t as m,j as s,S as de,g as ue,h as A,i as G,B as g,I as z}from"./index-D9kBRMR0.js";import{S as U}from"./select-BpKQyMvD.js";import{T as me}from"./textarea-DjwjAAG8.js";import{S as ge}from"./switch-BJ4Ar_OA.js";import{u as pe}from"./use-providers-DLcAY6E1.js";import"./chevron-down-BQcW9sFf.js";import"./check-BN_PVKzE.js";const fe=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],N="__follow_task__",R=8;function W(P,y){return P instanceof Error?P.message:y}function je(){const{locale:P,setLocale:y,t:e}=te(),{data:p}=ne(),{data:H}=pe(),{data:w}=le(),{data:r}=ie(),u=re(),i=oe(),S=ce(),[K,D]=t.useState(N),[E,k]=t.useState(""),[V,j]=t.useState(!1),[d,_]=t.useState(""),[o,L]=t.useState(""),[C,I]=t.useState(""),[M,f]=t.useState(!1),[q,h]=t.useState(!1),[b,l]=t.useState(null);t.useEffect(()=>{!p||!w||(D(p.commitMessageProviderId||N),k(p.commitMessagePrompt||w.prompt),j(!1))},[p,w]),t.useEffect(()=>{r&&(f(r.enabled),h(!1),l(null),_(""),L(""),I(""))},[r?.enabled]);const J=[{value:N,label:e("跟随任务")},...(H??[]).filter(a=>a.availability.type!=="NOT_FOUND").map(a=>({value:a.provider.id,label:a.provider.name}))],x=r?.enabled??!1,n=!x&&M?"enable":x&&!M?"disable":x&&q?"change":"idle",O=n!=="idle",Q=e(O?n==="disable"?"将关闭":n==="enable"?"将启用":"已启用":x?"已启用":"未启用"),X=t.useCallback(a=>{D(a);const v=a===N?null:a;u.mutate({commitMessageProviderId:v},{onError:()=>m.error(e("保存失败"))})},[u,e]),Y=t.useCallback(()=>{const a=E.trim()||null;u.mutate({commitMessagePrompt:a},{onSuccess:()=>{j(!1),m.success(e("已保存"))},onError:()=>m.error(e("保存失败"))})},[E,u,e]),c=t.useCallback(()=>{_(""),L(""),I("")},[]),Z=t.useCallback(()=>{f(r?.enabled??!1),h(!1),l(null),c()},[r?.enabled,c]),F=t.useCallback(a=>{if((a==="change"||a==="disable")&&!d)return l(e("请输入当前密码")),!1;if(a==="enable"||a==="change"){if(o.length<R)return l(e("密码至少需要 8 个字符")),!1;if(o!==C)return l(e("两次输入不一致")),!1}return l(null),!0},[C,d,o,e]),B=t.useCallback(()=>{if(n==="idle"||!F(n))return;const a=n==="disable"?{enabled:!1,currentPassword:d}:n==="enable"?{enabled:!0,newPassword:o}:{currentPassword:d,newPassword:o};i.mutate(a,{onSuccess:v=>{f(v.enabled),h(!1),l(null),c(),m.success(e(n==="disable"?"已关闭":"已保存"))},onError:v=>{const T=W(v,e("保存失败"));T.toLowerCase().includes("current password")?l(e("当前密码不正确")):T.toLowerCase().includes("at least 8")?l(e("密码至少需要 8 个字符")):l(T)}})},[n,c,d,o,e,i,F]),$=t.useCallback(a=>{!r||i.isPending||(f(a),h(!1),l(null),c())},[r,c,i.isPending]),ee=t.useCallback(()=>{S.mutate(void 0,{onSuccess:()=>m.success(e("已退出登录")),onError:a=>m.error(W(a,e("退出登录失败")))})},[S,e]),se=t.useCallback(a=>{a.preventDefault(),B()},[B]),ae=t.useCallback(()=>{!r||i.isPending||(f(!0),h(!0),l(null),c())},[r,c,i.isPending]);return s.jsxs(de,{children:[s.jsx(ue,{title:e("通用设置"),className:"mb-1"}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(A,{label:e("显示语言"),description:e("界面语言会保存到本地数据库,重启后继续生效。"),align:"center",children:s.jsx(U,{value:P,onChange:a=>y(a),options:fe})})}),s.jsx(G,{className:"mt-8 mb-1",children:e("访问安全")}),s.jsx("div",{className:"divide-y divide-border/60",children:s.jsx(A,{label:e("访问密码"),description:e("开启后,进入 Agent Tower 需要输入密码。"),controlWidth:"fixed",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-foreground",children:Q}),s.jsx(ge,{checked:M,onCheckedChange:$,disabled:!r||i.isPending,"aria-label":e("访问密码")})]}),x&&n==="idle"&&s.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[s.jsx(g,{type:"button",size:"sm",variant:"outline",className:"w-full sm:w-auto",onClick:ae,disabled:i.isPending,children:e("修改密码")}),s.jsx(g,{type:"button",size:"sm",variant:"ghost",className:"w-full sm:w-auto",onClick:ee,disabled:S.isPending,children:S.isPending?e("退出中..."):e("退出登录")})]}),O&&s.jsxs("form",{className:"space-y-2",onSubmit:se,children:[(n==="change"||n==="disable")&&s.jsx(z,{type:"password",autoComplete:"current-password",placeholder:e("当前密码"),value:d,onChange:a=>{_(a.target.value),l(null)},disabled:i.isPending,"aria-invalid":!!(b&&!d)}),(n==="enable"||n==="change")&&s.jsxs(s.Fragment,{children:[s.jsx(z,{type:"password",autoComplete:"new-password",placeholder:e(n==="enable"?"访问密码":"新密码"),value:o,onChange:a=>{L(a.target.value),l(null)},disabled:i.isPending,"aria-invalid":!!(b&&o.length<R)}),s.jsx(z,{type:"password",autoComplete:"new-password",placeholder:e("确认密码"),value:C,onChange:a=>{I(a.target.value),l(null)},disabled:i.isPending,"aria-invalid":!!(b&&o!==C)})]}),(n==="change"||n==="disable")&&s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e(n==="disable"?"关闭后不再要求访问密码。":"保存后其他已登录页面需要重新输入。")}),b&&s.jsx("p",{className:"text-xs text-destructive",children:b}),s.jsxs("div",{className:"flex flex-col-reverse gap-2 pt-1 sm:flex-row sm:justify-end",children:[s.jsx(g,{type:"button",size:"sm",variant:"ghost",className:"w-full sm:w-auto",onClick:Z,disabled:i.isPending,children:e("取消")}),s.jsx(g,{type:"submit",size:"sm",className:"w-full sm:w-auto",disabled:i.isPending,children:i.isPending?e("保存中..."):e(n==="disable"?"关闭访问密码":"保存")})]})]})]})})}),s.jsx(G,{className:"mt-8 mb-1",children:e("Git Commit Message")}),s.jsxs("div",{className:"divide-y divide-border/60",children:[s.jsx(A,{label:e("Agent 渠道"),description:e('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。'),children:s.jsx(U,{value:K,onChange:X,options:J})}),s.jsx(A,{label:e("提示词模板"),description:e("自定义生成 commit message 的提示词。留空则使用内置默认模板。"),children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(me,{value:E,onChange:a=>{k(a.target.value),j(!0)},rows:5,className:"font-mono resize-y"}),V&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{k(p?.commitMessagePrompt||w?.prompt||""),j(!1)},children:e("取消")}),s.jsx(g,{size:"sm",onClick:Y,disabled:u.isPending,children:u.isPending?e("保存中..."):e("保存")})]})]})})]})]})}export{je as GeneralSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as t,j as o}from"./index-
|
|
1
|
+
import{k as t,j as o}from"./index-D9kBRMR0.js";const r=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],c=t("at-sign",r);const s=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],i=t("globe",s),l=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("path",{d:"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1z",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M8 1a7 7 0 0 0 0 14V1z",fill:"currentColor"})]}),h=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.4"}),o.jsx("circle",{cx:"8",cy:"8",r:"3",fill:"currentColor"})]}),x=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"})}),d=({className:e})=>o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:o.jsx("path",{d:"M13.5 4.5L6.5 11.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),w=({className:e})=>o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",className:e,xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5"}),o.jsx("path",{d:"M5.5 5.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});export{c as A,i as G,h as I,d as a,x as b,w as c,l as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as f,r as o,L as u,j as e,R as h,X as b}from"./index-
|
|
1
|
+
import{u as f,r as o,L as u,j as e,R as h,X as b}from"./index-D9kBRMR0.js";function p(){const{t:s}=f(),[a,c]=o.useState(null),x=o.useRef(null),d=o.useRef(null),i=o.useRef(null),t=a?u.find(r=>r.id===a):null,l=o.useCallback(()=>{c(null)},[]);return o.useEffect(()=>{if(!t){i.current?.focus(),i.current=null;return}d.current?.focus();const r=n=>{if(n.key==="Escape"){n.preventDefault(),l();return}n.key==="Tab"&&(n.preventDefault(),d.current?.focus())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,l]),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("style",{children:h}),e.jsx("header",{className:"border-b border-border px-6 py-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Loading Animation Preview"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("10 个首屏加载动画候选 · 颜色遵循 Agent Tower 设计规范 · 点击卡片查看全屏效果")})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8",inert:t?!0:void 0,"aria-hidden":t?!0:void 0,children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map((r,n)=>{const m=r.component;return e.jsxs("button",{onClick:g=>{i.current=g.currentTarget,c(r.id)},className:"group relative flex flex-col bg-card border border-border rounded-lg p-5 text-left transition-shadow hover:shadow-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",children:[e.jsxs("span",{className:"absolute top-3 right-3 text-[11px] font-semibold text-muted-foreground/60 tabular-nums",children:["#",n+1]}),e.jsx("div",{className:"flex items-center justify-center h-28 mb-4",children:e.jsx(m,{})}),e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:s(r.description)})]},r.id)})}),e.jsxs("div",{className:"mt-10 p-5 border border-border rounded-lg bg-muted/30",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground mb-2",children:s("设计推荐")}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1.5 leading-relaxed",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("首选:Charcoal Breathe (#10)")})," — ",s("品牌感最强,Charcoal 色块+Tower 图标呼吸,用户对产品的第一印象即品牌本身。")]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("备选A:Tower Pulse (#1)")})," — ",s("品牌图标直接出现,脉冲节奏稳定,不浮夸,适合工作台场景。")]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-foreground",children:s("备选B:Terminal Cursor (#4)")})," — ",s("终端光标闪烁,贴合 Agent/终端协作的核心场景,开发者亲切感强。")]})]})]})]}),t&&e.jsxs("div",{ref:x,className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:r=>{r.target===r.currentTarget&&l()},role:"dialog","aria-modal":"true","aria-label":s("全屏预览:{name}",{name:t.name}),children:[e.jsx("button",{ref:d,onClick:l,className:"absolute top-4 right-4 p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":s("关闭预览"),children:e.jsx(b,{size:20})}),e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"scale-[2] origin-center",children:e.jsx(t.component,{})}),e.jsxs("div",{className:"text-center mt-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-sm",children:s(t.description)})]}),e.jsx("span",{className:"text-xs text-muted-foreground/60 mt-2",children:s("按 Esc 或点击关闭按钮退出")})]})]})]})}export{p as LoadingPreviewPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as x,m,q as o,p as u,u as p,r as g,t as n,j as e,S as a,a3 as f,B as i,a5 as h}from"./index-
|
|
1
|
+
import{k as x,m,q as o,p as u,u as p,r as g,t as n,j as e,S as a,a3 as f,B as i,a5 as h}from"./index-D9kBRMR0.js";import{C as j}from"./copy-DaoAUKTO.js";import{C as b}from"./check-BN_PVKzE.js";const y=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],N=x("server",y);function C(){return m({queryKey:o.system.mcpConfig,queryFn:()=>u.get("/system/mcp-config")})}function v({mode:s,label:t}){const r=s==="desktop-packaged";return e.jsx("span",{className:`inline-flex items-center rounded-md px-2 py-1 text-[11px] font-medium ${r?"bg-emerald-50 text-emerald-700":"bg-amber-50 text-amber-700"}`,children:t})}function z(){const{t:s}=p(),{data:t,isLoading:r,isError:l,refetch:d}=C(),c=g.useCallback(async()=>{if(t?.configJson)try{await navigator.clipboard.writeText(t.configJson),n.success(s("MCP 配置已复制"))}catch{n.error(s("复制 MCP 配置失败"))}},[t?.configJson,s]);return r?e.jsx(a,{children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-neutral-500"})})}):l||!t?e.jsxs(a,{children:[e.jsx("h2",{className:"mb-1 text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("div",{className:"mt-5 rounded-lg border border-red-100 bg-red-50 px-4 py-3 text-sm text-red-700",children:s("MCP 配置加载失败")}),e.jsx(i,{className:"mt-4",size:"sm",variant:"outline",onClick:()=>{d()},children:s("重试")})]}):e.jsxs(a,{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:s("MCP 配置")}),e.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-neutral-500",children:s("复制下面的 JSON 到支持 MCP 的客户端配置中。桌面打包版使用 App 内置 runtime,不需要全局安装 agent-tower。")})]}),e.jsxs(i,{size:"sm",onClick:c,children:[e.jsx(j,{size:14}),s("复制配置")]})]}),e.jsxs("div",{className:"space-y-3 border-b border-neutral-100 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(v,{mode:t.runtimeMode,label:t.runtimeMode==="desktop-packaged"?s("桌面打包 runtime"):s("工作区 runtime")}),e.jsx("span",{className:"text-[12px] text-neutral-400",children:t.serverName})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(h,{size:12}),"Command"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.command})]}),e.jsxs("div",{className:"rounded-lg border border-neutral-100 bg-neutral-50/70 p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-medium uppercase text-neutral-400",children:[e.jsx(N,{size:12}),"Entry"]}),e.jsx("div",{className:"break-all font-mono text-[12px] leading-relaxed text-neutral-800",children:t.args.at(-1)??""})]})]})]}),e.jsxs("div",{className:"pt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:"mcpServers JSON"}),t.runtimeMode==="desktop-packaged"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-emerald-600",children:[e.jsx(b,{size:12}),s("无需全局 CLI")]})]}),e.jsx("textarea",{readOnly:!0,value:t.configJson,rows:14,className:"w-full resize-y rounded-lg border border-neutral-200 bg-neutral-950 px-3 py-3 font-mono text-[12px] leading-relaxed text-neutral-100 outline-none"}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-neutral-400",children:s("当前版本只生成通用 MCP 配置,不会自动修改 Claude、Codex 或其他第三方客户端配置文件。")})]})]})}export{z as McpSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,j as n,l as o}from"./index-
|
|
1
|
+
import{r as i,j as n,l as o}from"./index-D9kBRMR0.js";function d(r){const t=r.trim();if(!t)return"?";const e=t.split(/\s+/).filter(Boolean);return e.length>=2?`${e[0][0]??""}${e[1][0]??""}`.toUpperCase():Array.from(t).slice(0,2).join("").toUpperCase()}function a(r){const t=r.trim();return/^#([0-9a-f]{3,8})$/i.test(t)||/^rgba?\(/i.test(t)||/^hsla?\(/i.test(t)}function l(r){const t=r.trim();return t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("data:image/")||t.startsWith("blob:")}function h(r,t){const e=r?.trim()??"";return!e||a(e)||l(e)?d(t):e.length<=2?e.toUpperCase():e.slice(0,2).toUpperCase()}function p(r){const t=r?.trim()??"";if(!(!t||!a(t)))return{backgroundColor:t,color:"#ffffff"}}function g({name:r,avatar:t,className:e}){const[u,c]=i.useState(null),s=t?.trim()??"",f=!!s&&l(s)&&u!==s,m=i.useMemo(()=>h(s,r),[r,s]);return f?n.jsx("img",{src:s,alt:r,loading:"lazy",onError:()=>c(s),className:o("h-7 w-7 shrink-0 rounded-full border border-neutral-200 bg-white object-cover",e)}):n.jsx("div",{className:o("flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-neutral-200 bg-neutral-100 text-[10px] font-semibold text-neutral-600",e),style:p(s),"aria-label":r,children:m})}export{g as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as P,m as q,o as E,n as k,q as v,p as h,u as R,r as o,j as e,S as g,a1 as B,g as W,h as j,a2 as z,I as d,B as L,a3 as M,a4 as A,i as K,$ as Q}from"./index-
|
|
1
|
+
import{k as P,m as q,o as E,n as k,q as v,p as h,u as R,r as o,j as e,S as g,a1 as B,g as W,h as j,a2 as z,I as d,B as L,a3 as M,a4 as A,i as K,$ as Q}from"./index-D9kBRMR0.js";import{S as O}from"./select-BpKQyMvD.js";import{S as _}from"./switch-BJ4Ar_OA.js";import{M as D}from"./message-square-DxbkpGqF.js";import{C as H}from"./circle-alert-oa-BQ5e7.js";import"./chevron-down-BQcW9sFf.js";import"./check-BN_PVKzE.js";const $=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],G=P("link",$);function J(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function V(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function X(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function ne(){const{t}=R(),{data:i,isLoading:y}=J(),l=V(),n=X(),N=[{value:"none",label:t("关闭")},{value:"feishu",label:t("飞书 Webhook")}],[a,x]=o.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[m,p]=o.useState(!1),[f,r]=o.useState("idle"),u=o.useRef(void 0);if(o.useEffect(()=>{i&&!m&&x({webhookUrl:i.feishuWebhookUrl??"",baseUrl:i.thirdPartyBaseUrl??"",titleTemplate:i.taskInReviewTitleTemplate??"",bodyTemplate:i.taskInReviewBodyTemplate??""})},[i,m]),o.useEffect(()=>(n.isSuccess?(r("success"),u.current=setTimeout(()=>r("idle"),3e3)):n.isError&&(r("error"),u.current=setTimeout(()=>r("idle"),5e3)),()=>clearTimeout(u.current)),[n.isSuccess,n.isError]),y)return e.jsx(g,{children:e.jsx(B,{rows:3})});const T=i?.osNotificationEnabled??!0,b=i?.thirdPartyChannel??"none",c=(s,I)=>{x(F=>({...F,[s]:I})),p(!0)},S=s=>{l.mutate({osNotificationEnabled:s})},C=s=>{l.mutate({thirdPartyChannel:s})},U=()=>{l.mutate({feishuWebhookUrl:a.webhookUrl.trim()||null,thirdPartyBaseUrl:a.baseUrl.trim()||null,taskInReviewTitleTemplate:a.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:a.bodyTemplate.trim()||t('✅ "{taskTitle}" 已完成,等待审查')},{onSuccess:()=>p(!1)})},w=()=>{a.webhookUrl.trim()&&n.mutate({channel:"feishu",webhookUrl:a.webhookUrl.trim(),baseUrl:a.baseUrl.trim()||void 0})};return e.jsxs(g,{children:[e.jsx(W,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:z,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(_,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:D,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(O,{value:b,onChange:s=>C(s),options:N})}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4 sm:pl-11",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-webhook-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Webhook URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"feishu-webhook-url",value:a.webhookUrl,onChange:s=>c("webhookUrl",s.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"min-w-0 flex-1 font-mono"}),e.jsxs(L,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(M,{size:12,className:"mr-1 animate-spin motion-reduce:animate-none"}),t("测试")]})]}),f==="success"&&e.jsxs("div",{role:"status",className:"mt-2 flex items-center gap-1.5 text-xs text-success",children:[e.jsx(A,{size:12,"aria-hidden":"true"}),t("测试消息发送成功")]}),f==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 flex items-center gap-1.5 text-xs text-destructive",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),t("发送失败,请检查 Webhook 地址")]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-base-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(G,{size:11,"aria-hidden":"true"}),t("跳转地址")]})}),e.jsx(d,{id:"feishu-base-url",value:a.baseUrl,onChange:s=>c("baseUrl",s.target.value),placeholder:"http://localhost:5173",className:"font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t('通知卡片中的"查看任务"按钮跳转地址前缀')})]})]})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(K,{children:t("通知模板")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("支持变量: {taskTitle}, {taskId}, {projectId}, {projectName}, {status}",{taskTitle:"{taskTitle}",taskId:"{taskId}",projectId:"{projectId}",projectName:"{projectName}",status:"{status}"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-title-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("标题")}),e.jsx(d,{id:"notification-title-template",value:a.titleTemplate,onChange:s=>c("titleTemplate",s.target.value),placeholder:"Agent Tower"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-body-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("内容")}),e.jsx(d,{id:"notification-body-template",value:a.bodyTemplate,onChange:s=>c("bodyTemplate",s.target.value),placeholder:t('✅ "{taskTitle}" 已完成,等待审查')})]})]})]})]}),m&&e.jsx(Q,{saving:l.isPending,onSave:U})]})}export{ne as NotificationSettingsPage};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{u as T,r as g,j as e,S,g as J,s as M,v as w,I as U,B as E,w as p,l as P}from"./index-
|
|
1
|
+
import{u as T,r as g,j as e,S,g as J,s as M,v as w,I as U,B as E,w as p,l as P}from"./index-D9kBRMR0.js";import{u as _,a as z,b as B,c as F}from"./use-profiles-BlGgvdYm.js";import{M as G}from"./modal-Cymk-6Df.js";import{C as $}from"./confirm-dialog-CRiC3xBd.js";import{T as R}from"./textarea-DjwjAAG8.js";import{L as H}from"./layers-Bo4aml98.js";import{C as q}from"./chevron-down-BQcW9sFf.js";import{P as K,T as Q}from"./trash-2-R46i6Uus.js";import{P as W}from"./pencil-DOL2nlgg.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(K,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx(Q,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=_(),{data:c}=z(),h=B(),j=F(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
|
|
2
2
|
|
|
3
3
|
}`),v("")},D=()=>{if(!(!n||!i.trim()))try{const s=JSON.parse(b);v(""),h.mutate({agentType:n.agentType,variant:i.trim().toUpperCase(),config:s},{onSuccess:()=>r(null)})}catch{v(t("JSON 格式错误"))}},L=(s,l)=>{N({agentType:s,variant:l})},A=()=>{o&&j.mutate({agentType:o.agentType,variant:o.variant},{onSettled:()=>N(null)})},I=(s,l)=>!!c?.executors[s]?.[l];if(m)return e.jsx(S,{children:e.jsx(Z,{})});const C=a?.executors??{};return e.jsxs(S,{children:[e.jsx(J,{title:t("Profile 配置"),description:t("管理 Agent 执行器的配置变体。每个变体定义一组运行参数。"),className:"mb-4"}),e.jsx("div",{className:"space-y-3",children:Object.entries(C).map(([s,l])=>e.jsx(Y,{agentType:s,variants:l,isBuiltIn:d=>I(s,d),onEdit:(d,V)=>k(s,d,V),onNew:()=>O(s),onDelete:d=>L(s,d)},s))}),Object.keys(C).length===0&&e.jsx(M,{icon:H,message:t("暂无 Profile 配置")}),e.jsx(G,{isOpen:!!n,onClose:()=>r(null),title:n?.isNew?t("新增 Variant — {agentType}",{agentType:y[n.agentType]??n.agentType}):t("编辑 {variant}",{variant:n?.variant??""}),action:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outline",onClick:()=>r(null),children:t("取消")}),e.jsx(E,{onClick:D,disabled:h.isPending,children:h.isPending?t("保存中..."):t("保存")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{label:t("Variant 名称"),htmlFor:"profile-variant-name",children:e.jsx(U,{id:"profile-variant-name",value:i,onChange:s=>x(s.target.value),disabled:!n?.isNew,placeholder:t("例如: CUSTOM"),className:"font-mono"})}),e.jsxs(w,{label:t("配置 (JSON)"),htmlFor:"profile-variant-json",children:[e.jsx(R,{id:"profile-variant-json",value:b,onChange:s=>{u(s.target.value),v("")},rows:6,className:"resize-none font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:f})]})]})}),e.jsx($,{isOpen:o!==null,onClose:()=>{j.isPending||N(null)},onConfirm:A,title:t("删除 Profile Variant"),description:o?t('确定删除 "{name}"?此操作不可撤销。',{name:`${y[o.agentType]??o.agentType} / ${o.variant}`}):"",confirmText:t("删除"),cancelText:t("取消"),variant:"danger",isLoading:j.isPending})]})}export{de as ProfileSettingsPage};
|