apteva 0.4.17 → 0.4.19

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.
Files changed (78) hide show
  1. package/dist/ActivityPage.9a1qg4bp.js +3 -0
  2. package/dist/ApiDocsPage.rfpf7ws1.js +4 -0
  3. package/dist/App.1nmg2h01.js +4 -0
  4. package/dist/App.5qw2dtxs.js +4 -0
  5. package/dist/App.6nc5acvk.js +4 -0
  6. package/dist/App.7vzbaz56.js +4 -0
  7. package/dist/App.8rfz30p1.js +4 -0
  8. package/dist/App.amwp54wf.js +4 -0
  9. package/dist/App.e4202qb4.js +267 -0
  10. package/dist/App.errxz2q4.js +4 -0
  11. package/dist/App.f8qsyhpr.js +4 -0
  12. package/dist/App.g8vq68n0.js +20 -0
  13. package/dist/App.kfyrnznw.js +13 -0
  14. package/dist/{App.mq6jqare.js → App.p02f4ret.js} +1 -1
  15. package/dist/App.p93mmyqw.js +4 -0
  16. package/dist/App.qmg33p02.js +4 -0
  17. package/dist/App.sdsc0258.js +4 -0
  18. package/dist/ConnectionsPage.7zqba1r0.js +3 -0
  19. package/dist/McpPage.kf2g327t.js +3 -0
  20. package/dist/SettingsPage.472c15ep.js +3 -0
  21. package/dist/SkillsPage.xdxnh68a.js +3 -0
  22. package/dist/TasksPage.7g0b8xwc.js +3 -0
  23. package/dist/TelemetryPage.pr7rbz4r.js +3 -0
  24. package/dist/TestsPage.zhc6rqjm.js +3 -0
  25. package/dist/apteva-kit.css +1 -1
  26. package/dist/index.html +1 -1
  27. package/dist/styles.css +1 -1
  28. package/package.json +9 -4
  29. package/src/auth/middleware.ts +2 -0
  30. package/src/channels/index.ts +40 -0
  31. package/src/channels/telegram.ts +306 -0
  32. package/src/db.ts +342 -11
  33. package/src/integrations/agentdojo.ts +1 -1
  34. package/src/mcp-handler.ts +31 -24
  35. package/src/mcp-platform.ts +41 -1
  36. package/src/providers.ts +22 -9
  37. package/src/routes/api/agent-utils.ts +38 -2
  38. package/src/routes/api/agents.ts +65 -2
  39. package/src/routes/api/channels.ts +182 -0
  40. package/src/routes/api/integrations.ts +13 -5
  41. package/src/routes/api/mcp.ts +27 -9
  42. package/src/routes/api/projects.ts +19 -2
  43. package/src/routes/api/system.ts +26 -12
  44. package/src/routes/api/telemetry.ts +30 -0
  45. package/src/routes/api/triggers.ts +478 -0
  46. package/src/routes/api/webhooks.ts +171 -0
  47. package/src/routes/api.ts +7 -1
  48. package/src/routes/static.ts +12 -3
  49. package/src/server.ts +43 -6
  50. package/src/triggers/agentdojo.ts +253 -0
  51. package/src/triggers/composio.ts +264 -0
  52. package/src/triggers/index.ts +71 -0
  53. package/src/tui/AgentList.tsx +145 -0
  54. package/src/tui/App.tsx +102 -0
  55. package/src/tui/Login.tsx +104 -0
  56. package/src/tui/api.ts +72 -0
  57. package/src/tui/index.tsx +7 -0
  58. package/src/web/App.tsx +18 -11
  59. package/src/web/components/agents/AgentCard.tsx +14 -7
  60. package/src/web/components/agents/AgentPanel.tsx +94 -137
  61. package/src/web/components/common/Icons.tsx +16 -0
  62. package/src/web/components/common/index.ts +1 -0
  63. package/src/web/components/connections/ConnectionsPage.tsx +54 -0
  64. package/src/web/components/connections/IntegrationsTab.tsx +144 -0
  65. package/src/web/components/connections/OverviewTab.tsx +137 -0
  66. package/src/web/components/connections/TriggersTab.tsx +1169 -0
  67. package/src/web/components/index.ts +1 -0
  68. package/src/web/components/layout/Header.tsx +196 -4
  69. package/src/web/components/layout/Sidebar.tsx +7 -1
  70. package/src/web/components/mcp/IntegrationsPanel.tsx +19 -3
  71. package/src/web/components/settings/SettingsPage.tsx +364 -2
  72. package/src/web/components/tasks/TasksPage.tsx +2 -2
  73. package/src/web/components/tests/TestsPage.tsx +1 -2
  74. package/src/web/context/TelemetryContext.tsx +14 -1
  75. package/src/web/context/index.ts +1 -1
  76. package/src/web/hooks/useAgents.ts +15 -11
  77. package/src/web/types.ts +1 -1
  78. package/dist/App.fq4xbpcz.js +0 -228
