apteva 0.4.19 → 0.4.20
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/dist/ActivityPage.h769ek3a.js +3 -0
- package/dist/{ApiDocsPage.rfpf7ws1.js → ApiDocsPage.kf6bbwkk.js} +1 -1
- package/dist/{App.7vzbaz56.js → App.039re6cf.js} +1 -1
- package/dist/{App.amwp54wf.js → App.2jmkqm8c.js} +1 -1
- package/dist/{App.p93mmyqw.js → App.2yy66bnp.js} +1 -1
- package/dist/{App.f8qsyhpr.js → App.3515wsb4.js} +1 -1
- package/dist/{App.6nc5acvk.js → App.7v1w3ys9.js} +1 -1
- package/dist/{App.sdsc0258.js → App.c90t3dxg.js} +1 -1
- package/dist/{App.5qw2dtxs.js → App.edwahsvz.js} +1 -1
- package/dist/{App.qmg33p02.js → App.jfx3der4.js} +1 -1
- package/dist/{App.kfyrnznw.js → App.n4jb3c22.js} +1 -1
- package/dist/App.q3bpx15d.js +20 -0
- package/dist/{App.e4202qb4.js → App.r0a2nmqs.js} +84 -84
- package/dist/{App.8rfz30p1.js → App.s2yrcz15.js} +1 -1
- package/dist/{App.1nmg2h01.js → App.s5j82a5j.js} +1 -1
- package/dist/{App.errxz2q4.js → App.tg1b94tx.js} +1 -1
- package/dist/ConnectionsPage.a67fjgbf.js +3 -0
- package/dist/McpPage.d4p3xvtk.js +3 -0
- package/dist/SettingsPage.46sqpe39.js +3 -0
- package/dist/SkillsPage.j9hkqm99.js +3 -0
- package/dist/TasksPage.6pvkb7s7.js +3 -0
- package/dist/TelemetryPage.5zq9msb5.js +3 -0
- package/dist/TestsPage.24432yqt.js +3 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/mcp-platform.ts +353 -2
- package/src/routes/api/agents.ts +15 -2
- package/src/routes/api/system.ts +12 -1
- package/src/routes/auth.ts +11 -2
- package/src/web/App.tsx +1 -1
- package/src/web/components/dashboard/Dashboard.tsx +5 -4
- package/src/web/context/AuthContext.tsx +18 -11
- package/src/web/hooks/useAgents.ts +7 -3
- package/src/web/hooks/useOnboarding.ts +9 -30
- package/dist/ActivityPage.9a1qg4bp.js +0 -3
- package/dist/App.g8vq68n0.js +0 -20
- package/dist/ConnectionsPage.7zqba1r0.js +0 -3
- package/dist/McpPage.kf2g327t.js +0 -3
- package/dist/SettingsPage.472c15ep.js +0 -3
- package/dist/SkillsPage.xdxnh68a.js +0 -3
- package/dist/TasksPage.7g0b8xwc.js +0 -3
- package/dist/TelemetryPage.pr7rbz4r.js +0 -3
- package/dist/TestsPage.zhc6rqjm.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Q as y,T as E,U as D,aa as l}from"./App.
|
|
1
|
+
import{Q as y,T as E,U as D,aa as l}from"./App.q3bpx15d.js";var M=y(E(),1);var z=y(D(),1),V={get:"#61affe",post:"#49cc90",put:"#fca130",delete:"#f93e3e",patch:"#50e3c2"};function c({method:I,path:A,parameters:F,requestBody:L,authFetch:T}){let[U,R]=M.useState({}),[G,O]=M.useState(""),[_,k]=M.useState(null),[w,q]=M.useState(!1),[B,f]=M.useState(null);M.useEffect(()=>{if(L?.content?.["application/json"]?.schema){let W=L.content["application/json"].schema;if(W.example)O(JSON.stringify(W.example,null,2));else if(W.properties){let $={};for(let[N,Q]of Object.entries(W.properties))if(Q.example!==void 0)$[N]=Q.example;else if(Q.type==="string")$[N]="";else if(Q.type==="number"||Q.type==="integer")$[N]=0;else if(Q.type==="boolean")$[N]=!1;else if(Q.type==="array")$[N]=[];else if(Q.type==="object")$[N]={};O(JSON.stringify($,null,2))}}},[L]);let C=async()=>{q(!0),f(null),k(null);try{let W=A,$=[];for(let Z of F||[]){let H=U[Z.name]||"";if(Z.in==="path")W=W.replace(`{${Z.name}}`,encodeURIComponent(H));else if(Z.in==="query"&&H)$.push(`${Z.name}=${encodeURIComponent(H)}`)}if($.length>0)W+=`?${$.join("&")}`;let N={method:I.toUpperCase()};if(G&&["post","put","patch"].includes(I))N.headers={"Content-Type":"application/json"},N.body=G;let Q=await T(`/api${W}`,N),X;if(Q.headers.get("content-type")?.includes("application/json"))X=await Q.json();else X=await Q.text();k({status:Q.status,data:X})}catch(W){f(W.message||"Request failed")}finally{q(!1)}},b=F?.filter((W)=>W.in==="path")||[],K=F?.filter((W)=>W.in==="query")||[],S=["post","put","patch"].includes(I)&&L;return z.jsxDEV("div",{style:{marginTop:16,padding:16,background:"#0a0a14",borderRadius:6,border:"1px solid #222"},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#f97316",marginBottom:12,fontWeight:600},children:"Try it out"},void 0,!1,void 0,this),b.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Path Parameters"},void 0,!1,void 0,this),b.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),K.length>0&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Query Parameters"},void 0,!1,void 0,this),K.map((W)=>z.jsxDEV("div",{style:{marginBottom:8},children:[z.jsxDEV("label",{style:{fontSize:12,color:"#888",display:"block",marginBottom:4},children:[W.name," ",W.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("input",{type:"text",value:U[W.name]||"",onChange:($)=>R({...U,[W.name]:$.target.value}),placeholder:W.schema?.type||"string",style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:13,fontFamily:"monospace"}},void 0,!1,void 0,this)]},W.name,!0,void 0,this))]},void 0,!0,void 0,this),S&&z.jsxDEV("div",{style:{marginBottom:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:"Request Body (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(W)=>O(W.target.value),rows:6,style:{width:"100%",padding:"8px 12px",background:"#111",border:"1px solid #333",borderRadius:4,color:"#fff",fontSize:12,fontFamily:"monospace",resize:"vertical"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:C,disabled:w,style:{padding:"10px 20px",background:w?"#333":"#f97316",color:w?"#666":"#000",border:"none",borderRadius:4,cursor:w?"not-allowed":"pointer",fontSize:13,fontWeight:600},children:w?"Executing...":"Execute"},void 0,!1,void 0,this),B&&z.jsxDEV("div",{style:{marginTop:12,padding:12,background:"#2a1515",borderRadius:4,color:"#f66",fontSize:12},children:B},void 0,!1,void 0,this),_&&z.jsxDEV("div",{style:{marginTop:12},children:[z.jsxDEV("div",{style:{fontSize:11,color:"#666",marginBottom:6},children:["Response"," ",z.jsxDEV("span",{style:{color:_.status>=200&&_.status<300?"#49cc90":"#f66"},children:_.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("pre",{style:{padding:12,background:"#111",borderRadius:4,color:"#888",fontSize:11,fontFamily:"monospace",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:typeof _.data==="string"?_.data:JSON.stringify(_.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function h(){let{authFetch:I}=l(),[A,F]=M.useState(null),[L,T]=M.useState(!0),[U,R]=M.useState(new Set),[G,O]=M.useState(null),[_,k]=M.useState(!1);M.useEffect(()=>{B()},[]);async function w(){if(!A)return;try{await navigator.clipboard.writeText(JSON.stringify(A,null,2)),k(!0),setTimeout(()=>k(!1),2000)}catch(N){console.error("Failed to copy:",N)}}function q(){if(!A)return;let N=new Blob([JSON.stringify(A,null,2)],{type:"application/json"}),Q=URL.createObjectURL(N),X=document.createElement("a");X.href=Q,X.download="apteva-openapi.json",X.click(),URL.revokeObjectURL(Q)}async function B(){try{let N=await I("/api/openapi");if(N.ok){let Q=await N.json();F(Q)}}catch(N){console.error("Failed to load OpenAPI spec:",N)}finally{T(!1)}}function f(N){R((Q)=>{let X=new Set(Q);if(X.has(N))X.delete(N);else X.add(N);return X})}function C(N,Q=0){if(!N)return"{}";if(Q>2)return"...";if(N.$ref)return N.$ref.split("/").pop()||"Object";if(N.type==="array")return`${C(N.items,Q+1)}[]`;if(N.type==="object"&&N.properties){let X=Object.entries(N.properties).slice(0,3).map(([Z,H])=>`${Z}: ${H.type||"any"}`).join(", "),Y=Object.keys(N.properties).length>3?", ...":"";return`{ ${X}${Y} }`}return N.type||"any"}if(L)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#888"},children:"Loading API documentation..."},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(!A)return z.jsxDEV("div",{style:{padding:24},children:z.jsxDEV("p",{style:{color:"#f66"},children:"Failed to load API documentation"},void 0,!1,void 0,this)},void 0,!1,void 0,this);let b=A.tags||[],K=Object.entries(A.paths);function S(N){let Q=new Set;function X(Y){if(!Y)return;if(typeof Y==="object"){if(Y.$ref){let Z=Y.$ref.split("/").pop();if(Z)Q.add(Z)}for(let Z of Object.values(Y))X(Z)}}return X(N.requestBody),X(N.responses),Q}function W(){if(!G||!A.components?.schemas)return Object.keys(A.components?.schemas||{});let N=new Set;for(let[Q,X]of $)for(let[Y,Z]of Object.entries(X)){if(!["get","post","put","delete","patch"].includes(Y))continue;if(Z.tags?.includes(G))S(Z).forEach((g)=>N.add(g))}return Array.from(N)}let $=G?K.filter(([N,Q])=>Object.values(Q).some((X)=>X.tags?.includes(G))):K;return z.jsxDEV("div",{style:{padding:24,maxWidth:1000,height:"100%",overflowY:"auto"},children:[z.jsxDEV("div",{style:{marginBottom:24},children:[z.jsxDEV("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[z.jsxDEV("h1",{style:{fontSize:24,fontWeight:600},children:A.info.title},void 0,!1,void 0,this),z.jsxDEV("div",{style:{display:"flex",gap:8},children:[z.jsxDEV("button",{onClick:w,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:_?"#49cc90":"#1a1a2e",color:_?"#000":"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:_?"Copied!":"Copy JSON"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:q,style:{padding:"8px 16px",borderRadius:4,border:"1px solid #333",background:"#1a1a2e",color:"#fff",cursor:"pointer",fontSize:12,fontFamily:"inherit"},children:"Download"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{style:{color:"#888",marginBottom:8},children:A.info.description.split(`
|
|
2
2
|
`)[0]},void 0,!1,void 0,this),z.jsxDEV("p",{style:{color:"#666",fontSize:12},children:["Version: ",A.info.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",padding:12,borderRadius:6,marginBottom:24,fontFamily:"monospace"},children:[z.jsxDEV("span",{style:{color:"#888"},children:"Base URL: "},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#61affe"},children:[window.location.origin,"/api"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{marginBottom:24,display:"flex",flexWrap:"wrap",gap:8},children:[z.jsxDEV("button",{onClick:()=>O(null),style:{padding:"6px 12px",borderRadius:4,border:"1px solid #333",background:G===null?"#333":"transparent",color:G===null?"#fff":"#888",cursor:"pointer",fontSize:12},children:"All"},void 0,!1,void 0,this),b.map((N)=>z.jsxDEV("button",{onClick:()=>O(N.name),style:{padding:"6px 12px",borderRadius:4,border:"1px solid #333",background:G===N.name?"#333":"transparent",color:G===N.name?"#fff":"#888",cursor:"pointer",fontSize:12},title:N.description,children:N.name},N.name,!1,void 0,this))]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:8},children:$.map(([N,Q])=>Object.entries(Q).filter(([X])=>["get","post","put","delete","patch"].includes(X)).map(([X,Y])=>{let Z=`${X}:${N}`,H=U.has(Z),g=X.toUpperCase(),j=V[X]||"#888";return z.jsxDEV("div",{style:{border:"1px solid #333",borderRadius:6,overflow:"hidden"},children:[z.jsxDEV("div",{onClick:()=>f(Z),style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:H?"#1a1a2e":"transparent",cursor:"pointer"},children:[z.jsxDEV("span",{style:{background:j,color:"#000",padding:"4px 8px",borderRadius:4,fontSize:11,fontWeight:600,minWidth:60,textAlign:"center"},children:g},void 0,!1,void 0,this),z.jsxDEV("span",{style:{fontFamily:"monospace",color:"#fff"},children:N},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888",flex:1,fontSize:13},children:Y.summary},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#666",fontSize:12},children:H?"[-]":"[+]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&z.jsxDEV("div",{style:{padding:16,background:"#0d0d1a",borderTop:"1px solid #333"},children:[Y.description&&z.jsxDEV("p",{style:{color:"#888",marginBottom:16,fontSize:13},children:Y.description},void 0,!1,void 0,this),Y.parameters&&Y.parameters.length>0&&z.jsxDEV("div",{style:{marginBottom:16},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:"Parameters"},void 0,!1,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12},children:Y.parameters.map((J)=>z.jsxDEV("div",{style:{display:"flex",gap:12,marginBottom:8,fontSize:12},children:[z.jsxDEV("span",{style:{color:"#61affe",minWidth:100},children:[J.name,J.required&&z.jsxDEV("span",{style:{color:"#f66"},children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("span",{style:{color:"#666"},children:["(",J.in,")"]},void 0,!0,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:J.schema?.type||"string"},void 0,!1,void 0,this),J.description&&z.jsxDEV("span",{style:{color:"#666"},children:["- ",J.description]},void 0,!0,void 0,this)]},J.name,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.requestBody&&z.jsxDEV("div",{style:{marginBottom:16},children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:["Request Body",Y.requestBody.required&&z.jsxDEV("span",{style:{color:"#f66"},children:" (required)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12,fontFamily:"monospace",fontSize:12,color:"#49cc90"},children:Object.entries(Y.requestBody.content||{}).map(([J,P])=>z.jsxDEV("div",{children:[z.jsxDEV("span",{style:{color:"#666"},children:[J,": "]},void 0,!0,void 0,this),C(P.schema)]},J,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.responses&&z.jsxDEV("div",{children:[z.jsxDEV("h4",{style:{fontSize:13,color:"#888",marginBottom:8},children:"Responses"},void 0,!1,void 0,this),z.jsxDEV("div",{style:{background:"#1a1a2e",borderRadius:4,padding:12},children:Object.entries(Y.responses).map(([J,P])=>{let v=P.content?.["application/json"]?.schema,u=v?.$ref?.split("/").pop(),n=v?.type,i=v?.items?.$ref?.split("/").pop();return z.jsxDEV("div",{style:{marginBottom:12,fontSize:12},children:[z.jsxDEV("div",{style:{display:"flex",gap:12,marginBottom:4},children:[z.jsxDEV("span",{style:{color:J.startsWith("2")?"#49cc90":"#f66",minWidth:40},children:J},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:P.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),v&&z.jsxDEV("div",{style:{marginLeft:52,padding:"8px 12px",background:"#0d0d1a",borderRadius:4,fontFamily:"monospace"},children:u?z.jsxDEV("span",{style:{color:"#61affe"},children:u},void 0,!1,void 0,this):n==="array"&&i?z.jsxDEV("span",{style:{color:"#61affe"},children:[i,"[]"]},void 0,!0,void 0,this):n==="array"?z.jsxDEV("span",{style:{color:"#888"},children:"array"},void 0,!1,void 0,this):z.jsxDEV("span",{style:{color:"#888"},children:C(v)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},J,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV(c,{method:X,path:N,parameters:Y.parameters,requestBody:Y.requestBody,authFetch:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Z,!0,void 0,this)}))},void 0,!1,void 0,this),A.components?.schemas&&W().length>0&&z.jsxDEV("div",{style:{marginTop:32},children:[z.jsxDEV("h2",{style:{fontSize:18,fontWeight:600,marginBottom:16},children:["Schemas ",G&&z.jsxDEV("span",{style:{color:"#666",fontSize:14},children:["(",G,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{style:{display:"flex",flexDirection:"column",gap:8},children:W().map((N)=>{let Q=A.components.schemas[N];if(!Q)return null;return z.jsxDEV("div",{style:{border:"1px solid #333",borderRadius:6,padding:12},children:[z.jsxDEV("h3",{style:{fontSize:14,color:"#61affe",marginBottom:8},children:N},void 0,!1,void 0,this),Q.properties&&z.jsxDEV("div",{style:{fontSize:12},children:Object.entries(Q.properties).map(([X,Y])=>z.jsxDEV("div",{style:{display:"flex",gap:8,marginBottom:4,fontFamily:"monospace"},children:[z.jsxDEV("span",{style:{color:"#fff",minWidth:120},children:X},void 0,!1,void 0,this),z.jsxDEV("span",{style:{color:"#888"},children:[Y.type||(Y.$ref?Y.$ref.split("/").pop():"any"),Y.nullable&&" | null"]},void 0,!0,void 0,this),Y.enum&&z.jsxDEV("span",{style:{color:"#666"},children:["[",Y.enum.join(" | "),"]"]},void 0,!0,void 0,this)]},X,!0,void 0,this))},void 0,!1,void 0,this)]},N,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}export{h as ApiDocsPage};
|
|
3
3
|
|
|
4
4
|
//# debugId=CC4FEADFD3330E5F64756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Q as i,T as p,U as u}from"./App.
|
|
1
|
+
import{Q as i,T as p,U as u}from"./App.q3bpx15d.js";var n=i(p(),1),e=i(u(),1);function g({value:o,options:c,onChange:d,placeholder:f="Select..."}){let[a,l]=n.useState(!1),s=n.useRef(null),r=c.find((t)=>t.value===o);return n.useEffect(()=>{function t(m){if(s.current&&!s.current.contains(m.target))l(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),e.jsxDEV("div",{ref:s,className:"relative",children:[e.jsxDEV("button",{type:"button",onClick:()=>l(!a),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-left flex items-center justify-between focus:outline-none focus:border-[#f97316] text-[#e0e0e0] hover:border-[#333] transition",children:[e.jsxDEV("span",{className:r?"text-[#e0e0e0]":"text-[#666]",children:r?e.jsxDEV(e.Fragment,{children:[r.label,r.recommended&&e.jsxDEV("span",{className:"text-[#f97316] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):f},void 0,!1,void 0,this),e.jsxDEV(v,{isOpen:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&e.jsxDEV("div",{className:"absolute z-50 w-full min-w-max mt-1 bg-[#111] border border-[#222] rounded shadow-lg max-h-60 overflow-y-auto scrollbar-hide",children:c.map((t)=>e.jsxDEV("button",{type:"button",onClick:()=>{d(t.value),l(!1)},className:`w-full px-3 py-2 text-left flex items-center justify-between hover:bg-[#1a1a1a] transition ${t.value===o?"bg-[#1a1a1a] text-[#f97316]":"text-[#e0e0e0]"}`,children:[e.jsxDEV("span",{children:[t.label,t.recommended&&e.jsxDEV("span",{className:"text-[#f97316] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.value===o&&e.jsxDEV("svg",{className:"w-4 h-4 text-[#f97316]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},t.value,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function v({isOpen:o}){return e.jsxDEV("svg",{className:`w-4 h-4 text-[#666] transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}
|
|
2
2
|
export{g as P};
|
|
3
3
|
|
|
4
4
|
//# debugId=237C22B143A28DA764756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as r}from"./App.6nc5acvk.js";import{s as Oz}from"./App.sdsc0258.js";import{M as Jz,N as o}from"./App.p93mmyqw.js";import{P as t}from"./App.7vzbaz56.js";import{Q as a,T as Qz,U as zz,aa as c,da as Gz}from"./App.g8vq68n0.js";var J=a(Qz(),1);var z=a(zz(),1);function Mz(){let{authFetch:G}=c(),{projects:_,currentProjectId:H}=Gz(),[L,w]=J.useState([]),[W,B]=J.useState(!0),[q,F]=J.useState(!1),[U,T]=J.useState(null),[M,K]=J.useState(null),[Q,k]=J.useState("servers"),{confirm:y,ConfirmDialog:I}=Jz(),X=_.length>0,b=async()=>{try{let A=await(await G("/api/mcp/servers")).json();w(A.servers||[])}catch($){console.error("Failed to fetch MCP servers:",$)}B(!1)};J.useEffect(()=>{b()},[G]);let Z=L.filter(($)=>{if(!H)return!0;if(H==="unassigned")return $.project_id===null;return $.project_id===null||$.project_id===H}),S=async($)=>{try{await G(`/api/mcp/servers/${$}/start`,{method:"POST"}),b()}catch(A){console.error("Failed to start server:",A)}},C=async($)=>{try{await G(`/api/mcp/servers/${$}/stop`,{method:"POST"}),b()}catch(A){console.error("Failed to stop server:",A)}},m=async($)=>{if(!await y("Delete this MCP server?",{confirmText:"Delete",title:"Delete Server"}))return;try{if(await G(`/api/mcp/servers/${$}`,{method:"DELETE"}),M?.id===$)K(null);b()}catch(f){console.error("Failed to delete server:",f)}},g=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}),b()}catch(f){console.error("Failed to rename server:",f)}},V=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),b()}catch(f){throw console.error("Failed to update server:",f),f}};return z.jsxDEV(z.Fragment,{children:[I,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage Model Context Protocol servers for tool integrations."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>k("servers"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="servers"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"My Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("hosted"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="hosted"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Hosted Services"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="registry"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV(z.Fragment,{children:[W&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this),!W&&Z.length===0&&L.length===0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV(Oz,{className:"w-12 h-12 text-[#333] mx-auto mb-4"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No MCP servers configured"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"MCP servers extend your agents with tools like file access, web browsing, database connections, and more."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-3 justify-center",children:[z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Add Manually"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:"border border-[#333] hover:border-[#666] px-4 py-2 rounded font-medium transition",children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!W&&Z.length===0&&L.length>0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No servers match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!W&&Z.length>0&&z.jsxDEV("div",{className:"flex gap-6",children:[z.jsxDEV("div",{className:`space-y-3 ${M?"w-1/2":"w-full"}`,children:Z.map(($)=>{let f=$.type==="http"&&$.url||$.status==="running",p=X&&$.project_id?_.find((j)=>j.id===$.project_id):null;return z.jsxDEV(Wz,{server:$,project:p,selected:M?.id===$.id,onSelect:()=>K(f?$:null),onStart:()=>S($.id),onStop:()=>C($.id),onDelete:()=>m($.id),onEdit:()=>T($)},$.id,!1,void 0,this)})},void 0,!1,void 0,this),M&&z.jsxDEV("div",{className:"w-1/2",children:z.jsxDEV(Xz,{server:M,onClose:()=>K(null)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q==="hosted"&&z.jsxDEV(_z,{onServerAdded:b,projectId:H},void 0,!1,void 0,this),Q==="registry"&&z.jsxDEV(Zz,{onInstall:($)=>{b(),k("servers")}},void 0,!1,void 0,this),Q==="servers"&&z.jsxDEV("div",{className:"mt-8 p-4 bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("h3",{className:"font-medium mb-2",children:"Quick Start"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-3",children:"Add an MCP server by providing its npm package name. For example:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch"},{name:"memory",pkg:"@modelcontextprotocol/server-memory"}].map(($)=>z.jsxDEV("code",{className:"text-xs bg-[#0a0a0a] px-2 py-1 rounded",children:$.pkg},$.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&z.jsxDEV(Bz,{onClose:()=>F(!1),onAdded:()=>{F(!1),b()},projects:X?_:void 0,defaultProjectId:H&&H!=="unassigned"?H:null},void 0,!1,void 0,this),U&&z.jsxDEV(Uz,{server:U,projects:X?_:void 0,onClose:()=>T(null),onSaved:()=>{T(null),b()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Wz({server:G,project:_,selected:H,onSelect:L,onStart:w,onStop:W,onDelete:B,onEdit:q}){let F=G.type==="http"&&G.url,U=F||G.status==="running",T=()=>{if(F)return`${G.source||"remote"} • http`;return`${G.type} • ${G.package||G.command||"custom"}${G.status==="running"&&G.port?` • :${G.port}`:""}`},M=()=>{if(_)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${_.color}20`,color:_.color},children:_.name},void 0,!1,void 0,this);if(G.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,onClick:U?L:void 0,children:z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("div",{className:`w-2 h-2 rounded-full ${U?"bg-green-400":"bg-[#444]"}`},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666]",children:T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),q()},className:"text-sm text-[#666] hover:text-[#888] px-3 py-1 transition",title:"Edit server settings",children:"Edit"},void 0,!1,void 0,this),F?z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Remove"},void 0,!1,void 0,this):G.status==="running"?z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),L()},className:"text-sm text-[#f97316] hover:text-[#fb923c] px-3 py-1 transition",children:"Tools"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),W()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Stop"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),w()},className:"text-sm text-[#666] hover:text-green-400 px-3 py-1 transition",children:"Start"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Xz({server:G,onClose:_}){let{authFetch:H}=c(),[L,w]=J.useState([]),[W,B]=J.useState(null),[q,F]=J.useState(!0),[U,T]=J.useState(null),[M,K]=J.useState(null);return J.useEffect(()=>{(async()=>{F(!0),T(null);try{let k=await H(`/api/mcp/servers/${G.id}/tools`),y=await k.json();if(!k.ok){T(y.error||"Failed to fetch tools");return}w(y.tools||[]),B(y.serverInfo||null)}catch(k){T(`Failed to fetch tools: ${k}`)}finally{F(!1)}})()},[G.id,H]),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:[G.name," Tools"]},void 0,!0,void 0,this),W&&z.jsxDEV("p",{className:"text-xs text-[#666]",children:[W.name," v",W.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:_,className:"text-[#666] hover:text-[#888] text-xl leading-none",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 max-h-[500px] overflow-auto",children:[q&&z.jsxDEV("p",{className:"text-[#666]",children:"Loading tools..."},void 0,!1,void 0,this),U&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:U},void 0,!1,void 0,this),!q&&!U&&L.length===0&&z.jsxDEV("p",{className:"text-[#666]",children:"No tools available from this server."},void 0,!1,void 0,this),!q&&!U&&L.length>0&&!M&&z.jsxDEV("div",{className:"space-y-2",children:L.map((Q)=>z.jsxDEV("button",{onClick:()=>K(Q),className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#222] hover:border-[#333] rounded transition",children:[z.jsxDEV("div",{className:"font-medium text-sm",children:Q.name},void 0,!1,void 0,this),Q.description&&z.jsxDEV("div",{className:"text-xs text-[#666] mt-1",children:Q.description},void 0,!1,void 0,this)]},Q.name,!0,void 0,this))},void 0,!1,void 0,this),M&&z.jsxDEV(Yz,{serverId:G.id,tool:M,onBack:()=>K(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yz({serverId:G,tool:_,onBack:H}){let{authFetch:L}=c(),[w,W]=J.useState("{}"),[B,q]=J.useState(null),[F,U]=J.useState(null),[T,M]=J.useState(!1);J.useEffect(()=>{let Q=_.inputSchema;if(Q&&typeof Q==="object"&&"properties"in Q){let k=Q.properties,y={};for(let[I,X]of Object.entries(k))if(X.default!==void 0)y[I]=X.default;else if(X.type==="string")y[I]="";else if(X.type==="number"||X.type==="integer")y[I]=0;else if(X.type==="boolean")y[I]=!1;else if(X.type==="array")y[I]=[];else if(X.type==="object")y[I]={};W(JSON.stringify(y,null,2))}},[_]);let K=async()=>{M(!0),U(null),q(null);try{let Q=JSON.parse(w),k=await L(`/api/mcp/servers/${G}/tools/${encodeURIComponent(_.name)}/call`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:Q})}),y=await k.json();if(!k.ok){U(y.error||"Failed to call tool");return}q(y.result)}catch(Q){U(`Error: ${Q}`)}finally{M(!1)}};return z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888] text-sm",children:"← Back"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[#444]",children:"/"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"font-medium",children:_.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.description&&z.jsxDEV("p",{className:"text-sm text-[#666]",children:_.description},void 0,!1,void 0,this),_.inputSchema&&z.jsxDEV("div",{className:"text-xs",children:z.jsxDEV("details",{className:"cursor-pointer",children:[z.jsxDEV("summary",{className:"text-[#666] hover:text-[#888]",children:"Input Schema"},void 0,!1,void 0,this),z.jsxDEV("pre",{className:"mt-2 p-2 bg-[#0a0a0a] rounded text-[#888] overflow-auto max-h-32",children:JSON.stringify(_.inputSchema,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:w,onChange:(Q)=>W(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 h-32 font-mono text-sm focus:outline-none focus:border-[#f97316] resize-none",placeholder:"{}"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:K,disabled:T,className:"w-full bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:T?"Calling...":"Call Tool"},void 0,!1,void 0,this),F&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:F},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"space-y-2",children:[z.jsxDEV("div",{className:"text-sm text-[#666]",children:["Result ",B.isError&&z.jsxDEV("span",{className:"text-red-400",children:"(error)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:`p-3 rounded text-sm ${B.isError?"bg-red-500/10":"bg-green-500/10"}`,children:B.content.map((Q,k)=>z.jsxDEV("div",{className:"mb-2 last:mb-0",children:[Q.type==="text"&&z.jsxDEV("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:Q.text},void 0,!1,void 0,this),Q.type==="image"&&Q.data&&z.jsxDEV("img",{src:`data:${Q.mimeType||"image/png"};base64,${Q.data}`,alt:"Tool result",className:"max-w-full rounded"},void 0,!1,void 0,this)]},k,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zz({onInstall:G}){let{authFetch:_}=c(),[H,L]=J.useState(""),[w,W]=J.useState([]),[B,q]=J.useState(!1),[F,U]=J.useState(!1),[T,M]=J.useState(null),[K,Q]=J.useState(null),k=async(X)=>{q(!0),Q(null);try{let b=await _(`/api/mcp/registry?search=${encodeURIComponent(X)}&limit=20`),Z=await b.json();if(!b.ok)Q(Z.error||"Failed to search registry"),W([]);else W(Z.servers||[])}catch(b){Q(`Failed to search: ${b}`),W([])}finally{q(!1),U(!0)}},y=(X)=>{if(X.preventDefault(),H.trim())k(H.trim())};J.useEffect(()=>{k("")},[]);let I=async(X)=>{if(!X.npmPackage){Q("This server does not have an npm package");return}M(X.id),Q(null);try{let b=await _("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,type:"npm",package:X.npmPackage})});if(!b.ok){let Z=await b.json();Q(Z.error||"Failed to add server");return}G(X)}catch(b){Q(`Failed to add server: ${b}`)}finally{M(null)}};return z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:y,className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:H,onChange:(X)=>L(X.target.value),placeholder:"Search MCP servers (e.g., filesystem, github, slack...)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:B,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:B?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:K},void 0,!1,void 0,this),!B&&F&&w.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No servers found. Try a different search term."},void 0,!1,void 0,this),w.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:w.map((X)=>z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 hover:border-[#333] transition",children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:X.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:X.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[X.version&&z.jsxDEV("span",{children:["v",X.version]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded ${X.npmPackage?"bg-green-500/10 text-green-400":"bg-blue-500/10 text-blue-400"}`,children:X.npmPackage?"npm":"remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("code",{className:"text-xs text-[#555] bg-[#0a0a0a] px-2 py-0.5 rounded mt-2 inline-block truncate max-w-full",children:X.npmPackage||X.fullName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:X.npmPackage?z.jsxDEV("button",{onClick:()=>I(X),disabled:T===X.id,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:T===X.id?"Adding...":"Add"},void 0,!1,void 0,this):X.repository?z.jsxDEV("a",{href:X.repository,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#666] hover:text-[#f97316] transition",children:"View →"},void 0,!1,void 0,this):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this))},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Searching registry..."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Servers are sourced from the"," ",z.jsxDEV("a",{href:"https://github.com/modelcontextprotocol/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline",children:"official MCP registry"},void 0,!1,void 0,this),". Not all servers have npm packages - some require manual setup."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _z({onServerAdded:G,projectId:_}){let{authFetch:H}=c(),[L,w]=J.useState("composio"),[W,B]=J.useState("configs"),[q,F]=J.useState(!1),[U,T]=J.useState(!1),[M,K]=J.useState(!1),[Q,k]=J.useState([]),[y,I]=J.useState(new Set),[X,b]=J.useState(!0),[Z,S]=J.useState(!1),[C,m]=J.useState(null),{alert:g,AlertDialog:V}=o(),$=async()=>{try{let P=_&&_!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(_)}`:"/api/mcp/servers",[i,Y]=await Promise.all([H("/api/providers"),H(P)]),R=await i.json(),u=await Y.json(),D=R.providers||[],O=u.servers||[],N=new Set(O.filter((E)=>E.source==="composio"&&E.url).map((E)=>{let e=E.url.match(/\/v3\/mcp\/([^/]+)/);return e?e[1]:null}).filter(Boolean));I(N);let h=D.find((E)=>E.id==="composio"),l=D.find((E)=>E.id==="smithery"),n=D.find((E)=>E.id==="agentdojo"),d=h?.hasKey||!1,v=l?.hasKey||!1,s=n?.hasKey||!1;if(F(d),T(v),K(s),d)w("composio"),A();else if(v)w("smithery");else if(s)w("agentdojo")}catch(P){console.error("Failed to fetch providers:",P)}b(!1)},A=async()=>{S(!0);try{let P=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await(await H(`/api/integrations/composio/configs${P}`)).json();k(Y.configs||[])}catch(P){console.error("Failed to fetch Composio configs:",P)}S(!1)},f=async(P)=>{m(P);try{let i=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await H(`/api/integrations/composio/configs/${P}/add${i}`,{method:"POST"});if(Y.ok)I((R)=>new Set([...R,P])),G?.();else{let R=await Y.json();await g(R.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(i){console.error("Failed to add config:",i)}m(null)},p=(P)=>{return y.has(P)};if(J.useEffect(()=>{$()},[H,_]),X)return z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let j=q||U||M,x=[q,U,M].filter(Boolean).length;if(!j)return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#888] mb-2",children:"No hosted MCP services connected"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect Composio, Smithery, or AgentDojo in Settings to access cloud-based MCP servers."},void 0,!1,void 0,this),z.jsxDEV("a",{href:"/settings",className:"inline-block bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded text-sm font-medium transition",children:"Go to Settings →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return z.jsxDEV(z.Fragment,{children:[V,z.jsxDEV("div",{className:"space-y-6",children:[x>1&&z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1 w-fit",children:[q&&z.jsxDEV("button",{onClick:()=>{w("composio"),B("configs")},className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="composio"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio"]},void 0,!0,void 0,this),U&&z.jsxDEV("button",{onClick:()=>w("smithery"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="smithery"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery"]},void 0,!0,void 0,this),M&&z.jsxDEV("button",{onClick:()=>w("agentdojo"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="agentdojo"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&(x===1||L==="composio")&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>B("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Configs"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("connect"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="connect"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Connect Apps"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666]",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="connect"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect your accounts to enable tools in MCP configs"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"composio",projectId:_,onConnectionComplete:()=>{A()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP configs from Composio"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("button",{onClick:A,disabled:Z,className:"text-xs text-[#666] hover:text-[#888] transition",children:Z?"Loading...":"Refresh"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Create Config →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading configs..."},void 0,!1,void 0,this):Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP configs found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:["First ",z.jsxDEV("button",{onClick:()=>B("connect"),className:"text-[#f97316] hover:text-[#fb923c]",children:"connect some apps"},void 0,!1,void 0,this),", then create a config."]},void 0,!0,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#f97316] hover:text-[#fb923c] mt-2 inline-block",children:"Create in Composio →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:Q.map((P)=>{let i=p(P.id),Y=C===P.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${i?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:P.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[P.toolsCount," tools"]},void 0,!0,void 0,this),i&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.toolkits.length>0&&z.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:[P.toolkits.slice(0,4).map((R)=>z.jsxDEV("span",{className:"text-xs bg-[#1a1a1a] text-[#666] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this)),P.toolkits.length>4&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:["+",P.toolkits.length-4]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:[i?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>f(P.id),disabled:Y,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:Y?"Adding...":"Add"},void 0,!1,void 0,this),z.jsxDEV("a",{href:`https://app.composio.dev/mcp_configs/${P.id}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#888] transition",children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U&&(x===1||L==="smithery")&&z.jsxDEV("div",{children:[x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Add MCP servers from the Smithery registry"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://smithery.ai/servers",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Browse Smithery →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:["Smithery servers can be added from the ",z.jsxDEV("strong",{children:"Browse Registry"},void 0,!1,void 0,this)," tab."]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:"Your API key will be used automatically when adding Smithery servers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&(x===1||L==="agentdojo")&&z.jsxDEV($z,{projectId:_,onServerAdded:G,showProviderBadge:x===1},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded text-xs text-[#666]",children:[z.jsxDEV("strong",{className:"text-[#888]",children:"Tip:"},void 0,!1,void 0,this)," Connect apps first, then add MCP configs to make tools available to your agents."," · ",z.jsxDEV("a",{href:"/settings",className:"text-[#f97316] hover:text-[#fb923c]",children:"Add more providers in Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $z({projectId:G,onServerAdded:_,showProviderBadge:H}){let{authFetch:L}=c(),[w,W]=J.useState("configs"),[B,q]=J.useState([]),[F,U]=J.useState(new Set),[T,M]=J.useState(!1),[K,Q]=J.useState(null),{alert:k,AlertDialog:y}=o(),I=async()=>{M(!0);try{let Z=G&&G!=="unassigned"?`?project_id=${G}`:"",S=G&&G!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(G)}`:"/api/mcp/servers",[C,m]=await Promise.all([L(`/api/integrations/agentdojo/configs${Z}`),L(S)]),g=await C.json(),V=await m.json();q(g.configs||[]);let $=new Set((V.servers||[]).filter((A)=>A.source==="agentdojo").map((A)=>{let f=A.url?.match(/\/mcp\/([^/?]+)/);return f?f[1]:A.name}));U($)}catch(Z){console.error("Failed to fetch AgentDojo configs:",Z)}M(!1)},X=async(Z)=>{Q(Z);try{let S=G&&G!=="unassigned"?`?project_id=${G}`:"",C=await L(`/api/integrations/agentdojo/configs/${Z}/add${S}`,{method:"POST"});if(C.ok){let m=B.find((g)=>g.id===Z);U((g)=>new Set([...g,m?.slug||Z])),_?.()}else{let m=await C.json();await k(m.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(S){console.error("Failed to add config:",S)}Q(null)},b=(Z)=>{return F.has(Z.slug)||F.has(Z.id)||F.has(Z.name)};return J.useEffect(()=>{I()},[L,G]),z.jsxDEV(z.Fragment,{children:[y,z.jsxDEV("div",{children:[H&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>W("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>W("toolkits"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="toolkits"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Toolkits"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP servers from AgentDojo"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:I,disabled:T,className:"text-xs text-[#666] hover:text-[#888] transition",children:T?"Loading...":"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading servers..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP servers found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:[z.jsxDEV("button",{onClick:()=>W("toolkits"),className:"text-[#f97316] hover:text-[#fb923c]",children:"Browse toolkits"},void 0,!1,void 0,this)," ","to create a new MCP server."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:B.map((Z)=>{let S=b(Z),C=K===Z.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${S?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:Z.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[Z.toolsCount," tools"]},void 0,!0,void 0,this),S&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.mcpUrl&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.mcpUrl},void 0,!1,void 0,this),!Z.mcpUrl&&Z.slug&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:S?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>X(Z.id),disabled:C,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:C?"Adding...":"Add"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},Z.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w==="toolkits"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Browse available toolkits and create MCP servers"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"agentdojo",projectId:G,onConnectionComplete:()=>{I()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz(G){let _=[],H=G,L=null,w=G.match(/(?:npx\s+-y\s+)?(@?[\w-]+\/)?(@?[\w-]+)(?:@[\w.-]+)?/);if(w){let q=w[2]||w[1];if(q)L=q.replace(/^@/,"").replace(/-mcp$/,"").replace(/-server$/,"").replace(/^server-/,"").replace(/^mcp-/,"")}let W=/--(\w+[-\w]*)\s+(YOUR_\w+|<[\w_]+>|\{[\w_]+\}|\$[\w_]+|[\w_]*(?:TOKEN|KEY|SECRET|PASSWORD|USER|ID|APIKEY)[\w_]*)/gi,B;while((B=W.exec(G))!==null){let q=B[1],F=B[2],U=q.toUpperCase().replace(/-/g,"_"),T=L?`${L.toUpperCase().replace(/-/g,"_")}_${U}`:U;_.push({key:T,flag:q}),H=H.replace(new RegExp(`(--${q}\\s+)${F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i"),`--${q} $${T}`)}return{cleanCommand:H,credentials:_,serverName:L}}function Bz({onClose:G,onAdded:_,projects:H,defaultProjectId:L}){let{authFetch:w}=c(),[W,B]=J.useState("npm"),[q,F]=J.useState(""),[U,T]=J.useState(""),[M,K]=J.useState(""),[Q,k]=J.useState(""),[y,I]=J.useState(""),[X,b]=J.useState(""),[Z,S]=J.useState(""),[C,m]=J.useState([]),[g,V]=J.useState(L||null),[$,A]=J.useState(!1),[f,p]=J.useState(null),j=H&&H.length>0,x=()=>{m([...C,{key:"",value:""}])},P=(O,N,h)=>{let l=[...C];l[O][N]=h,m(l)},i=(O)=>{m(C.filter((N,h)=>h!==O))},Y=(O)=>{if(k(O),O.includes("YOUR_")||O.includes("<")||O.includes("{")||/TOKEN|KEY|SECRET|PASSWORD/i.test(O)){let{cleanCommand:N,credentials:h,serverName:l}=qz(O);if(!q&&l)F(l);if(h.length>0){let n=new Set(C.map((v)=>v.key)),d=h.filter((v)=>!n.has(v.key)).map((v)=>({key:v.key,value:""}));if(d.length>0)m([...C,...d]),k(N)}}},R=(O)=>{if(O.startsWith("npx ")||O.includes(" --")||O.includes("YOUR_")||O.includes("<")||/\s+(TOKEN|KEY|SECRET|PASSWORD)/i.test(O))B("command"),Y(O);else if(T(O),!q&&O){let h=O.replace(/^@[\w-]+\//,"").replace(/@[\w.-]+$/,"").replace(/^server-/,"").replace(/-server$/,"").replace(/^mcp-/,"").replace(/-mcp$/,"");if(h&&h!==O)F(h)}},u=async()=>{if(!q){p("Name is required");return}if(W==="npm"&&!U){p("npm package is required");return}if(W==="pip"&&!U){p("pip package is required");return}if(W==="command"&&!Q){p("Command is required");return}if(W==="http"&&!y){p("URL is required");return}A(!0),p(null);let O={};for(let{key:N,value:h}of C)if(N.trim())O[N.trim()]=h;try{let N={name:q};if(W==="npm")N.type="npm",N.package=U;else if(W==="pip"){if(N.type="pip",N.package=U,M)N.pip_module=M}else if(W==="http"){N.type="http",N.url=y;let l={"Content-Type":"application/json"};if(X&&Z){let n=btoa(`${X}:${Z}`);l.Authorization=`Basic ${n}`}N.headers=l}else{let l=Q.trim().split(/\s+/);N.type="custom",N.command=l[0],N.args=l.slice(1).join(" ")}if(Object.keys(O).length>0)N.env=O;if(g)N.project_id=g;let h=await w("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!h.ok){let l=await h.json();p(l.error||"Failed to add server"),A(!1);return}_()}catch(N){p("Failed to add server"),A(!1)}},D=(O,N)=>{B("npm"),F(O),T(N)};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Add MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:G,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-2",children:"Quick add:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem",type:"npm"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch",type:"npm"},{name:"memory",pkg:"@modelcontextprotocol/server-memory",type:"npm"},{name:"github",pkg:"@modelcontextprotocol/server-github",type:"npm"},{name:"time",pkg:"mcp-server-time",module:"mcp_server_time",type:"pip"}].map((O)=>z.jsxDEV("button",{onClick:()=>{if(B(O.type),F(O.name),T(O.pkg),O.type==="pip"&&"module"in O)K(O.module||"");else K("")},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] px-3 py-1 rounded transition",children:O.name},O.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded p-1",children:[z.jsxDEV("button",{onClick:()=>B("npm"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="npm"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"npm"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("pip"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="pip"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"pip"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("command"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="command"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Command"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("http"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="http"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"HTTP"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(O)=>F(O.target.value),placeholder:"e.g., pushover",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:g||"",onChange:(O)=>V(O||null),options:[{value:"",label:"Global (all projects)"},...H.map((O)=>({value:O.id,label:O.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global servers are available to all agents. Project-scoped servers are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>R(O.target.value),placeholder:"e.g., @modelcontextprotocol/server-filesystem or paste full command",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Package name or paste a full npx command with credentials"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="pip"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>{if(T(O.target.value),!M&&O.target.value){let N=O.target.value.split("[")[0].replace(/-/g,".");K(N)}},placeholder:"e.g., late-sdk[mcp]",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python package with extras, e.g., late-sdk[mcp] or mcp-server-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Module (optional)"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(O)=>K(O.target.value),placeholder:"e.g., late.mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python module to run with -m. Auto-detected from package name if not specified."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="command"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(O)=>Y(O.target.value),placeholder:"e.g., npx -y pushover-mcp@latest start --token YOUR_TOKEN",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Paste the full command - credentials like YOUR_TOKEN will be auto-extracted"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="http"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(O)=>I(O.target.value),placeholder:"e.g., https://example.com/wp-json/mcp/v1/messages",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded",children:[z.jsxDEV("p",{className:"text-xs text-[#666] mb-3",children:"Optional: Basic Auth credentials (will be encoded and stored securely)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Username"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(O)=>b(O.target.value),placeholder:"username",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Password"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Z,onChange:(O)=>S(O.target.value),placeholder:"password or app key",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:x,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"Add environment variables for API tokens and credentials. These are stored encrypted and passed to the server at startup."},void 0,!1,void 0,this),C.length>0&&z.jsxDEV("div",{className:"space-y-2",children:C.map((O,N)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:O.key,onChange:(h)=>P(N,"key",h.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:O.value,onChange:(h)=>P(N,"value",h.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>i(N),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},N,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:G,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:u,disabled:$||!q||(W==="npm"?!U:W==="pip"?!U:W==="http"?!y:!Q),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:$?"Adding...":"Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Uz({server:G,projects:_,onClose:H,onSaved:L}){let{authFetch:w}=c(),[W,B]=J.useState(G.name),[q,F]=J.useState(G.package||""),[U,T]=J.useState(G.command||""),[M,K]=J.useState(G.args||""),[Q,k]=J.useState(G.url||""),[y,I]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":")[0]||""}catch{return""}return""}),[X,b]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":").slice(1).join(":")||""}catch{return""}return""}),[Z,S]=J.useState(()=>{return Object.entries(G.env||{}).map(([Y,R])=>({key:Y,value:R}))}),[C,m]=J.useState(G.project_id),[g,V]=J.useState(!1),[$,A]=J.useState(null),f=_&&_.length>0,p=G.type==="http",j=()=>{S([...Z,{key:"",value:""}])},x=(Y,R,u)=>{let D=[...Z];D[Y][R]=u,S(D)},P=(Y)=>{S(Z.filter((R,u)=>u!==Y))},i=async()=>{if(!W.trim()){A("Name is required");return}V(!0),A(null);let Y={};for(let{key:R,value:u}of Z)if(R.trim())Y[R.trim()]=u;try{let R={name:W.trim(),env:Y};if(p){if(Q.trim())R.url=Q.trim();let D={"Content-Type":"application/json"};if(y&&X){let O=btoa(`${y}:${X}`);D.Authorization=`Basic ${O}`}R.headers=D}else{if(G.type==="npm"&&q.trim())R.package=q.trim();if(G.type==="pip"&&q.trim())R.package=q.trim();if(G.type==="custom"){if(U.trim())R.command=U.trim();if(M.trim())R.args=M.trim()}}R.project_id=C;let u=await w(`/api/mcp/servers/${G.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!u.ok){let D=await u.json();A(D.error||"Failed to save changes"),V(!1);return}if(G.status==="running"&&!p)try{await w(`/api/mcp/servers/${G.id}/stop`,{method:"POST"}),await w(`/api/mcp/servers/${G.id}/start`,{method:"POST"})}catch(D){console.error("Failed to restart server:",D)}L()}catch(R){A("Failed to save changes"),V(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Edit MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{className:"text-sm text-[#666] bg-[#0a0a0a] border border-[#222] rounded p-3",children:["Type: ",z.jsxDEV("span",{className:"text-[#888]",children:G.type},void 0,!1,void 0,this),G.package&&z.jsxDEV(z.Fragment,{children:[" • Package: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.package},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.command&&z.jsxDEV(z.Fragment,{children:[" • Command: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.command},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:W,onChange:(Y)=>B(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:C||"",onChange:(Y)=>m(Y||null),options:[{value:"",label:"Global (all projects)"},..._.map((Y)=>({value:Y.id,label:Y.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="pip"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Server URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(Y)=>k(Y.target.value),placeholder:"https://example.com/mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Authentication (Basic Auth)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:y,onChange:(Y)=>I(Y.target.value),placeholder:"Username",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:X,onChange:(Y)=>b(Y.target.value),placeholder:"Password / App Password",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty if no authentication required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.type==="custom"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(Y)=>T(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(Y)=>K(Y.target.value),placeholder:"e.g., --token $TOKEN --verbose",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!p&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:j,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"No environment variables configured."},void 0,!1,void 0,this),Z.length>0&&z.jsxDEV("div",{className:"space-y-2",children:Z.map((Y,R)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:Y.key,onChange:(u)=>x(R,"key",u.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Y.value,onChange:(u)=>x(R,"value",u.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>P(R),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},R,!0,void 0,this))},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:G.status==="running"?"Server will be automatically restarted to apply changes.":"Changes will take effect when the server is started."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:H,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:i,disabled:g||!W.trim(),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:g?"Saving...":"Save Changes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
1
|
+
import{i as r}from"./App.7v1w3ys9.js";import{s as Oz}from"./App.c90t3dxg.js";import{M as Jz,N as o}from"./App.2yy66bnp.js";import{P as t}from"./App.039re6cf.js";import{Q as a,T as Qz,U as zz,aa as c,da as Gz}from"./App.q3bpx15d.js";var J=a(Qz(),1);var z=a(zz(),1);function Mz(){let{authFetch:G}=c(),{projects:_,currentProjectId:H}=Gz(),[L,w]=J.useState([]),[W,B]=J.useState(!0),[q,F]=J.useState(!1),[U,T]=J.useState(null),[M,K]=J.useState(null),[Q,k]=J.useState("servers"),{confirm:y,ConfirmDialog:I}=Jz(),X=_.length>0,b=async()=>{try{let A=await(await G("/api/mcp/servers")).json();w(A.servers||[])}catch($){console.error("Failed to fetch MCP servers:",$)}B(!1)};J.useEffect(()=>{b()},[G]);let Z=L.filter(($)=>{if(!H)return!0;if(H==="unassigned")return $.project_id===null;return $.project_id===null||$.project_id===H}),S=async($)=>{try{await G(`/api/mcp/servers/${$}/start`,{method:"POST"}),b()}catch(A){console.error("Failed to start server:",A)}},C=async($)=>{try{await G(`/api/mcp/servers/${$}/stop`,{method:"POST"}),b()}catch(A){console.error("Failed to stop server:",A)}},m=async($)=>{if(!await y("Delete this MCP server?",{confirmText:"Delete",title:"Delete Server"}))return;try{if(await G(`/api/mcp/servers/${$}`,{method:"DELETE"}),M?.id===$)K(null);b()}catch(f){console.error("Failed to delete server:",f)}},g=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}),b()}catch(f){console.error("Failed to rename server:",f)}},V=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),b()}catch(f){throw console.error("Failed to update server:",f),f}};return z.jsxDEV(z.Fragment,{children:[I,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage Model Context Protocol servers for tool integrations."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>k("servers"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="servers"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"My Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("hosted"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="hosted"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Hosted Services"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="registry"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV(z.Fragment,{children:[W&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this),!W&&Z.length===0&&L.length===0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV(Oz,{className:"w-12 h-12 text-[#333] mx-auto mb-4"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No MCP servers configured"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"MCP servers extend your agents with tools like file access, web browsing, database connections, and more."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-3 justify-center",children:[z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Add Manually"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:"border border-[#333] hover:border-[#666] px-4 py-2 rounded font-medium transition",children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!W&&Z.length===0&&L.length>0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No servers match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!W&&Z.length>0&&z.jsxDEV("div",{className:"flex gap-6",children:[z.jsxDEV("div",{className:`space-y-3 ${M?"w-1/2":"w-full"}`,children:Z.map(($)=>{let f=$.type==="http"&&$.url||$.status==="running",p=X&&$.project_id?_.find((j)=>j.id===$.project_id):null;return z.jsxDEV(Wz,{server:$,project:p,selected:M?.id===$.id,onSelect:()=>K(f?$:null),onStart:()=>S($.id),onStop:()=>C($.id),onDelete:()=>m($.id),onEdit:()=>T($)},$.id,!1,void 0,this)})},void 0,!1,void 0,this),M&&z.jsxDEV("div",{className:"w-1/2",children:z.jsxDEV(Xz,{server:M,onClose:()=>K(null)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q==="hosted"&&z.jsxDEV(_z,{onServerAdded:b,projectId:H},void 0,!1,void 0,this),Q==="registry"&&z.jsxDEV(Zz,{onInstall:($)=>{b(),k("servers")}},void 0,!1,void 0,this),Q==="servers"&&z.jsxDEV("div",{className:"mt-8 p-4 bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("h3",{className:"font-medium mb-2",children:"Quick Start"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-3",children:"Add an MCP server by providing its npm package name. For example:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch"},{name:"memory",pkg:"@modelcontextprotocol/server-memory"}].map(($)=>z.jsxDEV("code",{className:"text-xs bg-[#0a0a0a] px-2 py-1 rounded",children:$.pkg},$.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&z.jsxDEV(Bz,{onClose:()=>F(!1),onAdded:()=>{F(!1),b()},projects:X?_:void 0,defaultProjectId:H&&H!=="unassigned"?H:null},void 0,!1,void 0,this),U&&z.jsxDEV(Uz,{server:U,projects:X?_:void 0,onClose:()=>T(null),onSaved:()=>{T(null),b()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Wz({server:G,project:_,selected:H,onSelect:L,onStart:w,onStop:W,onDelete:B,onEdit:q}){let F=G.type==="http"&&G.url,U=F||G.status==="running",T=()=>{if(F)return`${G.source||"remote"} • http`;return`${G.type} • ${G.package||G.command||"custom"}${G.status==="running"&&G.port?` • :${G.port}`:""}`},M=()=>{if(_)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${_.color}20`,color:_.color},children:_.name},void 0,!1,void 0,this);if(G.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,onClick:U?L:void 0,children:z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("div",{className:`w-2 h-2 rounded-full ${U?"bg-green-400":"bg-[#444]"}`},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666]",children:T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),q()},className:"text-sm text-[#666] hover:text-[#888] px-3 py-1 transition",title:"Edit server settings",children:"Edit"},void 0,!1,void 0,this),F?z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Remove"},void 0,!1,void 0,this):G.status==="running"?z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),L()},className:"text-sm text-[#f97316] hover:text-[#fb923c] px-3 py-1 transition",children:"Tools"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),W()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Stop"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),w()},className:"text-sm text-[#666] hover:text-green-400 px-3 py-1 transition",children:"Start"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Xz({server:G,onClose:_}){let{authFetch:H}=c(),[L,w]=J.useState([]),[W,B]=J.useState(null),[q,F]=J.useState(!0),[U,T]=J.useState(null),[M,K]=J.useState(null);return J.useEffect(()=>{(async()=>{F(!0),T(null);try{let k=await H(`/api/mcp/servers/${G.id}/tools`),y=await k.json();if(!k.ok){T(y.error||"Failed to fetch tools");return}w(y.tools||[]),B(y.serverInfo||null)}catch(k){T(`Failed to fetch tools: ${k}`)}finally{F(!1)}})()},[G.id,H]),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:[G.name," Tools"]},void 0,!0,void 0,this),W&&z.jsxDEV("p",{className:"text-xs text-[#666]",children:[W.name," v",W.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:_,className:"text-[#666] hover:text-[#888] text-xl leading-none",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 max-h-[500px] overflow-auto",children:[q&&z.jsxDEV("p",{className:"text-[#666]",children:"Loading tools..."},void 0,!1,void 0,this),U&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:U},void 0,!1,void 0,this),!q&&!U&&L.length===0&&z.jsxDEV("p",{className:"text-[#666]",children:"No tools available from this server."},void 0,!1,void 0,this),!q&&!U&&L.length>0&&!M&&z.jsxDEV("div",{className:"space-y-2",children:L.map((Q)=>z.jsxDEV("button",{onClick:()=>K(Q),className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#222] hover:border-[#333] rounded transition",children:[z.jsxDEV("div",{className:"font-medium text-sm",children:Q.name},void 0,!1,void 0,this),Q.description&&z.jsxDEV("div",{className:"text-xs text-[#666] mt-1",children:Q.description},void 0,!1,void 0,this)]},Q.name,!0,void 0,this))},void 0,!1,void 0,this),M&&z.jsxDEV(Yz,{serverId:G.id,tool:M,onBack:()=>K(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yz({serverId:G,tool:_,onBack:H}){let{authFetch:L}=c(),[w,W]=J.useState("{}"),[B,q]=J.useState(null),[F,U]=J.useState(null),[T,M]=J.useState(!1);J.useEffect(()=>{let Q=_.inputSchema;if(Q&&typeof Q==="object"&&"properties"in Q){let k=Q.properties,y={};for(let[I,X]of Object.entries(k))if(X.default!==void 0)y[I]=X.default;else if(X.type==="string")y[I]="";else if(X.type==="number"||X.type==="integer")y[I]=0;else if(X.type==="boolean")y[I]=!1;else if(X.type==="array")y[I]=[];else if(X.type==="object")y[I]={};W(JSON.stringify(y,null,2))}},[_]);let K=async()=>{M(!0),U(null),q(null);try{let Q=JSON.parse(w),k=await L(`/api/mcp/servers/${G}/tools/${encodeURIComponent(_.name)}/call`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:Q})}),y=await k.json();if(!k.ok){U(y.error||"Failed to call tool");return}q(y.result)}catch(Q){U(`Error: ${Q}`)}finally{M(!1)}};return z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888] text-sm",children:"← Back"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[#444]",children:"/"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"font-medium",children:_.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.description&&z.jsxDEV("p",{className:"text-sm text-[#666]",children:_.description},void 0,!1,void 0,this),_.inputSchema&&z.jsxDEV("div",{className:"text-xs",children:z.jsxDEV("details",{className:"cursor-pointer",children:[z.jsxDEV("summary",{className:"text-[#666] hover:text-[#888]",children:"Input Schema"},void 0,!1,void 0,this),z.jsxDEV("pre",{className:"mt-2 p-2 bg-[#0a0a0a] rounded text-[#888] overflow-auto max-h-32",children:JSON.stringify(_.inputSchema,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:w,onChange:(Q)=>W(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 h-32 font-mono text-sm focus:outline-none focus:border-[#f97316] resize-none",placeholder:"{}"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:K,disabled:T,className:"w-full bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:T?"Calling...":"Call Tool"},void 0,!1,void 0,this),F&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:F},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"space-y-2",children:[z.jsxDEV("div",{className:"text-sm text-[#666]",children:["Result ",B.isError&&z.jsxDEV("span",{className:"text-red-400",children:"(error)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:`p-3 rounded text-sm ${B.isError?"bg-red-500/10":"bg-green-500/10"}`,children:B.content.map((Q,k)=>z.jsxDEV("div",{className:"mb-2 last:mb-0",children:[Q.type==="text"&&z.jsxDEV("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:Q.text},void 0,!1,void 0,this),Q.type==="image"&&Q.data&&z.jsxDEV("img",{src:`data:${Q.mimeType||"image/png"};base64,${Q.data}`,alt:"Tool result",className:"max-w-full rounded"},void 0,!1,void 0,this)]},k,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zz({onInstall:G}){let{authFetch:_}=c(),[H,L]=J.useState(""),[w,W]=J.useState([]),[B,q]=J.useState(!1),[F,U]=J.useState(!1),[T,M]=J.useState(null),[K,Q]=J.useState(null),k=async(X)=>{q(!0),Q(null);try{let b=await _(`/api/mcp/registry?search=${encodeURIComponent(X)}&limit=20`),Z=await b.json();if(!b.ok)Q(Z.error||"Failed to search registry"),W([]);else W(Z.servers||[])}catch(b){Q(`Failed to search: ${b}`),W([])}finally{q(!1),U(!0)}},y=(X)=>{if(X.preventDefault(),H.trim())k(H.trim())};J.useEffect(()=>{k("")},[]);let I=async(X)=>{if(!X.npmPackage){Q("This server does not have an npm package");return}M(X.id),Q(null);try{let b=await _("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,type:"npm",package:X.npmPackage})});if(!b.ok){let Z=await b.json();Q(Z.error||"Failed to add server");return}G(X)}catch(b){Q(`Failed to add server: ${b}`)}finally{M(null)}};return z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:y,className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:H,onChange:(X)=>L(X.target.value),placeholder:"Search MCP servers (e.g., filesystem, github, slack...)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:B,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:B?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:K},void 0,!1,void 0,this),!B&&F&&w.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No servers found. Try a different search term."},void 0,!1,void 0,this),w.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:w.map((X)=>z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 hover:border-[#333] transition",children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:X.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:X.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[X.version&&z.jsxDEV("span",{children:["v",X.version]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded ${X.npmPackage?"bg-green-500/10 text-green-400":"bg-blue-500/10 text-blue-400"}`,children:X.npmPackage?"npm":"remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("code",{className:"text-xs text-[#555] bg-[#0a0a0a] px-2 py-0.5 rounded mt-2 inline-block truncate max-w-full",children:X.npmPackage||X.fullName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:X.npmPackage?z.jsxDEV("button",{onClick:()=>I(X),disabled:T===X.id,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:T===X.id?"Adding...":"Add"},void 0,!1,void 0,this):X.repository?z.jsxDEV("a",{href:X.repository,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#666] hover:text-[#f97316] transition",children:"View →"},void 0,!1,void 0,this):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this))},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Searching registry..."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Servers are sourced from the"," ",z.jsxDEV("a",{href:"https://github.com/modelcontextprotocol/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline",children:"official MCP registry"},void 0,!1,void 0,this),". Not all servers have npm packages - some require manual setup."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _z({onServerAdded:G,projectId:_}){let{authFetch:H}=c(),[L,w]=J.useState("composio"),[W,B]=J.useState("configs"),[q,F]=J.useState(!1),[U,T]=J.useState(!1),[M,K]=J.useState(!1),[Q,k]=J.useState([]),[y,I]=J.useState(new Set),[X,b]=J.useState(!0),[Z,S]=J.useState(!1),[C,m]=J.useState(null),{alert:g,AlertDialog:V}=o(),$=async()=>{try{let P=_&&_!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(_)}`:"/api/mcp/servers",[i,Y]=await Promise.all([H("/api/providers"),H(P)]),R=await i.json(),u=await Y.json(),D=R.providers||[],O=u.servers||[],N=new Set(O.filter((E)=>E.source==="composio"&&E.url).map((E)=>{let e=E.url.match(/\/v3\/mcp\/([^/]+)/);return e?e[1]:null}).filter(Boolean));I(N);let h=D.find((E)=>E.id==="composio"),l=D.find((E)=>E.id==="smithery"),n=D.find((E)=>E.id==="agentdojo"),d=h?.hasKey||!1,v=l?.hasKey||!1,s=n?.hasKey||!1;if(F(d),T(v),K(s),d)w("composio"),A();else if(v)w("smithery");else if(s)w("agentdojo")}catch(P){console.error("Failed to fetch providers:",P)}b(!1)},A=async()=>{S(!0);try{let P=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await(await H(`/api/integrations/composio/configs${P}`)).json();k(Y.configs||[])}catch(P){console.error("Failed to fetch Composio configs:",P)}S(!1)},f=async(P)=>{m(P);try{let i=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await H(`/api/integrations/composio/configs/${P}/add${i}`,{method:"POST"});if(Y.ok)I((R)=>new Set([...R,P])),G?.();else{let R=await Y.json();await g(R.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(i){console.error("Failed to add config:",i)}m(null)},p=(P)=>{return y.has(P)};if(J.useEffect(()=>{$()},[H,_]),X)return z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let j=q||U||M,x=[q,U,M].filter(Boolean).length;if(!j)return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#888] mb-2",children:"No hosted MCP services connected"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect Composio, Smithery, or AgentDojo in Settings to access cloud-based MCP servers."},void 0,!1,void 0,this),z.jsxDEV("a",{href:"/settings",className:"inline-block bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded text-sm font-medium transition",children:"Go to Settings →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return z.jsxDEV(z.Fragment,{children:[V,z.jsxDEV("div",{className:"space-y-6",children:[x>1&&z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1 w-fit",children:[q&&z.jsxDEV("button",{onClick:()=>{w("composio"),B("configs")},className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="composio"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio"]},void 0,!0,void 0,this),U&&z.jsxDEV("button",{onClick:()=>w("smithery"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="smithery"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery"]},void 0,!0,void 0,this),M&&z.jsxDEV("button",{onClick:()=>w("agentdojo"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="agentdojo"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&(x===1||L==="composio")&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>B("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Configs"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("connect"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="connect"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Connect Apps"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666]",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="connect"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect your accounts to enable tools in MCP configs"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"composio",projectId:_,onConnectionComplete:()=>{A()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP configs from Composio"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("button",{onClick:A,disabled:Z,className:"text-xs text-[#666] hover:text-[#888] transition",children:Z?"Loading...":"Refresh"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Create Config →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading configs..."},void 0,!1,void 0,this):Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP configs found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:["First ",z.jsxDEV("button",{onClick:()=>B("connect"),className:"text-[#f97316] hover:text-[#fb923c]",children:"connect some apps"},void 0,!1,void 0,this),", then create a config."]},void 0,!0,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#f97316] hover:text-[#fb923c] mt-2 inline-block",children:"Create in Composio →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:Q.map((P)=>{let i=p(P.id),Y=C===P.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${i?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:P.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[P.toolsCount," tools"]},void 0,!0,void 0,this),i&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.toolkits.length>0&&z.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:[P.toolkits.slice(0,4).map((R)=>z.jsxDEV("span",{className:"text-xs bg-[#1a1a1a] text-[#666] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this)),P.toolkits.length>4&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:["+",P.toolkits.length-4]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:[i?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>f(P.id),disabled:Y,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:Y?"Adding...":"Add"},void 0,!1,void 0,this),z.jsxDEV("a",{href:`https://app.composio.dev/mcp_configs/${P.id}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#888] transition",children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U&&(x===1||L==="smithery")&&z.jsxDEV("div",{children:[x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Add MCP servers from the Smithery registry"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://smithery.ai/servers",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Browse Smithery →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:["Smithery servers can be added from the ",z.jsxDEV("strong",{children:"Browse Registry"},void 0,!1,void 0,this)," tab."]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:"Your API key will be used automatically when adding Smithery servers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&(x===1||L==="agentdojo")&&z.jsxDEV($z,{projectId:_,onServerAdded:G,showProviderBadge:x===1},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded text-xs text-[#666]",children:[z.jsxDEV("strong",{className:"text-[#888]",children:"Tip:"},void 0,!1,void 0,this)," Connect apps first, then add MCP configs to make tools available to your agents."," · ",z.jsxDEV("a",{href:"/settings",className:"text-[#f97316] hover:text-[#fb923c]",children:"Add more providers in Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $z({projectId:G,onServerAdded:_,showProviderBadge:H}){let{authFetch:L}=c(),[w,W]=J.useState("configs"),[B,q]=J.useState([]),[F,U]=J.useState(new Set),[T,M]=J.useState(!1),[K,Q]=J.useState(null),{alert:k,AlertDialog:y}=o(),I=async()=>{M(!0);try{let Z=G&&G!=="unassigned"?`?project_id=${G}`:"",S=G&&G!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(G)}`:"/api/mcp/servers",[C,m]=await Promise.all([L(`/api/integrations/agentdojo/configs${Z}`),L(S)]),g=await C.json(),V=await m.json();q(g.configs||[]);let $=new Set((V.servers||[]).filter((A)=>A.source==="agentdojo").map((A)=>{let f=A.url?.match(/\/mcp\/([^/?]+)/);return f?f[1]:A.name}));U($)}catch(Z){console.error("Failed to fetch AgentDojo configs:",Z)}M(!1)},X=async(Z)=>{Q(Z);try{let S=G&&G!=="unassigned"?`?project_id=${G}`:"",C=await L(`/api/integrations/agentdojo/configs/${Z}/add${S}`,{method:"POST"});if(C.ok){let m=B.find((g)=>g.id===Z);U((g)=>new Set([...g,m?.slug||Z])),_?.()}else{let m=await C.json();await k(m.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(S){console.error("Failed to add config:",S)}Q(null)},b=(Z)=>{return F.has(Z.slug)||F.has(Z.id)||F.has(Z.name)};return J.useEffect(()=>{I()},[L,G]),z.jsxDEV(z.Fragment,{children:[y,z.jsxDEV("div",{children:[H&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>W("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>W("toolkits"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="toolkits"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Toolkits"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP servers from AgentDojo"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:I,disabled:T,className:"text-xs text-[#666] hover:text-[#888] transition",children:T?"Loading...":"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading servers..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP servers found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:[z.jsxDEV("button",{onClick:()=>W("toolkits"),className:"text-[#f97316] hover:text-[#fb923c]",children:"Browse toolkits"},void 0,!1,void 0,this)," ","to create a new MCP server."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:B.map((Z)=>{let S=b(Z),C=K===Z.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${S?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:Z.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[Z.toolsCount," tools"]},void 0,!0,void 0,this),S&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.mcpUrl&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.mcpUrl},void 0,!1,void 0,this),!Z.mcpUrl&&Z.slug&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:S?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>X(Z.id),disabled:C,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:C?"Adding...":"Add"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},Z.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w==="toolkits"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Browse available toolkits and create MCP servers"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"agentdojo",projectId:G,onConnectionComplete:()=>{I()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz(G){let _=[],H=G,L=null,w=G.match(/(?:npx\s+-y\s+)?(@?[\w-]+\/)?(@?[\w-]+)(?:@[\w.-]+)?/);if(w){let q=w[2]||w[1];if(q)L=q.replace(/^@/,"").replace(/-mcp$/,"").replace(/-server$/,"").replace(/^server-/,"").replace(/^mcp-/,"")}let W=/--(\w+[-\w]*)\s+(YOUR_\w+|<[\w_]+>|\{[\w_]+\}|\$[\w_]+|[\w_]*(?:TOKEN|KEY|SECRET|PASSWORD|USER|ID|APIKEY)[\w_]*)/gi,B;while((B=W.exec(G))!==null){let q=B[1],F=B[2],U=q.toUpperCase().replace(/-/g,"_"),T=L?`${L.toUpperCase().replace(/-/g,"_")}_${U}`:U;_.push({key:T,flag:q}),H=H.replace(new RegExp(`(--${q}\\s+)${F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i"),`--${q} $${T}`)}return{cleanCommand:H,credentials:_,serverName:L}}function Bz({onClose:G,onAdded:_,projects:H,defaultProjectId:L}){let{authFetch:w}=c(),[W,B]=J.useState("npm"),[q,F]=J.useState(""),[U,T]=J.useState(""),[M,K]=J.useState(""),[Q,k]=J.useState(""),[y,I]=J.useState(""),[X,b]=J.useState(""),[Z,S]=J.useState(""),[C,m]=J.useState([]),[g,V]=J.useState(L||null),[$,A]=J.useState(!1),[f,p]=J.useState(null),j=H&&H.length>0,x=()=>{m([...C,{key:"",value:""}])},P=(O,N,h)=>{let l=[...C];l[O][N]=h,m(l)},i=(O)=>{m(C.filter((N,h)=>h!==O))},Y=(O)=>{if(k(O),O.includes("YOUR_")||O.includes("<")||O.includes("{")||/TOKEN|KEY|SECRET|PASSWORD/i.test(O)){let{cleanCommand:N,credentials:h,serverName:l}=qz(O);if(!q&&l)F(l);if(h.length>0){let n=new Set(C.map((v)=>v.key)),d=h.filter((v)=>!n.has(v.key)).map((v)=>({key:v.key,value:""}));if(d.length>0)m([...C,...d]),k(N)}}},R=(O)=>{if(O.startsWith("npx ")||O.includes(" --")||O.includes("YOUR_")||O.includes("<")||/\s+(TOKEN|KEY|SECRET|PASSWORD)/i.test(O))B("command"),Y(O);else if(T(O),!q&&O){let h=O.replace(/^@[\w-]+\//,"").replace(/@[\w.-]+$/,"").replace(/^server-/,"").replace(/-server$/,"").replace(/^mcp-/,"").replace(/-mcp$/,"");if(h&&h!==O)F(h)}},u=async()=>{if(!q){p("Name is required");return}if(W==="npm"&&!U){p("npm package is required");return}if(W==="pip"&&!U){p("pip package is required");return}if(W==="command"&&!Q){p("Command is required");return}if(W==="http"&&!y){p("URL is required");return}A(!0),p(null);let O={};for(let{key:N,value:h}of C)if(N.trim())O[N.trim()]=h;try{let N={name:q};if(W==="npm")N.type="npm",N.package=U;else if(W==="pip"){if(N.type="pip",N.package=U,M)N.pip_module=M}else if(W==="http"){N.type="http",N.url=y;let l={"Content-Type":"application/json"};if(X&&Z){let n=btoa(`${X}:${Z}`);l.Authorization=`Basic ${n}`}N.headers=l}else{let l=Q.trim().split(/\s+/);N.type="custom",N.command=l[0],N.args=l.slice(1).join(" ")}if(Object.keys(O).length>0)N.env=O;if(g)N.project_id=g;let h=await w("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!h.ok){let l=await h.json();p(l.error||"Failed to add server"),A(!1);return}_()}catch(N){p("Failed to add server"),A(!1)}},D=(O,N)=>{B("npm"),F(O),T(N)};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Add MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:G,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-2",children:"Quick add:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem",type:"npm"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch",type:"npm"},{name:"memory",pkg:"@modelcontextprotocol/server-memory",type:"npm"},{name:"github",pkg:"@modelcontextprotocol/server-github",type:"npm"},{name:"time",pkg:"mcp-server-time",module:"mcp_server_time",type:"pip"}].map((O)=>z.jsxDEV("button",{onClick:()=>{if(B(O.type),F(O.name),T(O.pkg),O.type==="pip"&&"module"in O)K(O.module||"");else K("")},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] px-3 py-1 rounded transition",children:O.name},O.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded p-1",children:[z.jsxDEV("button",{onClick:()=>B("npm"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="npm"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"npm"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("pip"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="pip"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"pip"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("command"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="command"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Command"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("http"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="http"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"HTTP"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(O)=>F(O.target.value),placeholder:"e.g., pushover",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:g||"",onChange:(O)=>V(O||null),options:[{value:"",label:"Global (all projects)"},...H.map((O)=>({value:O.id,label:O.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global servers are available to all agents. Project-scoped servers are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>R(O.target.value),placeholder:"e.g., @modelcontextprotocol/server-filesystem or paste full command",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Package name or paste a full npx command with credentials"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="pip"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>{if(T(O.target.value),!M&&O.target.value){let N=O.target.value.split("[")[0].replace(/-/g,".");K(N)}},placeholder:"e.g., late-sdk[mcp]",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python package with extras, e.g., late-sdk[mcp] or mcp-server-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Module (optional)"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(O)=>K(O.target.value),placeholder:"e.g., late.mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python module to run with -m. Auto-detected from package name if not specified."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="command"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(O)=>Y(O.target.value),placeholder:"e.g., npx -y pushover-mcp@latest start --token YOUR_TOKEN",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Paste the full command - credentials like YOUR_TOKEN will be auto-extracted"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="http"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(O)=>I(O.target.value),placeholder:"e.g., https://example.com/wp-json/mcp/v1/messages",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded",children:[z.jsxDEV("p",{className:"text-xs text-[#666] mb-3",children:"Optional: Basic Auth credentials (will be encoded and stored securely)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Username"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(O)=>b(O.target.value),placeholder:"username",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Password"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Z,onChange:(O)=>S(O.target.value),placeholder:"password or app key",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:x,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"Add environment variables for API tokens and credentials. These are stored encrypted and passed to the server at startup."},void 0,!1,void 0,this),C.length>0&&z.jsxDEV("div",{className:"space-y-2",children:C.map((O,N)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:O.key,onChange:(h)=>P(N,"key",h.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:O.value,onChange:(h)=>P(N,"value",h.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>i(N),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},N,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:G,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:u,disabled:$||!q||(W==="npm"?!U:W==="pip"?!U:W==="http"?!y:!Q),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:$?"Adding...":"Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Uz({server:G,projects:_,onClose:H,onSaved:L}){let{authFetch:w}=c(),[W,B]=J.useState(G.name),[q,F]=J.useState(G.package||""),[U,T]=J.useState(G.command||""),[M,K]=J.useState(G.args||""),[Q,k]=J.useState(G.url||""),[y,I]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":")[0]||""}catch{return""}return""}),[X,b]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":").slice(1).join(":")||""}catch{return""}return""}),[Z,S]=J.useState(()=>{return Object.entries(G.env||{}).map(([Y,R])=>({key:Y,value:R}))}),[C,m]=J.useState(G.project_id),[g,V]=J.useState(!1),[$,A]=J.useState(null),f=_&&_.length>0,p=G.type==="http",j=()=>{S([...Z,{key:"",value:""}])},x=(Y,R,u)=>{let D=[...Z];D[Y][R]=u,S(D)},P=(Y)=>{S(Z.filter((R,u)=>u!==Y))},i=async()=>{if(!W.trim()){A("Name is required");return}V(!0),A(null);let Y={};for(let{key:R,value:u}of Z)if(R.trim())Y[R.trim()]=u;try{let R={name:W.trim(),env:Y};if(p){if(Q.trim())R.url=Q.trim();let D={"Content-Type":"application/json"};if(y&&X){let O=btoa(`${y}:${X}`);D.Authorization=`Basic ${O}`}R.headers=D}else{if(G.type==="npm"&&q.trim())R.package=q.trim();if(G.type==="pip"&&q.trim())R.package=q.trim();if(G.type==="custom"){if(U.trim())R.command=U.trim();if(M.trim())R.args=M.trim()}}R.project_id=C;let u=await w(`/api/mcp/servers/${G.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!u.ok){let D=await u.json();A(D.error||"Failed to save changes"),V(!1);return}if(G.status==="running"&&!p)try{await w(`/api/mcp/servers/${G.id}/stop`,{method:"POST"}),await w(`/api/mcp/servers/${G.id}/start`,{method:"POST"})}catch(D){console.error("Failed to restart server:",D)}L()}catch(R){A("Failed to save changes"),V(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Edit MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{className:"text-sm text-[#666] bg-[#0a0a0a] border border-[#222] rounded p-3",children:["Type: ",z.jsxDEV("span",{className:"text-[#888]",children:G.type},void 0,!1,void 0,this),G.package&&z.jsxDEV(z.Fragment,{children:[" • Package: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.package},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.command&&z.jsxDEV(z.Fragment,{children:[" • Command: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.command},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:W,onChange:(Y)=>B(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:C||"",onChange:(Y)=>m(Y||null),options:[{value:"",label:"Global (all projects)"},..._.map((Y)=>({value:Y.id,label:Y.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="pip"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Server URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(Y)=>k(Y.target.value),placeholder:"https://example.com/mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Authentication (Basic Auth)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:y,onChange:(Y)=>I(Y.target.value),placeholder:"Username",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:X,onChange:(Y)=>b(Y.target.value),placeholder:"Password / App Password",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty if no authentication required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.type==="custom"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(Y)=>T(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(Y)=>K(Y.target.value),placeholder:"e.g., --token $TOKEN --verbose",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!p&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:j,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"No environment variables configured."},void 0,!1,void 0,this),Z.length>0&&z.jsxDEV("div",{className:"space-y-2",children:Z.map((Y,R)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:Y.key,onChange:(u)=>x(R,"key",u.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Y.value,onChange:(u)=>x(R,"value",u.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>P(R),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},R,!0,void 0,this))},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:G.status==="running"?"Server will be automatically restarted to apply changes.":"Changes will take effect when the server is started."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:H,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:i,disabled:g||!W.trim(),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:g?"Saving...":"Save Changes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
2
2
|
export{Mz as h};
|
|
3
3
|
|
|
4
4
|
//# debugId=5835E74D4CBA249B64756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Q as L,T as P,U as N}from"./App.
|
|
1
|
+
import{Q as L,T as P,U as N}from"./App.q3bpx15d.js";var z=L(P(),1),w=L(N(),1);function U({children:q,onClose:y}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] rounded p-6 w-full max-w-xl lg:max-w-2xl border border-[#1a1a1a] max-h-[90vh] overflow-y-auto",children:q},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Q({title:q,message:y,confirmText:F="Confirm",cancelText:B="Cancel",confirmVariant:G="danger",onConfirm:I,onCancel:J}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm",children:[q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[#ccc] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("button",{onClick:J,className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:B},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:I,className:`flex-1 text-sm text-white px-4 py-2 rounded transition ${G==="danger"?"bg-red-500 hover:bg-red-600":"bg-[#f97316] hover:bg-[#ea580c]"}`,children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function R({title:q,message:y,buttonText:F="OK",variant:B="info",onClose:G}){let I={error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",info:"bg-blue-500/20 text-blue-400"},J={error:"✕",success:"✓",info:"ℹ"};return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm text-center",children:[w.jsxDEV("div",{className:`w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3 ${I[B]}`,children:w.jsxDEV("span",{className:"text-xl",children:J[B]},void 0,!1,void 0,this)},void 0,!1,void 0,this),q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[#ccc] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:G,className:"w-full text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function W(){let[q,y]=z.useState(null),F=z.useCallback((J,K={})=>{return new Promise((O)=>{y({message:J,options:K,resolve:O})})},[]),B=z.useCallback(()=>{q?.resolve(!0),y(null)},[q]),G=z.useCallback(()=>{q?.resolve(!1),y(null)},[q]),I=q?w.jsxDEV(Q,{title:q.options.title,message:q.message,confirmText:q.options.confirmText,cancelText:q.options.cancelText,confirmVariant:q.options.confirmVariant,onConfirm:B,onCancel:G},void 0,!1,void 0,this):null;return{confirm:F,ConfirmDialog:I}}function X(){let[q,y]=z.useState(null),F=z.useCallback((I,J={})=>{return new Promise((K)=>{y({message:I,options:J,resolve:K})})},[]),B=z.useCallback(()=>{q?.resolve(),y(null)},[q]),G=q?w.jsxDEV(R,{title:q.options.title,message:q.message,buttonText:q.options.buttonText,variant:q.options.variant,onClose:B},void 0,!1,void 0,this):null;return{alert:F,AlertDialog:G}}
|
|
2
2
|
export{U as L,W as M,X as N};
|
|
3
3
|
|
|
4
4
|
//# debugId=09CA02639775F39364756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{F as S,G as f,H as h,k as g,p as T}from"./App.sdsc0258.js";import{Q as M,T as u,U as I,X as C,aa as b,da as v}from"./App.g8vq68n0.js";var Y=M(u(),1);var q=M(I(),1);function j({onSelectAgent:z}){let{authFetch:Q}=b(),{currentProjectId:Z}=v(),[X,$]=Y.useState([]),[P,J]=Y.useState(!0),[U,G]=Y.useState("all"),[H,K]=Y.useState(null),[_,F]=Y.useState(!1),W=Y.useRef(null),{events:w}=C({category:"TASK"}),A=Y.useCallback(async()=>{try{let B=`/api/tasks?status=${U}`;if(Z!==null)B+=`&project_id=${encodeURIComponent(Z)}`;let R=await(await Q(B)).json();$(R.tasks||[])}catch(B){console.error("Failed to fetch tasks:",B)}finally{J(!1)}},[Q,U,Z]);Y.useEffect(()=>{A()},[A]),Y.useEffect(()=>{if(!w.length)return;let B=w[0];if(!B||B.id===W.current)return;let N=B.type;if(N==="task_created"||N==="task_updated"||N==="task_deleted")W.current=B.id,console.log("[TasksPage] Telemetry event:",N),A()},[w,A]);let p=Y.useCallback(async(B)=>{K(B),F(!0);try{let N=await Q(`/api/tasks/${B.agentId}/${B.id}`);if(console.log("[TasksPage] Fetch task response status:",N.status),N.ok){let R=await N.json();if(console.log("[TasksPage] Task data:",R),console.log("[TasksPage] Has trajectory:",!!R.task?.trajectory,"Length:",R.task?.trajectory?.length),R.task)K({...R.task,agentId:B.agentId,agentName:B.agentName})}else console.error("[TasksPage] Failed to fetch task:",N.status,await N.text())}catch(N){console.error("Failed to fetch task details:",N)}finally{F(!1)}},[Q]),O={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};return q.jsxDEV("div",{className:"flex-1 flex overflow-hidden",children:[q.jsxDEV("div",{className:`flex-1 p-4 md:p-6 overflow-auto ${H?"hidden md:block md:w-1/2 lg:w-2/3":""}`,children:q.jsxDEV("div",{className:"max-w-4xl",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("h1",{className:"text-xl md:text-2xl font-semibold mb-1",children:"Tasks"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"View tasks from all running agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1",children:[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map((B)=>q.jsxDEV("button",{onClick:()=>G(B.value),className:`px-3 py-1.5 rounded text-sm transition whitespace-nowrap ${U===B.value?"bg-[#f97316] text-black":"bg-[#1a1a1a] hover:bg-[#222]"}`,children:B.label},B.value,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading tasks..."},void 0,!1,void 0,this):X.length===0?q.jsxDEV("div",{className:"text-center py-12",children:[q.jsxDEV(T,{className:"w-12 h-12 mx-auto mb-4 text-[#333]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"No tasks found"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#444] mt-1",children:"Tasks will appear here when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:X.map((B)=>q.jsxDEV("div",{onClick:()=>p(B),className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?.id===B.id&&H?.agentId===B.agentId?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[q.jsxDEV("div",{className:"flex-1",children:[q.jsxDEV("h3",{className:"font-medium",children:B.title},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:B.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${O[B.status]||O.pending}`,children:B.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B.description&&q.jsxDEV("p",{className:"text-sm text-[#888] mb-2 line-clamp-2",children:B.description},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[#555]",children:[q.jsxDEV("span",{className:"flex items-center gap-1",children:[B.type==="recurring"?q.jsxDEV(S,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):B.execute_at?q.jsxDEV(f,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):q.jsxDEV(h,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),B.type==="recurring"&&B.recurrence?m(B.recurrence):B.type]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Priority: ",B.priority]},void 0,!0,void 0,this),B.next_run&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.next_run)},void 0,!1,void 0,this),!B.next_run&&B.execute_at&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.execute_at)},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Created: ",new Date(B.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${B.agentId}-${B.id}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),H&&q.jsxDEV(l,{task:H,statusColors:O,onClose:()=>K(null),onSelectAgent:z,loading:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function l({task:z,statusColors:Q,onClose:Z,onSelectAgent:X,loading:$}){return q.jsxDEV("div",{className:"w-full md:w-1/2 lg:w-1/3 border-l border-[#1a1a1a] bg-[#0a0a0a] flex flex-col overflow-hidden",children:[q.jsxDEV("div",{className:"flex items-center justify-between p-4 border-b border-[#1a1a1a]",children:[q.jsxDEV("h2",{className:"font-medium truncate pr-2",children:"Task Details"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:Z,className:"text-[#666] hover:text-[#e0e0e0] transition",children:q.jsxDEV(g,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("h3",{className:"text-lg font-medium",children:z.title},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${Q[z.status]}`,children:z.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>X?.(z.agentId),className:"text-sm text-[#f97316] hover:underline",children:z.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.description&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] whitespace-pre-wrap",children:z.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Type"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Priority"},void 0,!1,void 0,this),q.jsxDEV("p",{children:z.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Source"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.source},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.recurrence&&q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Recurrence"},void 0,!1,void 0,this),q.jsxDEV("p",{children:m(z.recurrence)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#444] mt-0.5 font-mono",children:z.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Created"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.execute_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Scheduled"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.executed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Started"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.completed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Completed"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.next_run&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Next Run"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.status==="failed"&&z.error&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:z.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.status==="completed"&&z.result&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof z.result==="string"?z.result:JSON.stringify(z.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&!z.trajectory&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#555]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.trajectory&&z.trajectory.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:["Trajectory (",z.trajectory.length," steps)"]},void 0,!0,void 0,this),q.jsxDEV(c,{trajectory:z.trajectory},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function c({trajectory:z}){let[Q,Z]=Y.useState(new Set),X=(J)=>{Z((U)=>{let G=new Set(U);if(G.has(J))G.delete(J);else G.add(J);return G})},$={user:{bg:"bg-blue-500/10",text:"text-blue-400",icon:"\uD83D\uDC64",label:"User"},assistant:{bg:"bg-purple-500/10",text:"text-purple-400",icon:"\uD83E\uDD16",label:"Assistant"}},P=(J)=>{let U=J.content;if(typeof U==="string"){let G=U.length>200,H=Q.has(J.id);return q.jsxDEV("div",{children:[q.jsxDEV("p",{className:`text-sm text-[#ccc] whitespace-pre-wrap break-words ${!H&&G?"line-clamp-4":""}`,children:U},void 0,!1,void 0,this),G&&q.jsxDEV("button",{onClick:()=>X(J.id),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:H?"Show less":"Show more..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return q.jsxDEV("div",{className:"space-y-2",children:U.map((G,H)=>{if(G.type==="tool_use"){let K=JSON.stringify(G.input,null,2),_=K.length>150,F=`${J.id}-${H}`,W=Q.has(F);return q.jsxDEV("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded p-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{className:"text-orange-400",children:"\uD83D\uDD27"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs font-medium text-orange-400",children:"Tool Call"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#888]",children:G.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto ${!W&&_?"line-clamp-3":""}`,children:K},void 0,!1,void 0,this),_&&q.jsxDEV("button",{onClick:()=>X(F),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:W?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}if(G.type==="tool_result"){let K=G.is_error,_=`${J.id}-${H}`,F=Q.has(_),W=G.content.length>150;return q.jsxDEV("div",{className:`${K?"bg-red-500/10 border-red-500/20":"bg-teal-500/10 border-teal-500/20"} border rounded p-2`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{children:K?"❌":"\uD83D\uDCCB"},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${K?"text-red-400":"text-teal-400"}`,children:"Tool Result"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto whitespace-pre-wrap break-words ${!F&&W?"line-clamp-3":""}`,children:G.content},void 0,!1,void 0,this),W&&q.jsxDEV("button",{onClick:()=>X(_),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:F?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}return null})},void 0,!1,void 0,this)};return q.jsxDEV("div",{className:"space-y-2",children:z.map((J)=>{let U=$[J.role]||$.assistant;return q.jsxDEV("div",{className:`${U.bg} border border-[#1a1a1a] rounded overflow-hidden p-3`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[q.jsxDEV("span",{children:U.icon},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${U.text}`,children:U.label},void 0,!1,void 0,this),J.model&&q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",J.model]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",new Date(J.created_at).toLocaleTimeString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),P(J)]},J.id,!0,void 0,this)})},void 0,!1,void 0,this)}var y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function m(z){try{let Q=z.trim().split(/\s+/);if(Q.length!==5)return z;let[Z,X,$,P,J]=Q;if(Z.startsWith("*/")&&X==="*"&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(Z.slice(2));if(G===1)return"Every minute";return`Every ${G} minutes`}if(Z!=="*"&&!Z.includes("/")&&X==="*"&&$==="*"&&P==="*"&&J==="*")return"Every hour";if(X.startsWith("*/")&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(X.slice(2));if(G===1)return"Every hour";return`Every ${G} hours`}let U=(G,H)=>{let K=parseInt(G),_=parseInt(H);if(isNaN(K))return"";let F=K>=12?"PM":"AM";return`${K===0?12:K>12?K-12:K}:${_.toString().padStart(2,"0")} ${F}`};if(X!=="*"&&!X.includes("/")&&$==="*"&&P==="*"){let G=U(X,Z);if(J==="*")return`Daily at ${G}`;let H=J.split(",").map((K)=>{let _=parseInt(K.trim());return y[_]||K});if(H.length===7)return`Daily at ${G}`;if(H.length===5&&!H.includes("Sat")&&!H.includes("Sun"))return`Weekdays at ${G}`;if(H.length===1)return`Weekly on ${H[0]} at ${G}`;return`${H.join(" & ")} at ${G}`}return z}catch{return z}}function L(z){let Q=new Date(z),Z=new Date,X=Q.getTime()-Z.getTime(),$=Math.abs(X),P=X>0,J=Math.floor($/60000),U=Math.floor($/3600000),G=Math.floor($/86400000),H=Q.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),K=Q.toDateString()===Z.toDateString(),_=new Date(Z);_.setDate(_.getDate()+1);let F=Q.toDateString()===_.toDateString(),W=new Date(Z);W.setDate(W.getDate()-1);let w=Q.toDateString()===W.toDateString();if(K){if(J<1)return P?"now":"just now";if(J<60)return P?`in ${J} min (${H})`:`${J} min ago`;return P?`in ${U}h (${H})`:`${U}h ago`}if(F)return`Tomorrow at ${H}`;if(w)return`Yesterday at ${H}`;if(G<7)return`${y[Q.getDay()]} at ${H}`;return Q.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${H}`}
|
|
1
|
+
import{F as S,G as f,H as h,k as g,p as T}from"./App.c90t3dxg.js";import{Q as M,T as u,U as I,X as C,aa as b,da as v}from"./App.q3bpx15d.js";var Y=M(u(),1);var q=M(I(),1);function j({onSelectAgent:z}){let{authFetch:Q}=b(),{currentProjectId:Z}=v(),[X,$]=Y.useState([]),[P,J]=Y.useState(!0),[U,G]=Y.useState("all"),[H,K]=Y.useState(null),[_,F]=Y.useState(!1),W=Y.useRef(null),{events:w}=C({category:"TASK"}),A=Y.useCallback(async()=>{try{let B=`/api/tasks?status=${U}`;if(Z!==null)B+=`&project_id=${encodeURIComponent(Z)}`;let R=await(await Q(B)).json();$(R.tasks||[])}catch(B){console.error("Failed to fetch tasks:",B)}finally{J(!1)}},[Q,U,Z]);Y.useEffect(()=>{A()},[A]),Y.useEffect(()=>{if(!w.length)return;let B=w[0];if(!B||B.id===W.current)return;let N=B.type;if(N==="task_created"||N==="task_updated"||N==="task_deleted")W.current=B.id,console.log("[TasksPage] Telemetry event:",N),A()},[w,A]);let p=Y.useCallback(async(B)=>{K(B),F(!0);try{let N=await Q(`/api/tasks/${B.agentId}/${B.id}`);if(console.log("[TasksPage] Fetch task response status:",N.status),N.ok){let R=await N.json();if(console.log("[TasksPage] Task data:",R),console.log("[TasksPage] Has trajectory:",!!R.task?.trajectory,"Length:",R.task?.trajectory?.length),R.task)K({...R.task,agentId:B.agentId,agentName:B.agentName})}else console.error("[TasksPage] Failed to fetch task:",N.status,await N.text())}catch(N){console.error("Failed to fetch task details:",N)}finally{F(!1)}},[Q]),O={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};return q.jsxDEV("div",{className:"flex-1 flex overflow-hidden",children:[q.jsxDEV("div",{className:`flex-1 p-4 md:p-6 overflow-auto ${H?"hidden md:block md:w-1/2 lg:w-2/3":""}`,children:q.jsxDEV("div",{className:"max-w-4xl",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("h1",{className:"text-xl md:text-2xl font-semibold mb-1",children:"Tasks"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"View tasks from all running agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1",children:[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map((B)=>q.jsxDEV("button",{onClick:()=>G(B.value),className:`px-3 py-1.5 rounded text-sm transition whitespace-nowrap ${U===B.value?"bg-[#f97316] text-black":"bg-[#1a1a1a] hover:bg-[#222]"}`,children:B.label},B.value,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading tasks..."},void 0,!1,void 0,this):X.length===0?q.jsxDEV("div",{className:"text-center py-12",children:[q.jsxDEV(T,{className:"w-12 h-12 mx-auto mb-4 text-[#333]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"No tasks found"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#444] mt-1",children:"Tasks will appear here when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:X.map((B)=>q.jsxDEV("div",{onClick:()=>p(B),className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?.id===B.id&&H?.agentId===B.agentId?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[q.jsxDEV("div",{className:"flex-1",children:[q.jsxDEV("h3",{className:"font-medium",children:B.title},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:B.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${O[B.status]||O.pending}`,children:B.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B.description&&q.jsxDEV("p",{className:"text-sm text-[#888] mb-2 line-clamp-2",children:B.description},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[#555]",children:[q.jsxDEV("span",{className:"flex items-center gap-1",children:[B.type==="recurring"?q.jsxDEV(S,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):B.execute_at?q.jsxDEV(f,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):q.jsxDEV(h,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),B.type==="recurring"&&B.recurrence?m(B.recurrence):B.type]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Priority: ",B.priority]},void 0,!0,void 0,this),B.next_run&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.next_run)},void 0,!1,void 0,this),!B.next_run&&B.execute_at&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.execute_at)},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Created: ",new Date(B.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${B.agentId}-${B.id}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),H&&q.jsxDEV(l,{task:H,statusColors:O,onClose:()=>K(null),onSelectAgent:z,loading:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function l({task:z,statusColors:Q,onClose:Z,onSelectAgent:X,loading:$}){return q.jsxDEV("div",{className:"w-full md:w-1/2 lg:w-1/3 border-l border-[#1a1a1a] bg-[#0a0a0a] flex flex-col overflow-hidden",children:[q.jsxDEV("div",{className:"flex items-center justify-between p-4 border-b border-[#1a1a1a]",children:[q.jsxDEV("h2",{className:"font-medium truncate pr-2",children:"Task Details"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:Z,className:"text-[#666] hover:text-[#e0e0e0] transition",children:q.jsxDEV(g,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("h3",{className:"text-lg font-medium",children:z.title},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${Q[z.status]}`,children:z.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>X?.(z.agentId),className:"text-sm text-[#f97316] hover:underline",children:z.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.description&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] whitespace-pre-wrap",children:z.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Type"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Priority"},void 0,!1,void 0,this),q.jsxDEV("p",{children:z.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Source"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.source},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.recurrence&&q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Recurrence"},void 0,!1,void 0,this),q.jsxDEV("p",{children:m(z.recurrence)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#444] mt-0.5 font-mono",children:z.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Created"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.execute_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Scheduled"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.executed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Started"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.completed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Completed"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.next_run&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Next Run"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.status==="failed"&&z.error&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:z.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.status==="completed"&&z.result&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof z.result==="string"?z.result:JSON.stringify(z.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&!z.trajectory&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#555]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.trajectory&&z.trajectory.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:["Trajectory (",z.trajectory.length," steps)"]},void 0,!0,void 0,this),q.jsxDEV(c,{trajectory:z.trajectory},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function c({trajectory:z}){let[Q,Z]=Y.useState(new Set),X=(J)=>{Z((U)=>{let G=new Set(U);if(G.has(J))G.delete(J);else G.add(J);return G})},$={user:{bg:"bg-blue-500/10",text:"text-blue-400",icon:"\uD83D\uDC64",label:"User"},assistant:{bg:"bg-purple-500/10",text:"text-purple-400",icon:"\uD83E\uDD16",label:"Assistant"}},P=(J)=>{let U=J.content;if(typeof U==="string"){let G=U.length>200,H=Q.has(J.id);return q.jsxDEV("div",{children:[q.jsxDEV("p",{className:`text-sm text-[#ccc] whitespace-pre-wrap break-words ${!H&&G?"line-clamp-4":""}`,children:U},void 0,!1,void 0,this),G&&q.jsxDEV("button",{onClick:()=>X(J.id),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:H?"Show less":"Show more..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return q.jsxDEV("div",{className:"space-y-2",children:U.map((G,H)=>{if(G.type==="tool_use"){let K=JSON.stringify(G.input,null,2),_=K.length>150,F=`${J.id}-${H}`,W=Q.has(F);return q.jsxDEV("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded p-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{className:"text-orange-400",children:"\uD83D\uDD27"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs font-medium text-orange-400",children:"Tool Call"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#888]",children:G.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto ${!W&&_?"line-clamp-3":""}`,children:K},void 0,!1,void 0,this),_&&q.jsxDEV("button",{onClick:()=>X(F),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:W?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}if(G.type==="tool_result"){let K=G.is_error,_=`${J.id}-${H}`,F=Q.has(_),W=G.content.length>150;return q.jsxDEV("div",{className:`${K?"bg-red-500/10 border-red-500/20":"bg-teal-500/10 border-teal-500/20"} border rounded p-2`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{children:K?"❌":"\uD83D\uDCCB"},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${K?"text-red-400":"text-teal-400"}`,children:"Tool Result"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto whitespace-pre-wrap break-words ${!F&&W?"line-clamp-3":""}`,children:G.content},void 0,!1,void 0,this),W&&q.jsxDEV("button",{onClick:()=>X(_),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:F?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}return null})},void 0,!1,void 0,this)};return q.jsxDEV("div",{className:"space-y-2",children:z.map((J)=>{let U=$[J.role]||$.assistant;return q.jsxDEV("div",{className:`${U.bg} border border-[#1a1a1a] rounded overflow-hidden p-3`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[q.jsxDEV("span",{children:U.icon},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${U.text}`,children:U.label},void 0,!1,void 0,this),J.model&&q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",J.model]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",new Date(J.created_at).toLocaleTimeString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),P(J)]},J.id,!0,void 0,this)})},void 0,!1,void 0,this)}var y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function m(z){try{let Q=z.trim().split(/\s+/);if(Q.length!==5)return z;let[Z,X,$,P,J]=Q;if(Z.startsWith("*/")&&X==="*"&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(Z.slice(2));if(G===1)return"Every minute";return`Every ${G} minutes`}if(Z!=="*"&&!Z.includes("/")&&X==="*"&&$==="*"&&P==="*"&&J==="*")return"Every hour";if(X.startsWith("*/")&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(X.slice(2));if(G===1)return"Every hour";return`Every ${G} hours`}let U=(G,H)=>{let K=parseInt(G),_=parseInt(H);if(isNaN(K))return"";let F=K>=12?"PM":"AM";return`${K===0?12:K>12?K-12:K}:${_.toString().padStart(2,"0")} ${F}`};if(X!=="*"&&!X.includes("/")&&$==="*"&&P==="*"){let G=U(X,Z);if(J==="*")return`Daily at ${G}`;let H=J.split(",").map((K)=>{let _=parseInt(K.trim());return y[_]||K});if(H.length===7)return`Daily at ${G}`;if(H.length===5&&!H.includes("Sat")&&!H.includes("Sun"))return`Weekdays at ${G}`;if(H.length===1)return`Weekly on ${H[0]} at ${G}`;return`${H.join(" & ")} at ${G}`}return z}catch{return z}}function L(z){let Q=new Date(z),Z=new Date,X=Q.getTime()-Z.getTime(),$=Math.abs(X),P=X>0,J=Math.floor($/60000),U=Math.floor($/3600000),G=Math.floor($/86400000),H=Q.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),K=Q.toDateString()===Z.toDateString(),_=new Date(Z);_.setDate(_.getDate()+1);let F=Q.toDateString()===_.toDateString(),W=new Date(Z);W.setDate(W.getDate()-1);let w=Q.toDateString()===W.toDateString();if(K){if(J<1)return P?"now":"just now";if(J<60)return P?`in ${J} min (${H})`:`${J} min ago`;return P?`in ${U}h (${H})`:`${U}h ago`}if(F)return`Tomorrow at ${H}`;if(w)return`Yesterday at ${H}`;if(G<7)return`${y[Q.getDay()]} at ${H}`;return Q.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${H}`}
|
|
2
2
|
export{j as e,m as f,L as g};
|
|
3
3
|
|
|
4
4
|
//# debugId=70495ECA00A83B0164756E2164756E21
|