apteva 0.4.19 → 0.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/ActivityPage.h769ek3a.js +3 -0
  2. package/dist/{ApiDocsPage.rfpf7ws1.js → ApiDocsPage.kf6bbwkk.js} +1 -1
  3. package/dist/{App.7vzbaz56.js → App.039re6cf.js} +1 -1
  4. package/dist/{App.amwp54wf.js → App.2jmkqm8c.js} +1 -1
  5. package/dist/{App.p93mmyqw.js → App.2yy66bnp.js} +1 -1
  6. package/dist/{App.f8qsyhpr.js → App.3515wsb4.js} +1 -1
  7. package/dist/{App.6nc5acvk.js → App.7v1w3ys9.js} +1 -1
  8. package/dist/{App.sdsc0258.js → App.c90t3dxg.js} +1 -1
  9. package/dist/{App.5qw2dtxs.js → App.edwahsvz.js} +1 -1
  10. package/dist/{App.qmg33p02.js → App.jfx3der4.js} +1 -1
  11. package/dist/{App.kfyrnznw.js → App.n4jb3c22.js} +1 -1
  12. package/dist/App.q3bpx15d.js +20 -0
  13. package/dist/{App.e4202qb4.js → App.r0a2nmqs.js} +84 -84
  14. package/dist/{App.8rfz30p1.js → App.s2yrcz15.js} +1 -1
  15. package/dist/{App.1nmg2h01.js → App.s5j82a5j.js} +1 -1
  16. package/dist/{App.errxz2q4.js → App.tg1b94tx.js} +1 -1
  17. package/dist/ConnectionsPage.a67fjgbf.js +3 -0
  18. package/dist/McpPage.d4p3xvtk.js +3 -0
  19. package/dist/SettingsPage.46sqpe39.js +3 -0
  20. package/dist/SkillsPage.j9hkqm99.js +3 -0
  21. package/dist/TasksPage.6pvkb7s7.js +3 -0
  22. package/dist/TelemetryPage.5zq9msb5.js +3 -0
  23. package/dist/TestsPage.24432yqt.js +3 -0
  24. package/dist/index.html +1 -1
  25. package/package.json +1 -1
  26. package/src/mcp-platform.ts +353 -2
  27. package/src/routes/api/agents.ts +15 -2
  28. package/src/routes/api/system.ts +12 -1
  29. package/src/routes/auth.ts +11 -2
  30. package/src/web/App.tsx +1 -1
  31. package/src/web/components/dashboard/Dashboard.tsx +5 -4
  32. package/src/web/context/AuthContext.tsx +18 -11
  33. package/src/web/hooks/useAgents.ts +7 -3
  34. package/src/web/hooks/useOnboarding.ts +9 -30
  35. package/dist/ActivityPage.9a1qg4bp.js +0 -3
  36. package/dist/App.g8vq68n0.js +0 -20
  37. package/dist/ConnectionsPage.7zqba1r0.js +0 -3
  38. package/dist/McpPage.kf2g327t.js +0 -3
  39. package/dist/SettingsPage.472c15ep.js +0 -3
  40. package/dist/SkillsPage.xdxnh68a.js +0 -3
  41. package/dist/TasksPage.7g0b8xwc.js +0 -3
  42. package/dist/TelemetryPage.pr7rbz4r.js +0 -3
  43. package/dist/TestsPage.zhc6rqjm.js +0 -3
@@ -1,4 +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)}
1
+ import{i as cn}from"./App.7v1w3ys9.js";import{P as A}from"./App.039re6cf.js";import{Q as K,T as vn,U as Z,aa as S,da as x}from"./App.q3bpx15d.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
2
  export{_l as a,sl as b};
3
3
 
4
4
  //# debugId=805EA685099AB3D564756E2164756E21
