agentstudio 0.2.2 → 0.2.4
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/index.js +2 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{AgentsPage-DgoZNP6l.js → AgentsPage-rLPOC44M.js} +1 -1
- package/public/assets/{Button-BHiMThm4.js → Button-CfU7z0eT.js} +1 -1
- package/public/assets/{ChatPage-LoTJrT43.js → ChatPage-Cl0wXezZ.js} +88 -88
- package/public/assets/{CommandsPage-CwEoyASk.js → CommandsPage-BgFvm2GI.js} +1 -1
- package/public/assets/{DashboardPage-BSi_T1tY.js → DashboardPage-BoonTnMH.js} +1 -1
- package/public/assets/{FileBrowser-Df-zwNDa.js → FileBrowser-BiAm3yrg.js} +1 -1
- package/public/assets/{GeneralSettingsPage-DcGmAzci.js → GeneralSettingsPage-BDayH81k.js} +1 -1
- package/public/assets/{LandingPage-DPKvTTja.js → LandingPage-DqS5qWgL.js} +1 -1
- package/public/assets/{LoginPage-BPJUgLru.js → LoginPage-C87yR34d.js} +1 -1
- package/public/assets/{McpAdminSettingsPage-CZZS-pa0.js → McpAdminSettingsPage-DIJs6UrH.js} +1 -1
- package/public/assets/{McpPage-CPF7txxc.js → McpPage-Dc4U_68i.js} +1 -1
- package/public/assets/{MemorySettingsPage-YenW4l-g.js → MemorySettingsPage-TErKrnR2.js} +1 -1
- package/public/assets/{PluginsPage-zlAB63Im.js → PluginsPage-DmCoLCdj.js} +1 -1
- package/public/assets/{ProjectSelector-Bq0NQ_bV.js → ProjectSelector-CFrsNw4L.js} +1 -1
- package/public/assets/{ProjectsPage-BMBRp4RN.js → ProjectsPage-DjumWKPo.js} +1 -1
- package/public/assets/{ScheduledTasksPage-B_hOD6AS.js → ScheduledTasksPage-CsFL7MD9.js} +1 -1
- package/public/assets/{SettingsLayout-CY9Siffq.js → SettingsLayout-D18ZK4TY.js} +1 -1
- package/public/assets/{SkillsPage-X-LMnwZd.js → SkillsPage-DxIdnjRM.js} +1 -1
- package/public/assets/{SubagentsPage-DIG_rKjQ.js → SubagentsPage-DWCgPFzI.js} +1 -1
- package/public/assets/{SystemInfoPage-CWgKWnQg.js → SystemInfoPage-C_kd76VQ.js} +1 -1
- package/public/assets/{TelemetrySettingsPage-BLnMagRZ.js → TelemetrySettingsPage-recK8TS7.js} +1 -1
- package/public/assets/{ToastTestPage-CQ0nobQd.js → ToastTestPage-DYwSASe6.js} +1 -1
- package/public/assets/{VersionSettingsPage-BxjDPWm0.js → VersionSettingsPage-DC_PL1Lo.js} +1 -1
- package/public/assets/{_basePickBy-D_S4EWYL.js → _basePickBy-DtI5oYel.js} +1 -1
- package/public/assets/{_baseUniq-BmQef9o6.js → _baseUniq-kP1SFZPO.js} +1 -1
- package/public/assets/{arc-DzCTkvPU.js → arc-cZ3PN_u0.js} +1 -1
- package/public/assets/{architectureDiagram-VXUJARFQ-8nWlVbiO.js → architectureDiagram-VXUJARFQ-BRn1b9Ct.js} +1 -1
- package/public/assets/{blockDiagram-VD42YOAC-DbHo3vzo.js → blockDiagram-VD42YOAC-B6Fmf92Z.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-DqFGiZ7Y.js → c4Diagram-YG6GDRKO-BdApn9Kl.js} +1 -1
- package/public/assets/channel-CIc09SLj.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-KZtUHSw3.js → chunk-4BX2VUAB-CFByNt-E.js} +1 -1
- package/public/assets/{chunk-55IACEB6-DTotxzVH.js → chunk-55IACEB6-DOcPvMrL.js} +1 -1
- package/public/assets/{chunk-B4BG7PRW-CkjDO6x_.js → chunk-B4BG7PRW-CYQhDwZH.js} +1 -1
- package/public/assets/{chunk-DI55MBZ5-ZN0hc9BQ.js → chunk-DI55MBZ5-fO-G4DQE.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4--jXmtjeY.js → chunk-FMBD7UC4-CvFCkBe9.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-D-FiWiLB.js → chunk-QN33PNHL-C4dfuLJX.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-BRs4hln6.js → chunk-QZHKN3VN-BHcbArKX.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BUZTflc7.js → chunk-TZMSLE5B-NAHq3aeT.js} +1 -1
- package/public/assets/{classDiagram-2ON5EDUG-7Lo3C-C9.js → classDiagram-2ON5EDUG-BX8bS8-I.js} +1 -1
- package/public/assets/{classDiagram-v2-WZHVMYZB-7Lo3C-C9.js → classDiagram-v2-WZHVMYZB-BX8bS8-I.js} +1 -1
- package/public/assets/clone-CPcgYjA1.js +1 -0
- package/public/assets/{cose-bilkent-S5V4N54A-s2WN1XmV.js → cose-bilkent-S5V4N54A-C06C9ZJa.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-CxaKwQyB.js → dagre-6UL2VRFP-DCPyTNLq.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-SU1hlbjn.js → diagram-PSM6KHXK-D_EHe21D.js} +1 -1
- package/public/assets/{diagram-QEK2KX5R-hcM85tep.js → diagram-QEK2KX5R-BlulhQOc.js} +1 -1
- package/public/assets/{diagram-S2PKOQOG-BOmtKWhQ.js → diagram-S2PKOQOG-DeNVHhsT.js} +1 -1
- package/public/assets/{erDiagram-Q2GNP2WA-CsTay3Qr.js → erDiagram-Q2GNP2WA-Bnz9kE57.js} +1 -1
- package/public/assets/{flowDiagram-NV44I4VS-QLwVU4W3.js → flowDiagram-NV44I4VS-CFn031Y3.js} +1 -1
- package/public/assets/{ganttDiagram-LVOFAZNH-CEJd76u6.js → ganttDiagram-LVOFAZNH-BSduoCu_.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-Cr7KuVc8.js → gitGraphDiagram-NY62KEGX-Bjbb7yAS.js} +1 -1
- package/public/assets/{graph-B12xs1JB.js → graph-D2RBy8e5.js} +1 -1
- package/public/assets/{index-BFYHztzB.js → index-BLjehayc.js} +2 -2
- package/public/assets/{infoDiagram-F6ZHWCRC-B6PyESp0.js → infoDiagram-F6ZHWCRC-BfeoDjKc.js} +1 -1
- package/public/assets/{journeyDiagram-XKPGCS4Q-DSlyGZSv.js → journeyDiagram-XKPGCS4Q-8tSVYPVe.js} +1 -1
- package/public/assets/{kanban-definition-3W4ZIXB7-DbDLw__g.js → kanban-definition-3W4ZIXB7-DwrpLyOH.js} +1 -1
- package/public/assets/{layout-OtboCb25.js → layout-B6w-fMcI.js} +1 -1
- package/public/assets/{linear-Bg3HtxIB.js → linear-ClbokBhh.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-DZ4bp0qm.js → mindmap-definition-VGOIOE7T-BurOGP_m.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-Am2n8jc0.js → pieDiagram-ADFJNKIX-MUQTeIhp.js} +1 -1
- package/public/assets/{quadrantDiagram-AYHSOK5B-DPm8iQzH.js → quadrantDiagram-AYHSOK5B-COgCGFdz.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-hVW5YE3R.js → requirementDiagram-UZGBJVZJ-DlYkINPo.js} +1 -1
- package/public/assets/{sankeyDiagram-TZEHDZUN-DX8gGHoq.js → sankeyDiagram-TZEHDZUN-oj7WNP67.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-Brl8T0m9.js → sequenceDiagram-WL72ISMW-TUi1zhlp.js} +1 -1
- package/public/assets/{stateDiagram-FKZM4ZOC-CxrXSnfX.js → stateDiagram-FKZM4ZOC-B7tNjdp0.js} +1 -1
- package/public/assets/{stateDiagram-v2-4FDKWEC3-BJfGHaLv.js → stateDiagram-v2-4FDKWEC3-9TkkItno.js} +1 -1
- package/public/assets/{table-D-FJ6K6j.js → table-Br8ioTXr.js} +1 -1
- package/public/assets/{timeline-definition-IT6M3QCI-CO6fKxuR.js → timeline-definition-IT6M3QCI-CSSGR7Wj.js} +1 -1
- package/public/assets/{treemap-KMMF4GRG-BsoblFM5.js → treemap-KMMF4GRG-BAb3Fz4w.js} +1 -1
- package/public/assets/{xychartDiagram-PRI3JC2R-B6g-H_PO.js → xychartDiagram-PRI3JC2R-Cd2BfyOw.js} +1 -1
- package/public/index.html +1 -1
- package/routes/sessions.d.ts.map +1 -1
- package/routes/sessions.js +17 -3
- package/routes/sessions.js.map +1 -1
- package/services/__tests__/projectMetadataStorage.test.d.ts +5 -0
- package/services/__tests__/projectMetadataStorage.test.d.ts.map +1 -0
- package/services/__tests__/projectMetadataStorage.test.js +154 -0
- package/services/__tests__/projectMetadataStorage.test.js.map +1 -0
- package/services/projectMetadataStorage.d.ts +7 -1
- package/services/projectMetadataStorage.d.ts.map +1 -1
- package/services/projectMetadataStorage.js +102 -27
- package/services/projectMetadataStorage.js.map +1 -1
- package/services/sessionManager.d.ts.map +1 -1
- package/services/sessionManager.js +17 -3
- package/services/sessionManager.js.map +1 -1
- package/public/assets/channel-DlGw39mX.js +0 -1
- package/public/assets/clone-180En6VP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as m,W as Q}from"./monaco-editor-DHKm5-VF.js";import{a as g,A as u}from"./agents-D9dWnZr0.js";import{b as ce,c as U,s as V,a as b}from"./index-
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as m,W as Q}from"./monaco-editor-DHKm5-VF.js";import{a as g,A as u}from"./agents-D9dWnZr0.js";import{b as ce,c as U,s as V,a as b}from"./index-BLjehayc.js";import{T as me,a as xe,b as B,c as v,d as pe,e as C}from"./table-Br8ioTXr.js";import{u as ge}from"./tools-zTM46-tZ.js";import{g as ue,L as N,v as he,C as M,n as be,z as fe,D as z,H as W,k as X,I as G,J as K,y as Y,E as ye}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";const Te=()=>{const{t:a}=ge("pages"),{isMobile:l}=ce(),[x,c]=m.useState([]),[Z,D]=m.useState(!0),[$,ee]=m.useState(""),[w,te]=m.useState(""),[ae,f]=m.useState(!1),[p,q]=m.useState(null),[o,y]=m.useState({name:"",type:"stdio",config:""}),[S,O]=m.useState(!1),[T,L]=m.useState(!1),[h,I]=m.useState({}),se=async()=>{try{D(!0);const t=await g(`${u}/mcp`);if(t.ok){const r=await t.json();c(r.servers||[])}else console.error("Failed to load MCP configs:",t.status),c([])}catch(t){console.error("Failed to load MCP configs:",t),c([])}finally{D(!1)}};Q.useEffect(()=>{se()},[]),Q.useEffect(()=>{const t=setTimeout(()=>{te($)},300);return()=>clearTimeout(t)},[$]);const k=async t=>{try{console.log("Validating MCP server:",t),c(s=>s.map(n=>n.name===t?{...n,status:"validating"}:n));const r=await g(`${u}/mcp/${t}/validate`,{method:"POST"});if(console.log("Validation response status:",r.status),r.ok){const s=await r.json();c(n=>n.map(i=>i.name===t?{...i,status:"active",tools:s.tools||[],error:void 0}:i))}else{const s=await r.json();let n=s.error||a("mcp.errors.validationFailed");s.details&&(n+=`
|
|
2
2
|
${s.details}`),c(i=>i.map(d=>d.name===t?{...d,status:"error",error:n,tools:void 0}:d))}}catch(r){console.error("MCP server validation failed:",r),c(s=>s.map(n=>n.name===t?{...n,status:"error",error:a("mcp.errors.networkError"),tools:void 0}:n))}},re=async()=>{for(const t of x)await k(t.name)},F=x.filter(t=>{const r=w.toLowerCase(),s=t.name.toLowerCase().includes(r),n=t.command?.toLowerCase().includes(r)||!1,i=t.args?.join(" ").toLowerCase().includes(r)||!1,d=t.url?.toLowerCase().includes(r)||!1;return s||n||i||d}),E=t=>{q(t);const{name:r,status:s,error:n,tools:i,lastValidated:d,...j}=t;y({name:t.name,type:t.type,config:JSON.stringify(j,null,2)}),f(!0)},H=t=>{let r="";t.type==="stdio"?r=`${t.command} ${t.args?.join(" ")||""}`.trim():r=t.url||"",navigator.clipboard.writeText(r).then(()=>{V(a("mcp.commandCopied"))}).catch(()=>{b(a("mcp.errors.copyFailed"))})},J=async t=>{if(window.confirm(a("mcp.confirmDelete",{name:t})))try{const r=await g(`${u}/mcp/${t}`,{method:"DELETE"});if(r.ok)c(s=>s.filter(n=>n.name!==t));else{const s=await r.json();throw new Error(s.error||a("mcp.errors.deleteFailed"))}}catch(r){console.error("Delete config failed:",r),b(a("mcp.errors.deleteFailed"),r instanceof Error?r.message:a("errors:common.unknownError"))}},R=()=>{y({name:"",type:"stdio",config:""}),q(null)},le=async()=>{try{L(!0);const t=await g(`${u}/mcp/claude-code`);if(t.ok){const s=(await t.json()).servers||[];if(s.length===0){U(a("mcp.import.noConfigFound"));return}let n=0,i=0;for(const d of s){if(x.find(P=>P.name===d.name)){i++;continue}const ie={...d},_=await g(`${u}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(_.ok){const P=await _.json();c(de=>[P.server,...de]),n++}}n>0?V(a("mcp.import.success",{imported:n,skipped:i})):U(a("mcp.import.allExist"))}else{const r=await t.json();throw new Error(r.error||a("mcp.errors.importFailed"))}}catch(t){console.error("Failed to import from Claude Code:",t),b(a("mcp.errors.importFailed"),t instanceof Error?t.message:a("errors:common.unknownError"))}finally{L(!1)}},A=(t,r)=>{if(!t.trim())return!1;try{const s=JSON.parse(t);if(!s.type||s.type!==r)return!1;if(r==="stdio"){if(!s.command||!Array.isArray(s.args))return!1}else if(r==="http"&&(!s.url||typeof s.url!="string"))return!1;return!(s.timeout&&typeof s.timeout!="number"||s.autoApprove&&!Array.isArray(s.autoApprove))}catch{return!1}},ne=async t=>{if(t.preventDefault(),!o.name.trim()){b(a("mcp.form.nameRequired"));return}if(!A(o.config,o.type)){b(a("mcp.form.configInvalid",{fields:o.type==="stdio"?a("mcp.form.requiredFieldsStdio"):a("mcp.form.requiredFieldsHttp")}));return}O(!0);try{const r=JSON.parse(o.config);let s;if(p)console.log("Updating existing MCP server:",p.name,"with config:",r),s=await g(`${u}/mcp/${p.name}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});else{const n={name:o.name,...r};s=await g(`${u}/mcp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}if(s.ok){const n=await s.json();c(p?d=>d.map(j=>j.name===p.name?n.server:j):d=>[n.server,...d]),R(),f(!1);const i=n.server.name;await k(i)}else{const n=await s.json();throw new Error(n.error||a("mcp.errors.saveFailed"))}}catch(r){console.error("Failed to save MCP config:",r),b(a("mcp.errors.saveFailed"),r instanceof Error?r.message:a("errors:common.unknownError"))}finally{O(!1)}},oe=()=>{f(!1),R()};return Z?e.jsx("div",{className:`${l?"p-4":"p-8"} flex items-center justify-center min-h-[60vh]`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:a("mcp.loading")})]})}):e.jsxs("div",{className:`${l?"p-4":"p-8"}`,children:[e.jsxs("div",{className:`${l?"mb-6":"mb-8"}`,children:[e.jsx("div",{className:`flex items-center ${l?"mb-4":"justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${l?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:a("mcp.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${l?"mt-1":"mt-2"}`,children:a("mcp.subtitle")})]})}),e.jsx("div",{className:"mb-6 bg-white dark:bg-gray-800 rounded-lg shadow p-4 md:p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-gray-900 dark:text-gray-100",children:x.length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:a("mcp.stats.total")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-green-600 dark:text-green-400",children:x.filter(t=>t.status==="active").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:a("mcp.stats.active")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-red-600 dark:text-red-400",children:x.filter(t=>t.status==="error").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:a("mcp.stats.error")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-blue-600 dark:text-blue-400",children:x.filter(t=>t.status==="validating").length}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:a("mcp.stats.validating")})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl md:text-3xl font-bold text-purple-600 dark:text-purple-400",children:x.reduce((t,r)=>t+(r.tools?.length||0),0)}),e.jsx("div",{className:"text-xs md:text-sm text-gray-600 dark:text-gray-400",children:a("mcp.stats.tools")})]})]})}),e.jsxs("div",{className:`${l?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${l?"":"flex-1"} relative`,children:[e.jsx(ue,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:a("mcp.searchPlaceholder"),value:$,onChange:t=>ee(t.target.value),className:`pl-10 pr-4 ${l?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${l?"text-sm":""}`})]}),e.jsxs("div",{className:`${l?"flex space-x-2":"flex items-center space-x-3"}`,children:[e.jsxs("button",{onClick:re,disabled:x.length===0,className:`${l?"flex-1 px-3 py-2 text-sm":"px-5 py-3"} bg-gray-600 text-white rounded-lg hover:bg-gray-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap font-medium flex items-center ${l?"justify-center":"space-x-2"} disabled:opacity-50 disabled:cursor-not-allowed`,title:a("mcp.validateAll"),children:[e.jsx(N,{className:`${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:a("mcp.validateAll")})]}),e.jsxs("button",{onClick:le,disabled:T,className:`${l?"flex-1 px-3 py-2 text-sm":"px-5 py-3"} bg-green-600 text-white rounded-lg hover:bg-green-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap font-medium flex items-center ${l?"justify-center":"space-x-2"} disabled:opacity-50 disabled:cursor-not-allowed`,children:[T&&e.jsx(N,{className:`${l?"w-4 h-4":"w-5 h-5"} animate-spin`}),e.jsx("span",{children:a(T?"mcp.import.importing":"mcp.import.button")})]}),e.jsxs("button",{onClick:()=>f(!0),className:`${l?"flex-1 px-3 py-2 text-sm":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 hover:shadow-md active:scale-95 transition-all whitespace-nowrap flex items-center ${l?"justify-center":"space-x-2"} font-medium`,children:[e.jsx(he,{className:`${l?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:a("mcp.addServer")})]})]})]})]}),F.length===0?e.jsxs("div",{className:`text-center ${l?"py-8":"py-16"} bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:[e.jsx("div",{className:`${l?"text-4xl":"text-6xl"} mb-4`,children:"🖥️"}),e.jsx("h3",{className:`${l?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:a(w?"mcp.noResults":"mcp.noServers")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${l?"mb-4":"mb-6"}`,children:a(w?"mcp.adjustSearch":"mcp.addFirstServer")}),!w&&e.jsx("button",{onClick:()=>f(!0),className:`${l?"px-4 py-2 text-sm":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:a("mcp.addServer")})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"md:hidden space-y-4",children:F.map((t,r)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow overflow-hidden",children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-start space-x-3 mb-3",children:[e.jsx("div",{className:"text-2xl",children:t.type==="http"?"🌐":"🖥️"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-base font-medium text-gray-900 dark:text-white truncate",children:t.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:t.type==="stdio"?`${t.command} ${t.args?.join(" ")||""}`.trim():t.url})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm mb-3",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 block mb-1",children:[a("mcp.table.type"),":"]}),e.jsx("span",{className:`inline-flex items-center px-2 py-1 text-xs font-medium rounded-full ${t.type==="http"?"bg-blue-100 text-blue-800":"bg-purple-100 text-purple-800"}`,children:t.type==="http"?"HTTP":"Stdio"})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 block mb-1",children:[a("mcp.table.status"),":"]}),t.status==="active"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800",children:[e.jsx(M,{className:"w-3 h-3 mr-1"}),a("mcp.status.active")]}),t.status==="error"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-red-100 text-red-800",children:[e.jsx(be,{className:"w-3 h-3 mr-1"}),a("mcp.status.error")]}),t.status==="validating"&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800",children:[e.jsx(N,{className:"w-3 h-3 mr-1 animate-spin"}),a("mcp.status.validating")]}),!t.status&&e.jsxs("span",{className:"inline-flex items-center px-2 py-1 text-xs font-medium rounded-full bg-gray-100 text-gray-800",children:[e.jsx(fe,{className:"w-3 h-3 mr-1"}),a("mcp.status.unvalidated")]})]})]}),t.status==="active"&&t.tools&&t.tools.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("button",{onClick:()=>I(s=>({...s,[t.name]:!s[t.name]})),className:"flex items-center space-x-2 text-sm text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors mb-2 w-full",children:[e.jsx(z,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[t.tools.length," ",a("mcp.table.tools")]}),h[t.name]?e.jsx(W,{className:"w-4 h-4 ml-auto text-gray-400"}):e.jsx(X,{className:"w-4 h-4 ml-auto text-gray-400"})]}),h[t.name]&&e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-40 overflow-y-auto",children:t.tools.map((s,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-1 rounded text-xs font-mono border border-green-200 dark:border-green-800",title:s,children:s},n))}),!h[t.name]&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.tools.slice(0,3).map((s,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-0.5 rounded text-xs font-mono",title:s,children:s},n)),t.tools.length>3&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:["+",t.tools.length-3]})]})]}),t.status==="error"&&t.error&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 mb-3 p-2 bg-red-50 dark:bg-red-900/20 rounded border border-red-200 dark:border-red-800",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-xs",children:t.error})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:a("mcp.table.actions")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>k(t.name),disabled:t.status==="validating",className:"p-2 text-green-600 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/50 rounded-md transition-colors disabled:opacity-50",title:a("mcp.actions.validate"),children:t.status==="validating"?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(M,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>H(t),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-900/50 rounded-md transition-colors",title:a("mcp.actions.copyCommand"),children:e.jsx(G,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>E(t),className:"p-2 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:a("mcp.actions.edit"),children:e.jsx(K,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>J(t.name),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:a("mcp.actions.delete"),children:e.jsx(Y,{className:"w-4 h-4"})})]})]})})]},t.name+"-"+r))}),e.jsx("div",{className:"hidden md:block bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(me,{children:[e.jsx(xe,{children:e.jsxs(B,{children:[e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("mcp.table.server")}),e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("mcp.table.type")}),e.jsx(v,{className:"px-6 py-3 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("mcp.table.tools")}),e.jsx(v,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:a("mcp.table.actions")})]})}),e.jsx(pe,{children:F.map((t,r)=>e.jsxs(B,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(C,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:t.type==="http"?"🌐":"🖥️"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:t.source==="plugin"?a("mcp.source.plugin"):a("mcp.source.local")})]}),t.status==="error"&&t.error&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 mt-1 max-w-md",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans",children:t.error})})]})]})}),e.jsx(C,{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 text-xs font-medium rounded-full ${t.type==="http"?"bg-blue-100 text-blue-800":"bg-purple-100 text-purple-800"}`,children:t.type==="http"?"HTTP":"Stdio"})}),e.jsx(C,{className:"px-6 py-4",children:t.status==="active"&&t.tools&&t.tools.length>0?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>I(s=>({...s,[t.name]:!s[t.name]})),className:"flex items-center space-x-2 text-sm text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors mb-2 group",children:[e.jsx(z,{className:"w-4 h-4"}),e.jsxs("span",{className:"font-medium",children:[t.tools.length," ",a("mcp.table.tools")]}),h[t.name]?e.jsx(W,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"}):e.jsx(X,{className:"w-4 h-4 text-gray-400 group-hover:text-blue-600"})]}),h[t.name]&&e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-48 overflow-y-auto pr-2",children:t.tools.map((s,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-1 rounded text-xs font-mono border border-green-200 dark:border-green-800 hover:bg-green-100 dark:hover:bg-green-900/50 transition-colors",title:s,children:s},n))}),!h[t.name]&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.tools.slice(0,5).map((s,n)=>e.jsx("code",{className:"inline-block bg-green-50 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-2 py-0.5 rounded text-xs font-mono",title:s,children:s},n)),t.tools.length>5&&e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:["+",t.tools.length-5]})]})]}):e.jsx("span",{className:"text-sm text-gray-400",children:t.status==="active"?a("mcp.table.noTools"):"-"})}),e.jsx(C,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx("button",{onClick:()=>k(t.name),disabled:t.status==="validating",className:"inline-flex items-center px-2 py-1 text-xs font-medium text-green-600 bg-green-50 dark:bg-green-900/50 rounded-md hover:bg-green-100 dark:hover:bg-green-900/70 transition-colors disabled:opacity-50",title:a("mcp.actions.validate"),children:t.status==="validating"?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(M,{className:"w-3 h-3"})}),e.jsx("button",{onClick:()=>H(t),className:"inline-flex items-center px-2 py-1 text-xs font-medium text-gray-600 bg-gray-50 dark:bg-gray-900/50 rounded-md hover:bg-gray-100 dark:hover:bg-gray-900/70 transition-colors",title:a("mcp.actions.copyCommand"),children:e.jsx(G,{className:"w-3 h-3"})}),t.source==="plugin"?e.jsxs("button",{onClick:()=>E(t),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:a("mcp.actions.view"),children:[e.jsx(ye,{className:"w-3 h-3 mr-1"}),a("mcp.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>E(t),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:a("mcp.actions.edit"),children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),a("mcp.actions.edit")]}),e.jsx("button",{onClick:()=>J(t.name),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:a("mcp.actions.delete"),children:e.jsx(Y,{className:"w-4 h-4"})})]})]})})]},t.name+"-"+r))})]})})]}),ae&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full ${l?"max-w-full":"max-w-2xl"} mx-4 max-h-[90vh] overflow-y-auto`,children:e.jsxs("div",{className:`${l?"p-4":"p-6"}`,children:[e.jsxs("div",{className:`flex items-center ${l?"flex-col space-y-3":"justify-between"} mb-4`,children:[e.jsx("h2",{className:`${l?"text-lg":"text-xl"} font-semibold text-gray-900 dark:text-white`,children:a(p?"mcp.modal.editTitle":"mcp.modal.addTitle")}),e.jsxs("div",{className:`flex ${l?"w-full space-x-2":"space-x-3"}`,children:[e.jsx("button",{type:"button",onClick:oe,disabled:S,className:`${l?"flex-1 px-3 py-2 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50`,children:a("common:actions.cancel")}),e.jsx("button",{type:"submit",form:"mcp-config-form",disabled:S||!o.name.trim()||!A(o.config,o.type),className:`${l?"flex-1 px-3 py-2 text-sm":"px-4 py-2"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:a(S?"mcp.modal.saving":p?"mcp.modal.saveConfig":"mcp.modal.addConfig")})]})]}),e.jsx("form",{id:"mcp-config-form",onSubmit:ne,children:e.jsxs("div",{className:`${l?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:a("mcp.form.serverName")}),e.jsx("input",{type:"text",value:o.name,onChange:t=>y({...o,name:t.target.value}),placeholder:a("mcp.form.serverNamePlaceholder"),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${l?"text-sm":""}`,required:!0,disabled:!!p}),p&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:a("mcp.form.nameNotEditable")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:a("mcp.form.mcpType")}),e.jsxs("select",{value:o.type,onChange:t=>{const r=t.target.value;y({...o,type:r,config:r==="stdio"?`{
|
|
3
3
|
"type": "stdio",
|
|
4
4
|
"command": "npx",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as a}from"./monaco-editor-DHKm5-VF.js";import{a as m,A as g}from"./agents-D9dWnZr0.js";import{s as h,a as p}from"./index-
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as a}from"./monaco-editor-DHKm5-VF.js";import{a as m,A as g}from"./agents-D9dWnZr0.js";import{s as h,a as p}from"./index-BLjehayc.js";import{u as b}from"./tools-zTM46-tZ.js";import{J as f,e as j,a3 as u,a4 as k}from"./ui-components-BsYwJvCF.js";import"./syntax-highlighting-CnREyncB.js";const F=()=>{const{t:s}=b("pages"),[r,l]=a.useState(""),[o,i]=a.useState(!1),[n,d]=a.useState(!1);a.useEffect(()=>{c()},[]);const c=async()=>{d(!0);try{const t=await m(`${g}/settings/global-memory`);if(t.ok){const y=await t.text();l(y)}}catch(t){console.error("Failed to load global memory:",t)}finally{d(!1)}},x=async()=>{try{if((await m(`${g}/settings/global-memory`,{method:"POST",headers:{"Content-Type":"text/plain"},body:r})).ok)i(!1),h(s("settings.memorySettings.saveSuccess"));else throw new Error("Failed to save")}catch(t){console.error("Failed to save global memory:",t),p(s("settings.memorySettings.saveFailed"))}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-2",children:s("settings.memorySettings.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:s("settings.memorySettings.description")})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("settings.memorySettings.fileSourceInfo")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"block font-medium text-gray-900 dark:text-white",children:s("settings.memorySettings.memoryContent")}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs("button",{onClick:()=>i(!o),className:"flex items-center space-x-1 px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsx(f,{className:"w-4 h-4"}),e.jsx("span",{children:s(o?"settings.memorySettings.cancelEdit":"settings.memorySettings.edit")})]}),e.jsxs("button",{onClick:c,disabled:n,className:"flex items-center space-x-1 px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 disabled:opacity-50",children:[e.jsx(j,{className:"w-4 h-4"}),e.jsx("span",{children:s(n?"settings.memorySettings.refreshing":"settings.memorySettings.refresh")})]})]})]}),o?e.jsxs("div",{className:"space-y-3",children:[e.jsx("textarea",{value:r,onChange:t=>l(t.target.value),rows:20,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent font-mono text-sm",placeholder:s("settings.memorySettings.placeholder")}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx("button",{onClick:()=>i(!1),className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-300",children:s("settings.memorySettings.cancel")}),e.jsxs("button",{onClick:x,className:"flex items-center space-x-1 px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(u,{className:"w-4 h-4"}),e.jsx("span",{children:s("settings.memorySettings.saveMemory")})]})]})]}):e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4 bg-gray-50 dark:bg-gray-700/50 min-h-[300px]",children:n?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:s("settings.memorySettings.loading")})}):r?e.jsx("pre",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap font-mono",children:r}):e.jsx("div",{className:"flex items-center justify-center h-64 text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"w-12 h-12 mx-auto mb-3 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:s("settings.memorySettings.noMemory")}),e.jsx("p",{className:"text-xs mt-1",children:s("settings.memorySettings.clickEditToStart")})]})})}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 space-y-1",children:[e.jsxs("p",{children:["• ",s("settings.memorySettings.infoAutoLoad")]}),e.jsxs("p",{children:["• ",s("settings.memorySettings.infoSuggestions")]}),e.jsxs("p",{children:["• ",s("settings.memorySettings.infoFileLocation")]})]})]})]})})]})};export{F as MemorySettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o,W as A}from"./monaco-editor-DHKm5-VF.js";import{u as Z,b as D,c as E,a as w,A as N}from"./agents-D9dWnZr0.js";import{a as P,s as T,c as H,b as z}from"./index-BFYHztzB.js";import{u as $}from"./tools-zTM46-tZ.js";import{c as de,B as v}from"./Button-BHiMThm4.js";import{$ as I,aR as K,f as q,g as _,v as J,U as oe,y as X,X as ue,E as Y,e as me,_ as xe,aS as ge,Z as pe,t as he,o as ye,V as be,C as fe,at as je}from"./ui-components-BsYwJvCF.js";import{F as ve}from"./FileExplorer-BB3suHzW.js";import"./syntax-highlighting-CnREyncB.js";const ee=o.createContext(void 0),se=()=>{const s=o.useContext(ee);if(!s)throw new Error("Tabs compound components must be used within Tabs");return s},ae=o.forwardRef(({value:s,onValueChange:a,defaultValue:l,className:i,children:n},r)=>{const[p,m]=o.useState(s||l||"");o.useEffect(()=>{s!==void 0&&m(s)},[s]);const y=o.useCallback(t=>{m(t),a?.(t)},[a]);return e.jsx(ee.Provider,{value:{value:p,onValueChange:y},children:e.jsx("div",{ref:r,className:i,children:n})})});ae.displayName="Tabs";const te=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`inline-flex h-10 items-center justify-center rounded-md bg-gray-100 dark:bg-gray-800 p-1 text-gray-500 dark:text-gray-400 ${s||""}`,...l,children:a}));te.displayName="TabsList";const Q=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r,onValueChange:p}=se(),m=r===a;return e.jsx("button",{ref:n,type:"button",role:"tab","aria-selected":m,onClick:()=>p?.(a),className:`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${m?"bg-white dark:bg-gray-950 text-gray-950 dark:text-gray-50 shadow-sm":"hover:bg-gray-200/50 dark:hover:bg-gray-700/50"} ${s||""}`,...i,children:l})});Q.displayName="TabsTrigger";const V=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r}=se();return r!==a?null:e.jsx("div",{ref:n,role:"tabpanel",className:`mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 ${s||""}`,...i,children:l})});V.displayName="TabsContent";const ke=()=>{const s=Z(),{t:a}=$("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugin-marketplaces"],queryFn:async()=>{const t=await w(`${N}/plugins/marketplaces`);if(!t.ok)throw new Error("Failed to fetch marketplaces");return(await t.json()).marketplaces}}),p=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to add marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceAddSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceAddError"),t.message)}}),m=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}/sync`,{method:"POST"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to sync marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceSyncSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceSyncError"),t.message)}}),y=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}`,{method:"DELETE"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to remove marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.marketplaceRemoveSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceRemoveError"),t.message)}});return{marketplaces:l,isLoading:i,error:n,refetch:r,addMarketplace:p.mutate,isAddingMarketplace:p.isPending,syncMarketplace:m.mutate,isSyncingMarketplace:m.isPending,removeMarketplace:y.mutate,isRemovingMarketplace:y.isPending}},we=()=>{const s=Z(),{t:a}=$("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugins-available"],queryFn:async()=>{const g=await w(`${N}/plugins/available`);if(!g.ok)throw new Error("Failed to fetch available plugins");return(await g.json()).plugins}}),{data:p=[],isLoading:m,error:y,refetch:t}=D({queryKey:["plugins-installed"],queryFn:async()=>{const g=await w(`${N}/plugins/installed`);if(!g.ok)throw new Error("Failed to fetch installed plugins");return(await g.json()).plugins}}),u=E({mutationFn:async g=>{const f=await w(`${N}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!f.ok){const b=await f.json();throw new Error(b.error||"Failed to install plugin")}return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.installSuccess"))},onError:g=>{P(a("plugins.messages.installError"),g.message)}}),h=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/enable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to enable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.enableSuccess"))},onError:g=>{P(a("plugins.messages.enableError"),g.message)}}),S=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/disable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to disable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.disableSuccess"))},onError:g=>{P(a("plugins.messages.disableError"),g.message)}}),j=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}`,{method:"DELETE"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to uninstall plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.uninstallSuccess"))},onError:g=>{P(a("plugins.messages.uninstallError"),g.message)}});return{availablePlugins:l,isLoadingAvailable:i,availableError:n,refetchAvailable:r,installedPlugins:p,isLoadingInstalled:m,installedError:y,refetchInstalled:t,installPlugin:u.mutate,isInstallingPlugin:u.isPending,enablePlugin:h.mutate,isEnablingPlugin:h.isPending,disablePlugin:S.mutate,isDisablingPlugin:S.isPending,uninstallPlugin:j.mutate,isUninstallingPlugin:j.isPending}},Ne=(s,a)=>D({queryKey:["plugin-detail",s,a],queryFn:async()=>{if(!s||!a)return null;const l=await w(`${N}/plugins/${s}/${a}`);if(!l.ok)throw new Error("Failed to fetch plugin details");return await l.json()},enabled:!!s&&!!a}),Se=(s,a,l)=>D({queryKey:["plugin-file-content",s,a,l],queryFn:async()=>{if(!s||!a||!l)return null;const i=await w(`${N}/plugins/${s}/${a}/files/${l}`);if(!i.ok)throw new Error("Failed to fetch file content");return await i.json()},enabled:!!s&&!!a&&!!l}),M=A.forwardRef(({className:s,type:a,...l},i)=>e.jsx("input",{type:a,className:de("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:i,...l}));M.displayName="Input";const F=o.forwardRef(({className:s,...a},l)=>e.jsx("label",{ref:l,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${s||""}`,...a}));F.displayName="Label";const re=({open:s,onOpenChange:a,children:l})=>(o.useEffect(()=>{const i=n=>{n.key==="Escape"&&s&&a&&a(!1)};return s&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[s,a]),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>a&&a(!1)}),e.jsx("div",{className:"relative z-50 w-full flex items-center justify-center",children:l})]}):null),O=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 ${s||""}`,...l,children:a}));O.displayName="DialogContent";const le=({className:s,children:a,...l})=>e.jsx("div",{className:`mb-4 ${s||""}`,...l,children:a}),B=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("h2",{ref:i,className:`text-lg font-semibold text-gray-900 dark:text-white ${s||""}`,...l,children:a}));B.displayName="DialogTitle";const Ce=({className:s,children:a,...l})=>e.jsx("div",{className:`flex justify-end space-x-2 ${s||""}`,...l,children:a}),G=o.forwardRef(({children:s,value:a,onValueChange:l,...i},n)=>{const[r,p]=o.useState(!1),[m,y]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&y(a)},[a]);const t=u=>{y(u),l&&l(u),p(!1)};return e.jsx("div",{ref:n,className:"relative",...i,children:o.Children.map(s,u=>o.isValidElement(u)?o.cloneElement(u,{selectedValue:m,isOpen:r,setIsOpen:p,onSelect:t}):u)})});G.displayName="Select";const U=o.forwardRef(({children:s,selectedValue:a,isOpen:l,setIsOpen:i,className:n,...r},p)=>e.jsxs("button",{ref:p,type:"button",onClick:()=>i&&i(!l),className:`flex h-10 w-full items-center justify-between rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 ${n||""}`,...r,children:[e.jsx("div",{className:"flex-1 text-left flex items-center",children:s}),e.jsx("svg",{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}));U.displayName="SelectTrigger";const ne=o.forwardRef(({placeholder:s,selectedValue:a,children:l},i)=>l?e.jsx("span",{ref:i,children:l}):e.jsx("span",{ref:i,children:a||s}));ne.displayName="SelectValue";const W=o.forwardRef(({children:s,isOpen:a,onSelect:l,...i},n)=>a?e.jsx("div",{ref:n,className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-lg",...i,children:o.Children.map(s,r=>o.isValidElement(r)?o.cloneElement(r,{onSelect:l}):r)}):null);W.displayName="SelectContent";const L=o.forwardRef(({value:s,children:a,onSelect:l,...i},n)=>e.jsx("div",{ref:n,onClick:()=>l&&l(s),className:"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100",...i,children:a}));L.displayName="SelectItem";const Ee=({isOpen:s,onClose:a,onAdd:l,isAdding:i})=>{const{t:n}=$("pages"),[r,p]=o.useState({name:"",type:"github",source:"",description:"",branch:"main"}),m=t=>{t.preventDefault(),l(r),y()},y=()=>{p({name:"",type:"github",source:"",description:"",branch:"main"}),a()};return e.jsx(re,{open:s,onOpenChange:y,children:e.jsxs(O,{className:"max-w-[600px] w-full max-h-[90vh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(B,{children:n("plugins.marketplaces.addModal.title")})}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(F,{htmlFor:"name",children:n("plugins.marketplaces.addModal.name")}),e.jsx(M,{id:"name",value:r.name,onChange:t=>p({...r,name:t.target.value}),placeholder:n("plugins.marketplaces.addModal.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"type",children:n("plugins.marketplaces.addModal.type")}),e.jsxs(G,{value:r.type,onValueChange:t=>p({...r,type:t}),children:[e.jsx(U,{children:e.jsxs("div",{className:"flex items-center space-x-2",children:[r.type==="github"&&e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]}),r.type==="git"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]}),r.type==="local"&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})]})}),e.jsxs(W,{children:[e.jsx(L,{value:"github",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]})}),e.jsx(L,{value:"git",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]})}),e.jsx(L,{value:"local",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})})]})]})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"source",children:n("plugins.marketplaces.addModal.source")}),e.jsx(M,{id:"source",value:r.source,onChange:t=>p({...r,source:t.target.value}),placeholder:r.type==="local"?n("plugins.marketplaces.addModal.sourcePlaceholderLocal"):r.type==="github"?n("plugins.marketplaces.addModal.sourcePlaceholderGithub"):n("plugins.marketplaces.addModal.sourcePlaceholderGit"),required:!0})]}),(r.type==="git"||r.type==="github")&&e.jsxs("div",{children:[e.jsx(F,{htmlFor:"branch",children:n("plugins.marketplaces.addModal.branch")}),e.jsx(M,{id:"branch",value:r.branch,onChange:t=>p({...r,branch:t.target.value}),placeholder:n("plugins.marketplaces.addModal.branchPlaceholder")})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"description",children:n("plugins.marketplaces.addModal.description")}),e.jsx(M,{id:"description",value:r.description,onChange:t=>p({...r,description:t.target.value}),placeholder:n("plugins.marketplaces.addModal.descriptionPlaceholder")})]})]}),e.jsxs(Ce,{className:"mt-6",children:[e.jsx(v,{type:"button",variant:"outline",onClick:y,disabled:i,children:n("plugins.marketplaces.addModal.cancel")}),e.jsx(v,{type:"submit",disabled:i,children:n(i?"plugins.marketplaces.addModal.adding":"plugins.marketplaces.addModal.add")})]})]})]})})},Pe=({marketplaces:s,isLoading:a,onAddMarketplace:l,isAdding:i,onSyncMarketplace:n,isSyncing:r,onRemoveMarketplace:p,isRemoving:m,onMarketplaceClick:y})=>{const{t}=$("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(!1),f=s.filter(x=>x.displayName.toLowerCase().includes(h.toLowerCase())||x.source.toLowerCase().includes(h.toLowerCase())),b=(x,C)=>{window.confirm(t("plugins.marketplaces.confirmDelete",{name:C}))&&p(x)};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center justify-between"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.marketplaces.searchPlaceholder"),value:h,onChange:x=>S(x.target.value),className:"pl-10"})]}),e.jsxs(v,{onClick:()=>g(!0),className:u?"w-full":"",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}),f.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t(h?"plugins.marketplaces.noResults":"plugins.marketplaces.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t("plugins.marketplaces.addFirst")}),!h&&e.jsxs(v,{onClick:()=>g(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}):e.jsx("div",{className:"space-y-4",children:f.map(x=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>y?.(x.id),children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400",children:x.displayName}),e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 flex items-center space-x-1",children:[x.type==="github"&&e.jsx(I,{className:"w-3 h-3"}),x.type==="git"&&e.jsx(K,{className:"w-3 h-3"}),x.type==="local"&&e.jsx(q,{className:"w-3 h-3"}),e.jsx("span",{children:t(`plugins.marketplaces.types.${x.type}`)})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:x.source}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[x.pluginCount," plugins"]}),x.lastSync&&e.jsxs("span",{children:["Last sync: ",new Date(x.lastSync).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>n(x.id),disabled:r,className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",title:t("plugins.marketplaces.actions.sync"),children:e.jsx(oe,{className:`w-4 h-4 text-green-600 dark:text-green-400 ${r?"animate-spin":""}`})}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>b(x.id,x.displayName),disabled:m,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",title:t("plugins.marketplaces.actions.delete"),children:e.jsx(X,{className:"w-4 h-4 text-red-600 dark:text-red-400"})})]})]})},x.id))}),e.jsx(Ee,{isOpen:j,onClose:()=>g(!1),onAdd:l,isAdding:i})]})},Me=({isOpen:s,onClose:a,marketplaceName:l,pluginName:i})=>{const{t:n}=$("pages"),{data:r,isLoading:p}=Ne(s?l:null,s?i:null),[m,y]=o.useState("overview");A.useEffect(()=>{r&&console.log("Plugin Detail Data:",r)},[r]);const[t,u]=o.useState(null),[h,S]=o.useState(null),{data:j}=Se(t?l:null,t?i:null,t),g=d=>{u(d.relativePath),y("file")},f=d=>{const c=d.relativePath.includes("/")?d.relativePath.substring(0,d.relativePath.lastIndexOf("/")):"";S(c),y("directory")},b=()=>{y("overview"),u(null),S(null)},x=d=>{switch(d){case"command":return e.jsx(ye,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"});case"agent":return e.jsx(he,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"});case"skill":return e.jsx(pe,{className:"w-4 h-4 text-green-600 dark:text-green-400"});case"hook":return e.jsx(ge,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"});case"mcp":return e.jsx(xe,{className:"w-4 h-4 text-red-600 dark:text-red-400"});default:return e.jsx(me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}},C=d=>{const c=`plugins.detail.componentTypes.${d}`;return n(c,{defaultValue:d})};if(!s)return null;const k=[];return r?.components&&(r.components.commands?.forEach(d=>k.push({...d,typeLabel:"command"})),r.components.agents?.forEach(d=>k.push({...d,typeLabel:"agent"})),r.components.skills?.forEach(d=>k.push({...d,typeLabel:"skill"})),r.components.hooks?.forEach(d=>k.push({...d,typeLabel:"hook"})),r.components.mcpServers?.forEach(d=>k.push({...d,typeLabel:"mcp"}))),e.jsx(re,{open:s,onOpenChange:a,children:e.jsxs(O,{className:"max-w-[1200px] w-full h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{children:[m==="overview"&&(r?.manifest?.name||i),m==="file"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:t})]}),m==="directory"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:h||n("plugins.detail.root")})]})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:a,children:e.jsx(ue,{className:"w-4 h-4"})})]})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})}):r?e.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[m==="overview"&&e.jsxs("div",{className:"h-full overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:r?.manifest?.name||i}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r?.manifest?.description||r?.plugin?.manifest?.description||n("plugins.detail.noDescription")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.version")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.version||r?.plugin?.manifest?.version||"-"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.author")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:(()=>{const d=r?.manifest?.author||r?.plugin?.manifest?.author;return d?typeof d=="string"?d:d.name:"-"})()})]}),(r?.manifest?.license||r?.plugin?.manifest?.license)&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.license")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.license||r?.plugin?.manifest?.license})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:[n("plugins.detail.components")," (",k.length,")"]}),k.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.type")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.name")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.description")}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:k.map((d,c)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[x(d.type),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:C(d.type)})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-white",children:d.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.description||"-"})}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>g(d),title:n("plugins.detail.viewEntryFile"),className:"text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:e.jsx(Y,{className:"w-4 h-4"})}),d.type==="skill"&&e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>f(d),title:n("plugins.detail.browseDirectory"),className:"text-purple-600 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/30",children:e.jsx(q,{className:"w-4 h-4"})})]})]},c))})]})}):e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("plugins.detail.noComponents")})]})]}),m==="file"&&e.jsx("div",{className:"h-full overflow-y-auto p-6",children:j?e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 p-4 rounded-lg font-mono",children:j.content}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})}),m==="directory"&&r?.plugin?.installPath&&e.jsx(ve,{projectPath:h?`${r.plugin.installPath}/${h}`:r.plugin.installPath,onFileSelect:d=>{console.log("Selected file:",d)},className:"h-full"})]}):e.jsx("div",{className:"text-center py-12 text-gray-500",children:n("plugins.detail.loadFailed")})]})})},$e=({plugins:s,isLoading:a,marketplaces:l,onInstallPlugin:i,isInstalling:n,onUninstallPlugin:r,isUninstalling:p,selectedMarketplace:m,onMarketplaceChange:y})=>{const{t}=$("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(null),[f,b]=o.useState(!1),x=s.filter(c=>{const R=c.name.toLowerCase().includes(h.toLowerCase())||c.description.toLowerCase().includes(h.toLowerCase()),ie=!m||c.marketplaceId===m,ce=!f||c.installed;return R&&ie&&ce}),C=A.useMemo(()=>m?l.find(R=>R.id===m)?.displayName||m:t("plugins.browse.filters.allMarketplaces"),[m,l,t]),k=c=>{i({pluginName:c.name,marketplaceName:c.marketplaceName,marketplaceId:c.marketplaceId})},d=c=>{window.confirm(t("plugins.browse.confirmUninstall",{name:c.name}))&&r({marketplaceName:c.marketplaceName,pluginName:c.name})};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):l.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.goAddMarketplace")})]}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center gap-4"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.browse.searchPlaceholder"),value:h,onChange:c=>S(c.target.value),className:"pl-10"})]}),e.jsx("div",{className:`${u?"":"w-64"}`,children:e.jsxs(G,{value:m??"all",onValueChange:c=>y(c==="all"?null:c),children:[e.jsx(U,{className:"text-gray-900 dark:text-gray-100",children:e.jsx(ne,{children:C})}),e.jsxs(W,{children:[e.jsx(L,{value:"all",children:t("plugins.browse.filters.allMarketplaces")}),l.map(c=>e.jsx(L,{value:c.id,children:c.displayName},c.id))]})]})}),e.jsxs("div",{className:" flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"showOnlyInstalled",checked:f,onChange:c=>b(c.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsx("label",{htmlFor:"showOnlyInstalled",className:"text-sm font-medium text-gray-900 dark:text-gray-300 cursor-pointer whitespace-nowrap",children:t("plugins.browse.filters.showOnlyInstalled")})]})]}),x.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noResults")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.adjustSearch")})]}):e.jsx("div",{className:"space-y-4",children:x.map(c=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx(be,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.name}),c.installed&&e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300 flex items-center space-x-1",children:[e.jsx(fe,{className:"w-3 h-3"}),e.jsx("span",{children:t("plugins.browse.card.installed")})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[t("plugins.browse.card.from")," ",c.marketplace]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.card.version",{version:c.version})}),c.components.commands>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.commands",{count:c.components.commands})})]}),c.components.skills>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.skills",{count:c.components.skills})})]}),c.components.agents>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.agents",{count:c.components.agents})})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>g({marketplace:c.marketplaceName,name:c.name}),className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx(Y,{className:"w-4 h-4 mr-1 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("plugins.browse.actions.details")})]}),c.installed?e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>d(c),disabled:p,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",children:[e.jsx(X,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"ml-1 text-red-600 dark:text-red-400",children:t("plugins.browse.actions.uninstall")})]}):e.jsxs(v,{variant:"outline",size:"sm",disabled:n,onClick:()=>k(c),className:"border-blue-300 dark:border-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:[e.jsx(je,{className:"w-4 h-4 mr-1 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:t("plugins.browse.actions.install")})]})]})]})},`${c.name}@${c.marketplace}`))}),j&&e.jsx(Me,{isOpen:!!j,onClose:()=>g(null),marketplaceName:j.marketplace,pluginName:j.name})]})},Ve=()=>{const{t:s}=$("pages"),{isMobile:a}=z(),[l,i]=o.useState("marketplaces"),[n,r]=o.useState(null),p=c=>{r(c),i("browse")},{marketplaces:m,isLoading:y,addMarketplace:t,isAddingMarketplace:u,syncMarketplace:h,isSyncingMarketplace:S,removeMarketplace:j,isRemovingMarketplace:g}=ke(),{availablePlugins:f,isLoadingAvailable:b,installPlugin:x,isInstallingPlugin:C,uninstallPlugin:k,isUninstallingPlugin:d}=we();return e.jsxs("div",{className:`${a?"p-4":"p-8"}`,children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("plugins.title")}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:s("plugins.subtitle")})]}),e.jsxs(ae,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(te,{className:`grid w-full ${a?"grid-cols-2":"grid-cols-2 max-w-xl"}`,children:[e.jsx(Q,{value:"marketplaces",children:s("plugins.tabs.marketplaces")}),e.jsx(Q,{value:"browse",children:s("plugins.tabs.browse")})]}),e.jsx(V,{value:"marketplaces",className:"mt-6",children:e.jsx(Pe,{marketplaces:m,isLoading:y,onAddMarketplace:t,isAdding:u,onSyncMarketplace:h,isSyncing:S,onRemoveMarketplace:j,isRemoving:g,onMarketplaceClick:p})}),e.jsx(V,{value:"browse",className:"mt-6",children:e.jsx($e,{plugins:f,isLoading:b,marketplaces:m,onInstallPlugin:x,isInstalling:C,onUninstallPlugin:k,isUninstalling:d,selectedMarketplace:n,onMarketplaceChange:r})})]})]})};export{Ve as PluginsPage,Ve as default};
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o,W as A}from"./monaco-editor-DHKm5-VF.js";import{u as Z,b as D,c as E,a as w,A as N}from"./agents-D9dWnZr0.js";import{a as P,s as T,c as H,b as z}from"./index-BLjehayc.js";import{u as $}from"./tools-zTM46-tZ.js";import{c as de,B as v}from"./Button-CfU7z0eT.js";import{$ as I,aR as K,f as q,g as _,v as J,U as oe,y as X,X as ue,E as Y,e as me,_ as xe,aS as ge,Z as pe,t as he,o as ye,V as be,C as fe,at as je}from"./ui-components-BsYwJvCF.js";import{F as ve}from"./FileExplorer-BB3suHzW.js";import"./syntax-highlighting-CnREyncB.js";const ee=o.createContext(void 0),se=()=>{const s=o.useContext(ee);if(!s)throw new Error("Tabs compound components must be used within Tabs");return s},ae=o.forwardRef(({value:s,onValueChange:a,defaultValue:l,className:i,children:n},r)=>{const[p,m]=o.useState(s||l||"");o.useEffect(()=>{s!==void 0&&m(s)},[s]);const y=o.useCallback(t=>{m(t),a?.(t)},[a]);return e.jsx(ee.Provider,{value:{value:p,onValueChange:y},children:e.jsx("div",{ref:r,className:i,children:n})})});ae.displayName="Tabs";const te=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`inline-flex h-10 items-center justify-center rounded-md bg-gray-100 dark:bg-gray-800 p-1 text-gray-500 dark:text-gray-400 ${s||""}`,...l,children:a}));te.displayName="TabsList";const Q=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r,onValueChange:p}=se(),m=r===a;return e.jsx("button",{ref:n,type:"button",role:"tab","aria-selected":m,onClick:()=>p?.(a),className:`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${m?"bg-white dark:bg-gray-950 text-gray-950 dark:text-gray-50 shadow-sm":"hover:bg-gray-200/50 dark:hover:bg-gray-700/50"} ${s||""}`,...i,children:l})});Q.displayName="TabsTrigger";const V=o.forwardRef(({className:s,value:a,children:l,...i},n)=>{const{value:r}=se();return r!==a?null:e.jsx("div",{ref:n,role:"tabpanel",className:`mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 ${s||""}`,...i,children:l})});V.displayName="TabsContent";const ke=()=>{const s=Z(),{t:a}=$("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugin-marketplaces"],queryFn:async()=>{const t=await w(`${N}/plugins/marketplaces`);if(!t.ok)throw new Error("Failed to fetch marketplaces");return(await t.json()).marketplaces}}),p=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to add marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceAddSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceAddError"),t.message)}}),m=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}/sync`,{method:"POST"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to sync marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),T(a("plugins.messages.marketplaceSyncSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceSyncError"),t.message)}}),y=E({mutationFn:async t=>{const u=await w(`${N}/plugins/marketplaces/${t}`,{method:"DELETE"});if(!u.ok){const h=await u.json();throw new Error(h.error||"Failed to remove marketplace")}return u.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugin-marketplaces"]}),s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.marketplaceRemoveSuccess"))},onError:t=>{P(a("plugins.messages.marketplaceRemoveError"),t.message)}});return{marketplaces:l,isLoading:i,error:n,refetch:r,addMarketplace:p.mutate,isAddingMarketplace:p.isPending,syncMarketplace:m.mutate,isSyncingMarketplace:m.isPending,removeMarketplace:y.mutate,isRemovingMarketplace:y.isPending}},we=()=>{const s=Z(),{t:a}=$("pages"),{data:l=[],isLoading:i,error:n,refetch:r}=D({queryKey:["plugins-available"],queryFn:async()=>{const g=await w(`${N}/plugins/available`);if(!g.ok)throw new Error("Failed to fetch available plugins");return(await g.json()).plugins}}),{data:p=[],isLoading:m,error:y,refetch:t}=D({queryKey:["plugins-installed"],queryFn:async()=>{const g=await w(`${N}/plugins/installed`);if(!g.ok)throw new Error("Failed to fetch installed plugins");return(await g.json()).plugins}}),u=E({mutationFn:async g=>{const f=await w(`${N}/plugins/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!f.ok){const b=await f.json();throw new Error(b.error||"Failed to install plugin")}return f.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.installSuccess"))},onError:g=>{P(a("plugins.messages.installError"),g.message)}}),h=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/enable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to enable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),H(a("plugins.messages.enableSuccess"))},onError:g=>{P(a("plugins.messages.enableError"),g.message)}}),S=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}/disable`,{method:"POST"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to disable plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.disableSuccess"))},onError:g=>{P(a("plugins.messages.disableError"),g.message)}}),j=E({mutationFn:async({marketplaceName:g,pluginName:f})=>{const b=await w(`${N}/plugins/${g}/${f}`,{method:"DELETE"});if(!b.ok){const x=await b.json();throw new Error(x.error||"Failed to uninstall plugin")}return b.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["plugins-available"]}),s.invalidateQueries({queryKey:["plugins-installed"]}),T(a("plugins.messages.uninstallSuccess"))},onError:g=>{P(a("plugins.messages.uninstallError"),g.message)}});return{availablePlugins:l,isLoadingAvailable:i,availableError:n,refetchAvailable:r,installedPlugins:p,isLoadingInstalled:m,installedError:y,refetchInstalled:t,installPlugin:u.mutate,isInstallingPlugin:u.isPending,enablePlugin:h.mutate,isEnablingPlugin:h.isPending,disablePlugin:S.mutate,isDisablingPlugin:S.isPending,uninstallPlugin:j.mutate,isUninstallingPlugin:j.isPending}},Ne=(s,a)=>D({queryKey:["plugin-detail",s,a],queryFn:async()=>{if(!s||!a)return null;const l=await w(`${N}/plugins/${s}/${a}`);if(!l.ok)throw new Error("Failed to fetch plugin details");return await l.json()},enabled:!!s&&!!a}),Se=(s,a,l)=>D({queryKey:["plugin-file-content",s,a,l],queryFn:async()=>{if(!s||!a||!l)return null;const i=await w(`${N}/plugins/${s}/${a}/files/${l}`);if(!i.ok)throw new Error("Failed to fetch file content");return await i.json()},enabled:!!s&&!!a&&!!l}),M=A.forwardRef(({className:s,type:a,...l},i)=>e.jsx("input",{type:a,className:de("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:i,...l}));M.displayName="Input";const F=o.forwardRef(({className:s,...a},l)=>e.jsx("label",{ref:l,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${s||""}`,...a}));F.displayName="Label";const re=({open:s,onOpenChange:a,children:l})=>(o.useEffect(()=>{const i=n=>{n.key==="Escape"&&s&&a&&a(!1)};return s&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[s,a]),s?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:()=>a&&a(!1)}),e.jsx("div",{className:"relative z-50 w-full flex items-center justify-center",children:l})]}):null),O=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("div",{ref:i,className:`relative bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 ${s||""}`,...l,children:a}));O.displayName="DialogContent";const le=({className:s,children:a,...l})=>e.jsx("div",{className:`mb-4 ${s||""}`,...l,children:a}),B=o.forwardRef(({className:s,children:a,...l},i)=>e.jsx("h2",{ref:i,className:`text-lg font-semibold text-gray-900 dark:text-white ${s||""}`,...l,children:a}));B.displayName="DialogTitle";const Ce=({className:s,children:a,...l})=>e.jsx("div",{className:`flex justify-end space-x-2 ${s||""}`,...l,children:a}),G=o.forwardRef(({children:s,value:a,onValueChange:l,...i},n)=>{const[r,p]=o.useState(!1),[m,y]=o.useState(a||"");o.useEffect(()=>{a!==void 0&&y(a)},[a]);const t=u=>{y(u),l&&l(u),p(!1)};return e.jsx("div",{ref:n,className:"relative",...i,children:o.Children.map(s,u=>o.isValidElement(u)?o.cloneElement(u,{selectedValue:m,isOpen:r,setIsOpen:p,onSelect:t}):u)})});G.displayName="Select";const U=o.forwardRef(({children:s,selectedValue:a,isOpen:l,setIsOpen:i,className:n,...r},p)=>e.jsxs("button",{ref:p,type:"button",onClick:()=>i&&i(!l),className:`flex h-10 w-full items-center justify-between rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 ${n||""}`,...r,children:[e.jsx("div",{className:"flex-1 text-left flex items-center",children:s}),e.jsx("svg",{className:"h-4 w-4 opacity-50 ml-2 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}));U.displayName="SelectTrigger";const ne=o.forwardRef(({placeholder:s,selectedValue:a,children:l},i)=>l?e.jsx("span",{ref:i,children:l}):e.jsx("span",{ref:i,children:a||s}));ne.displayName="SelectValue";const W=o.forwardRef(({children:s,isOpen:a,onSelect:l,...i},n)=>a?e.jsx("div",{ref:n,className:"absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-lg",...i,children:o.Children.map(s,r=>o.isValidElement(r)?o.cloneElement(r,{onSelect:l}):r)}):null);W.displayName="SelectContent";const L=o.forwardRef(({value:s,children:a,onSelect:l,...i},n)=>e.jsx("div",{ref:n,onClick:()=>l&&l(s),className:"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-900 dark:text-gray-100",...i,children:a}));L.displayName="SelectItem";const Ee=({isOpen:s,onClose:a,onAdd:l,isAdding:i})=>{const{t:n}=$("pages"),[r,p]=o.useState({name:"",type:"github",source:"",description:"",branch:"main"}),m=t=>{t.preventDefault(),l(r),y()},y=()=>{p({name:"",type:"github",source:"",description:"",branch:"main"}),a()};return e.jsx(re,{open:s,onOpenChange:y,children:e.jsxs(O,{className:"max-w-[600px] w-full max-h-[90vh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(B,{children:n("plugins.marketplaces.addModal.title")})}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(F,{htmlFor:"name",children:n("plugins.marketplaces.addModal.name")}),e.jsx(M,{id:"name",value:r.name,onChange:t=>p({...r,name:t.target.value}),placeholder:n("plugins.marketplaces.addModal.namePlaceholder"),required:!0})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"type",children:n("plugins.marketplaces.addModal.type")}),e.jsxs(G,{value:r.type,onValueChange:t=>p({...r,type:t}),children:[e.jsx(U,{children:e.jsxs("div",{className:"flex items-center space-x-2",children:[r.type==="github"&&e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]}),r.type==="git"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]}),r.type==="local"&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})]})}),e.jsxs(W,{children:[e.jsx(L,{value:"github",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{className:"w-4 h-4"}),e.jsx("span",{children:"GitHub"})]})}),e.jsx(L,{value:"git",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx("span",{children:"Git Repository"})]})}),e.jsx(L,{value:"local",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Local Directory"})]})})]})]})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"source",children:n("plugins.marketplaces.addModal.source")}),e.jsx(M,{id:"source",value:r.source,onChange:t=>p({...r,source:t.target.value}),placeholder:r.type==="local"?n("plugins.marketplaces.addModal.sourcePlaceholderLocal"):r.type==="github"?n("plugins.marketplaces.addModal.sourcePlaceholderGithub"):n("plugins.marketplaces.addModal.sourcePlaceholderGit"),required:!0})]}),(r.type==="git"||r.type==="github")&&e.jsxs("div",{children:[e.jsx(F,{htmlFor:"branch",children:n("plugins.marketplaces.addModal.branch")}),e.jsx(M,{id:"branch",value:r.branch,onChange:t=>p({...r,branch:t.target.value}),placeholder:n("plugins.marketplaces.addModal.branchPlaceholder")})]}),e.jsxs("div",{children:[e.jsx(F,{htmlFor:"description",children:n("plugins.marketplaces.addModal.description")}),e.jsx(M,{id:"description",value:r.description,onChange:t=>p({...r,description:t.target.value}),placeholder:n("plugins.marketplaces.addModal.descriptionPlaceholder")})]})]}),e.jsxs(Ce,{className:"mt-6",children:[e.jsx(v,{type:"button",variant:"outline",onClick:y,disabled:i,children:n("plugins.marketplaces.addModal.cancel")}),e.jsx(v,{type:"submit",disabled:i,children:n(i?"plugins.marketplaces.addModal.adding":"plugins.marketplaces.addModal.add")})]})]})]})})},Pe=({marketplaces:s,isLoading:a,onAddMarketplace:l,isAdding:i,onSyncMarketplace:n,isSyncing:r,onRemoveMarketplace:p,isRemoving:m,onMarketplaceClick:y})=>{const{t}=$("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(!1),f=s.filter(x=>x.displayName.toLowerCase().includes(h.toLowerCase())||x.source.toLowerCase().includes(h.toLowerCase())),b=(x,C)=>{window.confirm(t("plugins.marketplaces.confirmDelete",{name:C}))&&p(x)};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center justify-between"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.marketplaces.searchPlaceholder"),value:h,onChange:x=>S(x.target.value),className:"pl-10"})]}),e.jsxs(v,{onClick:()=>g(!0),className:u?"w-full":"",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}),f.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t(h?"plugins.marketplaces.noResults":"plugins.marketplaces.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t("plugins.marketplaces.addFirst")}),!h&&e.jsxs(v,{onClick:()=>g(!0),children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),t("plugins.marketplaces.addButton")]})]}):e.jsx("div",{className:"space-y-4",children:f.map(x=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6 hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 cursor-pointer",onClick:()=>y?.(x.id),children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400",children:x.displayName}),e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300 flex items-center space-x-1",children:[x.type==="github"&&e.jsx(I,{className:"w-3 h-3"}),x.type==="git"&&e.jsx(K,{className:"w-3 h-3"}),x.type==="local"&&e.jsx(q,{className:"w-3 h-3"}),e.jsx("span",{children:t(`plugins.marketplaces.types.${x.type}`)})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:x.source}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[x.pluginCount," plugins"]}),x.lastSync&&e.jsxs("span",{children:["Last sync: ",new Date(x.lastSync).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>n(x.id),disabled:r,className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",title:t("plugins.marketplaces.actions.sync"),children:e.jsx(oe,{className:`w-4 h-4 text-green-600 dark:text-green-400 ${r?"animate-spin":""}`})}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>b(x.id,x.displayName),disabled:m,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",title:t("plugins.marketplaces.actions.delete"),children:e.jsx(X,{className:"w-4 h-4 text-red-600 dark:text-red-400"})})]})]})},x.id))}),e.jsx(Ee,{isOpen:j,onClose:()=>g(!1),onAdd:l,isAdding:i})]})},Me=({isOpen:s,onClose:a,marketplaceName:l,pluginName:i})=>{const{t:n}=$("pages"),{data:r,isLoading:p}=Ne(s?l:null,s?i:null),[m,y]=o.useState("overview");A.useEffect(()=>{r&&console.log("Plugin Detail Data:",r)},[r]);const[t,u]=o.useState(null),[h,S]=o.useState(null),{data:j}=Se(t?l:null,t?i:null,t),g=d=>{u(d.relativePath),y("file")},f=d=>{const c=d.relativePath.includes("/")?d.relativePath.substring(0,d.relativePath.lastIndexOf("/")):"";S(c),y("directory")},b=()=>{y("overview"),u(null),S(null)},x=d=>{switch(d){case"command":return e.jsx(ye,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"});case"agent":return e.jsx(he,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"});case"skill":return e.jsx(pe,{className:"w-4 h-4 text-green-600 dark:text-green-400"});case"hook":return e.jsx(ge,{className:"w-4 h-4 text-orange-600 dark:text-orange-400"});case"mcp":return e.jsx(xe,{className:"w-4 h-4 text-red-600 dark:text-red-400"});default:return e.jsx(me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}},C=d=>{const c=`plugins.detail.componentTypes.${d}`;return n(c,{defaultValue:d})};if(!s)return null;const k=[];return r?.components&&(r.components.commands?.forEach(d=>k.push({...d,typeLabel:"command"})),r.components.agents?.forEach(d=>k.push({...d,typeLabel:"agent"})),r.components.skills?.forEach(d=>k.push({...d,typeLabel:"skill"})),r.components.hooks?.forEach(d=>k.push({...d,typeLabel:"hook"})),r.components.mcpServers?.forEach(d=>k.push({...d,typeLabel:"mcp"}))),e.jsx(re,{open:s,onOpenChange:a,children:e.jsxs(O,{className:"max-w-[1200px] w-full h-[90vh] overflow-hidden flex flex-col",children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(B,{children:[m==="overview"&&(r?.manifest?.name||i),m==="file"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:t})]}),m==="directory"&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(v,{variant:"ghost",size:"sm",onClick:b,children:["← ",n("plugins.detail.back")]}),e.jsx("span",{className:"text-base",children:h||n("plugins.detail.root")})]})]}),e.jsx(v,{variant:"ghost",size:"sm",onClick:a,children:e.jsx(ue,{className:"w-4 h-4"})})]})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})}):r?e.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[m==="overview"&&e.jsxs("div",{className:"h-full overflow-y-auto p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:r?.manifest?.name||i}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r?.manifest?.description||r?.plugin?.manifest?.description||n("plugins.detail.noDescription")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.version")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.version||r?.plugin?.manifest?.version||"-"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.author")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:(()=>{const d=r?.manifest?.author||r?.plugin?.manifest?.author;return d?typeof d=="string"?d:d.name:"-"})()})]}),(r?.manifest?.license||r?.plugin?.manifest?.license)&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:n("plugins.detail.license")}),e.jsx("p",{className:"text-gray-900 dark:text-white",children:r?.manifest?.license||r?.plugin?.manifest?.license})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:[n("plugins.detail.components")," (",k.length,")"]}),k.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.type")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.name")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.description")}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:n("plugins.detail.actions")})]})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:k.map((d,c)=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[x(d.type),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:C(d.type)})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm font-mono text-gray-900 dark:text-white",children:d.name})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:d.description||"-"})}),e.jsxs("td",{className:"px-4 py-3 text-right space-x-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>g(d),title:n("plugins.detail.viewEntryFile"),className:"text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:e.jsx(Y,{className:"w-4 h-4"})}),d.type==="skill"&&e.jsx(v,{variant:"ghost",size:"sm",onClick:()=>f(d),title:n("plugins.detail.browseDirectory"),className:"text-purple-600 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/30",children:e.jsx(q,{className:"w-4 h-4"})})]})]},c))})]})}):e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("plugins.detail.noComponents")})]})]}),m==="file"&&e.jsx("div",{className:"h-full overflow-y-auto p-6",children:j?e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-100 p-4 rounded-lg font-mono",children:j.content}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})})}),m==="directory"&&r?.plugin?.installPath&&e.jsx(ve,{projectPath:h?`${r.plugin.installPath}/${h}`:r.plugin.installPath,onFileSelect:d=>{console.log("Selected file:",d)},className:"h-full"})]}):e.jsx("div",{className:"text-center py-12 text-gray-500",children:n("plugins.detail.loadFailed")})]})})},$e=({plugins:s,isLoading:a,marketplaces:l,onInstallPlugin:i,isInstalling:n,onUninstallPlugin:r,isUninstalling:p,selectedMarketplace:m,onMarketplaceChange:y})=>{const{t}=$("pages"),{isMobile:u}=z(),[h,S]=o.useState(""),[j,g]=o.useState(null),[f,b]=o.useState(!1),x=s.filter(c=>{const R=c.name.toLowerCase().includes(h.toLowerCase())||c.description.toLowerCase().includes(h.toLowerCase()),ie=!m||c.marketplaceId===m,ce=!f||c.installed;return R&&ie&&ce}),C=A.useMemo(()=>m?l.find(R=>R.id===m)?.displayName||m:t("plugins.browse.filters.allMarketplaces"),[m,l,t]),k=c=>{i({pluginName:c.name,marketplaceName:c.marketplaceName,marketplaceId:c.marketplaceId})},d=c=>{window.confirm(t("plugins.browse.confirmUninstall",{name:c.name}))&&r({marketplaceName:c.marketplaceName,pluginName:c.name})};return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"Loading..."})]})}):l.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📦"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noMarketplaces")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.goAddMarketplace")})]}):e.jsxs("div",{children:[e.jsxs("div",{className:`${u?"space-y-3":"flex items-center gap-4"} mb-6`,children:[e.jsxs("div",{className:`${u?"":"flex-1 max-w-md"} relative`,children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx(M,{type:"text",placeholder:t("plugins.browse.searchPlaceholder"),value:h,onChange:c=>S(c.target.value),className:"pl-10"})]}),e.jsx("div",{className:`${u?"":"w-64"}`,children:e.jsxs(G,{value:m??"all",onValueChange:c=>y(c==="all"?null:c),children:[e.jsx(U,{className:"text-gray-900 dark:text-gray-100",children:e.jsx(ne,{children:C})}),e.jsxs(W,{children:[e.jsx(L,{value:"all",children:t("plugins.browse.filters.allMarketplaces")}),l.map(c=>e.jsx(L,{value:c.id,children:c.displayName},c.id))]})]})}),e.jsxs("div",{className:" flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"showOnlyInstalled",checked:f,onChange:c=>b(c.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsx("label",{htmlFor:"showOnlyInstalled",className:"text-sm font-medium text-gray-900 dark:text-gray-300 cursor-pointer whitespace-nowrap",children:t("plugins.browse.filters.showOnlyInstalled")})]})]}),x.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-medium text-gray-900 dark:text-white mb-2",children:t("plugins.browse.noResults")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:t("plugins.browse.adjustSearch")})]}):e.jsx("div",{className:"space-y-4",children:x.map(c=>e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx(be,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:c.name}),c.installed&&e.jsxs("span",{className:"px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300 flex items-center space-x-1",children:[e.jsx(fe,{className:"w-3 h-3"}),e.jsx("span",{children:t("plugins.browse.card.installed")})]})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[t("plugins.browse.card.from")," ",c.marketplace]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.card.version",{version:c.version})}),c.components.commands>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.commands",{count:c.components.commands})})]}),c.components.skills>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.skills",{count:c.components.skills})})]}),c.components.agents>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t("plugins.browse.components.agents",{count:c.components.agents})})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>g({marketplace:c.marketplaceName,name:c.name}),className:"border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx(Y,{className:"w-4 h-4 mr-1 text-gray-700 dark:text-gray-300"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("plugins.browse.actions.details")})]}),c.installed?e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>d(c),disabled:p,className:"border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/30",children:[e.jsx(X,{className:"w-4 h-4 text-red-600 dark:text-red-400"}),e.jsx("span",{className:"ml-1 text-red-600 dark:text-red-400",children:t("plugins.browse.actions.uninstall")})]}):e.jsxs(v,{variant:"outline",size:"sm",disabled:n,onClick:()=>k(c),className:"border-blue-300 dark:border-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/30",children:[e.jsx(je,{className:"w-4 h-4 mr-1 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:t("plugins.browse.actions.install")})]})]})]})},`${c.name}@${c.marketplace}`))}),j&&e.jsx(Me,{isOpen:!!j,onClose:()=>g(null),marketplaceName:j.marketplace,pluginName:j.name})]})},Ve=()=>{const{t:s}=$("pages"),{isMobile:a}=z(),[l,i]=o.useState("marketplaces"),[n,r]=o.useState(null),p=c=>{r(c),i("browse")},{marketplaces:m,isLoading:y,addMarketplace:t,isAddingMarketplace:u,syncMarketplace:h,isSyncingMarketplace:S,removeMarketplace:j,isRemovingMarketplace:g}=ke(),{availablePlugins:f,isLoadingAvailable:b,installPlugin:x,isInstallingPlugin:C,uninstallPlugin:k,isUninstallingPlugin:d}=we();return e.jsxs("div",{className:`${a?"p-4":"p-8"}`,children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:s("plugins.title")}),e.jsx("p",{className:"mt-2 text-gray-600 dark:text-gray-400",children:s("plugins.subtitle")})]}),e.jsxs(ae,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(te,{className:`grid w-full ${a?"grid-cols-2":"grid-cols-2 max-w-xl"}`,children:[e.jsx(Q,{value:"marketplaces",children:s("plugins.tabs.marketplaces")}),e.jsx(Q,{value:"browse",children:s("plugins.tabs.browse")})]}),e.jsx(V,{value:"marketplaces",className:"mt-6",children:e.jsx(Pe,{marketplaces:m,isLoading:y,onAddMarketplace:t,isAdding:u,onSyncMarketplace:h,isSyncing:S,onRemoveMarketplace:j,isRemoving:g,onMarketplaceClick:p})}),e.jsx(V,{value:"browse",className:"mt-6",children:e.jsx($e,{plugins:f,isLoading:b,marketplaces:m,onInstallPlugin:x,isInstalling:C,onUninstallPlugin:k,isUninstalling:d,selectedMarketplace:n,onMarketplaceChange:r})})]})]})};export{Ve as PluginsPage,Ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as x}from"./monaco-editor-DHKm5-VF.js";import{u as G,a as D,A as F}from"./agents-D9dWnZr0.js";import{a as H,b as J,c as M}from"./useAgents-BlQGwXjx.js";import{F as v}from"./FileBrowser-Df-zwNDa.js";import{a as S}from"./index-BFYHztzB.js";import{u as E}from"./tools-zTM46-tZ.js";import{X as I,ai as A,g as V,u as Y}from"./ui-components-BsYwJvCF.js";const ie=({agent:a,onProjectSelect:c,onClose:g})=>{const{t:r}=E("components"),[l,j]=x.useState(!1),[f,d]=x.useState(!1),[$,u]=x.useState(!1),[B,b]=x.useState(!1),[P,w]=x.useState(""),[q,N]=x.useState(!1),C=H(),z=J(),k=G(),{data:L,isLoading:Q}=M(a.id),p=L?.projects||[],R=async()=>{j(!0);try{const t=a.id.replace(/[-_]/g,"-"),s=new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),i=`${t}-project-${s}`,m=await C.mutateAsync({agentId:a.id,projectName:i});await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(m.project.path)}catch(t){console.error("Failed to create project:",t),S(r("projectSelector.createProjectFailed",{error:""}),t instanceof Error?t.message:r("projectSelector.unknownError"))}finally{j(!1)}},K=()=>{u(!0)},T=(t,s)=>{s&&(w(t),u(!1),N(!0))},U=async t=>{j(!0);try{const s=t,i=await C.mutateAsync({agentId:a.id,projectName:s,parentDirectory:P||void 0});await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(i.project.path)}catch(s){console.error("Failed to create project:",s),S(r("projectSelector.createProjectFailed",{error:""}),s instanceof Error?s.message:r("projectSelector.unknownError"))}finally{j(!1),N(!1),w("")}},W=()=>{d(!0)},_=async(t,s)=>{if(s){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===a.id)&&(n=!0)}catch{}if(console.log("Import path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),n)c(t),b(!1);else if(window.confirm(r("projectSelector.importConfirmation",{agentName:a.name,path:t})))try{await z.mutateAsync({agentId:a.id,projectPath:t}),await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(t),b(!1)}catch(h){console.error("Failed to import project:",h),S(r("projectSelector.importProjectFailed",{error:""}),h instanceof Error?h.message:r("projectSelector.unknownError"))}}},O=async(t,s)=>{if(s){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===a.id)&&(n=!0)}catch{}console.log("Path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),(n||window.confirm(r("projectSelector.importConfirmation",{agentName:a.name,path:t})))&&(c(t),d(!1))}};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"text-2xl",children:a.ui.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:a.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:r("projectSelector.selectProjectDirectory")})]})]}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 flex-shrink-0",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col md:flex-row",children:[e.jsxs("div",{className:"w-full md:w-1/2 p-6 md:border-r border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.projectActions")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:R,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-primary/40 dark:border-primary/60 rounded-lg hover:bg-primary/5 dark:hover:bg-primary/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:`w-6 h-6 ${l?"text-gray-400 dark:text-gray-500":"text-primary"}`})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r(l?"projectSelector.creatingProject":"projectSelector.quickCreateProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.quickCreateDescription")})]})]}),e.jsxs("button",{onClick:K,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.customLocationCreate")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.customLocationDescription")})]})]}),e.jsxs("button",{onClick:W,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(V,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.browseProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.browseDescription")})]})]})]})]}),e.jsxs("div",{className:"w-full md:w-1/2 p-6 flex flex-col min-h-[300px] md:min-h-0",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.recentProjects")}),Q?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-blue-600 dark:border-t-blue-500 rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-sm",children:r("projectSelector.loadingProjects")})]})}):p.length>0?e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{className:"space-y-2 max-h-full overflow-y-auto",children:p.map((t,s)=>e.jsxs("button",{onClick:()=>c(t.path),className:"w-full flex items-center space-x-3 p-4 border border-gray-100 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left",children:[e.jsx("div",{className:"w-5 h-5 flex-shrink-0 text-xl text-primary",children:t.defaultAgentIcon||"📁"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:t.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:t.path}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.lastAccessed",{date:new Date(t.lastAccessed).toLocaleString()})})]})]},t.id||s))})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx(Y,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-3"}),e.jsx("p",{className:"text-base font-medium",children:r("projectSelector.noRecentProjects")}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.createProjectToStart")})]})})]})]}),e.jsx("div",{className:"flex justify-end p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsx("button",{onClick:g,className:"px-6 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.cancel")})})]}),f&&e.jsx(v,{title:r("projectSelector.selectProjectDirectory"),allowFiles:!1,allowDirectories:!0,onSelect:O,onClose:()=>d(!1)}),$&&e.jsx(v,{title:r("projectSelector.selectParentDirectory"),allowFiles:!1,allowDirectories:!0,allowNewDirectory:!0,onSelect:T,onClose:()=>u(!1)}),B&&e.jsx(v,{title:r("projectSelector.importProject"),allowFiles:!1,allowDirectories:!0,onSelect:_,onClose:()=>b(!1)}),q&&e.jsx(Z,{parentDirectory:P,onConfirm:U,onCancel:()=>{N(!1),w("")}})]})},Z=({parentDirectory:a,onConfirm:c,onCancel:g})=>{const{t:r}=E("components"),[l,j]=x.useState(""),f=d=>{d.preventDefault(),l.trim()&&c(l.trim())};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectSelector.dialog.createNewProject")}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:r("projectSelector.dialog.projectWillBeCreatedAt")}),e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-700 rounded text-sm font-mono text-gray-800 dark:text-gray-200 break-all",children:a})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"projectName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectSelector.dialog.projectName")}),e.jsx("input",{id:"projectName",type:"text",value:l,onChange:d=>j(d.target.value),placeholder:r("projectSelector.dialog.projectNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent",autoFocus:!0,required:!0})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.dialog.cancel")}),e.jsx("button",{type:"submit",disabled:!l.trim(),className:"px-4 py-2 text-sm bg-blue-600 dark:bg-blue-500 text-white rounded-lg hover:bg-blue-700 dark:hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("projectSelector.dialog.createProject")})]})]})]})})};export{ie as P};
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as x}from"./monaco-editor-DHKm5-VF.js";import{u as G,a as D,A as F}from"./agents-D9dWnZr0.js";import{a as H,b as J,c as M}from"./useAgents-BlQGwXjx.js";import{F as v}from"./FileBrowser-BiAm3yrg.js";import{a as S}from"./index-BLjehayc.js";import{u as E}from"./tools-zTM46-tZ.js";import{X as I,ai as A,g as V,u as Y}from"./ui-components-BsYwJvCF.js";const ie=({agent:a,onProjectSelect:c,onClose:g})=>{const{t:r}=E("components"),[l,j]=x.useState(!1),[f,d]=x.useState(!1),[$,u]=x.useState(!1),[B,b]=x.useState(!1),[P,w]=x.useState(""),[q,N]=x.useState(!1),C=H(),z=J(),k=G(),{data:L,isLoading:Q}=M(a.id),p=L?.projects||[],R=async()=>{j(!0);try{const t=a.id.replace(/[-_]/g,"-"),s=new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),i=`${t}-project-${s}`,m=await C.mutateAsync({agentId:a.id,projectName:i});await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(m.project.path)}catch(t){console.error("Failed to create project:",t),S(r("projectSelector.createProjectFailed",{error:""}),t instanceof Error?t.message:r("projectSelector.unknownError"))}finally{j(!1)}},K=()=>{u(!0)},T=(t,s)=>{s&&(w(t),u(!1),N(!0))},U=async t=>{j(!0);try{const s=t,i=await C.mutateAsync({agentId:a.id,projectName:s,parentDirectory:P||void 0});await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(i.project.path)}catch(s){console.error("Failed to create project:",s),S(r("projectSelector.createProjectFailed",{error:""}),s instanceof Error?s.message:r("projectSelector.unknownError"))}finally{j(!1),N(!1),w("")}},W=()=>{d(!0)},_=async(t,s)=>{if(s){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===a.id)&&(n=!0)}catch{}if(console.log("Import path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),n)c(t),b(!1);else if(window.confirm(r("projectSelector.importConfirmation",{agentName:a.name,path:t})))try{await z.mutateAsync({agentId:a.id,projectPath:t}),await k.invalidateQueries({queryKey:["agent-projects",a.id]}),c(t),b(!1)}catch(h){console.error("Failed to import project:",h),S(r("projectSelector.importProjectFailed",{error:""}),h instanceof Error?h.message:r("projectSelector.unknownError"))}}},O=async(t,s)=>{if(s){const i=t.replace(/\/$/,""),m=p.map(o=>o.path.replace(/\/$/,""));let n=m.includes(i);if(!n)try{const o=await D(`${F}/files/browse?path=${encodeURIComponent(t)}/.cc-sessions`);o.ok&&(await o.json()).items?.some(y=>y.isDirectory&&y.name===a.id)&&(n=!0)}catch{}console.log("Path comparison:",{selectedPath:i,agentProjects:m,isExisting:n}),(n||window.confirm(r("projectSelector.importConfirmation",{agentName:a.name,path:t})))&&(c(t),d(!1))}};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl mx-4 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"text-2xl",children:a.ui.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:a.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:r("projectSelector.selectProjectDirectory")})]})]}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 flex-shrink-0",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col md:flex-row",children:[e.jsxs("div",{className:"w-full md:w-1/2 p-6 md:border-r border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.projectActions")}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{onClick:R,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-primary/40 dark:border-primary/60 rounded-lg hover:bg-primary/5 dark:hover:bg-primary/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:`w-6 h-6 ${l?"text-gray-400 dark:text-gray-500":"text-primary"}`})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r(l?"projectSelector.creatingProject":"projectSelector.quickCreateProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.quickCreateDescription")})]})]}),e.jsxs("button",{onClick:K,disabled:l,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(A,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.customLocationCreate")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.customLocationDescription")})]})]}),e.jsxs("button",{onClick:W,className:"w-full flex items-center space-x-4 p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(V,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:r("projectSelector.browseProject")}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:r("projectSelector.browseDescription")})]})]})]})]}),e.jsxs("div",{className:"w-full md:w-1/2 p-6 flex flex-col min-h-[300px] md:min-h-0",children:[e.jsx("h4",{className:"text-base font-medium text-gray-900 dark:text-white mb-4",children:r("projectSelector.recentProjects")}),Q?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-blue-600 dark:border-t-blue-500 rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-sm",children:r("projectSelector.loadingProjects")})]})}):p.length>0?e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{className:"space-y-2 max-h-full overflow-y-auto",children:p.map((t,s)=>e.jsxs("button",{onClick:()=>c(t.path),className:"w-full flex items-center space-x-3 p-4 border border-gray-100 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors text-left",children:[e.jsx("div",{className:"w-5 h-5 flex-shrink-0 text-xl text-primary",children:t.defaultAgentIcon||"📁"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white truncate",children:t.name}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:t.path}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.lastAccessed",{date:new Date(t.lastAccessed).toLocaleString()})})]})]},t.id||s))})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx(Y,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-3"}),e.jsx("p",{className:"text-base font-medium",children:r("projectSelector.noRecentProjects")}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:r("projectSelector.createProjectToStart")})]})})]})]}),e.jsx("div",{className:"flex justify-end p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsx("button",{onClick:g,className:"px-6 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.cancel")})})]}),f&&e.jsx(v,{title:r("projectSelector.selectProjectDirectory"),allowFiles:!1,allowDirectories:!0,onSelect:O,onClose:()=>d(!1)}),$&&e.jsx(v,{title:r("projectSelector.selectParentDirectory"),allowFiles:!1,allowDirectories:!0,allowNewDirectory:!0,onSelect:T,onClose:()=>u(!1)}),B&&e.jsx(v,{title:r("projectSelector.importProject"),allowFiles:!1,allowDirectories:!0,onSelect:_,onClose:()=>b(!1)}),q&&e.jsx(Z,{parentDirectory:P,onConfirm:U,onCancel:()=>{N(!1),w("")}})]})},Z=({parentDirectory:a,onConfirm:c,onCancel:g})=>{const{t:r}=E("components"),[l,j]=x.useState(""),f=d=>{d.preventDefault(),l.trim()&&c(l.trim())};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectSelector.dialog.createNewProject")}),e.jsx("button",{onClick:g,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(I,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:r("projectSelector.dialog.projectWillBeCreatedAt")}),e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-700 rounded text-sm font-mono text-gray-800 dark:text-gray-200 break-all",children:a})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{htmlFor:"projectName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectSelector.dialog.projectName")}),e.jsx("input",{id:"projectName",type:"text",value:l,onChange:d=>j(d.target.value),placeholder:r("projectSelector.dialog.projectNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent",autoFocus:!0,required:!0})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{type:"button",onClick:g,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:r("projectSelector.dialog.cancel")}),e.jsx("button",{type:"submit",disabled:!l.trim(),className:"px-4 py-2 text-sm bg-blue-600 dark:bg-blue-500 text-white rounded-lg hover:bg-blue-700 dark:hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:r("projectSelector.dialog.createProject")})]})]})]})})};export{ie as P};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o}from"./monaco-editor-DHKm5-VF.js";import{a as E,A as T}from"./agents-D9dWnZr0.js";import{s as G,a as L,b as Ue}from"./index-BFYHztzB.js";import{f as xe}from"./dateFormat-CXa8VnEC.js";import{u as se}from"./tools-zTM46-tZ.js";import{a4 as Ie,aK as Fe,t as W,a2 as ie,r as je,y as Z,M as Re,k as st,u as Ee,aL as Ke,a5 as $e,e as nt,X as _,j as me,a3 as lt,T as dt,g as Te,v as ge,o as De,D as fe,m as Pe,J as Ne,a7 as de,A as Ae,I as oe,aM as ce,a8 as ot,E as ct,aN as Se,aO as it,aP as xt,_ as mt,f as gt}from"./ui-components-BsYwJvCF.js";import{u as ht}from"./useAgents-BlQGwXjx.js";import{F as Le}from"./FileBrowser-Df-zwNDa.js";import{T as ze,a as Oe,b as ke,c as Y,d as Be,e as Q}from"./table-D-FJ6K6j.js";import{f as yt,g as pt}from"./useCommands-DOxDeFSx.js";import{C as ut}from"./CommandForm-CZRscRtm.js";import{g as we}from"./UnifiedToolSelector-Bw-E7HW4.js";import{b as bt,c as jt,S as ft}from"./SubagentForm-Cq06CQqr.js";import{u as Nt}from"./useProjects-cgsJNlsy.js";import{u as kt}from"./useClaudeVersions-DJ6VKG1y.js";import"./syntax-highlighting-CnREyncB.js";const wt=({projects:n,agents:C,onOpenProject:t,onMemoryManagement:r,onCommandManagement:p,onSubAgentManagement:u,onA2AManagement:k,onSettings:y,onDeleteProject:v,onAgentChanged:h,className:M=""})=>{const{t:g}=se("pages"),[i,f]=o.useState(null),I=async(d,m)=>{if(m!==d.defaultAgent)try{f(d.id);const P=await E(`${T}/projects/${encodeURIComponent(d.path)}/default-agent`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:m})});if(P.ok){const w=C.find(O=>O.id===m);w&&h&&h(d.id,w),G("助手切换成功")}else{const w=await P.json();throw new Error(w.error||"切换助手失败")}}catch(P){console.error("Failed to change agent:",P),L("切换助手失败",P instanceof Error?P.message:"未知错误")}finally{f(null)}},K=(d,m=!1)=>e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>t(d),className:`text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:underline cursor-pointer text-left truncate ${m?"text-base":""}`,children:d.name}),e.jsx("button",{onClick:()=>t(d),className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors flex-shrink-0",title:g("projects.actions.open"),children:e.jsx(Re,{className:"w-3 h-3"})})]}),d.description&&e.jsx("div",{className:`text-gray-500 dark:text-gray-400 truncate ${m?"text-sm mt-1":"text-sm max-w-xs"}`,children:d.description})]}),U=d=>{const m=C.filter(w=>w.enabled),P=i===d.id;return e.jsxs("div",{className:"relative inline-block",onClick:w=>w.stopPropagation(),children:[e.jsx("select",{value:d.defaultAgent,onChange:w=>I(d,w.target.value),disabled:P,className:"appearance-none bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 rounded-md px-3 py-1.5 pr-8 text-xs font-medium cursor-pointer border border-gray-200 dark:border-gray-600 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",title:"切换助手",children:m.map(w=>e.jsxs("option",{value:w.id,className:"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:[w.ui.icon," ",w.name]},w.id))}),e.jsx(st,{className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-3 h-3 text-gray-400 dark:text-gray-300 pointer-events-none"})]})},D=d=>e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(Ee,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",title:d.path,children:d.path})]}),z=(d,m)=>e.jsxs("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400",children:[m,e.jsx("span",{children:xe(d)})]}),x=d=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx("button",{onClick:()=>r(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Ie,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>p(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Fe,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(W,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>k(d),className:"p-1.5 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>y(d),className:"p-1.5 text-indigo-600 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-900/50 rounded-md transition-colors",title:"项目设置",children:e.jsx(je,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>v(d),className:"p-1.5 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]});return e.jsxs("div",{className:`space-y-4 ${M}`,children:[e.jsx("div",{className:"md:hidden space-y-4",children:n.map(d=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"p-4 cursor-pointer",onClick:()=>t(d),children:e.jsx("div",{className:"flex items-start space-x-3",children:K(d,!0)})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 text-sm mb-3 px-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.agent"),":"]}),e.jsx("div",{children:U(d)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.lastActive"),":"]}),e.jsx("div",{className:"text-right",children:z(d.lastAccessed,e.jsx(Ke,{className:"w-4 h-4"}))})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("common:path"),":"]}),e.jsx("div",{className:"text-right text-xs truncate ml-2 max-w-[200px]",children:d.path})]})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:g("projects.table.actions")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>r(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Fe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>u(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(W,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>k(d),className:"p-2 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>y(d),className:"p-2 text-indigo-600 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-900/50 rounded-md transition-colors",title:"项目设置",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>v(d),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]})})]},d.id))}),e.jsx("div",{className:"hidden md:block bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-x-auto",children:e.jsxs("table",{className:"min-w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky left-0 bg-white dark:bg-gray-800 z-10 w-64",children:g("projects.table.project")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.agent")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:g("common:path")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("common:createdAt")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.lastActive")}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky right-0 bg-white dark:bg-gray-800 z-10 w-32",children:g("projects.table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:n.map((d,m)=>e.jsxs("tr",{className:"group hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 sticky left-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-64 max-w-[256px]",children:e.jsx("div",{className:"truncate",children:K(d)})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap w-32",children:U(d)}),e.jsx("td",{className:"px-6 py-4 max-w-xs truncate",children:D(d)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:z(d.createdAt,e.jsx($e,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:z(d.lastAccessed,e.jsx(Ke,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium sticky right-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-32",children:x(d)})]},d.id+"-"+m))})]})})]})},vt=({project:n,onClose:C})=>{const[t,r]=o.useState(""),[p,u]=o.useState(!0),[k,y]=o.useState(!1),[v,h]=o.useState(null);o.useEffect(()=>{(async()=>{try{u(!0),h(null);const i=await E(`${T}/projects/claude-md?path=${encodeURIComponent(n.path)}`);if(i.ok){const f=await i.json();r(f.content||"")}else if(i.status===404)r("");else throw new Error("加载 CLAUDE.md 文件失败")}catch(i){console.error("Failed to load CLAUDE.md:",i),h(i instanceof Error?i.message:"未知错误")}finally{u(!1)}})()},[n.id]);const M=async()=>{try{if(y(!0),h(null),!(await E(`${T}/projects/claude-md?path=${encodeURIComponent(n.path)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})})).ok)throw new Error("保存 CLAUDE.md 文件失败");const i=document.getElementById("save-button");if(i){const f=i.textContent;i.textContent="已保存",setTimeout(()=>{i.textContent==="已保存"&&(i.textContent=f)},2e3)}}catch(g){console.error("Failed to save CLAUDE.md:",g),h(g instanceof Error?g.message:"保存失败")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(nt,{className:"w-6 h-6 text-blue-600"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"项目记忆管理"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n.name})]})]}),e.jsx("button",{onClick:C,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(_,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 flex flex-col p-6 overflow-hidden",children:p?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"正在加载 CLAUDE.md..."})]})}):v?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(me,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"加载失败"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"编辑项目的记忆文件 (CLAUDE.md),用于存储项目相关的上下文信息和指导。"}),e.jsx("div",{className:"flex-1 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:e.jsx("textarea",{value:t,onChange:g=>r(g.target.value),placeholder:`# 项目记忆
|
|
1
|
+
import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o}from"./monaco-editor-DHKm5-VF.js";import{a as E,A as T}from"./agents-D9dWnZr0.js";import{s as G,a as L,b as Ue}from"./index-BLjehayc.js";import{f as xe}from"./dateFormat-CXa8VnEC.js";import{u as se}from"./tools-zTM46-tZ.js";import{a4 as Ie,aK as Fe,t as W,a2 as ie,r as je,y as Z,M as Re,k as st,u as Ee,aL as Ke,a5 as $e,e as nt,X as _,j as me,a3 as lt,T as dt,g as Te,v as ge,o as De,D as fe,m as Pe,J as Ne,a7 as de,A as Ae,I as oe,aM as ce,a8 as ot,E as ct,aN as Se,aO as it,aP as xt,_ as mt,f as gt}from"./ui-components-BsYwJvCF.js";import{u as ht}from"./useAgents-BlQGwXjx.js";import{F as Le}from"./FileBrowser-BiAm3yrg.js";import{T as ze,a as Oe,b as ke,c as Y,d as Be,e as Q}from"./table-Br8ioTXr.js";import{f as yt,g as pt}from"./useCommands-DOxDeFSx.js";import{C as ut}from"./CommandForm-CZRscRtm.js";import{g as we}from"./UnifiedToolSelector-Bw-E7HW4.js";import{b as bt,c as jt,S as ft}from"./SubagentForm-Cq06CQqr.js";import{u as Nt}from"./useProjects-cgsJNlsy.js";import{u as kt}from"./useClaudeVersions-DJ6VKG1y.js";import"./syntax-highlighting-CnREyncB.js";const wt=({projects:n,agents:C,onOpenProject:t,onMemoryManagement:r,onCommandManagement:p,onSubAgentManagement:u,onA2AManagement:k,onSettings:y,onDeleteProject:v,onAgentChanged:h,className:M=""})=>{const{t:g}=se("pages"),[i,f]=o.useState(null),I=async(d,m)=>{if(m!==d.defaultAgent)try{f(d.id);const P=await E(`${T}/projects/${encodeURIComponent(d.path)}/default-agent`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:m})});if(P.ok){const w=C.find(O=>O.id===m);w&&h&&h(d.id,w),G("助手切换成功")}else{const w=await P.json();throw new Error(w.error||"切换助手失败")}}catch(P){console.error("Failed to change agent:",P),L("切换助手失败",P instanceof Error?P.message:"未知错误")}finally{f(null)}},K=(d,m=!1)=>e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>t(d),className:`text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:underline cursor-pointer text-left truncate ${m?"text-base":""}`,children:d.name}),e.jsx("button",{onClick:()=>t(d),className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors flex-shrink-0",title:g("projects.actions.open"),children:e.jsx(Re,{className:"w-3 h-3"})})]}),d.description&&e.jsx("div",{className:`text-gray-500 dark:text-gray-400 truncate ${m?"text-sm mt-1":"text-sm max-w-xs"}`,children:d.description})]}),U=d=>{const m=C.filter(w=>w.enabled),P=i===d.id;return e.jsxs("div",{className:"relative inline-block",onClick:w=>w.stopPropagation(),children:[e.jsx("select",{value:d.defaultAgent,onChange:w=>I(d,w.target.value),disabled:P,className:"appearance-none bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 rounded-md px-3 py-1.5 pr-8 text-xs font-medium cursor-pointer border border-gray-200 dark:border-gray-600 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed",title:"切换助手",children:m.map(w=>e.jsxs("option",{value:w.id,className:"bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:[w.ui.icon," ",w.name]},w.id))}),e.jsx(st,{className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-3 h-3 text-gray-400 dark:text-gray-300 pointer-events-none"})]})},D=d=>e.jsxs("div",{className:"flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(Ee,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",title:d.path,children:d.path})]}),z=(d,m)=>e.jsxs("div",{className:"flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400",children:[m,e.jsx("span",{children:xe(d)})]}),x=d=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx("button",{onClick:()=>r(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Ie,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>p(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Fe,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(d),className:"p-1.5 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(W,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>k(d),className:"p-1.5 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>y(d),className:"p-1.5 text-indigo-600 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-900/50 rounded-md transition-colors",title:"项目设置",children:e.jsx(je,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>v(d),className:"p-1.5 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]});return e.jsxs("div",{className:`space-y-4 ${M}`,children:[e.jsx("div",{className:"md:hidden space-y-4",children:n.map(d=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"p-4 cursor-pointer",onClick:()=>t(d),children:e.jsx("div",{className:"flex items-start space-x-3",children:K(d,!0)})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 text-sm mb-3 px-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.agent"),":"]}),e.jsx("div",{children:U(d)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("projects.table.lastActive"),":"]}),e.jsx("div",{className:"text-right",children:z(d.lastAccessed,e.jsx(Ke,{className:"w-4 h-4"}))})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[g("common:path"),":"]}),e.jsx("div",{className:"text-right text-xs truncate ml-2 max-w-[200px]",children:d.path})]})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:g("projects.table.actions")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>r(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectMemory.title"),children:e.jsx(Ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>p(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectCommands.title"),children:e.jsx(Fe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>u(d),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",title:g("components:projectSubAgents.title"),children:e.jsx(W,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>k(d),className:"p-2 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/50 rounded-md transition-colors",title:"A2A Protocol 管理",children:e.jsx(ie,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>y(d),className:"p-2 text-indigo-600 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-900/50 rounded-md transition-colors",title:"项目设置",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>v(d),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-md transition-colors",title:g("projects.actions.delete"),children:e.jsx(Z,{className:"w-4 h-4"})})]})]})})]},d.id))}),e.jsx("div",{className:"hidden md:block bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-x-auto",children:e.jsxs("table",{className:"min-w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky left-0 bg-white dark:bg-gray-800 z-10 w-64",children:g("projects.table.project")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.agent")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:g("common:path")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("common:createdAt")}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-32",children:g("projects.table.lastActive")}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider sticky right-0 bg-white dark:bg-gray-800 z-10 w-32",children:g("projects.table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:n.map((d,m)=>e.jsxs("tr",{className:"group hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx("td",{className:"px-6 py-4 sticky left-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-64 max-w-[256px]",children:e.jsx("div",{className:"truncate",children:K(d)})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap w-32",children:U(d)}),e.jsx("td",{className:"px-6 py-4 max-w-xs truncate",children:D(d)}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:z(d.createdAt,e.jsx($e,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400 w-32",children:z(d.lastAccessed,e.jsx(Ke,{className:"w-4 h-4"}))}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium sticky right-0 bg-white dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-700/50 z-10 w-32",children:x(d)})]},d.id+"-"+m))})]})})]})},vt=({project:n,onClose:C})=>{const[t,r]=o.useState(""),[p,u]=o.useState(!0),[k,y]=o.useState(!1),[v,h]=o.useState(null);o.useEffect(()=>{(async()=>{try{u(!0),h(null);const i=await E(`${T}/projects/claude-md?path=${encodeURIComponent(n.path)}`);if(i.ok){const f=await i.json();r(f.content||"")}else if(i.status===404)r("");else throw new Error("加载 CLAUDE.md 文件失败")}catch(i){console.error("Failed to load CLAUDE.md:",i),h(i instanceof Error?i.message:"未知错误")}finally{u(!1)}})()},[n.id]);const M=async()=>{try{if(y(!0),h(null),!(await E(`${T}/projects/claude-md?path=${encodeURIComponent(n.path)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})})).ok)throw new Error("保存 CLAUDE.md 文件失败");const i=document.getElementById("save-button");if(i){const f=i.textContent;i.textContent="已保存",setTimeout(()=>{i.textContent==="已保存"&&(i.textContent=f)},2e3)}}catch(g){console.error("Failed to save CLAUDE.md:",g),h(g instanceof Error?g.message:"保存失败")}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-[80vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(nt,{className:"w-6 h-6 text-blue-600"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"项目记忆管理"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:n.name})]})]}),e.jsx("button",{onClick:C,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:e.jsx(_,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 flex flex-col p-6 overflow-hidden",children:p?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("div",{className:"text-gray-600 dark:text-gray-400",children:"正在加载 CLAUDE.md..."})]})}):v?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(me,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"加载失败"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:v})]})}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-4",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"编辑项目的记忆文件 (CLAUDE.md),用于存储项目相关的上下文信息和指导。"}),e.jsx("div",{className:"flex-1 border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:e.jsx("textarea",{value:t,onChange:g=>r(g.target.value),placeholder:`# 项目记忆
|
|
2
2
|
|
|
3
3
|
此文件用于存储项目相关的上下文信息、开发指导和重要注意事项。
|
|
4
4
|
|