@@ -0,0 +1,3 @@
1
+ import{d as a}from"./App.1nmg2h01.js";import"./App.sdsc0258.js";import"./App.g8vq68n0.js";export{a as ActivityPage};
2
+
3
+ //# debugId=A836402CCF3683F564756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{Q as y,T as E,U as D,aa as l}from"./App.g8vq68n0.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
+ `)[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
+
4
+ //# debugId=CC4FEADFD3330E5F64756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{k as h}from"./App.sdsc0258.js";import{Q as g,T as A,U as p,W as v,Y as b,aa as x,da as y}from"./App.g8vq68n0.js";var d=g(A(),1);var e=g(p(),1);function I({agents:t,loading:r}){let{currentProjectId:s}=y(),[a,l]=d.useState(null),n=d.useMemo(()=>{if(s===null)return t;if(s==="unassigned")return t.filter((o)=>!o.projectId);return t.filter((o)=>o.projectId===s)},[t,s]),i=n.find((o)=>o.id===a)||null;return e.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxDEV("div",{className:"flex-[3] min-h-0 p-6 overflow-auto",children:e.jsxDEV(w,{agents:n,loading:r,selectedAgentId:a,onSelectAgent:l},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.jsxDEV("div",{className:"flex-[2] min-h-0 border-t border-[#1a1a1a] flex",children:[e.jsxDEV($,{agent:i,onClose:()=>l(null)},void 0,!1,void 0,this),e.jsxDEV(S,{agents:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function w({agents:t,loading:r,selectedAgentId:s,onSelectAgent:a}){if(r)return e.jsxDEV("div",{className:"flex items-center justify-center h-full text-[#666]",children:"Loading agents..."},void 0,!1,void 0,this);if(t.length===0)return e.jsxDEV("div",{className:"flex items-center justify-center h-full text-[#666]",children:e.jsxDEV("div",{className:"text-center",children:[e.jsxDEV("p",{className:"text-lg",children:"No agents found"},void 0,!1,void 0,this),e.jsxDEV("p",{className:"text-sm text-[#444] mt-1",children:"Create and start agents to see them here"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this);let l=t.filter((n)=>n.status==="running").length;return e.jsxDEV("div",{className:"h-full flex flex-col",children:[e.jsxDEV("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxDEV("h2",{className:"text-lg font-semibold",children:"Activity"},void 0,!1,void 0,this),e.jsxDEV("span",{className:"text-sm text-[#666]",children:[l," of ",t.length," running"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("div",{className:"flex-1 flex items-center justify-center",children:e.jsxDEV("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-8",children:t.map((n)=>e.jsxDEV(C,{agent:n,selected:s===n.id,onClick:()=>a(s===n.id?null:n.id)},n.id,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function C({agent:t,selected:r,onClick:s}){let{isActive:a,type:l}=b(t.id),n=t.status==="running",i=r?"ring-2 ring-[#f97316] shadow-[0_0_12px_rgba(249,115,22,0.3)]":n&&a?"ring-2 ring-green-400":n?"ring-1 ring-[#3b82f6]/60":"ring-1 ring-[#333]",o=n?a?"bg-green-500/10":"bg-[#1a1a1a]":"bg-[#111]",c=n?"text-[#e0e0e0]":"text-[#555]";return e.jsxDEV("button",{onClick:s,className:"flex flex-col items-center gap-2 group",children:[e.jsxDEV("div",{className:`w-16 h-16 rounded-full ${o} ${i} flex items-center justify-center transition-all duration-300 group-hover:scale-110 relative`,children:[e.jsxDEV("span",{className:`text-xl font-semibold ${c}`,children:t.name.charAt(0).toUpperCase()},void 0,!1,void 0,this),a&&n&&e.jsxDEV("div",{className:"absolute inset-0 rounded-full bg-green-400/20 animate-ping",style:{animationDuration:"1.5s"}},void 0,!1,void 0,this),n&&a&&e.jsxDEV("div",{className:"absolute inset-0 rounded-full animate-pulse",style:{boxShadow:"0 0 12px 3px rgba(74, 222, 128, 0.4)"}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("div",{className:"text-center max-w-[100px]",children:[e.jsxDEV("p",{className:`text-xs font-medium truncate ${c}`,children:t.name},void 0,!1,void 0,this),a&&l?e.jsxDEV("p",{className:"text-[10px] text-green-400 truncate",children:l},void 0,!1,void 0,this):e.jsxDEV("p",{className:`text-[10px] ${n?"text-[#3b82f6]":"text-[#444]"}`,children:n?"idle":"stopped"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var k={LLM:"bg-purple-500/20 text-purple-400",TOOL:"bg-blue-500/20 text-blue-400",CHAT:"bg-green-500/20 text-green-400",ERROR:"bg-red-500/20 text-red-400",SYSTEM:"bg-gray-500/20 text-gray-400",TASK:"bg-yellow-500/20 text-yellow-400",MEMORY:"bg-cyan-500/20 text-cyan-400",MCP:"bg-orange-500/20 text-orange-400"};function S({agents:t}){let{events:r}=v(),s=d.useRef(null),a=d.useMemo(()=>new Set(t.map((i)=>i.id)),[t]),l=d.useMemo(()=>{let i=new Map;return t.forEach((o)=>i.set(o.id,o.name)),i},[t]),n=d.useMemo(()=>{return r.filter((i)=>a.has(i.agent_id)).slice(0,50)},[r,a]);return e.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden border-l border-[#1a1a1a]",children:[e.jsxDEV("div",{className:"px-4 py-3 border-b border-[#1a1a1a] flex items-center justify-between shrink-0",children:[e.jsxDEV("h3",{className:"font-semibold text-sm",children:"Live Activity"},void 0,!1,void 0,this),e.jsxDEV("span",{className:"text-xs text-[#666]",children:[n.length," events"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("div",{ref:s,className:"flex-1 overflow-auto",children:n.length===0?e.jsxDEV("div",{className:"p-4 text-center text-[#666] text-sm",children:"No activity yet. Events appear in real-time."},void 0,!1,void 0,this):e.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:n.map((i)=>e.jsxDEV("div",{className:"px-4 py-2 hover:bg-[#111] transition",style:{animation:"slideIn 0.3s ease-out"},children:[e.jsxDEV("div",{className:"flex items-center gap-2",children:[e.jsxDEV("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${k[i.category]||"bg-[#222] text-[#888]"}`,children:i.category},void 0,!1,void 0,this),e.jsxDEV("span",{className:"text-xs font-medium truncate flex-1",children:i.type},void 0,!1,void 0,this),e.jsxDEV("span",{className:"text-[10px] text-[#555] shrink-0",children:M(i.timestamp)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("div",{className:"text-[10px] text-[#555] mt-0.5",children:[l.get(i.agent_id)||i.agent_id,i.duration_ms?` · ${i.duration_ms}ms`:""]},void 0,!0,void 0,this)]},i.id,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $({agent:t,onClose:r}){let{authFetch:s}=x(),[a,l]=d.useState(""),[n,i]=d.useState(!1),[o,c]=d.useState(null);if(d.useEffect(()=>{l(""),c(null)},[t?.id]),!t)return e.jsxDEV("div",{className:"w-80 shrink-0 flex items-center justify-center text-[#555] text-sm p-4 text-center",children:"Click an agent to send a quick command"},void 0,!1,void 0,this);let f=async()=>{if(!a.trim()||n)return;if(t.status!=="running"){c("Agent is not running"),setTimeout(()=>c(null),3000);return}i(!0);try{let m=await s(`/api/agents/${t.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:a,agent_id:t.id})});if(m.ok)c("Command sent"),l("");else{let N=await m.json().catch(()=>({}));c(N.error||"Failed to send")}}catch{c("Failed to send command")}finally{i(!1),setTimeout(()=>c(null),3000)}},u=t.status==="running";return e.jsxDEV("div",{className:"w-80 shrink-0 flex flex-col",children:[e.jsxDEV("div",{className:"px-4 py-3 border-b border-[#1a1a1a] flex items-center justify-between shrink-0",children:[e.jsxDEV("div",{className:"min-w-0",children:[e.jsxDEV("h3",{className:"font-semibold text-sm truncate",children:t.name},void 0,!1,void 0,this),e.jsxDEV("p",{className:`text-[10px] ${u?"text-green-400":"text-[#666]"}`,children:u?"Running":"Stopped"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("button",{onClick:r,className:"text-[#666] hover:text-[#e0e0e0] transition shrink-0 ml-2",children:e.jsxDEV(h,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.jsxDEV("div",{className:"flex-1 p-4 flex flex-col justify-end",children:[o&&e.jsxDEV("div",{className:`mb-3 px-3 py-2 rounded text-xs ${o==="Command sent"?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:o},void 0,!1,void 0,this),e.jsxDEV("div",{className:"flex gap-2",children:[e.jsxDEV("input",{type:"text",value:a,onChange:(m)=>l(m.target.value),onKeyDown:(m)=>m.key==="Enter"&&f(),placeholder:u?"Quick command...":"Agent not running",disabled:n||!u,className:"flex-1 bg-[#111] border border-[#1a1a1a] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316] placeholder-[#444] disabled:opacity-50"},void 0,!1,void 0,this),e.jsxDEV("button",{onClick:f,disabled:n||!a.trim()||!u,className:"px-3 py-2 bg-[#f97316]/20 text-[#f97316] rounded text-sm font-medium hover:bg-[#f97316]/30 transition disabled:opacity-30",children:n?"...":"Send"},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 M(t){let r=Math.floor((Date.now()-new Date(t).getTime())/1000);if(r<5)return"just now";if(r<60)return`${r}s ago`;let s=Math.floor(r/60);if(s<60)return`${s}m ago`;let a=Math.floor(s/60);if(a<24)return`${a}h ago`;return`${Math.floor(a/24)}d ago`}
2
+ export{I as d};
3
+
4
+ //# debugId=179E59998F7EBC2064756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{E as x,j as C,k as j}from"./App.sdsc0258.js";import{L as o,M as v}from"./App.p93mmyqw.js";import{P as n}from"./App.7vzbaz56.js";import{Q as D,T as t,U as E,aa as y,da as c}from"./App.g8vq68n0.js";var B=D(t(),1);var q=D(E(),1);function Nq(){let{projectsEnabled:z}=c(),[H,L]=B.useState("general"),T=[{key:"general",label:"General"},{key:"providers",label:"Providers"},...z?[{key:"projects",label:"Projects"}]:[],{key:"channels",label:"Channels"},{key:"api-keys",label:"API Keys"},{key:"account",label:"Account"},{key:"updates",label:"Updates"},{key:"data",label:"Data"}];return q.jsxDEV("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[q.jsxDEV("div",{className:"md:hidden border-b border-[#1a1a1a] bg-[#0a0a0a]",children:q.jsxDEV("div",{className:"flex overflow-x-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:T.map((J)=>q.jsxDEV("button",{onClick:()=>L(J.key),className:`flex-shrink-0 px-4 py-3 text-sm font-medium border-b-2 transition ${H===J.key?"border-[#f97316] text-[#f97316]":"border-transparent text-[#666] hover:text-[#888]"}`,children:J.label},J.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"hidden md:block w-48 border-r border-[#1a1a1a] p-4 flex-shrink-0",children:[q.jsxDEV("h2",{className:"text-sm font-medium text-[#666] uppercase tracking-wider mb-3",children:"Settings"},void 0,!1,void 0,this),q.jsxDEV("nav",{className:"space-y-1",children:T.map((J)=>q.jsxDEV(s,{label:J.label,active:H===J.key,onClick:()=>L(J.key)},J.key,!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 md:p-6",children:[H==="general"&&q.jsxDEV(e,{},void 0,!1,void 0,this),H==="providers"&&q.jsxDEV(qq,{},void 0,!1,void 0,this),H==="projects"&&z&&q.jsxDEV(zq,{},void 0,!1,void 0,this),H==="channels"&&q.jsxDEV(Gq,{},void 0,!1,void 0,this),H==="api-keys"&&q.jsxDEV(Yq,{},void 0,!1,void 0,this),H==="account"&&q.jsxDEV(Zq,{},void 0,!1,void 0,this),H==="updates"&&q.jsxDEV(Hq,{},void 0,!1,void 0,this),H==="data"&&q.jsxDEV($q,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function s({label:z,active:H,onClick:L}){return q.jsxDEV("button",{onClick:L,className:`w-full text-left px-3 py-2 rounded text-sm transition ${H?"bg-[#1a1a1a] text-[#e0e0e0]":"text-[#666] hover:bg-[#111] hover:text-[#888]"}`,children:z},void 0,!1,void 0,this)}function e(){let{authFetch:z}=y(),[H,L]=B.useState(""),[T,J]=B.useState(!0),[G,N]=B.useState(!1),[_,U]=B.useState(null);B.useEffect(()=>{(async()=>{try{let Y=await(await z("/api/settings/instance-url")).json();L(Y.instance_url||"")}catch{}J(!1)})()},[]);let R=async()=>{N(!0),U(null);try{let O=await z("/api/settings/instance-url",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instance_url:H})}),M=await O.json();if(O.ok)L(M.instance_url||""),U({type:"success",text:"Instance URL saved"});else U({type:"error",text:M.error||"Failed to save"})}catch{U({type:"error",text:"Failed to save"})}N(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"General"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Instance configuration."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Instance URL"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"The public HTTPS URL for this instance. Used for webhook callbacks from external services like Composio."},void 0,!1,void 0,this),T?q.jsxDEV("div",{className:"text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-3 max-w-lg",children:[q.jsxDEV("input",{type:"text",value:H,onChange:(O)=>L(O.target.value),placeholder:"https://your-domain.com",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316] font-mono text-sm"},void 0,!1,void 0,this),_&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${_.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:_.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:R,disabled:G,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black rounded text-sm font-medium transition",children:G?"Saving...":"Save"},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 qq(){let{authFetch:z}=y(),{projects:H,projectsEnabled:L}=c(),[T,J]=B.useState([]),[G,N]=B.useState(null),[_,U]=B.useState(""),[R,O]=B.useState(!1),[M,Y]=B.useState(!1),[W,Q]=B.useState(null),[b,F]=B.useState(null),{confirm:I,ConfirmDialog:K}=v(),w=async()=>{let m=await(await z("/api/providers")).json();J(m.providers||[])};B.useEffect(()=>{w()},[]);let f=async()=>{if(!G||!_)return;O(!0),Q(null),F(null);try{Y(!0);let m=await(await z(`/api/keys/${G}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})})).json();if(Y(!1),!m.valid){Q(m.error||"API key is invalid"),O(!1);return}let l=await z(`/api/keys/${G}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})}),h=await l.json();if(!l.ok)Q(h.error||"Failed to save key");else{let p="API key saved!";if(h.restartedAgents&&h.restartedAgents.length>0){let u=h.restartedAgents.filter((V)=>V.success).length;if(h.restartedAgents.length-u===0)p+=` Restarted ${u} agent${u>1?"s":""} with new key.`;else p+=` Restarted ${u}/${h.restartedAgents.length} agents.`}F(p),U(""),N(null),w()}}catch($){Q("Failed to save key")}O(!1)},g=async($)=>{if(!await I("Are you sure you want to remove this API key?",{confirmText:"Remove",title:"Remove API Key"}))return;await z(`/api/keys/${$}`,{method:"DELETE"}),w()},k=T.filter(($)=>$.type==="llm"),P=T.filter(($)=>$.type==="integration"),Z=k.filter(($)=>$.hasKey).length,X=P.filter(($)=>$.hasKey).length;return B.useEffect(()=>{if(b&&!G){let $=setTimeout(()=>F(null),5000);return()=>clearTimeout($)}},[b,G]),q.jsxDEV(q.Fragment,{children:[K,q.jsxDEV("div",{className:"space-y-10",children:[b&&!G&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center justify-between",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{children:b},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>F(null),className:"text-green-400 hover:text-green-300",children:q.jsxDEV(j,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"AI Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Manage your API keys for AI providers. ",Z," of ",k.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:k.map(($)=>q.jsxDEV(Qq,{provider:$,isEditing:G===$.id,apiKey:_,saving:R,testing:M,error:G===$.id?W:null,success:G===$.id?b:null,onStartEdit:()=>{N($.id),Q(null),F(null)},onCancelEdit:()=>{N(null),U(""),Q(null)},onApiKeyChange:U,onSave:f,onDelete:()=>g($.id)},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"MCP Integrations"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Connect to MCP gateways for tool integrations. ",X," of ",P.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:P.map(($)=>q.jsxDEV(Xq,{provider:$,isEditing:G===$.id,apiKey:_,saving:R,testing:M,error:G===$.id?W:null,success:G===$.id?b:null,onStartEdit:()=>{N($.id),Q(null),F(null)},onCancelEdit:()=>{N(null),U(""),Q(null)},onApiKeyChange:U,onSave:f,onDelete:()=>g($.id),projectsEnabled:L,projects:H,onRefresh:w},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var i=["#f97316","#6366f1","#22c55e","#ef4444","#3b82f6","#a855f7","#14b8a6","#f59e0b"];function zq(){let{projects:z,createProject:H,updateProject:L,deleteProject:T}=c(),[J,G]=B.useState(!1),[N,_]=B.useState(null),{confirm:U,ConfirmDialog:R}=v(),O=async(Q)=>{if(!await U("Are you sure you want to delete this project? Agents in this project will become unassigned.",{confirmText:"Delete",title:"Delete Project"}))return;await T(Q)},M=()=>{_(null),G(!0)},Y=(Q)=>{_(Q),G(!0)},W=()=>{G(!1),_(null)};return q.jsxDEV(q.Fragment,{children:[R,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Projects"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Organize agents into projects for better management."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:M,className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(x,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Project"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No projects yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create a project to organize your agents."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:z.map((Q)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 flex items-center gap-4",children:[q.jsxDEV("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:Q.color}},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:Q.name},void 0,!1,void 0,this),Q.description&&q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:Q.description},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-1",children:[Q.agentCount," agent",Q.agentCount!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("button",{onClick:()=>Y(Q),className:"text-sm text-[#888] hover:text-[#e0e0e0] px-2 py-1",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>O(Q.id),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Q.id,!0,void 0,this))},void 0,!1,void 0,this),J&&q.jsxDEV(Bq,{project:N,onSave:async(Q)=>{if(N){let b=await L(N.id,Q);if(b)W();return!!b}else{let b=await H(Q);if(b)W();return!!b}},onClose:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Bq({project:z,onSave:H,onClose:L}){let[T,J]=B.useState(z?.name||""),[G,N]=B.useState(z?.description||""),[_,U]=B.useState(z?.color||i[Math.floor(Math.random()*i.length)]),[R,O]=B.useState(!1),[M,Y]=B.useState(null),W=async()=>{if(!T.trim()){Y("Name is required");return}O(!0),Y(null);let Q=await H({name:T,description:G||void 0,color:_});if(O(!1),!Q)Y(z?"Failed to update project":"Failed to create project")};return q.jsxDEV(o,{onClose:L,children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-6",children:z?"Edit Project":"Create New Project"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:T,onChange:(Q)=>J(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"My Project",autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Description (optional)"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:G,onChange:(Q)=>N(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"A short description"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Color"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3 flex-wrap",children:i.map((Q)=>q.jsxDEV("button",{type:"button",onClick:()=>U(Q),className:`w-10 h-10 rounded-full transition ${_===Q?"ring-2 ring-white ring-offset-2 ring-offset-[#111]":"hover:scale-110"}`,style:{backgroundColor:Q}},Q,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-3 mt-6",children:[q.jsxDEV("button",{onClick:L,className:"flex-1 border border-[#333] hover:border-[#f97316] hover:text-[#f97316] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:W,disabled:R||!T.trim(),className:"flex-1 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:R?"Saving...":z?"Update":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hq(){let{authFetch:z}=y(),[H,L]=B.useState(null),[T,J]=B.useState(!1),[G,N]=B.useState(!1),[_,U]=B.useState(null),[R,O]=B.useState(null),[M,Y]=B.useState(null),W=async()=>{J(!0),U(null);try{let I=await z("/api/version");if(!I.ok)throw Error("Failed to check for updates");let K=await I.json();L(K)}catch(I){U("Failed to check for updates")}J(!1)},Q=async()=>{N(!0),U(null),O(null);try{let K=await(await z("/api/version/update",{method:"POST"})).json();if(!K.success)U(K.error||"Update failed");else{let w=K.restarted?.length||0,f=w>0?` ${w} running agent${w>1?"s":""} restarted.`:"";O(`Agent binary updated to v${K.version}.${f}`),await W()}}catch(I){U("Failed to update agent")}N(!1)};B.useEffect(()=>{W()},[]);let b=(I,K)=>{navigator.clipboard.writeText(I),Y(K),setTimeout(()=>Y(null),2000)},F=H?.apteva.updateAvailable||H?.agent.updateAvailable;return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Updates"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Check for new versions of apteva and the agent binary."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T&&!H?q.jsxDEV("div",{className:"text-[#666]",children:"Checking version info..."},void 0,!1,void 0,this):_&&!H?q.jsxDEV("div",{className:"text-red-400",children:_},void 0,!1,void 0,this):H?.isDocker?q.jsxDEV("div",{className:"space-y-6",children:[q.jsxDEV("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-blue-400 mb-2",children:[q.jsxDEV("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{d:"M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.186.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.186.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.186.186 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.186.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.185-.186H5.136a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"Docker Environment"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888]",children:"Updates are automatic when you pull a new image version."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Current Version"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"apteva + agent binary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.apteva.installed||"?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:["A newer version (v",H.apteva.latest,") is available. To update:"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2",children:[q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker pull apteva/apteva:latest"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker compose up -d"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText("docker pull apteva/apteva:latest && docker compose up -d"),Y("docker"),setTimeout(()=>Y(null),2000)},className:"mt-3 px-3 py-1.5 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="docker"?"Copied!":"Copy commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555]",children:"Your data is stored in a Docker volume and persists across updates."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):H?q.jsxDEV("div",{className:"space-y-6",children:[R&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 text-green-400",children:R},void 0,!1,void 0,this),_&&q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-400",children:_},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"apteva"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The app you're running"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.apteva.installed||"?"]},void 0,!0,void 0,this),H.apteva.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",H.apteva.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.apteva.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Update by running:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"npx apteva@latest"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>b("npx apteva@latest","apteva"),className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="apteva"?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Agent Binary"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The Go binary that runs agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.agent.installed||"?"]},void 0,!0,void 0,this),H.agent.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",H.agent.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.agent.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"A new version is available. Stop all agents before updating."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:q.jsxDEV("button",{onClick:Q,disabled:G,className:"px-4 py-2 bg-[#f97316] text-black rounded font-medium text-sm disabled:opacity-50",children:G?"Updating...":"Update Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!F&&!R&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center gap-2 text-green-400",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),"Everything is up to date!"]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:W,disabled:T,className:"text-sm text-[#666] hover:text-[#888] disabled:opacity-50",children:T?"Checking...":"Check for updates"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function Qq({provider:z,isEditing:H,apiKey:L,saving:T,testing:J,error:G,success:N,onStartEdit:_,onCancelEdit:U,onApiKeyChange:R,onSave:O,onDelete:M}){let Y=z.id==="ollama",[W,Q]=B.default.useState(null);return B.default.useEffect(()=>{if(Y&&z.hasKey)fetch("/api/providers/ollama/status").then((b)=>b.json()).then((b)=>Q({connected:b.connected,modelCount:b.modelCount})).catch(()=>Q({connected:!1}))},[Y,z.hasKey]),q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-green-500/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:z.type==="integration"?z.description||"MCP integration":Y?"Run models locally":`${z.models.length} models`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:`text-xs flex items-center gap-1 px-2 py-1 rounded whitespace-nowrap flex-shrink-0 ${Y&&W?W.connected?"text-green-400 bg-green-500/10":"text-yellow-400 bg-yellow-500/10":"text-green-400 bg-green-500/10"}`,children:Y&&W?W.connected?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),W.modelCount," models"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:"Not running"},void 0,!1,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this)},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded whitespace-nowrap flex-shrink-0",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:Y?"text":"password",value:L,onChange:(b)=>R(b.target.value),placeholder:Y?"http://localhost:11434":z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,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),Y&&q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Enter your Ollama server URL. Default is http://localhost:11434"},void 0,!1,void 0,this),G&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:G},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:U,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!L||T,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:J?"Validating...":T?"Saving...":Y?"Connect":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Download Ollama":"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:_,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:Y?"Change URL":"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Download Ollama":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:Y?"Configure":"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Xq({provider:z,isEditing:H,apiKey:L,saving:T,testing:J,error:G,success:N,onStartEdit:_,onCancelEdit:U,onApiKeyChange:R,onSave:O,onDelete:M,projectsEnabled:Y,projects:W,onRefresh:Q}){let{authFetch:b}=y(),[F,I]=B.useState([]),[K,w]=B.useState(""),[f,g]=B.useState(!1),[k,P]=B.useState(null),[Z,X]=B.useState(!1),{confirm:$,ConfirmDialog:m}=v(),l=async()=>{try{let S=await(await b(`/api/keys/${z.id}`)).json();I(S.keys||[])}catch(A){console.error("Failed to fetch keys:",A)}};B.useEffect(()=>{if(Y)l()},[z.id,Y]),B.useEffect(()=>{if(H)P(null)},[H]);let h=async()=>{if(!L)return;X(!0),P(null);try{let A=await b(`/api/keys/${z.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:L,project_id:K||null})}),S=await A.json();if(A.ok)R(""),w(""),U(),l(),Q();else P(S.error||"Failed to save key")}catch(A){console.error("Failed to save key:",A),P("Failed to save key")}X(!1)},p=async(A,S)=>{if(!await $(`Are you sure you want to remove this API key${S?` (${S})`:""}?`,{confirmText:"Remove",title:"Remove API Key"}))return;try{await b(`/api/keys/by-id/${A}`,{method:"DELETE"}),l(),Q()}catch(r){console.error("Failed to delete key:",r)}},u=F.find((A)=>!A.project_id),d=F.filter((A)=>A.project_id),V=(A)=>W.find((S)=>S.id===A)?.name||"Unknown",a=(A)=>W.find((S)=>S.id===A)?.color||"#666";if(!Y)return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:L,onChange:(A)=>R(A.target.value),placeholder:z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,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),G&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:G},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:U,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!L||T,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:J?"Validating...":T?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:_,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return q.jsxDEV(q.Fragment,{children:[m,q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${F.length>0?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.length>0?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),F.length," key",F.length!==1?"s":""]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.length>0&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[u&&q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("span",{className:"text-[#888]",children:"Global"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:u.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(u.id,"Global"),className:"text-red-400 hover:text-red-300 text-xs",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.slice(0,f?void 0:2).map((A)=>q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 min-w-0",children:[q.jsxDEV("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:a(A.project_id)}},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#888] truncate",children:A.name||V(A.project_id)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:A.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(A.id,A.name||V(A.project_id)),className:"text-red-400 hover:text-red-300 text-xs flex-shrink-0 ml-2",children:"Remove"},void 0,!1,void 0,this)]},A.id,!0,void 0,this)),d.length>2&&!f&&q.jsxDEV("button",{onClick:()=>g(!0),className:"text-xs text-[#666] hover:text-[#888] w-full text-center py-1",children:["Show ",d.length-2," more..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:L,onChange:(A)=>R(A.target.value),placeholder:"Enter API key...",autoFocus:!0,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),q.jsxDEV(n,{value:K,onChange:w,placeholder:"Global (all projects)",options:[{value:"",label:"Global (all projects)"},...W.map((A)=>({value:A.id,label:A.name}))]},void 0,!1,void 0,this),k&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:k},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{U(),w(""),P(null)},className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:h,disabled:!L||Z,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:Z?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:F.length>0?"View docs":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yq(){let{authFetch:z}=y(),[H,L]=B.useState([]),[T,J]=B.useState(!1),[G,N]=B.useState(""),[_,U]=B.useState("90"),[R,O]=B.useState(!1),[M,Y]=B.useState(null),[W,Q]=B.useState(null),[b,F]=B.useState(!1),{confirm:I,ConfirmDialog:K}=v(),w=async()=>{try{let $=await(await z("/api/keys/personal")).json();L($.keys||[])}catch{}};B.useEffect(()=>{w()},[]);let f=async()=>{if(!G.trim()){Y("Name is required");return}O(!0),Y(null);try{let X=await z("/api/keys/personal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim(),expires_in_days:_?parseInt(_):null})}),$=await X.json();if(!X.ok)Y($.error||"Failed to create key");else Q($.key),N(""),U("90"),w()}catch{Y("Failed to create key")}O(!1)},g=async(X,$)=>{if(!await I(`Delete API key "${$}"? This cannot be undone.`,{confirmText:"Delete",title:"Delete API Key"}))return;try{await z(`/api/keys/personal/${X}`,{method:"DELETE"}),w()}catch{}},k=()=>{if(W)navigator.clipboard.writeText(W),F(!0),setTimeout(()=>F(!1),2000)},P=(X)=>{if(!X)return"Never";return new Date(X).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},Z=(X)=>{if(!X)return!1;return new Date(X)<new Date};return q.jsxDEV(q.Fragment,{children:[K,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"API Keys"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Create personal API keys for programmatic access. Use them with the ",q.jsxDEV("code",{className:"text-[#888] bg-[#1a1a1a] px-1 rounded text-xs",children:"X-API-Key"},void 0,!1,void 0,this)," header."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!T&&!W&&q.jsxDEV("button",{onClick:()=>{J(!0),Y(null)},className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(x,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Key"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 mb-6",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 mb-2",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"API key created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Copy this key now. You won't be able to see it again."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#e0e0e0] break-all select-all",children:W},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:k,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm flex-shrink-0",children:b?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{Q(null),J(!1)},className:"mt-3 text-sm text-[#666] hover:text-[#888]",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T&&!W&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Create new API key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:G,onChange:(X)=>N(X.target.value),placeholder:"e.g. CI Pipeline, My Script",autoFocus:!0,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),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Expiration"},void 0,!1,void 0,this),q.jsxDEV("select",{value:_,onChange:(X)=>U(X.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",children:[q.jsxDEV("option",{value:"30",children:"30 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"90",children:"90 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"180",children:"180 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"365",children:"1 year"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"",children:"No expiration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{J(!1),Y(null),N("")},className:"flex-1 px-3 py-2 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:f,disabled:R||!G.trim(),className:"flex-1 px-3 py-2 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:R?"Creating...":"Create Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No API keys yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create an API key to access apteva programmatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:H.map((X)=>q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 flex items-center gap-4 ${!X.is_active||Z(X.expires_at)?"border-[#1a1a1a] opacity-60":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:X.name},void 0,!1,void 0,this),!X.is_active&&q.jsxDEV("span",{className:"text-xs text-red-400 bg-red-500/10 px-2 py-0.5 rounded",children:"Revoked"},void 0,!1,void 0,this),X.is_active&&Z(X.expires_at)&&q.jsxDEV("span",{className:"text-xs text-yellow-400 bg-yellow-500/10 px-2 py-0.5 rounded",children:"Expired"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-[#666]",children:[q.jsxDEV("code",{className:"font-mono text-xs bg-[#0a0a0a] px-2 py-0.5 rounded",children:[X.prefix,"..."]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Created ",P(X.created_at)]},void 0,!0,void 0,this),X.expires_at&&q.jsxDEV("span",{children:["Expires ",P(X.expires_at)]},void 0,!0,void 0,this),X.last_used_at&&q.jsxDEV("span",{children:["Last used ",P(X.last_used_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X.is_active&&q.jsxDEV("button",{onClick:()=>g(X.id,X.name),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1 flex-shrink-0",children:"Delete"},void 0,!1,void 0,this)]},X.id,!0,void 0,this))},void 0,!1,void 0,this),H.length>0&&q.jsxDEV("div",{className:"mt-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2 text-sm",children:"Usage"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-xs text-[#888]",children:'curl -H "X-API-Key: apt_..." http://localhost:4280/api/agents'},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 Zq(){let{authFetch:z,user:H}=y(),[L,T]=B.useState(""),[J,G]=B.useState(""),[N,_]=B.useState(""),[U,R]=B.useState(!1),[O,M]=B.useState(null),Y=async()=>{if(!L||!J||!N){M({type:"error",text:"All fields are required"});return}if(J!==N){M({type:"error",text:"New passwords do not match"});return}if(J.length<8){M({type:"error",text:"Password must be at least 8 characters"});return}R(!0),M(null);try{let W=await z("/api/auth/password",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:L,newPassword:J})}),Q=await W.json();if(W.ok)M({type:"success",text:"Password updated successfully"}),T(""),G(""),_("");else M({type:"error",text:Q.error||"Failed to update password"})}catch{M({type:"error",text:"Failed to update password"})}R(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Account Settings"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage your account and security."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-3",children:"Profile"},void 0,!1,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:"Username"},void 0,!1,void 0,this),q.jsxDEV("span",{children:H.username},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.email&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Email"},void 0,!1,void 0,this),q.jsxDEV("span",{children:H.email},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Role"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"capitalize",children:H.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Change Password"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Current Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:L,onChange:(W)=>T(W.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),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:J,onChange:(W)=>G(W.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),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Confirm New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:N,onChange:(W)=>_(W.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),O&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${O.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:O.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:Y,disabled:U||!L||!J||!N,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 disabled:cursor-not-allowed text-black rounded text-sm font-medium transition",children:U?"Updating...":"Update Password"},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 $q(){let{authFetch:z}=y(),[H,L]=B.useState(!1),[T,J]=B.useState(null),[G,N]=B.useState(null),{confirm:_,ConfirmDialog:U}=v(),R=async()=>{try{let Y=await(await z("/api/telemetry/stats")).json();N(Y.stats?.total_events||0)}catch{N(null)}};B.useEffect(()=>{R()},[]);let O=async()=>{if(!await _("Are you sure you want to delete all telemetry data? This cannot be undone.",{confirmText:"Clear All",title:"Clear Telemetry Data"}))return;L(!0),J(null);try{let Y=await z("/api/telemetry/clear",{method:"POST"}),W=await Y.json();if(Y.ok)J({type:"success",text:`Cleared ${W.deleted||0} telemetry events.`}),N(0);else J({type:"error",text:W.error||"Failed to clear telemetry"})}catch{J({type:"error",text:"Failed to clear telemetry"})}L(!1)};return q.jsxDEV(q.Fragment,{children:[U,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Data Management"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage stored data and telemetry."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Telemetry Data"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:G!==null?`${G.toLocaleString()} events stored`:"Loading..."},void 0,!1,void 0,this),T&&q.jsxDEV("div",{className:`mb-4 p-3 rounded text-sm ${T.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:T.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:H||G===0,className:"px-4 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm font-medium transition",children:H?"Clearing...":"Clear All Telemetry"},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 Gq(){let{authFetch:z}=y(),[H,L]=B.useState([]),[T,J]=B.useState([]),[G,N]=B.useState(!0),[_,U]=B.useState(!1),[R,O]=B.useState({name:"",agent_id:"",botToken:""}),[M,Y]=B.useState(!1),[W,Q]=B.useState(null),{confirm:b,ConfirmDialog:F}=v(),I=async()=>{try{let X=await(await z("/api/channels")).json();L(X.channels||[])}catch{}finally{N(!1)}},K=async()=>{try{let X=await(await z("/api/agents")).json();J((X.agents||[]).map(($)=>({id:$.id,name:$.name,status:$.status})))}catch{}};B.useEffect(()=>{I(),K()},[]);let w=async()=>{if(!R.name||!R.agent_id||!R.botToken)return;Y(!0),Q(null);try{let Z=await z("/api/channels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"telegram",name:R.name,agent_id:R.agent_id,config:{botToken:R.botToken}})});if(!Z.ok){let X=await Z.json();Q(X.error||"Failed to create channel")}else O({name:"",agent_id:"",botToken:""}),U(!1),await I()}catch(Z){Q(Z.message)}finally{Y(!1)}},f=async(Z)=>{let X=Z.status==="running"?"stop":"start";try{let $=await z(`/api/channels/${Z.id}/${X}`,{method:"POST"});if(!$.ok){let m=await $.json();Q(m.error||`Failed to ${X} channel`)}await I()}catch{Q(`Failed to ${X} channel`)}},g=async(Z)=>{if(!await b(`Delete channel "${Z.name}"?`,{confirmText:"Delete",title:"Delete Channel"}))return;try{await z(`/api/channels/${Z.id}`,{method:"DELETE"}),await I()}catch{}},k={running:"bg-green-500/20 text-green-400",stopped:"bg-[#333] text-[#666]",error:"bg-red-500/20 text-red-400"},P=(Z)=>{return T.find((X)=>X.id===Z)?.name||Z};return q.jsxDEV(q.Fragment,{children:[F,q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Channels"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"Connect agents to external messaging platforms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>U(!_),className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1.5 rounded text-sm font-medium transition",children:[q.jsxDEV(x,{},void 0,!1,void 0,this)," Add Channel"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W&&q.jsxDEV("div",{className:"mb-4 bg-red-500/10 text-red-400 border border-red-500/30 px-3 py-2 rounded text-sm flex items-center justify-between",children:[q.jsxDEV("span",{children:W},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>Q(null),className:"text-red-400 hover:text-red-300 ml-2",children:q.jsxDEV(j,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&q.jsxDEV("div",{className:"mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4 space-y-3",children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-2",children:"New Telegram Channel"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Channel Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:R.name,onChange:(Z)=>O((X)=>({...X,name:Z.target.value})),placeholder:"e.g. My Telegram Bot",className:"w-full bg-[#0a0a0a] border border-[#222] 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),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(n,{value:R.agent_id,options:T.map((Z)=>({value:Z.id,label:Z.name})),onChange:(Z)=>O((X)=>({...X,agent_id:Z})),placeholder:"Select an agent..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Bot Token"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:R.botToken,onChange:(Z)=>O((X)=>({...X,botToken:Z.target.value})),placeholder:"From @BotFather on Telegram",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:["Create a bot via ",q.jsxDEV("a",{href:"https://t.me/BotFather",target:"_blank",className:"text-[#f97316] hover:underline",children:"@BotFather"},void 0,!1,void 0,this)," on Telegram to get a token."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 pt-1",children:[q.jsxDEV("button",{onClick:w,disabled:M||!R.name||!R.agent_id||!R.botToken,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-1.5 rounded text-sm font-medium transition",children:M?"Creating...":"Create"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{U(!1),O({name:"",agent_id:"",botToken:""})},className:"border border-[#333] hover:border-[#444] px-4 py-1.5 rounded text-sm transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G?q.jsxDEV("p",{className:"text-[#666] text-sm",children:"Loading channels..."},void 0,!1,void 0,this):H.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No channels configured"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Add a Telegram channel to let users message your agents directly."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:H.map((Z)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:Z.name},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${k[Z.status]||k.stopped}`,children:Z.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:[Z.type==="telegram"?"Telegram":Z.type," → ",P(Z.agent_id)]},void 0,!0,void 0,this),Z.status==="error"&&Z.error&&q.jsxDEV("p",{className:"text-xs text-red-400 mt-1",children:Z.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2 ml-4",children:[q.jsxDEV("button",{onClick:()=>f(Z),className:`px-3 py-1 rounded text-xs font-medium transition ${Z.status==="running"?"bg-[#f97316]/20 text-[#f97316] hover:bg-[#f97316]/30":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:Z.status==="running"?"Stop":"Start"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>g(Z),className:"text-[#666] hover:text-red-400 transition text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}
2
+ export{Nq as c};
3
+
4
+ //# debugId=94748AB622E888B364756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{Q as d,T as _q,U as qq,aa as Hq}from"./App.g8vq68n0.js";var U=d(_q(),1);var q=d(qq(),1);function i(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="API_KEY")}function Jq(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="OAUTH2")}function $q(J){return i(J)&&Jq(J)}function Rq({providerId:J="composio",projectId:Q,onConnectionComplete:k,onBrowseTriggers:F,hideMcpConfig:K}){let{authFetch:Y}=Hq(),[y,R]=U.useState([]),[L,P]=U.useState([]),[M,N]=U.useState(!0),[m,Qq]=U.useState(""),[A,B]=U.useState(null),[O,l]=U.useState(null),[r,X]=U.useState(null),[_,I]=U.useState(null),[$,b]=U.useState(null),[f,u]=U.useState(""),[w,V]=U.useState(null),[v,c]=U.useState(""),[s,g]=U.useState(!1),[n,x]=U.useState(null),[C,D]=U.useState(null),G=U.useCallback(async()=>{N(!0),X(null);let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let[H,W]=await Promise.all([Y(`/api/integrations/${J}/apps${z}`),Y(`/api/integrations/${J}/connected${z}`)]),Z=await H.json(),j=await W.json();R(Z.apps||[]),P(j.accounts||[])}catch(H){console.error("Failed to fetch integrations:",H),X("Failed to load integrations")}N(!1)},[Y,J,Q]);U.useEffect(()=>{G()},[G]),U.useEffect(()=>{if(new URLSearchParams(window.location.search).get("connected"))window.history.replaceState({},"",window.location.pathname),G(),k?.()},[G,k]),U.useEffect(()=>{if(!O?.connectionId)return;let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=setInterval(async()=>{try{let Z=await(await Y(`/api/integrations/${J}/connection/${O.connectionId}${z}`)).json();if(Z.connection?.status==="active")l(null),B(null),G(),k?.();else if(Z.connection?.status==="failed")l(null),B(null),X(`Connection to ${O.appSlug} failed`)}catch(W){}},2000);return()=>clearInterval(H)},[O,Y,J,Q,G,k]);let h=async(z,H,W)=>{if($q(z)&&!H&&!W){I({app:z});return}if(i(z)&&!H&&!W){b({app:z}),u("");return}B(z.slug),X(null);try{let Z={appSlug:z.slug};if(H)Z.credentials={authScheme:"API_KEY",apiKey:H};let j=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",p=await Y(`/api/integrations/${J}/connect${j}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}),T=await p.json();if(!p.ok){X(T.error||"Failed to initiate connection"),B(null),b(null);return}if(T.status==="active"||!T.redirectUrl){B(null),b(null),G(),k?.();return}if(T.redirectUrl){l({appSlug:z.slug,connectionId:T.connectionId});let e=window.open(T.redirectUrl,`connect-${z.slug}`,"width=600,height=700,left=200,top=100");if(!e||e.closed)window.location.href=T.redirectUrl}}catch(Z){X(`Failed to connect: ${Z}`),B(null),b(null)}},Uq=(z)=>{if(z.preventDefault(),!$||!f.trim())return;h($.app,f.trim())},Wq=async(z)=>{let H=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let W=await Y(`/api/integrations/${J}/connection/${z.id}${H}`,{method:"DELETE"});if(W.ok)G();else{let Z=await W.json();X(Z.error||"Failed to disconnect")}}catch(W){X(`Failed to disconnect: ${W}`)}},Xq=(z)=>{V({app:z}),c(`${z.name} MCP`),x(null)},Yq=async()=>{if(!w||!v.trim())return;g(!0),X(null);try{let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=await Y(`/api/integrations/${J}/configs${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.replace(/[^a-zA-Z0-9\s-]/g,"").substring(0,30),toolkitSlug:w.app.slug})}),W=await H.json();if(!H.ok){X(W.error||"Failed to create MCP config"),g(!1);return}x(v),k?.()}catch(z){X(`Failed to create MCP config: ${z}`)}finally{g(!1)}},Zq=(z)=>{D({message:`Disconnect ${z.appName}?`,onConfirm:()=>{Wq(z),D(null)}})},a=(z)=>{return L.some((H)=>H.appId===z&&H.status==="active")},t=(z)=>{return L.find((H)=>H.appId===z&&H.status==="active")||L.find((H)=>H.appId===z)},o=y.filter((z)=>{if(!m)return!0;let H=m.toLowerCase();return z.name.toLowerCase().includes(H)||z.slug.toLowerCase().includes(H)||z.description?.toLowerCase().includes(H)||z.categories.some((W)=>W.toLowerCase().includes(H))}),E=o.filter((z)=>a(z.slug)),S=o.filter((z)=>!a(z.slug));if(M)return q.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading apps..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"space-y-6",children:[_&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[_.app.logo&&q.jsxDEV("img",{src:_.app.logo,alt:_.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",_.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Choose how to authenticate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("button",{onClick:()=>{I(null),b({app:_.app}),u("")},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Enter your ",_.app.name," API key directly"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),h(_.app,void 0,!0)},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"OAuth"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Sign in with your ",_.app.name," account"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>I(null),className:"w-full text-sm text-[#666] hover:text-white mt-4 py-2 transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[$.app.logo&&q.jsxDEV("img",{src:$.app.logo,alt:$.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",$.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Enter your API key to connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:Uq,children:[q.jsxDEV("input",{type:"password",value:f,onChange:(z)=>u(z.target.value),placeholder:"Enter API Key...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>b(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!f.trim()||A===$.app.slug,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:A===$.app.slug?"Connecting...":"Connect"},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),w&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:n?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"text-center mb-4",children:[q.jsxDEV("div",{className:"w-12 h-12 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3",children:q.jsxDEV("span",{className:"text-green-400 text-2xl",children:"✓"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("h3",{className:"font-medium text-lg",children:"MCP Config Created!"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mt-2",children:['"',n,'" has been created successfully.']},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-2",children:"You can now add it to your agents from the MCP Configs tab."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{V(null),x(null)},className:"w-full text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[w.app.logo&&q.jsxDEV("img",{src:w.app.logo,alt:w.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:"Create MCP Config"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:["Create an MCP config for ",w.app.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:(z)=>{z.preventDefault(),Yq()},children:[q.jsxDEV("label",{className:"block text-xs text-[#888] mb-1",children:"Config Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:v,onChange:(z)=>c(z.target.value),placeholder:"Enter config name...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0,maxLength:30},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>V(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!v.trim()||s,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:s?"Creating...":"Create Config"},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)},void 0,!1,void 0,this),C&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm mx-4",children:[q.jsxDEV("p",{className:"text-center mb-4",children:C.message},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>D(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:C.onConfirm,className:"flex-1 text-sm bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition",children:"Confirm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&q.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[q.jsxDEV("span",{children:r},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>X(null),className:"text-red-400 hover:text-red-300",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&q.jsxDEV("div",{className:"text-yellow-400 text-sm p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg flex items-center gap-2",children:[q.jsxDEV("span",{className:"animate-spin",children:"⟳"},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Waiting for ",O.appSlug," authorization..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:q.jsxDEV("input",{type:"text",value:m,onChange:(z)=>Qq(z.target.value),placeholder:"Search apps...",className:"w-full bg-[#111] border border-[#333] rounded-lg px-4 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),E.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Connected (",E.length,")"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:E.map((z)=>q.jsxDEV(zq,{app:z,connection:t(z.slug),onConnect:()=>h(z),onDisconnect:()=>{let H=t(z.slug);if(H)Zq(H)},onCreateMcpConfig:K?void 0:()=>Xq(z),onBrowseTriggers:F?()=>F(z.slug):void 0,connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Available Apps (",S.length,")"]},void 0,!0,void 0,this),S.length===0?q.jsxDEV("p",{className:"text-[#666] text-sm",children:m?"No apps match your search":"No apps available"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:S.slice(0,50).map((z)=>q.jsxDEV(zq,{app:z,onConnect:()=>h(z),connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this),S.length>50&&q.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 50 of ",S.length," apps. Use search to find more."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zq({app:J,connection:Q,onConnect:k,onDisconnect:F,onCreateMcpConfig:K,onBrowseTriggers:Y,connecting:y}){let R=Q?.status==="active",L=i(J),P=Jq(J),M=L&&P;return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition ${R?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start gap-3",children:[q.jsxDEV("div",{className:"w-10 h-10 rounded bg-[#1a1a1a] flex items-center justify-center flex-shrink-0 overflow-hidden",children:J.logo?q.jsxDEV("img",{src:J.logo,alt:J.name,className:"w-8 h-8 object-contain",onError:(N)=>{N.target.style.display="none"}},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-lg",children:J.name[0]?.toUpperCase()},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("h4",{className:"font-medium text-sm truncate",children:J.name},void 0,!1,void 0,this),R&&q.jsxDEV("span",{className:"text-xs text-green-400",children:"✓"},void 0,!1,void 0,this),!R&&L&&!P&&q.jsxDEV("span",{className:"text-[10px] bg-[#222] text-[#888] px-1.5 py-0.5 rounded",title:"Requires API Key",children:"API Key"},void 0,!1,void 0,this),!R&&M&&q.jsxDEV("span",{className:"text-[10px] bg-[#1a2a1a] text-[#6a6] px-1.5 py-0.5 rounded",title:"Supports API Key or OAuth",children:"API Key / OAuth"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.description&&q.jsxDEV("p",{className:"text-xs text-[#666] line-clamp-2 mt-0.5",children:J.description},void 0,!1,void 0,this),J.categories.length>0&&q.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:J.categories.slice(0,2).map((N)=>q.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded",children:N},N,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 flex gap-2",children:R?q.jsxDEV(q.Fragment,{children:[K&&q.jsxDEV("button",{onClick:K,className:"flex-1 text-xs bg-[#1a2a1a] hover:bg-[#1a3a1a] border border-green-500/30 hover:border-green-500/50 text-green-400 px-3 py-1.5 rounded transition",children:"Create MCP Config"},void 0,!1,void 0,this),Y&&q.jsxDEV("button",{onClick:Y,className:"flex-1 text-xs bg-[#1a1a2a] hover:bg-[#1a1a3a] border border-blue-500/30 hover:border-blue-500/50 text-blue-400 px-3 py-1.5 rounded transition",children:"Browse Triggers"},void 0,!1,void 0,this),F&&q.jsxDEV("button",{onClick:F,className:"text-xs text-[#666] hover:text-red-400 transition px-2",title:"Disconnect",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("button",{onClick:k,disabled:y,className:"w-full text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:y?"Connecting...":L&&!P?"Enter API Key":"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
+ export{Rq as i};
3
+
4
+ //# debugId=27B8734D1AEED54064756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{Q as i,T as p,U as u}from"./App.g8vq68n0.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
+ export{g as P};
3
+
4
+ //# debugId=237C22B143A28DA764756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{i as cn}from"./App.6nc5acvk.js";import{P as A}from"./App.7vzbaz56.js";import{Q as K,T as vn,U as Z,aa as S,da as x}from"./App.g8vq68n0.js";var Sn=K(vn(),1);var u=K(vn(),1);var p=K(Z(),1);function dn(){let{authFetch:N}=S(),{currentProjectId:b}=x(),[O,U]=u.useState([]),[B,g]=u.useState([]),[H,F]=u.useState(!0);if(u.useEffect(()=>{(async()=>{F(!0);let Q=b&&b!=="unassigned"?`?project_id=${b}`:"";try{let[w,X]=await Promise.all([N(`/api/subscriptions${Q}`).catch(()=>null),N("/api/agents").catch(()=>null)]);if(w?.ok){let L=await w.json();U(L.subscriptions||[])}if(X?.ok){let L=await X.json();g(L.agents||[])}}catch(w){console.error("Failed to fetch overview data:",w)}F(!1)})()},[N,b]),H)return p.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let I=O.filter(($)=>$.enabled),P=O.filter(($)=>!$.enabled),q=new Map(B.map(($)=>[$.id,$]));return p.jsxDEV("div",{className:"space-y-6",children:[p.jsxDEV("div",{className:"grid grid-cols-3 gap-4",children:[p.jsxDEV(Kn,{label:"Active",value:I.length},void 0,!1,void 0,this),p.jsxDEV(Kn,{label:"Disabled",value:P.length},void 0,!1,void 0,this),p.jsxDEV(Kn,{label:"Total",value:O.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p.jsxDEV("section",{children:[p.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Subscriptions (",O.length,")"]},void 0,!0,void 0,this),O.length===0?p.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center text-[#666] text-sm",children:"No subscriptions yet. Go to the Triggers tab to create one."},void 0,!1,void 0,this):p.jsxDEV("div",{className:"space-y-2",children:O.map(($)=>{let Q=q.get($.agent_id);return p.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[p.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${$.enabled?"bg-green-400":"bg-[#555]"}`},void 0,!1,void 0,this),p.jsxDEV("div",{className:"flex-1 min-w-0",children:[p.jsxDEV("div",{className:"text-sm font-medium truncate",children:$.trigger_slug.replace(/_/g," ").replace(/-/g," ")},void 0,!1,void 0,this),p.jsxDEV("div",{className:"text-xs text-[#666]",children:$.trigger_instance_id?`ID: ${$.trigger_instance_id.slice(0,12)}...`:"All instances"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p.jsxDEV("div",{className:"text-xs text-[#888] flex-shrink-0",children:[p.jsxDEV("span",{className:"text-[#555]",children:"→"},void 0,!1,void 0,this)," ",p.jsxDEV("span",{className:"text-[#f97316]",children:Q?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p.jsxDEV("span",{className:`text-xs px-2 py-0.5 rounded flex-shrink-0 ${$.enabled?"bg-green-500/10 text-green-400":"bg-[#1a1a1a] text-[#555]"}`,children:$.enabled?"active":"disabled"},void 0,!1,void 0,this)]},$.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Kn({label:N,value:b,valueColor:O}){return p.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[p.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:N},void 0,!1,void 0,this),p.jsxDEV("div",{className:`text-2xl font-bold ${O||"text-[#e0e0e0]"}`,children:b},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var v=K(vn(),1);var C=K(Z(),1);function _l({message:N="Loading...",fullScreen:b=!1}){let O=C.jsxDEV("div",{className:"flex items-center gap-3 text-[#666]",children:[C.jsxDEV("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",children:[C.jsxDEV("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"},void 0,!1,void 0,this),C.jsxDEV("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.jsxDEV("span",{children:N},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(b)return C.jsxDEV("div",{className:"min-h-screen bg-[#0a0a0a] text-[#e0e0e0] font-mono flex items-center justify-center",children:O},void 0,!1,void 0,this);return C.jsxDEV("div",{className:"flex items-center justify-center py-20",children:O},void 0,!1,void 0,this)}var l=K(Z(),1);function Tn(){let{authFetch:N}=S(),{currentProjectId:b}=x(),[O,U]=v.useState([]),[B,g]=v.useState("composio"),[H,F]=v.useState([]),[I,P]=v.useState(!0),[q,$]=v.useState([]),[Q,w]=v.useState([]),[X,L]=v.useState(!1),[r,Un]=v.useState(""),[Nn,Wn]=v.useState(""),[xn,t]=v.useState(!1),[G,j]=v.useState(null),[fn,gn]=v.useState([]),[e,Jn]=v.useState(""),[an,nn]=v.useState(!1),[V,Xn]=v.useState(""),[bn,Yn]=v.useState({}),[Vn,_n]=v.useState(!1),[y,sn]=v.useState([]),[En,Zn]=v.useState(!1),[wn,Dn]=v.useState([]),[s,Ln]=v.useState(""),[d,Mn]=v.useState(""),[qn,Qn]=v.useState(!1),[pn,kn]=v.useState(""),[$n,Rn]=v.useState({}),[rn,ln]=v.useState(!1),[T,On]=v.useState(""),[mn,zn]=v.useState(""),[Cn,Fn]=v.useState(!1),[k,tn]=v.useState([]),[In,R]=v.useState(null),z=b&&b!=="unassigned"?`?project_id=${b}`:"",Pn=v.useCallback(async()=>{try{let n=await N(`/api/triggers/providers${z}`);if(n.ok){let m=await n.json();U(m.providers||[])}}catch(n){console.error("Failed to fetch providers:",n)}},[N]),h=v.useCallback(async()=>{P(!0);try{let n=`provider=${B}`,m=z?"&":"?",i=z?`/api/triggers${z}&${n}`:`/api/triggers?${n}`,f=await N(i);if(f.ok){let _=await f.json();F(_.triggers||[])}}catch(n){console.error("Failed to fetch triggers:",n)}P(!1)},[N,z,B]),E=v.useCallback(async()=>{try{let n=await N(`/api/subscriptions${z}`);if(n.ok){let m=await n.json();$(m.subscriptions||[])}}catch(n){console.error("Failed to fetch subscriptions:",n)}},[N,z]),yn=v.useCallback(async()=>{try{let n=await N("/api/agents");if(n.ok){let m=await n.json();tn(m.agents||[])}}catch(n){}},[N]);v.useEffect(()=>{Pn(),h(),E(),yn()},[Pn,h,E,yn]);let jn=async(n)=>{L(!0);try{let m=`/api/triggers/types?provider=${B}`;if(n)m+=`&toolkit_slugs=${n}`;if(b&&b!=="unassigned")m+=`&project_id=${b}`;let i=await N(m);if(i.ok){let f=await i.json();w(f.types||[])}else{let f=await i.json();R(f.error||"Failed to fetch trigger types")}}catch(m){R("Failed to fetch trigger types")}L(!1)},en=async()=>{try{let n=await N(`/api/integrations/${B}/connected${z}`);if(n.ok){let m=await n.json();gn((m.accounts||[]).filter((i)=>i.status==="active"))}}catch(n){}},nl=(n)=>{j(n),Jn(""),Xn(""),Yn({}),t(!0),en()},J=B==="agentdojo",ll=async()=>{_n(!0),Ln(""),Mn(""),kn(""),Rn({}),console.log("[openAddDojoSub] Opening modal, selectedProvider:",B),console.log("[openAddDojoSub] currentProjectId:",b,"projectParam:",z),console.log("[openAddDojoSub] existing dojoTriggerTypes:",y.length,"dojoAccounts:",wn.length);let n=async()=>{if(y.length>0){console.log("[openAddDojoSub] Already have",y.length,"trigger types, skipping fetch");return}Zn(!0);try{let i="/api/triggers/types?provider=agentdojo";if(b&&b!=="unassigned")i+=`&project_id=${b}`;console.log("[openAddDojoSub] Fetching trigger types:",i);let f=await N(i),_=await f.json();if(console.log("[openAddDojoSub] Trigger types response:",f.status,"ok:",f.ok,"types count:",(_.types||[]).length,"error:",_.error),_.types&&_.types.length>0)console.log("[openAddDojoSub] Sample trigger type:",JSON.stringify(_.types[0]));sn(_.types||[])}catch(i){console.error("[openAddDojoSub] Failed to load trigger types:",i)}Zn(!1)},m=async()=>{try{let i=`/api/integrations/agentdojo/connected${z}`;console.log("[openAddDojoSub] Fetching connected accounts:",i);let f=await N(i),_=await f.json();if(console.log("[openAddDojoSub] Connected accounts response:",f.status,"ok:",f.ok,"accounts count:",(_.accounts||[]).length,"error:",_.error),_.accounts&&_.accounts.length>0)console.log("[openAddDojoSub] Sample account:",JSON.stringify(_.accounts[0]));let M=(_.accounts||[]).filter((c)=>c.status==="active");console.log("[openAddDojoSub] Active accounts:",M.length),Dn(M)}catch(i){console.error("[openAddDojoSub] Failed to load connected accounts:",i)}};await Promise.all([n(),m()])},ml=async()=>{let n=y.find((i)=>i.slug===s),m=n?Gn(wn,n.toolkit_slug):null;if(console.log("[handleAddDojoSub] tt:",n?.slug,"matched:",m?.id,m?.appName,"agentId:",d),!n||!d||!m)return;Qn(!0),R(null);try{let i=k.find((bl)=>bl.id===d),f="provider=agentdojo",_=z?`/api/triggers${z}&provider=agentdojo`:"/api/triggers?provider=agentdojo",M={callback_url:`${window.location.origin}/api/webhooks/agentdojo`,title:`${n.name} → ${i?.name||"Agent"}`,server:n.toolkit_slug,agent_id:d,...$n};console.log("[handleAddDojoSub] config:",JSON.stringify(M));let c=await N(_,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:n.slug,connectedAccountId:m.id,config:M})}),al=await c.json();if(!c.ok)R(al.error||"Failed to create subscription");else _n(!1),h()}catch(i){R(i.message||"Failed to create subscription")}Qn(!1)},il=async()=>{if(!G)return;if(J){if(!V||!D)return;nn(!0),R(null);try{let n=k.find((c)=>c.id===V),m=window.location.origin,i=`provider=${B}`,f=z?`/api/triggers${z}&${i}`:`/api/triggers?${i}`,_=await N(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:G.slug,connectedAccountId:D.id,config:{callback_url:`${m}/api/webhooks/agentdojo`,title:`${G.name} → ${n?.name||"Agent"}`,server:G.toolkit_slug,agent_id:V,...bn}})}),M=await _.json();if(!_.ok)R(M.error||"Failed to create subscription");else t(!1),j(null),h()}catch(n){R(n.message||"Failed to create subscription")}nn(!1);return}if(!e)return;nn(!0),R(null);try{let n=`provider=${B}`,m=z?`/api/triggers${z}&${n}`:`/api/triggers?${n}`,i=await N(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:G.slug,connectedAccountId:e})}),f=await i.json();if(!i.ok)R(f.error||"Failed to create trigger");else t(!1),j(null),h()}catch(n){R(n.message||"Failed to create trigger")}nn(!1)},hn=async(n,m)=>{let i=m==="active"?"disable":"enable";try{let f=z?`&provider=${B}`:`?provider=${B}`,_=await N(`/api/triggers/${n}/${i}${z}${f}`,{method:"POST"});if(_.ok)h();else{let M=await _.json();R(M.error||`Failed to ${i} trigger`)}}catch(f){R(`Failed to ${i} trigger`)}},An=async(n)=>{try{let m=z?`&provider=${B}`:`?provider=${B}`,i=await N(`/api/triggers/${n}${z}${m}`,{method:"DELETE"});if(i.ok)h();else{let f=await i.json();R(f.error||"Failed to delete trigger")}}catch(m){R("Failed to delete trigger")}},vl=async()=>{if(!T||!mn)return;let n=H.find((m)=>m.id===T);if(!n)return;Fn(!0),R(null);try{let m=await N("/api/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trigger_slug:n.trigger_slug,trigger_instance_id:n.id,agent_id:mn,provider:B,project_id:b&&b!=="unassigned"?b:null,public_url:window.location.origin})}),i=await m.json();if(!m.ok)R(i.error||"Failed to create subscription");else ln(!1),On(""),zn(""),E()}catch(m){R(m.message||"Failed to create subscription")}Fn(!1)},Nl=async(n)=>{let m=n.enabled?"disable":"enable";try{if((await N(`/api/subscriptions/${n.id}/${m}`,{method:"POST"})).ok)E()}catch(i){R(`Failed to ${m} subscription`)}},fl=async(n)=>{try{if((await N(`/api/subscriptions/${n}`,{method:"DELETE"})).ok)E()}catch(m){R("Failed to delete subscription")}},Bn=Q.filter((n)=>{if(!Nn)return!0;let m=Nn.toLowerCase();return n.name.toLowerCase().includes(m)||n.slug.toLowerCase().includes(m)||n.description.toLowerCase().includes(m)}),Gn=(n,m)=>{if(!m||n.length===0)return null;let i=m.toLowerCase();return n.find((f)=>f.appId?.toLowerCase()===i||f.appName?.toLowerCase()===i||f.appId?.toLowerCase().includes(i)||f.appName?.toLowerCase().includes(i))||null},Y=y.find((n)=>n.slug===s),Hn=Y?Gn(wn,Y.toolkit_slug):null,D=G&&J?Gn(fn,G.toolkit_slug):null,on=new Map(k.map((n)=>[n.id,n]));return l.jsxDEV("div",{className:"space-y-6",children:[In&&l.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[l.jsxDEV("span",{children:In},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:()=>R(null),className:"text-red-400 hover:text-red-300",children:"x"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O.length>1&&l.jsxDEV("div",{className:"flex items-center gap-2",children:[l.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:O.map((n)=>l.jsxDEV("button",{onClick:()=>{g(n.id),w([]),Un(""),Wn("")},className:`px-3 py-1 rounded text-xs font-medium transition ${B===n.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[n.name,!n.connected&&l.jsxDEV("span",{className:"ml-1 text-[10px] text-yellow-500",title:"API key not configured",children:"!"},void 0,!1,void 0,this)]},n.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!J&&l.jsxDEV("section",{children:[l.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[l.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Subscriptions (",q.length,")"]},void 0,!0,void 0,this),l.jsxDEV("button",{onClick:()=>ln(!0),className:"text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition",children:"+ Add Subscription"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.length===0?l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center text-[#666] text-sm",children:"No subscriptions yet. Add one to route trigger events to an agent."},void 0,!1,void 0,this):l.jsxDEV("div",{className:"space-y-2",children:q.map((n)=>{let m=on.get(n.agent_id);return l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[l.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${n.enabled?"bg-green-400":"bg-[#666]"}`},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex-1 min-w-0",children:[l.jsxDEV("div",{className:"text-sm font-medium truncate",children:[n.trigger_slug.replace(/_/g," "),l.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),l.jsxDEV("span",{className:"text-[#f97316]",children:m?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"text-xs text-[#666]",children:n.trigger_instance_id?`Instance: ${n.trigger_instance_id.slice(0,12)}...`:"All instances"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxDEV("button",{onClick:()=>Nl(n),className:`text-xs px-3 py-1 rounded transition ${n.enabled?"bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20":"bg-green-500/10 text-green-400 hover:bg-green-500/20"}`,children:n.enabled?"Disable":"Enable"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:()=>fl(n.id),className:"text-xs text-[#666] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},n.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!J&&l.jsxDEV("section",{children:[l.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Trigger Instances (",H.length,")"]},void 0,!0,void 0,this),I?l.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading triggers..."},void 0,!1,void 0,this):H.length===0?l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center text-[#666] text-sm",children:"No trigger instances. Browse trigger types below to create one."},void 0,!1,void 0,this):l.jsxDEV("div",{className:"space-y-2",children:H.map((n)=>l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[l.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${n.status==="active"?"bg-green-400":"bg-[#666]"}`},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex-1 min-w-0",children:[l.jsxDEV("div",{className:"text-sm font-medium truncate",children:n.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),l.jsxDEV("div",{className:"text-xs text-[#666]",children:["ID: ",n.id.slice(0,12),"... | Created: ",new Date(n.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxDEV("button",{onClick:()=>hn(n.id,n.status),className:`text-xs px-3 py-1 rounded transition ${n.status==="active"?"bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20":"bg-green-500/10 text-green-400 hover:bg-green-500/20"}`,children:n.status==="active"?"Disable":"Enable"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:()=>An(n.id),className:"text-xs text-[#666] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},n.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J&&l.jsxDEV("section",{children:[l.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[l.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Active Subscriptions (",H.length,")"]},void 0,!0,void 0,this),l.jsxDEV("button",{onClick:ll,className:"text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition",children:"+ Add Subscription"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I?l.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading subscriptions..."},void 0,!1,void 0,this):H.length===0?l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center text-[#666] text-sm",children:"No active subscriptions. Browse trigger types below to create one."},void 0,!1,void 0,this):l.jsxDEV("div",{className:"space-y-2",children:H.map((n)=>{let m=q.find((f)=>f.trigger_instance_id===n.id),i=m?on.get(m.agent_id):null;return l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[l.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${n.status==="active"?"bg-green-400":"bg-[#666]"}`},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex-1 min-w-0",children:[l.jsxDEV("div",{className:"text-sm font-medium truncate",children:[n.config?.title||n.trigger_slug.replace(/_/g," "),i&&l.jsxDEV(l.Fragment,{children:[l.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),l.jsxDEV("span",{className:"text-[#f97316]",children:i.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"text-xs text-[#666]",children:[n.config?.server&&l.jsxDEV("span",{children:[String(n.config.server)," | "]},void 0,!0,void 0,this),"ID: ",String(n.id).slice(0,8)," | Created: ",new Date(n.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l.jsxDEV("button",{onClick:()=>hn(n.id,n.status),className:`text-xs px-3 py-1 rounded transition ${n.status==="active"?"bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20":"bg-green-500/10 text-green-400 hover:bg-green-500/20"}`,children:n.status==="active"?"Disable":"Enable"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:()=>An(n.id),className:"text-xs text-[#666] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},n.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("section",{children:[l.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:"Browse Trigger Types"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex gap-2 mb-3",children:[l.jsxDEV("input",{type:"text",value:r,onChange:(n)=>Un(n.target.value),placeholder:"Toolkit filter (e.g. github, gmail, slack)",className:"flex-1 bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:()=>jn(r||void 0),disabled:X,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded transition disabled:opacity-50",children:X?"Loading...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.length>0&&l.jsxDEV(l.Fragment,{children:[l.jsxDEV("input",{type:"text",value:Nn,onChange:(n)=>Wn(n.target.value),placeholder:"Search trigger types...",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm mb-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Bn.slice(0,30).map((n)=>l.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] hover:border-[#333] rounded-lg p-3 transition",children:[l.jsxDEV("div",{className:"flex items-start gap-3",children:[n.logo?l.jsxDEV("img",{src:n.logo,alt:n.toolkit_name,className:"w-8 h-8 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):l.jsxDEV("div",{className:"w-8 h-8 rounded bg-[#1a1a1a] flex items-center justify-center text-xs flex-shrink-0",children:n.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex-1 min-w-0",children:[l.jsxDEV("div",{className:"text-sm font-medium truncate",children:n.name},void 0,!1,void 0,this),l.jsxDEV("div",{className:"text-xs text-[#666]",children:n.toolkit_name},void 0,!1,void 0,this),l.jsxDEV("div",{className:"text-xs text-[#555] mt-1 line-clamp-2",children:n.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("button",{onClick:()=>nl(n),className:"w-full mt-3 text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition",children:J?"Subscribe":"Create Trigger"},void 0,!1,void 0,this)]},n.slug,!0,void 0,this))},void 0,!1,void 0,this),Bn.length>30&&l.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 30 of ",Bn.length," types. Use search to filter."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),xn&&G&&l.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:l.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[l.jsxDEV("h3",{className:"font-medium mb-1",children:J?"Create Subscription":"Create Trigger"},void 0,!1,void 0,this),l.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:[G.name,G.toolkit_name&&l.jsxDEV("span",{className:"text-[#555]",children:[" (",G.toolkit_name,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"space-y-4",children:[!J&&l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),fn.length===0?l.jsxDEV("div",{className:"text-xs text-[#666] bg-[#0a0a0a] rounded p-3",children:"No connected accounts available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):l.jsxDEV(A,{value:e,onChange:Jn,placeholder:"Select account...",options:fn.map((n)=>({value:n.id,label:`${n.appName} (${n.id.slice(0,8)}...)`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J&&l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Route to Agent"},void 0,!1,void 0,this),k.length===0?l.jsxDEV("div",{className:"text-xs text-[#666] bg-[#0a0a0a] rounded p-3",children:"No agents available. Create an agent first."},void 0,!1,void 0,this):l.jsxDEV(A,{value:V,onChange:Xn,placeholder:"Select agent...",options:k.map((n)=>({value:n.id,label:`${n.name} (${n.status})`}))},void 0,!1,void 0,this),l.jsxDEV("div",{className:"mt-3",children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),D?l.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",D.appName]},void 0,!0,void 0,this):l.jsxDEV("div",{className:"text-xs text-yellow-400 bg-yellow-500/10 border border-yellow-500/20 rounded p-3",children:["No connected account for ",G?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.config_schema&&Object.keys(G.config_schema.properties||{}).length>0&&l.jsxDEV("div",{className:"mt-3",children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"space-y-2",children:Object.entries(G.config_schema.properties||{}).map(([n,m])=>{let i=(G.config_schema.required||[]).includes(n);return l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[m.title||n,i&&l.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("input",{type:"text",value:bn[n]||"",onChange:(f)=>Yn((_)=>({..._,[n]:f.target.value})),placeholder:m.description||`Enter ${m.title||n}...`,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},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)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex gap-2 mt-4",children:[l.jsxDEV("button",{onClick:()=>{t(!1),j(null)},className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:il,disabled:J?!V||!D||an||G?.config_schema&&(G.config_schema.required||[]).some((n)=>!bn[n]?.trim()):!e||an,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:an?"Creating...":J?"Subscribe":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),rn&&l.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:l.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[l.jsxDEV("h3",{className:"font-medium mb-1",children:"Route Trigger to Agent"},void 0,!1,void 0,this),l.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:H.length===0?"No trigger instances yet. Create one first from the Browse section below.":"Select a trigger instance and the agent that should handle its events."},void 0,!1,void 0,this),H.length>0?l.jsxDEV(l.Fragment,{children:[l.jsxDEV("div",{className:"space-y-4",children:[l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger Instance"},void 0,!1,void 0,this),l.jsxDEV(A,{value:T,onChange:On,placeholder:"Select trigger...",options:H.map((n)=>({value:n.id,label:`${n.trigger_slug.replace(/_/g," ")}`}))},void 0,!1,void 0,this),T&&l.jsxDEV("div",{className:"text-xs text-[#555] mt-1 font-mono",children:["ID: ",T.slice(0,16),"..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),l.jsxDEV(A,{value:mn,onChange:zn,placeholder:"Select agent...",options:k.map((n)=>({value:n.id,label:`${n.name} (${n.status})`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex gap-2 mt-5",children:[l.jsxDEV("button",{onClick:()=>{ln(!1),On(""),zn("")},className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:vl,disabled:!T||!mn||Cn,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:Cn?"Adding...":"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):l.jsxDEV("div",{className:"flex gap-2 mt-4",children:l.jsxDEV("button",{onClick:()=>ln(!1),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Close"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Vn&&l.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:l.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-lg mx-4",children:[l.jsxDEV("h3",{className:"font-medium mb-1",children:"Add Subscription"},void 0,!1,void 0,this),l.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:"Select a trigger from your connected apps and route it to an agent."},void 0,!1,void 0,this),l.jsxDEV("div",{className:"space-y-4",children:[l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger"},void 0,!1,void 0,this),En?l.jsxDEV("div",{className:"text-xs text-[#666] bg-[#0a0a0a] rounded p-3",children:"Loading triggers..."},void 0,!1,void 0,this):y.length===0?l.jsxDEV("div",{className:"text-xs text-[#666] bg-[#0a0a0a] rounded p-3",children:"No triggers available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):l.jsxDEV(l.Fragment,{children:[l.jsxDEV("input",{type:"text",value:pn,onChange:(n)=>kn(n.target.value),placeholder:"Search triggers...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm mb-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"max-h-48 overflow-y-auto border border-[#1a1a1a] rounded-lg",children:y.filter((n)=>{if(!pn)return!0;let m=pn.toLowerCase();return n.name.toLowerCase().includes(m)||n.slug.toLowerCase().includes(m)||n.toolkit_name.toLowerCase().includes(m)}).slice(0,50).map((n)=>l.jsxDEV("button",{onClick:()=>{Ln(n.slug),Rn({})},className:`w-full text-left px-3 py-2 text-sm flex items-center gap-2 transition border-b border-[#1a1a1a] last:border-0 ${s===n.slug?"bg-[#f97316]/10 text-[#f97316]":"hover:bg-[#1a1a1a] text-[#ccc]"}`,children:[n.logo?l.jsxDEV("img",{src:n.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):l.jsxDEV("div",{className:"w-5 h-5 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0",children:n.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"flex-1 min-w-0",children:[l.jsxDEV("div",{className:"truncate",children:n.name},void 0,!1,void 0,this),l.jsxDEV("div",{className:"text-[10px] text-[#666] truncate",children:n.toolkit_name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},n.slug,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),s&&l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),Hn?l.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",Hn.appName]},void 0,!0,void 0,this):l.jsxDEV("div",{className:"text-xs text-yellow-400 bg-yellow-500/10 border border-yellow-500/20 rounded p-3",children:["No connected account for ",Y?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Y&&Y.config_schema&&Object.keys(Y.config_schema.properties||{}).length>0&&l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),l.jsxDEV("div",{className:"space-y-2",children:Object.entries(Y.config_schema.properties||{}).map(([n,m])=>{let i=(Y.config_schema.required||[]).includes(n);return l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[m.title||n,i&&l.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("input",{type:"text",value:$n[n]||"",onChange:(f)=>Rn((_)=>({..._,[n]:f.target.value})),placeholder:m.description||`Enter ${m.title||n}...`,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},n,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{children:[l.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),k.length===0?l.jsxDEV("div",{className:"text-xs text-[#666] bg-[#0a0a0a] rounded p-3",children:"No agents available. Create an agent first."},void 0,!1,void 0,this):l.jsxDEV(A,{value:d,onChange:Mn,placeholder:"Select agent...",options:k.map((n)=>({value:n.id,label:`${n.name} (${n.status})`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:"flex gap-2 mt-5",children:[l.jsxDEV("button",{onClick:()=>_n(!1),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),l.jsxDEV("button",{onClick:ml,disabled:!s||!d||!Hn||qn||Y?.config_schema&&(Y.config_schema.required||[]).some((n)=>!$n[n]?.trim()),className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:qn?"Creating...":"Subscribe"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var o=K(vn(),1);var a=K(Z(),1);function un(){let{authFetch:N}=S(),{currentProjectId:b}=x(),O=b&&b!=="unassigned"?b:null,[U,B]=o.useState("composio"),g=[{id:"composio",name:"Composio"},{id:"agentdojo",name:"AgentDojo"}],[H,F]=o.useState(null),[I,P]=o.useState([]),[q,$]=o.useState(!1),Q=o.useCallback(async(w)=>{F(w),$(!0);try{let X=`/api/triggers/types?provider=${U}&toolkit_slugs=${w}`;if(O)X+=`&project_id=${O}`;let L=await N(X);if(L.ok){let r=await L.json();P(r.types||[])}}catch(X){console.error("Failed to fetch trigger types:",X)}$(!1)},[N,O,U]);return a.jsxDEV("div",{children:[a.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect external apps via OAuth or API Key. Connected apps can be used for triggers and MCP integrations."},void 0,!1,void 0,this),a.jsxDEV("div",{className:"flex items-center gap-2 mb-4",children:[a.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),a.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:g.map((w)=>a.jsxDEV("button",{onClick:()=>B(w.id),className:`px-3 py-1 rounded text-xs font-medium transition ${U===w.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:w.name},w.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.jsxDEV(cn,{providerId:U,projectId:O,hideMcpConfig:!0,onBrowseTriggers:Q},void 0,!1,void 0,this),H&&a.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[a.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[a.jsxDEV("div",{children:[a.jsxDEV("h3",{className:"font-medium",children:"Trigger Types"},void 0,!1,void 0,this),a.jsxDEV("p",{className:"text-xs text-[#666]",children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.jsxDEV("button",{onClick:()=>{F(null),P([])},className:"text-[#666] hover:text-white transition text-lg px-2",children:"x"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:q?a.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading trigger types..."},void 0,!1,void 0,this):I.length===0?a.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No trigger types available for this app."},void 0,!1,void 0,this):a.jsxDEV("div",{className:"space-y-2",children:I.map((w)=>a.jsxDEV("div",{className:"bg-[#0a0a0a] border border-[#1a1a1a] rounded-lg p-3",children:a.jsxDEV("div",{className:"flex items-start gap-3",children:[w.logo?a.jsxDEV("img",{src:w.logo,alt:w.toolkit_name,className:"w-6 h-6 rounded object-contain flex-shrink-0 mt-0.5"},void 0,!1,void 0,this):a.jsxDEV("div",{className:"w-6 h-6 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0 mt-0.5",children:w.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),a.jsxDEV("div",{className:"flex-1 min-w-0",children:[a.jsxDEV("div",{className:"text-sm font-medium",children:w.name},void 0,!1,void 0,this),a.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:w.description},void 0,!1,void 0,this),a.jsxDEV("div",{className:"flex items-center gap-2 mt-1.5",children:[a.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded font-mono",children:w.slug},void 0,!1,void 0,this),a.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${w.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:w.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},w.slug,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var W=K(Z(),1);function sl(){let[N,b]=Sn.useState("overview");return W.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:W.jsxDEV("div",{className:"max-w-6xl",children:[W.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:W.jsxDEV("div",{children:[W.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Connections"},void 0,!1,void 0,this),W.jsxDEV("p",{className:"text-[#666]",children:"Manage external app connections, triggers, and webhooks."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),W.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[{id:"overview",label:"Overview"},{id:"triggers",label:"Triggers"},{id:"integrations",label:"Integrations"}].map((U)=>W.jsxDEV("button",{onClick:()=>b(U.id),className:`px-4 py-2 rounded text-sm font-medium transition ${N===U.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:U.label},U.id,!1,void 0,this))},void 0,!1,void 0,this),N==="overview"&&W.jsxDEV(dn,{},void 0,!1,void 0,this),N==="triggers"&&W.jsxDEV(Tn,{},void 0,!1,void 0,this),N==="integrations"&&W.jsxDEV(un,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
2
+ export{_l as a,sl as b};
3
+
4
+ //# debugId=805EA685099AB3D564756E2164756E21
@@ -0,0 +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)}
2
+ export{Mz as h};
3
+
4
+ //# debugId=5835E74D4CBA249B64756E2164756E21