@@ -1,4 +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`}
1
+ import{k as h}from"./App.c90t3dxg.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.q3bpx15d.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
2
  export{I as d};
3
3
 
4
4
  //# debugId=179E59998F7EBC2064756E2164756E21
@@ -1,4 +1,4 @@
1
- import{P}from"./App.7vzbaz56.js";import{Q as N,T as Qq,U as c,W as o,aa as E,da as u}from"./App.g8vq68n0.js";var K=N(Qq(),1);var z=N(c(),1);function i(W){let H=W.category==="LLM",X=W.category==="TOOL",M=W.level==="error",$=W.data?.input_tokens||0,Z=W.data?.output_tokens||0;return{llm_calls:H?1:0,tool_calls:X?1:0,errors:M?1:0,input_tokens:$,output_tokens:Z}}function _q(){let{events:W,statusChangeCounter:H}=o(),{currentProjectId:X,currentProject:M}=u(),{authFetch:$}=E(),[Z,l]=K.useState(null),[C,v]=K.useState([]),[I,d]=K.useState([]),[r,h]=K.useState(!0),[Y,p]=K.useState({level:"",agent_id:""}),[k,n]=K.useState(new Set(["DATABASE"])),[R,a]=K.useState([]),[S,s]=K.useState(null),T=K.useRef(new Set),[t,m]=K.useState(new Set),f=K.useRef(new Set);K.useEffect(()=>{(async()=>{try{let G=await(await $("/api/agents")).json();a(G.agents||[])}catch(B){console.error("Failed to fetch agents:",B)}})()},[$]);let w=K.useMemo(()=>{if(X===null)return R;if(X==="unassigned")return R.filter((q)=>!q.projectId);return R.filter((q)=>q.projectId===X)},[R,X]),V=K.useMemo(()=>new Set(w.map((q)=>q.id)),[w]),g=async()=>{h(!0);try{let q=X==="unassigned"?"null":X||"",B=new URLSearchParams;if(q)B.set("project_id",q);let Q=await(await $(`/api/telemetry/stats${B.toString()?`?${B}`:""}`)).json();l(Q.stats);let J=new URLSearchParams;if(Y.level)J.set("level",Y.level);if(Y.agent_id)J.set("agent_id",Y.agent_id);if(q)J.set("project_id",q);J.set("limit","100");let O=(await(await $(`/api/telemetry/events?${J}`)).json()).events||[];v(O),T.current=new Set(O.map((Kq)=>Kq.id));let b=new URLSearchParams;if(b.set("group_by","agent"),q)b.set("project_id",q);let Jq=await(await $(`/api/telemetry/usage?${b}`)).json();d(Jq.usage||[])}catch(q){console.error("Failed to fetch telemetry:",q)}h(!1)};K.useEffect(()=>{g()},[Y,X,$,H]);let U=K.useMemo(()=>{if(!Z)return null;let q=0,B=0,G=0,Q=0,J=0,A=0;for(let y of W)if(!T.current.has(y.id)){q++;let O=i(y);B+=O.llm_calls,G+=O.tool_calls,Q+=O.errors,J+=O.input_tokens,A+=O.output_tokens}return{total_events:Z.total_events+q,total_llm_calls:Z.total_llm_calls+B,total_tool_calls:Z.total_tool_calls+G,total_errors:Z.total_errors+Q,total_input_tokens:Z.total_input_tokens+J,total_output_tokens:Z.total_output_tokens+A}},[Z,W]),D=K.useMemo(()=>{let q=new Map;for(let B of I)q.set(B.agent_id,{...B});for(let B of W)if(!T.current.has(B.id)){let G=i(B),Q=q.get(B.agent_id);if(Q)Q.llm_calls+=G.llm_calls,Q.tool_calls+=G.tool_calls,Q.errors+=G.errors,Q.input_tokens+=G.input_tokens,Q.output_tokens+=G.output_tokens;else q.set(B.agent_id,{agent_id:B.agent_id,llm_calls:G.llm_calls,tool_calls:G.tool_calls,errors:G.errors,input_tokens:G.input_tokens,output_tokens:G.output_tokens})}return Array.from(q.values())},[I,W]),F=K.default.useMemo(()=>{let q=W;if(X!==null)q=q.filter((J)=>V.has(J.agent_id));if(Y.agent_id)q=q.filter((J)=>J.agent_id===Y.agent_id);if(k.size>0)q=q.filter((J)=>!k.has(J.category));if(Y.level)q=q.filter((J)=>J.level===Y.level);let B=C;if(k.size>0)B=B.filter((J)=>!k.has(J.category));let G=new Set(q.map((J)=>J.id)),Q=[...q];for(let J of B)if(!G.has(J.id))Q.push(J),G.add(J.id);return Q.sort((J,A)=>new Date(A.timestamp).getTime()-new Date(J.timestamp).getTime()),Q.slice(0,100)},[W,C,Y,k,X,V]);K.useEffect(()=>{let q=[];for(let B of W)if(!f.current.has(B.id))f.current.add(B.id),q.push(B.id);if(q.length>0)m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.add(Q)),G}),setTimeout(()=>{m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.delete(Q)),G})},5000)},[W]);let x=(q)=>{return R.find((G)=>G.id===q)?.name||q},_=(q)=>{if(q>=1e6)return(q/1e6).toFixed(1)+"M";if(q>=1000)return(q/1000).toFixed(1)+"K";return q.toString()},e={debug:"text-[#555]",info:"text-blue-400",warn:"text-yellow-400",error:"text-red-400"},j={LLM:"bg-purple-500/20 text-purple-400 border-purple-500/30",TOOL:"bg-blue-500/20 text-blue-400 border-blue-500/30",CHAT:"bg-green-500/20 text-green-400 border-green-500/30",ERROR:"bg-red-500/20 text-red-400 border-red-500/30",SYSTEM:"bg-gray-500/20 text-gray-400 border-gray-500/30",TASK:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",MEMORY:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",MCP:"bg-orange-500/20 text-orange-400 border-orange-500/30",DATABASE:"bg-pink-500/20 text-pink-400 border-pink-500/30"},qq=["LLM","TOOL","CHAT","TASK","MEMORY","MCP","SYSTEM","DATABASE","ERROR"],zq=(q)=>{n((B)=>{let G=new Set(B);if(G.has(q))G.delete(q);else G.add(q);return G})},Bq=[{value:"",label:"All Agents"},...w.map((q)=>({value:q.id,label:q.name}))],Gq=[{value:"",label:"All Levels"},{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}];return z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:[M&&z.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:M.color}},void 0,!1,void 0,this),z.jsxDEV("h1",{className:"text-2xl font-semibold",children:X===null?"Telemetry":X==="unassigned"?"Telemetry - Unassigned":`Telemetry - ${M?.name||""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Monitor agent activity, token usage, and errors."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&z.jsxDEV("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:[z.jsxDEV(L,{label:"Events",value:_(U.total_events)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"LLM Calls",value:_(U.total_llm_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Tool Calls",value:_(U.total_tool_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Errors",value:_(U.total_errors),color:"red"},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Input Tokens",value:_(U.total_input_tokens)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Output Tokens",value:_(U.total_output_tokens)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.length>0&&z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("h2",{className:"text-lg font-medium mb-3",children:"Usage by Agent"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:z.jsxDEV("table",{className:"w-full text-sm",children:[z.jsxDEV("thead",{children:z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] text-[#666]",children:[z.jsxDEV("th",{className:"text-left p-3",children:"Agent"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"LLM Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Tool Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Input Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Output Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Errors"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("tbody",{children:D.map((q)=>z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] last:border-0",children:[z.jsxDEV("td",{className:"p-3 font-medium",children:x(q.agent_id)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.llm_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.tool_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.input_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.output_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right",children:q.errors>0?z.jsxDEV("span",{className:"text-red-400",children:q.errors},void 0,!1,void 0,this):z.jsxDEV("span",{className:"text-[#444]",children:"0"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.agent_id,!0,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),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[z.jsxDEV("div",{className:"w-44",children:z.jsxDEV(P,{value:Y.agent_id,options:Bq,onChange:(q)=>p({...Y,agent_id:q}),placeholder:"All Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-1.5 flex-1",children:qq.map((q)=>{let B=k.has(q),G=j[q]||"bg-[#222] text-[#888] border-[#333]";return z.jsxDEV("button",{onClick:()=>zq(q),className:`px-2 py-0.5 rounded text-xs border transition-all ${B?"bg-[#1a1a1a] text-[#555] border-[#333] opacity-50":G}`,children:q},q,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("div",{className:"w-36",children:z.jsxDEV(P,{value:Y.level,options:Gq,onChange:(q)=>p({...Y,level:q}),placeholder:"All Levels"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:g,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] border border-[#333] rounded text-sm transition",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("div",{className:"p-3 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("h2",{className:"font-medium",children:"Recent Events"},void 0,!1,void 0,this),W.length>0&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:[W.length," new"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r&&F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"Loading..."},void 0,!1,void 0,this):F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"No telemetry events yet. Events will appear here in real-time once agents start sending data."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:F.map((q)=>{let B=t.has(q.id);return z.jsxDEV("div",{className:`p-3 hover:bg-[#0a0a0a] cursor-pointer transition-all duration-500 ${B?"bg-green-500/5":""}`,style:{animation:B?"slideIn 0.3s ease-out":void 0},onClick:()=>s(S===q.id?null:q.id),children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[z.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs border transition-colors duration-300 ${j[q.category]||"bg-[#222] text-[#888] border-[#333]"}`,children:q.category},void 0,!1,void 0,this),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:q.type},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs ${e[q.level]||"text-[#666]"}`,children:q.level},void 0,!1,void 0,this),q.duration_ms&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:[q.duration_ms,"ms"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`w-1.5 h-1.5 rounded-full bg-green-400 transition-opacity duration-1000 ${B?"opacity-100":"opacity-0"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#555] mt-1",children:[x(q.agent_id)," · ",new Date(q.timestamp).toLocaleString()]},void 0,!0,void 0,this),q.error&&z.jsxDEV("div",{className:"text-xs text-red-400 mt-1 font-mono",children:q.error},void 0,!1,void 0,this),S===q.id&&q.data&&Object.keys(q.data).length>0&&z.jsxDEV("pre",{className:"text-xs text-[#666] mt-2 p-2 bg-[#0a0a0a] rounded overflow-x-auto",children:JSON.stringify(q.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},q.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,!1,void 0,this)}function L({label:W,value:H,color:X}){return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[z.jsxDEV("div",{className:"text-[#666] text-xs mb-1",children:W},void 0,!1,void 0,this),z.jsxDEV("div",{className:`text-2xl font-semibold ${X==="red"?"text-red-400":""}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
1
+ import{P}from"./App.039re6cf.js";import{Q as N,T as Qq,U as c,W as o,aa as E,da as u}from"./App.q3bpx15d.js";var K=N(Qq(),1);var z=N(c(),1);function i(W){let H=W.category==="LLM",X=W.category==="TOOL",M=W.level==="error",$=W.data?.input_tokens||0,Z=W.data?.output_tokens||0;return{llm_calls:H?1:0,tool_calls:X?1:0,errors:M?1:0,input_tokens:$,output_tokens:Z}}function _q(){let{events:W,statusChangeCounter:H}=o(),{currentProjectId:X,currentProject:M}=u(),{authFetch:$}=E(),[Z,l]=K.useState(null),[C,v]=K.useState([]),[I,d]=K.useState([]),[r,h]=K.useState(!0),[Y,p]=K.useState({level:"",agent_id:""}),[k,n]=K.useState(new Set(["DATABASE"])),[R,a]=K.useState([]),[S,s]=K.useState(null),T=K.useRef(new Set),[t,m]=K.useState(new Set),f=K.useRef(new Set);K.useEffect(()=>{(async()=>{try{let G=await(await $("/api/agents")).json();a(G.agents||[])}catch(B){console.error("Failed to fetch agents:",B)}})()},[$]);let w=K.useMemo(()=>{if(X===null)return R;if(X==="unassigned")return R.filter((q)=>!q.projectId);return R.filter((q)=>q.projectId===X)},[R,X]),V=K.useMemo(()=>new Set(w.map((q)=>q.id)),[w]),g=async()=>{h(!0);try{let q=X==="unassigned"?"null":X||"",B=new URLSearchParams;if(q)B.set("project_id",q);let Q=await(await $(`/api/telemetry/stats${B.toString()?`?${B}`:""}`)).json();l(Q.stats);let J=new URLSearchParams;if(Y.level)J.set("level",Y.level);if(Y.agent_id)J.set("agent_id",Y.agent_id);if(q)J.set("project_id",q);J.set("limit","100");let O=(await(await $(`/api/telemetry/events?${J}`)).json()).events||[];v(O),T.current=new Set(O.map((Kq)=>Kq.id));let b=new URLSearchParams;if(b.set("group_by","agent"),q)b.set("project_id",q);let Jq=await(await $(`/api/telemetry/usage?${b}`)).json();d(Jq.usage||[])}catch(q){console.error("Failed to fetch telemetry:",q)}h(!1)};K.useEffect(()=>{g()},[Y,X,$,H]);let U=K.useMemo(()=>{if(!Z)return null;let q=0,B=0,G=0,Q=0,J=0,A=0;for(let y of W)if(!T.current.has(y.id)){q++;let O=i(y);B+=O.llm_calls,G+=O.tool_calls,Q+=O.errors,J+=O.input_tokens,A+=O.output_tokens}return{total_events:Z.total_events+q,total_llm_calls:Z.total_llm_calls+B,total_tool_calls:Z.total_tool_calls+G,total_errors:Z.total_errors+Q,total_input_tokens:Z.total_input_tokens+J,total_output_tokens:Z.total_output_tokens+A}},[Z,W]),D=K.useMemo(()=>{let q=new Map;for(let B of I)q.set(B.agent_id,{...B});for(let B of W)if(!T.current.has(B.id)){let G=i(B),Q=q.get(B.agent_id);if(Q)Q.llm_calls+=G.llm_calls,Q.tool_calls+=G.tool_calls,Q.errors+=G.errors,Q.input_tokens+=G.input_tokens,Q.output_tokens+=G.output_tokens;else q.set(B.agent_id,{agent_id:B.agent_id,llm_calls:G.llm_calls,tool_calls:G.tool_calls,errors:G.errors,input_tokens:G.input_tokens,output_tokens:G.output_tokens})}return Array.from(q.values())},[I,W]),F=K.default.useMemo(()=>{let q=W;if(X!==null)q=q.filter((J)=>V.has(J.agent_id));if(Y.agent_id)q=q.filter((J)=>J.agent_id===Y.agent_id);if(k.size>0)q=q.filter((J)=>!k.has(J.category));if(Y.level)q=q.filter((J)=>J.level===Y.level);let B=C;if(k.size>0)B=B.filter((J)=>!k.has(J.category));let G=new Set(q.map((J)=>J.id)),Q=[...q];for(let J of B)if(!G.has(J.id))Q.push(J),G.add(J.id);return Q.sort((J,A)=>new Date(A.timestamp).getTime()-new Date(J.timestamp).getTime()),Q.slice(0,100)},[W,C,Y,k,X,V]);K.useEffect(()=>{let q=[];for(let B of W)if(!f.current.has(B.id))f.current.add(B.id),q.push(B.id);if(q.length>0)m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.add(Q)),G}),setTimeout(()=>{m((B)=>{let G=new Set(B);return q.forEach((Q)=>G.delete(Q)),G})},5000)},[W]);let x=(q)=>{return R.find((G)=>G.id===q)?.name||q},_=(q)=>{if(q>=1e6)return(q/1e6).toFixed(1)+"M";if(q>=1000)return(q/1000).toFixed(1)+"K";return q.toString()},e={debug:"text-[#555]",info:"text-blue-400",warn:"text-yellow-400",error:"text-red-400"},j={LLM:"bg-purple-500/20 text-purple-400 border-purple-500/30",TOOL:"bg-blue-500/20 text-blue-400 border-blue-500/30",CHAT:"bg-green-500/20 text-green-400 border-green-500/30",ERROR:"bg-red-500/20 text-red-400 border-red-500/30",SYSTEM:"bg-gray-500/20 text-gray-400 border-gray-500/30",TASK:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",MEMORY:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",MCP:"bg-orange-500/20 text-orange-400 border-orange-500/30",DATABASE:"bg-pink-500/20 text-pink-400 border-pink-500/30"},qq=["LLM","TOOL","CHAT","TASK","MEMORY","MCP","SYSTEM","DATABASE","ERROR"],zq=(q)=>{n((B)=>{let G=new Set(B);if(G.has(q))G.delete(q);else G.add(q);return G})},Bq=[{value:"",label:"All Agents"},...w.map((q)=>({value:q.id,label:q.name}))],Gq=[{value:"",label:"All Levels"},{value:"debug",label:"Debug"},{value:"info",label:"Info"},{value:"warn",label:"Warn"},{value:"error",label:"Error"}];return z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("div",{className:"flex items-center gap-3 mb-1",children:[M&&z.jsxDEV("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:M.color}},void 0,!1,void 0,this),z.jsxDEV("h1",{className:"text-2xl font-semibold",children:X===null?"Telemetry":X==="unassigned"?"Telemetry - Unassigned":`Telemetry - ${M?.name||""}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Monitor agent activity, token usage, and errors."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&z.jsxDEV("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-6",children:[z.jsxDEV(L,{label:"Events",value:_(U.total_events)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"LLM Calls",value:_(U.total_llm_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Tool Calls",value:_(U.total_tool_calls)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Errors",value:_(U.total_errors),color:"red"},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Input Tokens",value:_(U.total_input_tokens)},void 0,!1,void 0,this),z.jsxDEV(L,{label:"Output Tokens",value:_(U.total_output_tokens)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D.length>0&&z.jsxDEV("div",{className:"mb-6",children:[z.jsxDEV("h2",{className:"text-lg font-medium mb-3",children:"Usage by Agent"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:z.jsxDEV("table",{className:"w-full text-sm",children:[z.jsxDEV("thead",{children:z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] text-[#666]",children:[z.jsxDEV("th",{className:"text-left p-3",children:"Agent"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"LLM Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Tool Calls"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Input Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Output Tokens"},void 0,!1,void 0,this),z.jsxDEV("th",{className:"text-right p-3",children:"Errors"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("tbody",{children:D.map((q)=>z.jsxDEV("tr",{className:"border-b border-[#1a1a1a] last:border-0",children:[z.jsxDEV("td",{className:"p-3 font-medium",children:x(q.agent_id)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.llm_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.tool_calls)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.input_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right text-[#888]",children:_(q.output_tokens)},void 0,!1,void 0,this),z.jsxDEV("td",{className:"p-3 text-right",children:q.errors>0?z.jsxDEV("span",{className:"text-red-400",children:q.errors},void 0,!1,void 0,this):z.jsxDEV("span",{className:"text-[#444]",children:"0"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},q.agent_id,!0,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),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[z.jsxDEV("div",{className:"w-44",children:z.jsxDEV(P,{value:Y.agent_id,options:Bq,onChange:(q)=>p({...Y,agent_id:q}),placeholder:"All Agents"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap items-center gap-1.5 flex-1",children:qq.map((q)=>{let B=k.has(q),G=j[q]||"bg-[#222] text-[#888] border-[#333]";return z.jsxDEV("button",{onClick:()=>zq(q),className:`px-2 py-0.5 rounded text-xs border transition-all ${B?"bg-[#1a1a1a] text-[#555] border-[#333] opacity-50":G}`,children:q},q,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("div",{className:"w-36",children:z.jsxDEV(P,{value:Y.level,options:Gq,onChange:(q)=>p({...Y,level:q}),placeholder:"All Levels"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:g,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] border border-[#333] rounded text-sm transition",children:"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("div",{className:"p-3 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("h2",{className:"font-medium",children:"Recent Events"},void 0,!1,void 0,this),W.length>0&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:[W.length," new"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r&&F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"Loading..."},void 0,!1,void 0,this):F.length===0?z.jsxDEV("div",{className:"p-8 text-center text-[#666]",children:"No telemetry events yet. Events will appear here in real-time once agents start sending data."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"divide-y divide-[#1a1a1a]",children:F.map((q)=>{let B=t.has(q.id);return z.jsxDEV("div",{className:`p-3 hover:bg-[#0a0a0a] cursor-pointer transition-all duration-500 ${B?"bg-green-500/5":""}`,style:{animation:B?"slideIn 0.3s ease-out":void 0},onClick:()=>s(S===q.id?null:q.id),children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[z.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs border transition-colors duration-300 ${j[q.category]||"bg-[#222] text-[#888] border-[#333]"}`,children:q.category},void 0,!1,void 0,this),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:q.type},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-xs ${e[q.level]||"text-[#666]"}`,children:q.level},void 0,!1,void 0,this),q.duration_ms&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:[q.duration_ms,"ms"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`w-1.5 h-1.5 rounded-full bg-green-400 transition-opacity duration-1000 ${B?"opacity-100":"opacity-0"}`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#555] mt-1",children:[x(q.agent_id)," · ",new Date(q.timestamp).toLocaleString()]},void 0,!0,void 0,this),q.error&&z.jsxDEV("div",{className:"text-xs text-red-400 mt-1 font-mono",children:q.error},void 0,!1,void 0,this),S===q.id&&q.data&&Object.keys(q.data).length>0&&z.jsxDEV("pre",{className:"text-xs text-[#666] mt-2 p-2 bg-[#0a0a0a] rounded overflow-x-auto",children:JSON.stringify(q.data,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},q.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,!1,void 0,this)}function L({label:W,value:H,color:X}){return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[z.jsxDEV("div",{className:"text-[#666] text-xs mb-1",children:W},void 0,!1,void 0,this),z.jsxDEV("div",{className:`text-2xl font-semibold ${X==="red"?"text-red-400":""}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
2
  export{_q as O};
3
3
 
4
4
  //# debugId=228D7A9E65268BAC64756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{b as a}from"./App.s2yrcz15.js";import"./App.7v1w3ys9.js";import"./App.c90t3dxg.js";import"./App.2yy66bnp.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as ConnectionsPage};
2
+
3
+ //# debugId=CAD556CD8F752CA664756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{h as a}from"./App.2jmkqm8c.js";import"./App.7v1w3ys9.js";import"./App.c90t3dxg.js";import"./App.2yy66bnp.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as McpPage};
2
+
3
+ //# debugId=CB9E6708C961556D64756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{c as a}from"./App.edwahsvz.js";import"./App.c90t3dxg.js";import"./App.2yy66bnp.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as SettingsPage};
2
+
3
+ //# debugId=96AC58639A6F59EB64756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{J as a}from"./App.n4jb3c22.js";import"./App.2yy66bnp.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as SkillsPage};
2
+
3
+ //# debugId=26B039225940335164756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{e as a,f as b,g as c}from"./App.3515wsb4.js";import"./App.c90t3dxg.js";import"./App.q3bpx15d.js";export{c as formatRelativeTime,b as formatCron,a as TasksPage};
2
+
3
+ //# debugId=1477390B40B71BEA64756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{O as a}from"./App.tg1b94tx.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as TelemetryPage};
2
+
3
+ //# debugId=F8F551C6E649B33364756E2164756E21
@@ -0,0 +1,3 @@
1
+ import{K as a}from"./App.jfx3der4.js";import"./App.2yy66bnp.js";import"./App.039re6cf.js";import"./App.q3bpx15d.js";export{a as TestsPage};
2
+
3
+ //# debugId=52B6848F90A4BC2264756E2164756E21
package/dist/index.html CHANGED
@@ -11,6 +11,6 @@
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
14
- <script type="module" src="/App.e4202qb4.js"></script>
14
+ <script type="module" src="/App.r0a2nmqs.js"></script>
15
15
  </body>
16
16
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apteva",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "Run AI agents locally. Multi-provider support for Claude, GPT, Gemini, Llama, and more.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",