apteva 0.4.26 → 0.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActivityPage.41nbye4r.js +3 -0
- package/dist/{ApiDocsPage.3q5x9hhg.js → ApiDocsPage.4smnt8m3.js} +1 -1
- package/dist/{App.9bzz8dqh.js → App.0sbax9et.js} +1 -1
- package/dist/{App.a7h91mxr.js → App.0ws427h8.js} +1 -1
- package/dist/App.4ehxpt48.js +4 -0
- package/dist/App.6q6bar8b.js +4 -0
- package/dist/{App.wnap3h7r.js → App.ca1rz1ph.js} +1 -1
- package/dist/{App.e54ynjf2.js → App.ensa6z0r.js} +1 -1
- package/dist/{App.sb2fg71h.js → App.f8g7tych.js} +1 -1
- package/dist/App.kh7d2xj3.js +267 -0
- package/dist/App.mvtqv6qc.js +20 -0
- package/dist/{App.2prdcxgq.js → App.ncgc9cxy.js} +1 -1
- package/dist/{App.r2c5nw36.js → App.p0fb1pds.js} +1 -1
- package/dist/{App.6ftxk387.js → App.pmaq48sj.js} +1 -1
- package/dist/{App.40azyqz6.js → App.yv87t9m5.js} +1 -1
- package/dist/App.zjmfm8p6.js +4 -0
- package/dist/ConnectionsPage.anb3rv9a.js +3 -0
- package/dist/McpPage.y396h6fy.js +3 -0
- package/dist/SettingsPage.5k6vp396.js +3 -0
- package/dist/SkillsPage.yj3xdsay.js +3 -0
- package/dist/{TasksPage.65dcf4vw.js → TasksPage.sjv0khtv.js} +1 -1
- package/dist/TelemetryPage.2qm4w16r.js +3 -0
- package/dist/TestsPage.zzs4qfj8.js +3 -0
- package/dist/index.html +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/channels/telegram.ts +5 -0
- package/src/crypto.ts +13 -4
- package/src/db.ts +25 -2
- package/src/providers.ts +44 -0
- package/src/routes/api/agent-utils.ts +64 -9
- package/src/routes/api/agents.ts +41 -13
- package/src/routes/api/integrations.ts +16 -6
- package/src/routes/api/mcp.ts +7 -0
- package/src/web/components/activity/ActivityPage.tsx +3 -3
- package/src/web/components/agents/AgentCard.tsx +5 -5
- package/src/web/components/agents/AgentPanel.tsx +81 -20
- package/src/web/components/mcp/McpPage.tsx +16 -5
- package/src/web/components/settings/SettingsPage.tsx +279 -30
- package/src/web/context/ProjectContext.tsx +5 -0
- package/src/web/context/TelemetryContext.tsx +14 -0
- package/src/web/types.ts +20 -2
- package/dist/ActivityPage.cycn14ck.js +0 -3
- package/dist/App.0wwyytz2.js +0 -4
- package/dist/App.fq11mvc7.js +0 -4
- package/dist/App.h6k4j1w9.js +0 -4
- package/dist/App.jq5tmjws.js +0 -267
- package/dist/App.k377qek6.js +0 -20
- package/dist/ConnectionsPage.6fyhqfhz.js +0 -3
- package/dist/McpPage.hk2qt1qt.js +0 -3
- package/dist/SettingsPage.gwpx9v7v.js +0 -3
- package/dist/SkillsPage.j5zech2z.js +0 -3
- package/dist/TelemetryPage.07xrbd7k.js +0 -3
- package/dist/TestsPage.q6zfephf.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{k as _0}from"./App.e54ynjf2.js";import{R as x}from"./App.r2c5nw36.js";import{S as O,V as X1,W as n,ca as g,fa as j}from"./App.k377qek6.js";var $0=O(X1(),1);var D=O(X1(),1);var U=O(n(),1);function m0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=D.useState([]),[Q,V]=D.useState([]),[W,T]=D.useState(!0);if(D.useEffect(()=>{(async()=>{T(!0);let y=H&&H!=="unassigned"?`?project_id=${H}`:"";try{let[I,a]=await Promise.all([R(`/api/subscriptions${y}`).catch(()=>null),R("/api/agents").catch(()=>null)]);if(I?.ok){let G=await I.json();F(G.subscriptions||[])}if(a?.ok){let G=await a.json();V(G.agents||[])}}catch(I){console.error("Failed to fetch overview data:",I)}T(!1)})()},[R,H]),W)return U.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let A=J.filter((Y)=>Y.enabled),S=J.filter((Y)=>!Y.enabled),l=new Map(Q.map((Y)=>[Y.id,Y]));return U.jsxDEV("div",{className:"space-y-6",children:[U.jsxDEV("div",{className:"grid grid-cols-3 gap-4",children:[U.jsxDEV(C1,{label:"Active",value:A.length},void 0,!1,void 0,this),U.jsxDEV(C1,{label:"Disabled",value:S.length},void 0,!1,void 0,this),U.jsxDEV(C1,{label:"Total",value:J.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("section",{children:[U.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Subscriptions (",J.length,")"]},void 0,!0,void 0,this),J.length===0?U.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):U.jsxDEV("div",{className:"space-y-2",children:J.map((Y)=>{let y=l.get(Y.agent_id);return U.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[U.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Y.enabled?"bg-green-400":"bg-[#555]"}`},void 0,!1,void 0,this),U.jsxDEV("div",{className:"flex-1 min-w-0",children:[U.jsxDEV("div",{className:"text-sm font-medium truncate",children:Y.trigger_slug.replace(/_/g," ").replace(/-/g," ")},void 0,!1,void 0,this),U.jsxDEV("div",{className:"text-xs text-[#666]",children:Y.trigger_instance_id?`ID: ${Y.trigger_instance_id.slice(0,12)}...`:"All instances"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("div",{className:"text-xs text-[#888] flex-shrink-0",children:[U.jsxDEV("span",{className:"text-[#555]",children:"→"},void 0,!1,void 0,this)," ",U.jsxDEV("span",{className:"text-[#f97316]",children:y?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("span",{className:`text-xs px-2 py-0.5 rounded flex-shrink-0 ${Y.enabled?"bg-green-500/10 text-green-400":"bg-[#1a1a1a] text-[#555]"}`,children:Y.enabled?"active":"disabled"},void 0,!1,void 0,this)]},Y.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function C1({label:R,value:H,valueColor:J}){return U.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[U.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:R},void 0,!1,void 0,this),U.jsxDEV("div",{className:`text-2xl font-bold ${J||"text-[#e0e0e0]"}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $=O(X1(),1);var i=O(n(),1);function I0({message:R="Loading...",fullScreen:H=!1}){let J=i.jsxDEV("div",{className:"flex items-center gap-3 text-[#666]",children:[i.jsxDEV("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",children:[i.jsxDEV("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"},void 0,!1,void 0,this),i.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),i.jsxDEV("span",{children:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(H)return i.jsxDEV("div",{className:"min-h-screen bg-[#0a0a0a] text-[#e0e0e0] font-mono flex items-center justify-center",children:J},void 0,!1,void 0,this);return i.jsxDEV("div",{className:"flex items-center justify-center py-20",children:J},void 0,!1,void 0,this)}var m=O(n(),1);function v0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=$.useState([]),[Q,V]=$.useState(""),[W,T]=$.useState([]),[A,S]=$.useState(!0),[l,Y]=$.useState([]),[y,I]=$.useState([]),[a,G]=$.useState(!1),[b,k]=$.useState(""),[o,F1]=$.useState(""),[R0,v1]=$.useState(!1),[B,_1]=$.useState(null),[f1,z0]=$.useState([]),[$1,I1]=$.useState(""),[Y1,R1]=$.useState(!1),[r,n1]=$.useState(""),[Z1,P1]=$.useState({}),[l1,G0]=$.useState(""),[H0,q1]=$.useState(!1),[p,J0]=$.useState([]),[K0,k1]=$.useState(!1),[A1,U0]=$.useState([]),[Q1,X0]=$.useState([]),[s,y1]=$.useState(""),[t,W1]=$.useState(""),[e,h1]=$.useState(""),[i1,T1]=$.useState(!1),[B1,z1]=$.useState({}),[S1,Y0]=$.useState(""),[a1,G1]=$.useState(!1),[M1,p1]=$.useState(""),[u1,H1]=$.useState(!1),[O1,x1]=$.useState(""),[Z0,J1]=$.useState(!1),[c,L1]=$.useState(""),[K1,b1]=$.useState(""),[V1,c1]=$.useState(!1),[h,q0]=$.useState([]),[d1,Z]=$.useState(null),X=H&&H!=="unassigned"?`?project_id=${H}`:"",E1=$.useCallback(async()=>{try{let N=await R(`/api/triggers/providers${X}`);if(N.ok){let _=((await N.json()).providers||[]).filter((f)=>f.connected);if(F(_),_.length>0)V((f)=>{if(!f||!_.find((K)=>K.id===f))return _[0].id;return f})}}catch(N){console.error("Failed to fetch providers:",N)}},[R]),u=$.useCallback(async()=>{S(!0);try{let N=`provider=${Q}`,v=X?"&":"?",_=X?`/api/triggers${X}&${N}`:`/api/triggers?${N}`,f=await R(_);if(f.ok){let K=await f.json();T(K.triggers||[])}}catch(N){console.error("Failed to fetch triggers:",N)}S(!1)},[R,X,Q]),N1=$.useCallback(async()=>{try{let N=await R(`/api/subscriptions${X}`);if(N.ok){let v=await N.json();Y(v.subscriptions||[])}}catch(N){console.error("Failed to fetch subscriptions:",N)}},[R,X]),D1=$.useCallback(async()=>{try{let N=await R(`/api/agents${X}`);if(N.ok){let v=await N.json();q0(v.agents||[])}}catch(N){}},[R,X]);$.useEffect(()=>{E1(),u(),N1(),D1()},[E1,u,N1,D1]);let Q0=async(N)=>{G(!0);try{let v=`/api/triggers/types?provider=${Q}`;if(N)v+=`&toolkit_slugs=${N}`;if(H&&H!=="unassigned")v+=`&project_id=${H}`;let _=await R(v);if(_.ok){let f=await _.json();I(f.types||[])}else{let f=await _.json();Z(f.error||"Failed to fetch trigger types")}}catch(v){Z("Failed to fetch trigger types")}G(!1)},W0=async()=>{try{let N=await R(`/api/integrations/${Q}/connected${X}`);if(N.ok){let v=await N.json();z0((v.accounts||[]).filter((_)=>_.status==="active"))}}catch(N){}},B0=(N)=>{_1(N),I1(""),n1(""),P1({}),G0(""),v1(!0),W0()},C=Q==="agentdojo",M0=async()=>{q1(!0),W1(""),y1(""),h1(""),z1({}),Y0("");let N=async()=>{if(p.length>0)return;k1(!0);try{let f="/api/triggers/types?provider=agentdojo";if(H&&H!=="unassigned")f+=`&project_id=${H}`;let L=await(await R(f)).json();J0(L.types||[])}catch(f){console.error("Failed to load trigger types:",f)}k1(!1)},v=async()=>{try{let f=`/api/integrations/agentdojo/connected${X}`,q=((await(await R(f)).json()).accounts||[]).filter((E)=>E.status==="active");U0(q)}catch(f){console.error("Failed to load connected accounts:",f)}},_=async()=>{if(Q1.length>0)return;try{let f=`/api/integrations/agentdojo/apps${X}`,L=await(await R(f)).json();X0((L.apps||[]).map((q)=>({id:q.id,name:q.name,slug:q.slug,logo:q.logo})))}catch(f){console.error("Failed to load apps:",f)}};await Promise.all([N(),v(),_()])},O0=async()=>{let N=p.find((_)=>_.slug===t),v=U1;if(!N||!e||!v)return;T1(!0),Z(null);try{let _=h.find((F0)=>F0.id===e),f="provider=agentdojo",K=X?`/api/triggers${X}&provider=agentdojo`:"/api/triggers?provider=agentdojo",L={callback_url:`${window.location.origin}/api/webhooks/agentdojo`,title:`${N.name} → ${_?.name||"Agent"}`,server:N.toolkit_slug,agent_id:e,...B1},q=await R(K,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:N.slug,connectedAccountId:v.id,config:L})}),E=await q.json();if(!q.ok)Z(E.error||"Failed to create subscription");else q1(!1),u()}catch(_){Z(_.message||"Failed to create subscription")}T1(!1)},L0=async()=>{if(!B)return;if(C){if(!r||!m1)return;R1(!0),Z(null);try{let N=h.find((q)=>q.id===r),v=window.location.origin,_=`provider=${Q}`,f=X?`/api/triggers${X}&${_}`:`/api/triggers?${_}`,K=await R(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:m1.id,config:{callback_url:`${v}/api/webhooks/agentdojo`,title:`${B.name} → ${N?.name||"Agent"}`,server:B.toolkit_slug,agent_id:r,...Z1}})}),L=await K.json();if(!K.ok)Z(L.error||"Failed to create subscription");else v1(!1),_1(null),u()}catch(N){Z(N.message||"Failed to create subscription")}R1(!1);return}if(!$1)return;R1(!0),Z(null);try{let N=`provider=${Q}`,v=X?`/api/triggers${X}&${N}`:`/api/triggers?${N}`,_=await R(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:$1})}),f=await _.json();if(!_.ok)Z(f.error||"Failed to create trigger");else v1(!1),_1(null),u()}catch(N){Z(N.message||"Failed to create trigger")}R1(!1)},g1=async(N,v)=>{let _=v==="active"?"disable":"enable";try{let f=X?`&provider=${Q}`:`?provider=${Q}`,K=await R(`/api/triggers/${N}/${_}${X}${f}`,{method:"POST"});if(K.ok)u();else{let L=await K.json();Z(L.error||`Failed to ${_} trigger`)}}catch(f){Z(`Failed to ${_} trigger`)}},j1=async(N)=>{try{let v=X?`&provider=${Q}`:`?provider=${Q}`,_=await R(`/api/triggers/${N}${X}${v}`,{method:"DELETE"});if(_.ok)u();else{let f=await _.json();Z(f.error||"Failed to delete trigger")}}catch(v){Z("Failed to delete trigger")}},b0=async()=>{if(!c||!K1)return;let N=W.find((v)=>v.id===c);if(!N)return;c1(!0),Z(null);try{let v=await R("/api/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trigger_slug:N.trigger_slug,trigger_instance_id:N.id,agent_id:K1,provider:Q,project_id:H&&H!=="unassigned"?H:null,public_url:window.location.origin})}),_=await v.json();if(!v.ok)Z(_.error||"Failed to create subscription");else J1(!1),L1(""),b1(""),N1()}catch(v){Z(v.message||"Failed to create subscription")}c1(!1)},w0=async(N)=>{let v=N.enabled?"disable":"enable";try{if((await R(`/api/subscriptions/${N.id}/${v}`,{method:"POST"})).ok)N1()}catch(_){Z(`Failed to ${v} subscription`)}},C0=async(N)=>{try{if((await R(`/api/subscriptions/${N}`,{method:"DELETE"})).ok)N1()}catch(v){Z("Failed to delete subscription")}},w1=y.filter((N)=>{if(!o)return!0;let v=o.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)||N.description.toLowerCase().includes(v)}),o1=(N,v)=>{if(!v||N.length===0)return null;let _=v.toLowerCase().replace(/[-_]/g," "),f=N.find((q)=>q.appId?.toLowerCase()===v.toLowerCase()||q.appName?.toLowerCase()===v.toLowerCase());if(f)return f;let K=N.find((q)=>q.appId?.toLowerCase().includes(_)||q.appName?.toLowerCase().replace(/[-_]/g," ").includes(_)||_.includes(q.appId?.toLowerCase()||"")||_.includes(q.appName?.toLowerCase().replace(/[-_]/g," ")||""));if(K)return K;let L=_.split(/\s+/);return N.find((q)=>{let E=(q.appName||"").toLowerCase().replace(/[-_]/g," ").split(/\s+/);return L[0]&&E[0]&&L[0]===E[0]})||null},M=p.find((N)=>N.slug===t),r1=M?o1(A1,M.toolkit_slug):null,U1=S1?A1.find((N)=>N.id===S1)||r1:r1,s1=B&&C?o1(f1,B.toolkit_slug):null,m1=l1?f1.find((N)=>N.id===l1)||s1:s1,t1=$.default.useMemo(()=>{let N=new Map;for(let _ of Q1)if(_.logo)N.set(_.slug,_.logo);let v=new Map;for(let _ of p){let f=v.get(_.toolkit_slug);if(f)f.count++;else{let K=N.get(_.toolkit_slug)||_.logo||null;v.set(_.toolkit_slug,{slug:_.toolkit_slug,name:_.toolkit_name,logo:K,count:1})}}return Array.from(v.values()).sort((_,f)=>_.name.localeCompare(f.name))},[p,Q1]),e1=s?p.filter((N)=>N.toolkit_slug===s):[],d=t1.find((N)=>N.slug===s),N0=new Map(h.map((N)=>[N.id,N]));if(J.length===0&&!A)return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[m.jsxDEV("p",{className:"text-[#666]",children:"No trigger providers configured."},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-sm text-[#555] mt-1",children:"Add API keys for Composio or AgentDojo in Settings to enable triggers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return m.jsxDEV("div",{className:"space-y-6",children:[d1&&m.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:[m.jsxDEV("span",{children:d1},void 0,!1,void 0,this),m.jsxDEV("button",{onClick:()=>Z(null),className:"text-red-400 hover:text-red-300",children:"x"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.length>1&&m.jsxDEV("div",{className:"flex items-center gap-2",children:[m.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:J.map((N)=>m.jsxDEV("button",{onClick:()=>{V(N.id),I([]),k(""),F1("")},className:`px-3 py-1 rounded text-xs font-medium transition ${Q===N.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:N.name},N.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!C&&m.jsxDEV("section",{children:[m.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Subscriptions (",l.length,")"]},void 0,!0,void 0,this),m.jsxDEV("button",{onClick:()=>J1(!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),l.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:l.map((N)=>{let v=N0.get(N.agent_id);return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:[N.trigger_slug.replace(/_/g," "),m.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#f97316]",children:v?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>w0(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),m.jsxDEV("button",{onClick:()=>C0(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),!C&&m.jsxDEV("section",{children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Trigger Instances (",W.length,")"]},void 0,!0,void 0,this),A?m.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading triggers..."},void 0,!1,void 0,this):W.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:W.map((N)=>m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:N.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>g1(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),m.jsxDEV("button",{onClick:()=>j1(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),C&&m.jsxDEV("section",{children:[m.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Active Subscriptions (",W.length,")"]},void 0,!0,void 0,this),m.jsxDEV("button",{onClick:M0,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),A?m.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading subscriptions..."},void 0,!1,void 0,this):W.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:W.map((N)=>{let v=l.find((f)=>f.trigger_instance_id===N.id),_=v?N0.get(v.agent_id):null;return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:[N.config?.title||N.trigger_slug.replace(/_/g," "),_&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#f97316]",children:_.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{className:"text-xs text-[#666]",children:[N.config?.server&&m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>g1(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),m.jsxDEV("button",{onClick:()=>j1(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),m.jsxDEV("section",{children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:"Browse Trigger Types"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"flex gap-2 mb-3",children:[m.jsxDEV("input",{type:"text",value:b,onChange:(N)=>k(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),m.jsxDEV("button",{onClick:()=>Q0(b||void 0),disabled:a,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded transition disabled:opacity-50",children:a?"Loading...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.length>0&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("input",{type:"text",value:o,onChange:(N)=>F1(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),m.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w1.slice(0,30).map((N)=>m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] hover:border-[#333] rounded-lg p-3 transition",children:[m.jsxDEV("div",{className:"flex items-start gap-3",children:[N.logo?m.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):m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("div",{className:"text-xs text-[#666]",children:N.toolkit_name},void 0,!1,void 0,this),m.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),m.jsxDEV("button",{onClick:()=>B0(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:C?"Subscribe":"Create Trigger"},void 0,!1,void 0,this)]},N.slug,!0,void 0,this))},void 0,!1,void 0,this),w1.length>30&&m.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 30 of ",w1.length," types. Use search to filter."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R0&&B&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:C?"Create Subscription":"Create Trigger"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:[B.name,B.toolkit_name&&m.jsxDEV("span",{className:"text-[#555]",children:[" (",B.toolkit_name,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{className:"space-y-4",children:[!C&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),f1.length===0?m.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):m.jsxDEV(x,{value:$1,onChange:I1,placeholder:"Select account...",options:f1.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),C&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Route to Agent"},void 0,!1,void 0,this),h.length===0?m.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):m.jsxDEV(x,{value:r,onChange:n1,placeholder:"Select agent...",options:h.map((N)=>({value:N.id,label:`${N.name} (${N.status})`}))},void 0,!1,void 0,this),m.jsxDEV("div",{className:"mt-3",children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),m1?m.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",m1.appName]},void 0,!0,void 0,this):m.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 ",B?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B.config_schema&&Object.keys(B.config_schema.properties||{}).length>0&&m.jsxDEV("div",{className:"mt-3",children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"space-y-2",children:Object.entries(B.config_schema.properties||{}).map(([N,v])=>{let _=(B.config_schema.required||[]).includes(N);return m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[v.title||N,_&&m.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("input",{type:"text",value:Z1[N]||"",onChange:(f)=>P1((K)=>({...K,[N]:f.target.value})),placeholder:v.description||`Enter ${v.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),m.jsxDEV("div",{className:"flex gap-2 mt-4",children:[m.jsxDEV("button",{onClick:()=>{v1(!1),_1(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),m.jsxDEV("button",{onClick:L0,disabled:C?!r||!m1||Y1||B?.config_schema&&(B.config_schema.required||[]).some((N)=>!Z1[N]?.trim()):!$1||Y1,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:Y1?"Creating...":C?"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),Z0&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:"Route Trigger to Agent"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:W.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),W.length>0?m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"space-y-4",children:[m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger Instance"},void 0,!1,void 0,this),m.jsxDEV(x,{value:c,onChange:L1,placeholder:"Select trigger...",options:W.map((N)=>({value:N.id,label:`${N.trigger_slug.replace(/_/g," ")}`}))},void 0,!1,void 0,this),c&&m.jsxDEV("div",{className:"text-xs text-[#555] mt-1 font-mono",children:["ID: ",c.slice(0,16),"..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),m.jsxDEV(x,{value:K1,onChange:b1,placeholder:"Select agent...",options:h.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),m.jsxDEV("div",{className:"flex gap-2 mt-5",children:[m.jsxDEV("button",{onClick:()=>{J1(!1),L1(""),b1("")},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),m.jsxDEV("button",{onClick:b0,disabled:!c||!K1||V1,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:V1?"Adding...":"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("div",{className:"flex gap-2 mt-4",children:m.jsxDEV("button",{onClick:()=>J1(!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),H0&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-lg mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:"Add Subscription"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:"Select an app and trigger, then route it to an agent."},void 0,!1,void 0,this),K0?m.jsxDEV("div",{className:"text-center py-8 text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):p.length===0?m.jsxDEV("div",{className:"text-center py-8 text-[#666] text-sm",children:"No triggers available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):m.jsxDEV("div",{className:"space-y-4",children:[m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"App"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"relative",children:[m.jsxDEV("button",{onClick:()=>{G1(!a1),H1(!1),p1("")},className:"w-full flex items-center gap-2 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm text-left hover:border-[#555] transition",children:[d?m.jsxDEV(m.Fragment,{children:[d.logo?m.jsxDEV("img",{src:d.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):m.jsxDEV("div",{className:"w-5 h-5 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0",children:d.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"flex-1 truncate",children:d.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[10px] text-[#666]",children:[d.count," triggers"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("span",{className:"text-[#666] flex-1",children:"Select app..."},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#666] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a1&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>G1(!1)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#0a0a0a] border border-[#333] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[m.jsxDEV("div",{className:"p-2 border-b border-[#1a1a1a] flex-shrink-0",children:m.jsxDEV("input",{type:"text",value:M1,onChange:(N)=>p1(N.target.value),placeholder:"Search apps...",className:"w-full bg-[#111] border border-[#333] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"overflow-y-auto flex-1",children:t1.filter((N)=>{if(!M1)return!0;let v=M1.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)}).map((N)=>m.jsxDEV("button",{onClick:()=>{y1(N.slug),W1(""),z1({}),G1(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[#1a1a1a] ${s===N.slug?"bg-[#1a1a1a] text-[#f97316]":""}`,children:[N.logo?m.jsxDEV("img",{src:N.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):m.jsxDEV("div",{className:"w-5 h-5 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0",children:N.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"flex-1 truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[10px] text-[#666]",children:N.count},void 0,!1,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)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),s&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"relative",children:[m.jsxDEV("button",{onClick:()=>{H1(!u1),G1(!1),x1("")},className:"w-full flex items-center gap-2 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm text-left hover:border-[#555] transition",children:[M?m.jsxDEV(m.Fragment,{children:[m.jsxDEV("span",{className:"flex-1 truncate",children:M.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${M.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:M.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("span",{className:"text-[#666] flex-1",children:"Select trigger..."},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#666] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u1&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>H1(!1)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#0a0a0a] border border-[#333] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[e1.length>3&&m.jsxDEV("div",{className:"p-2 border-b border-[#1a1a1a] flex-shrink-0",children:m.jsxDEV("input",{type:"text",value:O1,onChange:(N)=>x1(N.target.value),placeholder:"Search triggers...",className:"w-full bg-[#111] border border-[#333] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"overflow-y-auto flex-1",children:e1.filter((N)=>{if(!O1)return!0;let v=O1.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)||N.description.toLowerCase().includes(v)}).map((N)=>m.jsxDEV("button",{onClick:()=>{W1(N.slug),z1({}),H1(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[#1a1a1a] ${t===N.slug?"bg-[#1a1a1a] text-[#f97316]":""}`,children:[m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("div",{className:"text-[10px] text-[#666] truncate",children:N.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${N.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:N.type},void 0,!1,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)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),U1?m.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",U1.appName]},void 0,!0,void 0,this):m.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 ",M?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&M.config_schema&&Object.keys(M.config_schema.properties||{}).length>0&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"space-y-2",children:Object.entries(M.config_schema.properties||{}).map(([N,v])=>{let _=(M.config_schema.required||[]).includes(N);return m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[v.title||N,_&&m.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("input",{type:"text",value:B1[N]||"",onChange:(f)=>z1((K)=>({...K,[N]:f.target.value})),placeholder:v.description||`Enter ${v.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),m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),h.length===0?m.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):m.jsxDEV(x,{value:e,onChange:h1,placeholder:"Select agent...",options:h.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),m.jsxDEV("div",{className:"flex gap-2 mt-5",children:[m.jsxDEV("button",{onClick:()=>q1(!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),m.jsxDEV("button",{onClick:O0,disabled:!t||!e||!U1||i1||M?.config_schema&&(M.config_schema.required||[]).some((N)=>!B1[N]?.trim()),className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:i1?"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 P=O(X1(),1);var z=O(n(),1);function f0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),J=H&&H!=="unassigned"?H:null,F=J?`?project_id=${J}`:"",[Q,V]=P.useState([]),[W,T]=P.useState("");P.useEffect(()=>{R(`/api/triggers/providers${F}`).then((G)=>G.json()).then((G)=>{let b=(G.providers||[]).filter((k)=>k.connected);if(V(b),b.length>0&&!b.find((k)=>k.id===W))T(b[0].id)}).catch(()=>{})},[R]);let[A,S]=P.useState(null),[l,Y]=P.useState([]),[y,I]=P.useState(!1),a=P.useCallback(async(G)=>{S(G),I(!0);try{let b=`/api/triggers/types?provider=${W}&toolkit_slugs=${G}`;if(J)b+=`&project_id=${J}`;let k=await R(b);if(k.ok){let o=await k.json();Y(o.types||[])}}catch(b){console.error("Failed to fetch trigger types:",b)}I(!1)},[R,J,W]);return z.jsxDEV("div",{children:[z.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),Q.length>1&&z.jsxDEV("div",{className:"flex items-center gap-2 mb-4",children:[z.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:Q.map((G)=>z.jsxDEV("button",{onClick:()=>T(G.id),className:`px-3 py-1 rounded text-xs font-medium transition ${W===G.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:G.name},G.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#666]",children:"No integration providers configured."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#555] mt-1",children:"Add API keys for Composio or AgentDojo in Settings."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(_0,{providerId:W,projectId:J,hideMcpConfig:!0,onBrowseTriggers:a},void 0,!1,void 0,this),A&&z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:"Trigger Types"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666]",children:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>{S(null),Y([])},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),z.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:y?z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading trigger types..."},void 0,!1,void 0,this):l.length===0?z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No trigger types available for this app."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:l.map((G)=>z.jsxDEV("div",{className:"bg-[#0a0a0a] border border-[#1a1a1a] rounded-lg p-3",children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[G.logo?z.jsxDEV("img",{src:G.logo,alt:G.toolkit_name,className:"w-6 h-6 rounded object-contain flex-shrink-0 mt-0.5"},void 0,!1,void 0,this):z.jsxDEV("div",{className:"w-6 h-6 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0 mt-0.5",children:G.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"text-sm font-medium",children:G.name},void 0,!1,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:G.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-1.5",children:[z.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded font-mono",children:G.slug},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${G.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:G.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)},G.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=O(n(),1);function JN(){let[R,H]=$0.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((F)=>w.jsxDEV("button",{onClick:()=>H(F.id),className:`px-4 py-2 rounded text-sm font-medium transition ${R===F.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:F.label},F.id,!1,void 0,this))},void 0,!1,void 0,this),R==="overview"&&w.jsxDEV(m0,{},void 0,!1,void 0,this),R==="triggers"&&w.jsxDEV(v0,{},void 0,!1,void 0,this),R==="integrations"&&w.jsxDEV(f0,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
1
|
+
import{k as _0}from"./App.ensa6z0r.js";import{R as x}from"./App.p0fb1pds.js";import{S as O,V as X1,W as n,ca as g,fa as j}from"./App.mvtqv6qc.js";var $0=O(X1(),1);var D=O(X1(),1);var U=O(n(),1);function m0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=D.useState([]),[Q,V]=D.useState([]),[W,T]=D.useState(!0);if(D.useEffect(()=>{(async()=>{T(!0);let y=H&&H!=="unassigned"?`?project_id=${H}`:"";try{let[I,a]=await Promise.all([R(`/api/subscriptions${y}`).catch(()=>null),R("/api/agents").catch(()=>null)]);if(I?.ok){let G=await I.json();F(G.subscriptions||[])}if(a?.ok){let G=await a.json();V(G.agents||[])}}catch(I){console.error("Failed to fetch overview data:",I)}T(!1)})()},[R,H]),W)return U.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let A=J.filter((Y)=>Y.enabled),S=J.filter((Y)=>!Y.enabled),l=new Map(Q.map((Y)=>[Y.id,Y]));return U.jsxDEV("div",{className:"space-y-6",children:[U.jsxDEV("div",{className:"grid grid-cols-3 gap-4",children:[U.jsxDEV(C1,{label:"Active",value:A.length},void 0,!1,void 0,this),U.jsxDEV(C1,{label:"Disabled",value:S.length},void 0,!1,void 0,this),U.jsxDEV(C1,{label:"Total",value:J.length},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("section",{children:[U.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Subscriptions (",J.length,")"]},void 0,!0,void 0,this),J.length===0?U.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):U.jsxDEV("div",{className:"space-y-2",children:J.map((Y)=>{let y=l.get(Y.agent_id);return U.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[U.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Y.enabled?"bg-green-400":"bg-[#555]"}`},void 0,!1,void 0,this),U.jsxDEV("div",{className:"flex-1 min-w-0",children:[U.jsxDEV("div",{className:"text-sm font-medium truncate",children:Y.trigger_slug.replace(/_/g," ").replace(/-/g," ")},void 0,!1,void 0,this),U.jsxDEV("div",{className:"text-xs text-[#666]",children:Y.trigger_instance_id?`ID: ${Y.trigger_instance_id.slice(0,12)}...`:"All instances"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("div",{className:"text-xs text-[#888] flex-shrink-0",children:[U.jsxDEV("span",{className:"text-[#555]",children:"→"},void 0,!1,void 0,this)," ",U.jsxDEV("span",{className:"text-[#f97316]",children:y?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U.jsxDEV("span",{className:`text-xs px-2 py-0.5 rounded flex-shrink-0 ${Y.enabled?"bg-green-500/10 text-green-400":"bg-[#1a1a1a] text-[#555]"}`,children:Y.enabled?"active":"disabled"},void 0,!1,void 0,this)]},Y.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function C1({label:R,value:H,valueColor:J}){return U.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[U.jsxDEV("div",{className:"text-xs text-[#666] mb-1",children:R},void 0,!1,void 0,this),U.jsxDEV("div",{className:`text-2xl font-bold ${J||"text-[#e0e0e0]"}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $=O(X1(),1);var i=O(n(),1);function I0({message:R="Loading...",fullScreen:H=!1}){let J=i.jsxDEV("div",{className:"flex items-center gap-3 text-[#666]",children:[i.jsxDEV("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",children:[i.jsxDEV("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"},void 0,!1,void 0,this),i.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),i.jsxDEV("span",{children:R},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(H)return i.jsxDEV("div",{className:"min-h-screen bg-[#0a0a0a] text-[#e0e0e0] font-mono flex items-center justify-center",children:J},void 0,!1,void 0,this);return i.jsxDEV("div",{className:"flex items-center justify-center py-20",children:J},void 0,!1,void 0,this)}var m=O(n(),1);function v0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=$.useState([]),[Q,V]=$.useState(""),[W,T]=$.useState([]),[A,S]=$.useState(!0),[l,Y]=$.useState([]),[y,I]=$.useState([]),[a,G]=$.useState(!1),[b,k]=$.useState(""),[o,F1]=$.useState(""),[R0,v1]=$.useState(!1),[B,_1]=$.useState(null),[f1,z0]=$.useState([]),[$1,I1]=$.useState(""),[Y1,R1]=$.useState(!1),[r,n1]=$.useState(""),[Z1,P1]=$.useState({}),[l1,G0]=$.useState(""),[H0,q1]=$.useState(!1),[p,J0]=$.useState([]),[K0,k1]=$.useState(!1),[A1,U0]=$.useState([]),[Q1,X0]=$.useState([]),[s,y1]=$.useState(""),[t,W1]=$.useState(""),[e,h1]=$.useState(""),[i1,T1]=$.useState(!1),[B1,z1]=$.useState({}),[S1,Y0]=$.useState(""),[a1,G1]=$.useState(!1),[M1,p1]=$.useState(""),[u1,H1]=$.useState(!1),[O1,x1]=$.useState(""),[Z0,J1]=$.useState(!1),[c,L1]=$.useState(""),[K1,b1]=$.useState(""),[V1,c1]=$.useState(!1),[h,q0]=$.useState([]),[d1,Z]=$.useState(null),X=H&&H!=="unassigned"?`?project_id=${H}`:"",E1=$.useCallback(async()=>{try{let N=await R(`/api/triggers/providers${X}`);if(N.ok){let _=((await N.json()).providers||[]).filter((f)=>f.connected);if(F(_),_.length>0)V((f)=>{if(!f||!_.find((K)=>K.id===f))return _[0].id;return f})}}catch(N){console.error("Failed to fetch providers:",N)}},[R]),u=$.useCallback(async()=>{S(!0);try{let N=`provider=${Q}`,v=X?"&":"?",_=X?`/api/triggers${X}&${N}`:`/api/triggers?${N}`,f=await R(_);if(f.ok){let K=await f.json();T(K.triggers||[])}}catch(N){console.error("Failed to fetch triggers:",N)}S(!1)},[R,X,Q]),N1=$.useCallback(async()=>{try{let N=await R(`/api/subscriptions${X}`);if(N.ok){let v=await N.json();Y(v.subscriptions||[])}}catch(N){console.error("Failed to fetch subscriptions:",N)}},[R,X]),D1=$.useCallback(async()=>{try{let N=await R(`/api/agents${X}`);if(N.ok){let v=await N.json();q0(v.agents||[])}}catch(N){}},[R,X]);$.useEffect(()=>{E1(),u(),N1(),D1()},[E1,u,N1,D1]);let Q0=async(N)=>{G(!0);try{let v=`/api/triggers/types?provider=${Q}`;if(N)v+=`&toolkit_slugs=${N}`;if(H&&H!=="unassigned")v+=`&project_id=${H}`;let _=await R(v);if(_.ok){let f=await _.json();I(f.types||[])}else{let f=await _.json();Z(f.error||"Failed to fetch trigger types")}}catch(v){Z("Failed to fetch trigger types")}G(!1)},W0=async()=>{try{let N=await R(`/api/integrations/${Q}/connected${X}`);if(N.ok){let v=await N.json();z0((v.accounts||[]).filter((_)=>_.status==="active"))}}catch(N){}},B0=(N)=>{_1(N),I1(""),n1(""),P1({}),G0(""),v1(!0),W0()},C=Q==="agentdojo",M0=async()=>{q1(!0),W1(""),y1(""),h1(""),z1({}),Y0("");let N=async()=>{if(p.length>0)return;k1(!0);try{let f="/api/triggers/types?provider=agentdojo";if(H&&H!=="unassigned")f+=`&project_id=${H}`;let L=await(await R(f)).json();J0(L.types||[])}catch(f){console.error("Failed to load trigger types:",f)}k1(!1)},v=async()=>{try{let f=`/api/integrations/agentdojo/connected${X}`,q=((await(await R(f)).json()).accounts||[]).filter((E)=>E.status==="active");U0(q)}catch(f){console.error("Failed to load connected accounts:",f)}},_=async()=>{if(Q1.length>0)return;try{let f=`/api/integrations/agentdojo/apps${X}`,L=await(await R(f)).json();X0((L.apps||[]).map((q)=>({id:q.id,name:q.name,slug:q.slug,logo:q.logo})))}catch(f){console.error("Failed to load apps:",f)}};await Promise.all([N(),v(),_()])},O0=async()=>{let N=p.find((_)=>_.slug===t),v=U1;if(!N||!e||!v)return;T1(!0),Z(null);try{let _=h.find((F0)=>F0.id===e),f="provider=agentdojo",K=X?`/api/triggers${X}&provider=agentdojo`:"/api/triggers?provider=agentdojo",L={callback_url:`${window.location.origin}/api/webhooks/agentdojo`,title:`${N.name} → ${_?.name||"Agent"}`,server:N.toolkit_slug,agent_id:e,...B1},q=await R(K,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:N.slug,connectedAccountId:v.id,config:L})}),E=await q.json();if(!q.ok)Z(E.error||"Failed to create subscription");else q1(!1),u()}catch(_){Z(_.message||"Failed to create subscription")}T1(!1)},L0=async()=>{if(!B)return;if(C){if(!r||!m1)return;R1(!0),Z(null);try{let N=h.find((q)=>q.id===r),v=window.location.origin,_=`provider=${Q}`,f=X?`/api/triggers${X}&${_}`:`/api/triggers?${_}`,K=await R(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:m1.id,config:{callback_url:`${v}/api/webhooks/agentdojo`,title:`${B.name} → ${N?.name||"Agent"}`,server:B.toolkit_slug,agent_id:r,...Z1}})}),L=await K.json();if(!K.ok)Z(L.error||"Failed to create subscription");else v1(!1),_1(null),u()}catch(N){Z(N.message||"Failed to create subscription")}R1(!1);return}if(!$1)return;R1(!0),Z(null);try{let N=`provider=${Q}`,v=X?`/api/triggers${X}&${N}`:`/api/triggers?${N}`,_=await R(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:$1})}),f=await _.json();if(!_.ok)Z(f.error||"Failed to create trigger");else v1(!1),_1(null),u()}catch(N){Z(N.message||"Failed to create trigger")}R1(!1)},g1=async(N,v)=>{let _=v==="active"?"disable":"enable";try{let f=X?`&provider=${Q}`:`?provider=${Q}`,K=await R(`/api/triggers/${N}/${_}${X}${f}`,{method:"POST"});if(K.ok)u();else{let L=await K.json();Z(L.error||`Failed to ${_} trigger`)}}catch(f){Z(`Failed to ${_} trigger`)}},j1=async(N)=>{try{let v=X?`&provider=${Q}`:`?provider=${Q}`,_=await R(`/api/triggers/${N}${X}${v}`,{method:"DELETE"});if(_.ok)u();else{let f=await _.json();Z(f.error||"Failed to delete trigger")}}catch(v){Z("Failed to delete trigger")}},b0=async()=>{if(!c||!K1)return;let N=W.find((v)=>v.id===c);if(!N)return;c1(!0),Z(null);try{let v=await R("/api/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trigger_slug:N.trigger_slug,trigger_instance_id:N.id,agent_id:K1,provider:Q,project_id:H&&H!=="unassigned"?H:null,public_url:window.location.origin})}),_=await v.json();if(!v.ok)Z(_.error||"Failed to create subscription");else J1(!1),L1(""),b1(""),N1()}catch(v){Z(v.message||"Failed to create subscription")}c1(!1)},w0=async(N)=>{let v=N.enabled?"disable":"enable";try{if((await R(`/api/subscriptions/${N.id}/${v}`,{method:"POST"})).ok)N1()}catch(_){Z(`Failed to ${v} subscription`)}},C0=async(N)=>{try{if((await R(`/api/subscriptions/${N}`,{method:"DELETE"})).ok)N1()}catch(v){Z("Failed to delete subscription")}},w1=y.filter((N)=>{if(!o)return!0;let v=o.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)||N.description.toLowerCase().includes(v)}),o1=(N,v)=>{if(!v||N.length===0)return null;let _=v.toLowerCase().replace(/[-_]/g," "),f=N.find((q)=>q.appId?.toLowerCase()===v.toLowerCase()||q.appName?.toLowerCase()===v.toLowerCase());if(f)return f;let K=N.find((q)=>q.appId?.toLowerCase().includes(_)||q.appName?.toLowerCase().replace(/[-_]/g," ").includes(_)||_.includes(q.appId?.toLowerCase()||"")||_.includes(q.appName?.toLowerCase().replace(/[-_]/g," ")||""));if(K)return K;let L=_.split(/\s+/);return N.find((q)=>{let E=(q.appName||"").toLowerCase().replace(/[-_]/g," ").split(/\s+/);return L[0]&&E[0]&&L[0]===E[0]})||null},M=p.find((N)=>N.slug===t),r1=M?o1(A1,M.toolkit_slug):null,U1=S1?A1.find((N)=>N.id===S1)||r1:r1,s1=B&&C?o1(f1,B.toolkit_slug):null,m1=l1?f1.find((N)=>N.id===l1)||s1:s1,t1=$.default.useMemo(()=>{let N=new Map;for(let _ of Q1)if(_.logo)N.set(_.slug,_.logo);let v=new Map;for(let _ of p){let f=v.get(_.toolkit_slug);if(f)f.count++;else{let K=N.get(_.toolkit_slug)||_.logo||null;v.set(_.toolkit_slug,{slug:_.toolkit_slug,name:_.toolkit_name,logo:K,count:1})}}return Array.from(v.values()).sort((_,f)=>_.name.localeCompare(f.name))},[p,Q1]),e1=s?p.filter((N)=>N.toolkit_slug===s):[],d=t1.find((N)=>N.slug===s),N0=new Map(h.map((N)=>[N.id,N]));if(J.length===0&&!A)return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[m.jsxDEV("p",{className:"text-[#666]",children:"No trigger providers configured."},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-sm text-[#555] mt-1",children:"Add API keys for Composio or AgentDojo in Settings to enable triggers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return m.jsxDEV("div",{className:"space-y-6",children:[d1&&m.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:[m.jsxDEV("span",{children:d1},void 0,!1,void 0,this),m.jsxDEV("button",{onClick:()=>Z(null),className:"text-red-400 hover:text-red-300",children:"x"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.length>1&&m.jsxDEV("div",{className:"flex items-center gap-2",children:[m.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:J.map((N)=>m.jsxDEV("button",{onClick:()=>{V(N.id),I([]),k(""),F1("")},className:`px-3 py-1 rounded text-xs font-medium transition ${Q===N.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:N.name},N.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!C&&m.jsxDEV("section",{children:[m.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Subscriptions (",l.length,")"]},void 0,!0,void 0,this),m.jsxDEV("button",{onClick:()=>J1(!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),l.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:l.map((N)=>{let v=N0.get(N.agent_id);return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:[N.trigger_slug.replace(/_/g," "),m.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#f97316]",children:v?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>w0(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),m.jsxDEV("button",{onClick:()=>C0(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),!C&&m.jsxDEV("section",{children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Trigger Instances (",W.length,")"]},void 0,!0,void 0,this),A?m.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading triggers..."},void 0,!1,void 0,this):W.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:W.map((N)=>m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:N.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>g1(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),m.jsxDEV("button",{onClick:()=>j1(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),C&&m.jsxDEV("section",{children:[m.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888]",children:["Active Subscriptions (",W.length,")"]},void 0,!0,void 0,this),m.jsxDEV("button",{onClick:M0,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),A?m.jsxDEV("div",{className:"text-center py-6 text-[#666] text-sm",children:"Loading subscriptions..."},void 0,!1,void 0,this):W.length===0?m.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):m.jsxDEV("div",{className:"space-y-2",children:W.map((N)=>{let v=l.find((f)=>f.trigger_instance_id===N.id),_=v?N0.get(v.agent_id):null;return m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-3 flex items-center gap-3",children:[m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:[N.config?.title||N.trigger_slug.replace(/_/g," "),_&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("span",{className:"text-[#555] mx-1.5",children:"→"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#f97316]",children:_.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{className:"text-xs text-[#666]",children:[N.config?.server&&m.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),m.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m.jsxDEV("button",{onClick:()=>g1(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),m.jsxDEV("button",{onClick:()=>j1(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),m.jsxDEV("section",{children:[m.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:"Browse Trigger Types"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"flex gap-2 mb-3",children:[m.jsxDEV("input",{type:"text",value:b,onChange:(N)=>k(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),m.jsxDEV("button",{onClick:()=>Q0(b||void 0),disabled:a,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded transition disabled:opacity-50",children:a?"Loading...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.length>0&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("input",{type:"text",value:o,onChange:(N)=>F1(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),m.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w1.slice(0,30).map((N)=>m.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] hover:border-[#333] rounded-lg p-3 transition",children:[m.jsxDEV("div",{className:"flex items-start gap-3",children:[N.logo?m.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):m.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),m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"text-sm font-medium truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("div",{className:"text-xs text-[#666]",children:N.toolkit_name},void 0,!1,void 0,this),m.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),m.jsxDEV("button",{onClick:()=>B0(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:C?"Subscribe":"Create Trigger"},void 0,!1,void 0,this)]},N.slug,!0,void 0,this))},void 0,!1,void 0,this),w1.length>30&&m.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 30 of ",w1.length," types. Use search to filter."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R0&&B&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:C?"Create Subscription":"Create Trigger"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:[B.name,B.toolkit_name&&m.jsxDEV("span",{className:"text-[#555]",children:[" (",B.toolkit_name,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{className:"space-y-4",children:[!C&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),f1.length===0?m.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):m.jsxDEV(x,{value:$1,onChange:I1,placeholder:"Select account...",options:f1.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),C&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Route to Agent"},void 0,!1,void 0,this),h.length===0?m.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):m.jsxDEV(x,{value:r,onChange:n1,placeholder:"Select agent...",options:h.map((N)=>({value:N.id,label:`${N.name} (${N.status})`}))},void 0,!1,void 0,this),m.jsxDEV("div",{className:"mt-3",children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),m1?m.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",m1.appName]},void 0,!0,void 0,this):m.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 ",B?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B.config_schema&&Object.keys(B.config_schema.properties||{}).length>0&&m.jsxDEV("div",{className:"mt-3",children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"space-y-2",children:Object.entries(B.config_schema.properties||{}).map(([N,v])=>{let _=(B.config_schema.required||[]).includes(N);return m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[v.title||N,_&&m.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("input",{type:"text",value:Z1[N]||"",onChange:(f)=>P1((K)=>({...K,[N]:f.target.value})),placeholder:v.description||`Enter ${v.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),m.jsxDEV("div",{className:"flex gap-2 mt-4",children:[m.jsxDEV("button",{onClick:()=>{v1(!1),_1(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),m.jsxDEV("button",{onClick:L0,disabled:C?!r||!m1||Y1||B?.config_schema&&(B.config_schema.required||[]).some((N)=>!Z1[N]?.trim()):!$1||Y1,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:Y1?"Creating...":C?"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),Z0&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:"Route Trigger to Agent"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:W.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),W.length>0?m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"space-y-4",children:[m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger Instance"},void 0,!1,void 0,this),m.jsxDEV(x,{value:c,onChange:L1,placeholder:"Select trigger...",options:W.map((N)=>({value:N.id,label:`${N.trigger_slug.replace(/_/g," ")}`}))},void 0,!1,void 0,this),c&&m.jsxDEV("div",{className:"text-xs text-[#555] mt-1 font-mono",children:["ID: ",c.slice(0,16),"..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),m.jsxDEV(x,{value:K1,onChange:b1,placeholder:"Select agent...",options:h.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),m.jsxDEV("div",{className:"flex gap-2 mt-5",children:[m.jsxDEV("button",{onClick:()=>{J1(!1),L1(""),b1("")},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),m.jsxDEV("button",{onClick:b0,disabled:!c||!K1||V1,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:V1?"Adding...":"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("div",{className:"flex gap-2 mt-4",children:m.jsxDEV("button",{onClick:()=>J1(!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),H0&&m.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:m.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-lg mx-4",children:[m.jsxDEV("h3",{className:"font-medium mb-1",children:"Add Subscription"},void 0,!1,void 0,this),m.jsxDEV("p",{className:"text-xs text-[#666] mb-4",children:"Select an app and trigger, then route it to an agent."},void 0,!1,void 0,this),K0?m.jsxDEV("div",{className:"text-center py-8 text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):p.length===0?m.jsxDEV("div",{className:"text-center py-8 text-[#666] text-sm",children:"No triggers available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):m.jsxDEV("div",{className:"space-y-4",children:[m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"App"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"relative",children:[m.jsxDEV("button",{onClick:()=>{G1(!a1),H1(!1),p1("")},className:"w-full flex items-center gap-2 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm text-left hover:border-[#555] transition",children:[d?m.jsxDEV(m.Fragment,{children:[d.logo?m.jsxDEV("img",{src:d.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):m.jsxDEV("div",{className:"w-5 h-5 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0",children:d.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"flex-1 truncate",children:d.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[10px] text-[#666]",children:[d.count," triggers"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("span",{className:"text-[#666] flex-1",children:"Select app..."},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#666] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a1&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>G1(!1)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#0a0a0a] border border-[#333] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[m.jsxDEV("div",{className:"p-2 border-b border-[#1a1a1a] flex-shrink-0",children:m.jsxDEV("input",{type:"text",value:M1,onChange:(N)=>p1(N.target.value),placeholder:"Search apps...",className:"w-full bg-[#111] border border-[#333] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"overflow-y-auto flex-1",children:t1.filter((N)=>{if(!M1)return!0;let v=M1.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)}).map((N)=>m.jsxDEV("button",{onClick:()=>{y1(N.slug),W1(""),z1({}),G1(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[#1a1a1a] ${s===N.slug?"bg-[#1a1a1a] text-[#f97316]":""}`,children:[N.logo?m.jsxDEV("img",{src:N.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):m.jsxDEV("div",{className:"w-5 h-5 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0",children:N.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),m.jsxDEV("span",{className:"flex-1 truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[10px] text-[#666]",children:N.count},void 0,!1,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)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),s&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Trigger"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"relative",children:[m.jsxDEV("button",{onClick:()=>{H1(!u1),G1(!1),x1("")},className:"w-full flex items-center gap-2 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm text-left hover:border-[#555] transition",children:[M?m.jsxDEV(m.Fragment,{children:[m.jsxDEV("span",{className:"flex-1 truncate",children:M.name},void 0,!1,void 0,this),m.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${M.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:M.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this):m.jsxDEV("span",{className:"text-[#666] flex-1",children:"Select trigger..."},void 0,!1,void 0,this),m.jsxDEV("span",{className:"text-[#666] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u1&&m.jsxDEV(m.Fragment,{children:[m.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>H1(!1)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[#0a0a0a] border border-[#333] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[e1.length>3&&m.jsxDEV("div",{className:"p-2 border-b border-[#1a1a1a] flex-shrink-0",children:m.jsxDEV("input",{type:"text",value:O1,onChange:(N)=>x1(N.target.value),placeholder:"Search triggers...",className:"w-full bg-[#111] border border-[#333] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.jsxDEV("div",{className:"overflow-y-auto flex-1",children:e1.filter((N)=>{if(!O1)return!0;let v=O1.toLowerCase();return N.name.toLowerCase().includes(v)||N.slug.toLowerCase().includes(v)||N.description.toLowerCase().includes(v)}).map((N)=>m.jsxDEV("button",{onClick:()=>{W1(N.slug),z1({}),H1(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[#1a1a1a] ${t===N.slug?"bg-[#1a1a1a] text-[#f97316]":""}`,children:[m.jsxDEV("div",{className:"flex-1 min-w-0",children:[m.jsxDEV("div",{className:"truncate",children:N.name},void 0,!1,void 0,this),m.jsxDEV("div",{className:"text-[10px] text-[#666] truncate",children:N.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${N.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:N.type},void 0,!1,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)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),U1?m.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",U1.appName]},void 0,!0,void 0,this):m.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 ",M?.toolkit_name||"this app",". Connect it first in the Integrations tab."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&M.config_schema&&Object.keys(M.config_schema.properties||{}).length>0&&m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),m.jsxDEV("div",{className:"space-y-2",children:Object.entries(M.config_schema.properties||{}).map(([N,v])=>{let _=(M.config_schema.required||[]).includes(N);return m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-[11px] text-[#888] mb-1",children:[v.title||N,_&&m.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m.jsxDEV("input",{type:"text",value:B1[N]||"",onChange:(f)=>z1((K)=>({...K,[N]:f.target.value})),placeholder:v.description||`Enter ${v.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),m.jsxDEV("div",{children:[m.jsxDEV("label",{className:"block text-xs text-[#888] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),h.length===0?m.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):m.jsxDEV(x,{value:e,onChange:h1,placeholder:"Select agent...",options:h.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),m.jsxDEV("div",{className:"flex gap-2 mt-5",children:[m.jsxDEV("button",{onClick:()=>q1(!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),m.jsxDEV("button",{onClick:O0,disabled:!t||!e||!U1||i1||M?.config_schema&&(M.config_schema.required||[]).some((N)=>!B1[N]?.trim()),className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:i1?"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 P=O(X1(),1);var z=O(n(),1);function f0(){let{authFetch:R}=g(),{currentProjectId:H}=j(),J=H&&H!=="unassigned"?H:null,F=J?`?project_id=${J}`:"",[Q,V]=P.useState([]),[W,T]=P.useState("");P.useEffect(()=>{R(`/api/triggers/providers${F}`).then((G)=>G.json()).then((G)=>{let b=(G.providers||[]).filter((k)=>k.connected);if(V(b),b.length>0&&!b.find((k)=>k.id===W))T(b[0].id)}).catch(()=>{})},[R]);let[A,S]=P.useState(null),[l,Y]=P.useState([]),[y,I]=P.useState(!1),a=P.useCallback(async(G)=>{S(G),I(!0);try{let b=`/api/triggers/types?provider=${W}&toolkit_slugs=${G}`;if(J)b+=`&project_id=${J}`;let k=await R(b);if(k.ok){let o=await k.json();Y(o.types||[])}}catch(b){console.error("Failed to fetch trigger types:",b)}I(!1)},[R,J,W]);return z.jsxDEV("div",{children:[z.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),Q.length>1&&z.jsxDEV("div",{className:"flex items-center gap-2 mb-4",children:[z.jsxDEV("span",{className:"text-xs text-[#666]",children:"Provider:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#111] border border-[#1a1a1a] rounded-lg p-0.5",children:Q.map((G)=>z.jsxDEV("button",{onClick:()=>T(G.id),className:`px-3 py-1 rounded text-xs font-medium transition ${W===G.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:G.name},G.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#666]",children:"No integration providers configured."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#555] mt-1",children:"Add API keys for Composio or AgentDojo in Settings."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(_0,{providerId:W,projectId:J,hideMcpConfig:!0,onBrowseTriggers:a},void 0,!1,void 0,this),A&&z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:"Trigger Types"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666]",children:A},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>{S(null),Y([])},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),z.jsxDEV("div",{className:"flex-1 overflow-auto p-4",children:y?z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading trigger types..."},void 0,!1,void 0,this):l.length===0?z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No trigger types available for this app."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:l.map((G)=>z.jsxDEV("div",{className:"bg-[#0a0a0a] border border-[#1a1a1a] rounded-lg p-3",children:z.jsxDEV("div",{className:"flex items-start gap-3",children:[G.logo?z.jsxDEV("img",{src:G.logo,alt:G.toolkit_name,className:"w-6 h-6 rounded object-contain flex-shrink-0 mt-0.5"},void 0,!1,void 0,this):z.jsxDEV("div",{className:"w-6 h-6 rounded bg-[#1a1a1a] flex items-center justify-center text-[10px] flex-shrink-0 mt-0.5",children:G.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"text-sm font-medium",children:G.name},void 0,!1,void 0,this),z.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:G.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-1.5",children:[z.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded font-mono",children:G.slug},void 0,!1,void 0,this),z.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${G.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:G.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)},G.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=O(n(),1);function JN(){let[R,H]=$0.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((F)=>w.jsxDEV("button",{onClick:()=>H(F.id),className:`px-4 py-2 rounded text-sm font-medium transition ${R===F.id?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:F.label},F.id,!1,void 0,this))},void 0,!1,void 0,this),R==="overview"&&w.jsxDEV(m0,{},void 0,!1,void 0,this),R==="triggers"&&w.jsxDEV(v0,{},void 0,!1,void 0,this),R==="integrations"&&w.jsxDEV(f0,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
2
2
|
export{I0 as a,JN as b};
|
|
3
3
|
|
|
4
4
|
//# debugId=59BAB8E2425680DC64756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{S as d,V as _q,W as qq,ca as Hq}from"./App.k377qek6.js";var U=d(_q(),1);var q=d(qq(),1);function i(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="API_KEY")}function Jq(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="OAUTH2")}function $q(J){return i(J)&&Jq(J)}function Rq({providerId:J="composio",projectId:Q,onConnectionComplete:k,onBrowseTriggers:F,hideMcpConfig:K}){let{authFetch:Y}=Hq(),[y,R]=U.useState([]),[L,P]=U.useState([]),[M,N]=U.useState(!0),[m,Qq]=U.useState(""),[A,B]=U.useState(null),[O,l]=U.useState(null),[r,X]=U.useState(null),[_,I]=U.useState(null),[$,b]=U.useState(null),[f,u]=U.useState(""),[w,V]=U.useState(null),[v,c]=U.useState(""),[s,g]=U.useState(!1),[n,x]=U.useState(null),[C,D]=U.useState(null),G=U.useCallback(async()=>{N(!0),X(null);let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let[H,W]=await Promise.all([Y(`/api/integrations/${J}/apps${z}`),Y(`/api/integrations/${J}/connected${z}`)]),Z=await H.json(),j=await W.json();R(Z.apps||[]),P(j.accounts||[])}catch(H){console.error("Failed to fetch integrations:",H),X("Failed to load integrations")}N(!1)},[Y,J,Q]);U.useEffect(()=>{G()},[G]),U.useEffect(()=>{if(new URLSearchParams(window.location.search).get("connected"))window.history.replaceState({},"",window.location.pathname),G(),k?.()},[G,k]),U.useEffect(()=>{if(!O?.connectionId)return;let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=setInterval(async()=>{try{let Z=await(await Y(`/api/integrations/${J}/connection/${O.connectionId}${z}`)).json();if(Z.connection?.status==="active")l(null),B(null),G(),k?.();else if(Z.connection?.status==="failed")l(null),B(null),X(`Connection to ${O.appSlug} failed`)}catch(W){}},2000);return()=>clearInterval(H)},[O,Y,J,Q,G,k]);let h=async(z,H,W)=>{if($q(z)&&!H&&!W){I({app:z});return}if(i(z)&&!H&&!W){b({app:z}),u("");return}B(z.slug),X(null);try{let Z={appSlug:z.slug};if(H)Z.credentials={authScheme:"API_KEY",apiKey:H};let j=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",p=await Y(`/api/integrations/${J}/connect${j}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}),T=await p.json();if(!p.ok){X(T.error||"Failed to initiate connection"),B(null),b(null);return}if(T.status==="active"||!T.redirectUrl){B(null),b(null),G(),k?.();return}if(T.redirectUrl){l({appSlug:z.slug,connectionId:T.connectionId});let e=window.open(T.redirectUrl,`connect-${z.slug}`,"width=600,height=700,left=200,top=100");if(!e||e.closed)window.location.href=T.redirectUrl}}catch(Z){X(`Failed to connect: ${Z}`),B(null),b(null)}},Uq=(z)=>{if(z.preventDefault(),!$||!f.trim())return;h($.app,f.trim())},Wq=async(z)=>{let H=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let W=await Y(`/api/integrations/${J}/connection/${z.id}${H}`,{method:"DELETE"});if(W.ok)G();else{let Z=await W.json();X(Z.error||"Failed to disconnect")}}catch(W){X(`Failed to disconnect: ${W}`)}},Xq=(z)=>{V({app:z}),c(`${z.name} MCP`),x(null)},Yq=async()=>{if(!w||!v.trim())return;g(!0),X(null);try{let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=await Y(`/api/integrations/${J}/configs${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.replace(/[^a-zA-Z0-9\s-]/g,"").substring(0,30),toolkitSlug:w.app.slug})}),W=await H.json();if(!H.ok){X(W.error||"Failed to create MCP config"),g(!1);return}x(v),k?.()}catch(z){X(`Failed to create MCP config: ${z}`)}finally{g(!1)}},Zq=(z)=>{D({message:`Disconnect ${z.appName}?`,onConfirm:()=>{Wq(z),D(null)}})},a=(z)=>{return L.some((H)=>H.appId===z&&H.status==="active")},t=(z)=>{return L.find((H)=>H.appId===z&&H.status==="active")||L.find((H)=>H.appId===z)},o=y.filter((z)=>{if(!m)return!0;let H=m.toLowerCase();return z.name.toLowerCase().includes(H)||z.slug.toLowerCase().includes(H)||z.description?.toLowerCase().includes(H)||z.categories.some((W)=>W.toLowerCase().includes(H))}),E=o.filter((z)=>a(z.slug)),S=o.filter((z)=>!a(z.slug));if(M)return q.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading apps..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"space-y-6",children:[_&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[_.app.logo&&q.jsxDEV("img",{src:_.app.logo,alt:_.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",_.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Choose how to authenticate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("button",{onClick:()=>{I(null),b({app:_.app}),u("")},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Enter your ",_.app.name," API key directly"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),h(_.app,void 0,!0)},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"OAuth"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Sign in with your ",_.app.name," account"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>I(null),className:"w-full text-sm text-[#666] hover:text-white mt-4 py-2 transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[$.app.logo&&q.jsxDEV("img",{src:$.app.logo,alt:$.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",$.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Enter your API key to connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:Uq,children:[q.jsxDEV("input",{type:"password",value:f,onChange:(z)=>u(z.target.value),placeholder:"Enter API Key...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>b(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!f.trim()||A===$.app.slug,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:A===$.app.slug?"Connecting...":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:n?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"text-center mb-4",children:[q.jsxDEV("div",{className:"w-12 h-12 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3",children:q.jsxDEV("span",{className:"text-green-400 text-2xl",children:"✓"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("h3",{className:"font-medium text-lg",children:"MCP Config Created!"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mt-2",children:['"',n,'" has been created successfully.']},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-2",children:"You can now add it to your agents from the MCP Configs tab."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{V(null),x(null)},className:"w-full text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[w.app.logo&&q.jsxDEV("img",{src:w.app.logo,alt:w.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:"Create MCP Config"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:["Create an MCP config for ",w.app.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:(z)=>{z.preventDefault(),Yq()},children:[q.jsxDEV("label",{className:"block text-xs text-[#888] mb-1",children:"Config Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:v,onChange:(z)=>c(z.target.value),placeholder:"Enter config name...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0,maxLength:30},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>V(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!v.trim()||s,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:s?"Creating...":"Create Config"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),C&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm mx-4",children:[q.jsxDEV("p",{className:"text-center mb-4",children:C.message},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>D(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:C.onConfirm,className:"flex-1 text-sm bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition",children:"Confirm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&q.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[q.jsxDEV("span",{children:r},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>X(null),className:"text-red-400 hover:text-red-300",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&q.jsxDEV("div",{className:"text-yellow-400 text-sm p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg flex items-center gap-2",children:[q.jsxDEV("span",{className:"animate-spin",children:"⟳"},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Waiting for ",O.appSlug," authorization..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:q.jsxDEV("input",{type:"text",value:m,onChange:(z)=>Qq(z.target.value),placeholder:"Search apps...",className:"w-full bg-[#111] border border-[#333] rounded-lg px-4 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),E.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Connected (",E.length,")"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:E.map((z)=>q.jsxDEV(zq,{app:z,connection:t(z.slug),onConnect:()=>h(z),onDisconnect:()=>{let H=t(z.slug);if(H)Zq(H)},onCreateMcpConfig:K?void 0:()=>Xq(z),onBrowseTriggers:F?()=>F(z.slug):void 0,connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Available Apps (",S.length,")"]},void 0,!0,void 0,this),S.length===0?q.jsxDEV("p",{className:"text-[#666] text-sm",children:m?"No apps match your search":"No apps available"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:S.slice(0,50).map((z)=>q.jsxDEV(zq,{app:z,onConnect:()=>h(z),connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this),S.length>50&&q.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 50 of ",S.length," apps. Use search to find more."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zq({app:J,connection:Q,onConnect:k,onDisconnect:F,onCreateMcpConfig:K,onBrowseTriggers:Y,connecting:y}){let R=Q?.status==="active",L=i(J),P=Jq(J),M=L&&P;return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition ${R?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start gap-3",children:[q.jsxDEV("div",{className:"w-10 h-10 rounded bg-[#1a1a1a] flex items-center justify-center flex-shrink-0 overflow-hidden",children:J.logo?q.jsxDEV("img",{src:J.logo,alt:J.name,className:"w-8 h-8 object-contain",onError:(N)=>{N.target.style.display="none"}},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-lg",children:J.name[0]?.toUpperCase()},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("h4",{className:"font-medium text-sm truncate",children:J.name},void 0,!1,void 0,this),R&&q.jsxDEV("span",{className:"text-xs text-green-400",children:"✓"},void 0,!1,void 0,this),!R&&L&&!P&&q.jsxDEV("span",{className:"text-[10px] bg-[#222] text-[#888] px-1.5 py-0.5 rounded",title:"Requires API Key",children:"API Key"},void 0,!1,void 0,this),!R&&M&&q.jsxDEV("span",{className:"text-[10px] bg-[#1a2a1a] text-[#6a6] px-1.5 py-0.5 rounded",title:"Supports API Key or OAuth",children:"API Key / OAuth"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.description&&q.jsxDEV("p",{className:"text-xs text-[#666] line-clamp-2 mt-0.5",children:J.description},void 0,!1,void 0,this),J.categories.length>0&&q.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:J.categories.slice(0,2).map((N)=>q.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded",children:N},N,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 flex gap-2",children:R?q.jsxDEV(q.Fragment,{children:[K&&q.jsxDEV("button",{onClick:K,className:"flex-1 text-xs bg-[#1a2a1a] hover:bg-[#1a3a1a] border border-green-500/30 hover:border-green-500/50 text-green-400 px-3 py-1.5 rounded transition",children:"Create MCP Config"},void 0,!1,void 0,this),Y&&q.jsxDEV("button",{onClick:Y,className:"flex-1 text-xs bg-[#1a1a2a] hover:bg-[#1a1a3a] border border-blue-500/30 hover:border-blue-500/50 text-blue-400 px-3 py-1.5 rounded transition",children:"Browse Triggers"},void 0,!1,void 0,this),F&&q.jsxDEV("button",{onClick:F,className:"text-xs text-[#666] hover:text-red-400 transition px-2",title:"Disconnect",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("button",{onClick:k,disabled:y,className:"w-full text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:y?"Connecting...":L&&!P?"Enter API Key":"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
|
|
1
|
+
import{S as d,V as _q,W as qq,ca as Hq}from"./App.mvtqv6qc.js";var U=d(_q(),1);var q=d(qq(),1);function i(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="API_KEY")}function Jq(J){return J.authSchemes.some((Q)=>Q.toUpperCase()==="OAUTH2")}function $q(J){return i(J)&&Jq(J)}function Rq({providerId:J="composio",projectId:Q,onConnectionComplete:k,onBrowseTriggers:F,hideMcpConfig:K}){let{authFetch:Y}=Hq(),[y,R]=U.useState([]),[L,P]=U.useState([]),[M,N]=U.useState(!0),[m,Qq]=U.useState(""),[A,B]=U.useState(null),[O,l]=U.useState(null),[r,X]=U.useState(null),[_,I]=U.useState(null),[$,b]=U.useState(null),[f,u]=U.useState(""),[w,V]=U.useState(null),[v,c]=U.useState(""),[s,g]=U.useState(!1),[n,x]=U.useState(null),[C,D]=U.useState(null),G=U.useCallback(async()=>{N(!0),X(null);let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let[H,W]=await Promise.all([Y(`/api/integrations/${J}/apps${z}`),Y(`/api/integrations/${J}/connected${z}`)]),Z=await H.json(),j=await W.json();R(Z.apps||[]),P(j.accounts||[])}catch(H){console.error("Failed to fetch integrations:",H),X("Failed to load integrations")}N(!1)},[Y,J,Q]);U.useEffect(()=>{G()},[G]),U.useEffect(()=>{if(new URLSearchParams(window.location.search).get("connected"))window.history.replaceState({},"",window.location.pathname),G(),k?.()},[G,k]),U.useEffect(()=>{if(!O?.connectionId)return;let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=setInterval(async()=>{try{let Z=await(await Y(`/api/integrations/${J}/connection/${O.connectionId}${z}`)).json();if(Z.connection?.status==="active")l(null),B(null),G(),k?.();else if(Z.connection?.status==="failed")l(null),B(null),X(`Connection to ${O.appSlug} failed`)}catch(W){}},2000);return()=>clearInterval(H)},[O,Y,J,Q,G,k]);let h=async(z,H,W)=>{if($q(z)&&!H&&!W){I({app:z});return}if(i(z)&&!H&&!W){b({app:z}),u("");return}B(z.slug),X(null);try{let Z={appSlug:z.slug};if(H)Z.credentials={authScheme:"API_KEY",apiKey:H};let j=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",p=await Y(`/api/integrations/${J}/connect${j}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}),T=await p.json();if(!p.ok){X(T.error||"Failed to initiate connection"),B(null),b(null);return}if(T.status==="active"||!T.redirectUrl){B(null),b(null),G(),k?.();return}if(T.redirectUrl){l({appSlug:z.slug,connectionId:T.connectionId});let e=window.open(T.redirectUrl,`connect-${z.slug}`,"width=600,height=700,left=200,top=100");if(!e||e.closed)window.location.href=T.redirectUrl}}catch(Z){X(`Failed to connect: ${Z}`),B(null),b(null)}},Uq=(z)=>{if(z.preventDefault(),!$||!f.trim())return;h($.app,f.trim())},Wq=async(z)=>{let H=Q&&Q!=="unassigned"?`?project_id=${Q}`:"";try{let W=await Y(`/api/integrations/${J}/connection/${z.id}${H}`,{method:"DELETE"});if(W.ok)G();else{let Z=await W.json();X(Z.error||"Failed to disconnect")}}catch(W){X(`Failed to disconnect: ${W}`)}},Xq=(z)=>{V({app:z}),c(`${z.name} MCP`),x(null)},Yq=async()=>{if(!w||!v.trim())return;g(!0),X(null);try{let z=Q&&Q!=="unassigned"?`?project_id=${Q}`:"",H=await Y(`/api/integrations/${J}/configs${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.replace(/[^a-zA-Z0-9\s-]/g,"").substring(0,30),toolkitSlug:w.app.slug})}),W=await H.json();if(!H.ok){X(W.error||"Failed to create MCP config"),g(!1);return}x(v),k?.()}catch(z){X(`Failed to create MCP config: ${z}`)}finally{g(!1)}},Zq=(z)=>{D({message:`Disconnect ${z.appName}?`,onConfirm:()=>{Wq(z),D(null)}})},a=(z)=>{return L.some((H)=>H.appId===z&&H.status==="active")},t=(z)=>{return L.find((H)=>H.appId===z&&H.status==="active")||L.find((H)=>H.appId===z)},o=y.filter((z)=>{if(!m)return!0;let H=m.toLowerCase();return z.name.toLowerCase().includes(H)||z.slug.toLowerCase().includes(H)||z.description?.toLowerCase().includes(H)||z.categories.some((W)=>W.toLowerCase().includes(H))}),E=o.filter((z)=>a(z.slug)),S=o.filter((z)=>!a(z.slug));if(M)return q.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading apps..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"space-y-6",children:[_&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[_.app.logo&&q.jsxDEV("img",{src:_.app.logo,alt:_.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",_.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Choose how to authenticate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("button",{onClick:()=>{I(null),b({app:_.app}),u("")},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Enter your ",_.app.name," API key directly"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),h(_.app,void 0,!0)},className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#333] hover:border-[#f97316] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"OAuth"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[#666] mt-0.5",children:["Sign in with your ",_.app.name," account"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>I(null),className:"w-full text-sm text-[#666] hover:text-white mt-4 py-2 transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),$&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[$.app.logo&&q.jsxDEV("img",{src:$.app.logo,alt:$.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",$.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Enter your API key to connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:Uq,children:[q.jsxDEV("input",{type:"password",value:f,onChange:(z)=>u(z.target.value),placeholder:"Enter API Key...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>b(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!f.trim()||A===$.app.slug,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:A===$.app.slug?"Connecting...":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-md mx-4",children:n?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"text-center mb-4",children:[q.jsxDEV("div",{className:"w-12 h-12 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3",children:q.jsxDEV("span",{className:"text-green-400 text-2xl",children:"✓"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("h3",{className:"font-medium text-lg",children:"MCP Config Created!"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mt-2",children:['"',n,'" has been created successfully.']},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-2",children:"You can now add it to your agents from the MCP Configs tab."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{V(null),x(null)},className:"w-full text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[w.app.logo&&q.jsxDEV("img",{src:w.app.logo,alt:w.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:"Create MCP Config"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666]",children:["Create an MCP config for ",w.app.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:(z)=>{z.preventDefault(),Yq()},children:[q.jsxDEV("label",{className:"block text-xs text-[#888] mb-1",children:"Config Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:v,onChange:(z)=>c(z.target.value),placeholder:"Enter config name...",className:"w-full bg-[#0a0a0a] border border-[#333] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[#f97316]",autoFocus:!0,maxLength:30},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>V(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{type:"submit",disabled:!v.trim()||s,className:"flex-1 text-sm bg-[#f97316] hover:bg-[#ea580c] text-white px-4 py-2 rounded transition disabled:opacity-50",children:s?"Creating...":"Create Config"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),C&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm mx-4",children:[q.jsxDEV("p",{className:"text-center mb-4",children:C.message},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>D(null),className:"flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:C.onConfirm,className:"flex-1 text-sm bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition",children:"Confirm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&q.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[q.jsxDEV("span",{children:r},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>X(null),className:"text-red-400 hover:text-red-300",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&q.jsxDEV("div",{className:"text-yellow-400 text-sm p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg flex items-center gap-2",children:[q.jsxDEV("span",{className:"animate-spin",children:"⟳"},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Waiting for ",O.appSlug," authorization..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:q.jsxDEV("input",{type:"text",value:m,onChange:(z)=>Qq(z.target.value),placeholder:"Search apps...",className:"w-full bg-[#111] border border-[#333] rounded-lg px-4 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),E.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Connected (",E.length,")"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:E.map((z)=>q.jsxDEV(zq,{app:z,connection:t(z.slug),onConnect:()=>h(z),onDisconnect:()=>{let H=t(z.slug);if(H)Zq(H)},onCreateMcpConfig:K?void 0:()=>Xq(z),onBrowseTriggers:F?()=>F(z.slug):void 0,connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-3",children:["Available Apps (",S.length,")"]},void 0,!0,void 0,this),S.length===0?q.jsxDEV("p",{className:"text-[#666] text-sm",children:m?"No apps match your search":"No apps available"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:S.slice(0,50).map((z)=>q.jsxDEV(zq,{app:z,onConnect:()=>h(z),connecting:A===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this),S.length>50&&q.jsxDEV("p",{className:"text-xs text-[#555] mt-3 text-center",children:["Showing first 50 of ",S.length," apps. Use search to find more."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zq({app:J,connection:Q,onConnect:k,onDisconnect:F,onCreateMcpConfig:K,onBrowseTriggers:Y,connecting:y}){let R=Q?.status==="active",L=i(J),P=Jq(J),M=L&&P;return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition ${R?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start gap-3",children:[q.jsxDEV("div",{className:"w-10 h-10 rounded bg-[#1a1a1a] flex items-center justify-center flex-shrink-0 overflow-hidden",children:J.logo?q.jsxDEV("img",{src:J.logo,alt:J.name,className:"w-8 h-8 object-contain",onError:(N)=>{N.target.style.display="none"}},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-lg",children:J.name[0]?.toUpperCase()},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("h4",{className:"font-medium text-sm truncate",children:J.name},void 0,!1,void 0,this),R&&q.jsxDEV("span",{className:"text-xs text-green-400",children:"✓"},void 0,!1,void 0,this),!R&&L&&!P&&q.jsxDEV("span",{className:"text-[10px] bg-[#222] text-[#888] px-1.5 py-0.5 rounded",title:"Requires API Key",children:"API Key"},void 0,!1,void 0,this),!R&&M&&q.jsxDEV("span",{className:"text-[10px] bg-[#1a2a1a] text-[#6a6] px-1.5 py-0.5 rounded",title:"Supports API Key or OAuth",children:"API Key / OAuth"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),J.description&&q.jsxDEV("p",{className:"text-xs text-[#666] line-clamp-2 mt-0.5",children:J.description},void 0,!1,void 0,this),J.categories.length>0&&q.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:J.categories.slice(0,2).map((N)=>q.jsxDEV("span",{className:"text-[10px] bg-[#1a1a1a] text-[#555] px-1.5 py-0.5 rounded",children:N},N,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 flex gap-2",children:R?q.jsxDEV(q.Fragment,{children:[K&&q.jsxDEV("button",{onClick:K,className:"flex-1 text-xs bg-[#1a2a1a] hover:bg-[#1a3a1a] border border-green-500/30 hover:border-green-500/50 text-green-400 px-3 py-1.5 rounded transition",children:"Create MCP Config"},void 0,!1,void 0,this),Y&&q.jsxDEV("button",{onClick:Y,className:"flex-1 text-xs bg-[#1a1a2a] hover:bg-[#1a1a3a] border border-blue-500/30 hover:border-blue-500/50 text-blue-400 px-3 py-1.5 rounded transition",children:"Browse Triggers"},void 0,!1,void 0,this),F&&q.jsxDEV("button",{onClick:F,className:"text-xs text-[#666] hover:text-red-400 transition px-2",title:"Disconnect",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("button",{onClick:k,disabled:y,className:"w-full text-xs bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:y?"Connecting...":L&&!P?"Enter API Key":"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
|
|
2
2
|
export{Rq as k};
|
|
3
3
|
|
|
4
4
|
//# debugId=879C1544186FFE2D64756E2164756E21
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{O as Oz,P as Wz}from"./App.40azyqz6.js";import{R as j}from"./App.r2c5nw36.js";import{S as n,V as Qz,W as zz,ca as Jz,fa as Kz}from"./App.k377qek6.js";var W=n(Qz(),1);var z=n(zz(),1);function Rz(){let{authFetch:K}=Jz(),{projects:Z,currentProjectId:Y}=Kz(),[B,N]=W.useState([]),[y,M]=W.useState(!0),[X,U]=W.useState("installed"),[G,Q]=W.useState(!1),[C,H]=W.useState(!1),[v,T]=W.useState(null),{confirm:f,ConfirmDialog:w}=Oz(),{alert:P,AlertDialog:d}=Wz(),_=Z.length>0,[m,p]=W.useState(""),[h,Xz]=W.useState([]),[c,r]=W.useState(!1),[Yz,o]=W.useState(null),[a,i]=W.useState(""),[R,t]=W.useState([]),[I,u]=W.useState(!1),[V,b]=W.useState(null),[q,l]=W.useState(null),[e,S]=W.useState(null),[x,Zz]=W.useState(Y&&Y!=="unassigned"?Y:null),D=B.filter((J)=>{if(!Y)return!0;if(Y==="unassigned")return J.project_id===null;return J.project_id===null||J.project_id===Y}),F=async()=>{try{let O=await(await K("/api/skills")).json();N(O.skills||[])}catch(J){console.error("Failed to fetch skills:",J)}M(!1)},E=async(J)=>{r(!0);try{let O=J!==void 0?J:m,$=O?`/api/skills/marketplace/search?q=${encodeURIComponent(O)}`:"/api/skills/marketplace/featured",A=await(await K($)).json();Xz(A.skills||[])}catch(O){console.error("Failed to search marketplace:",O)}r(!1)};W.useEffect(()=>{F()},[K]),W.useEffect(()=>{if(X==="marketplace"&&h.length===0)E("")},[X]);let _z=async(J)=>{try{await K(`/api/skills/${J}/toggle`,{method:"POST"}),F()}catch(O){console.error("Failed to toggle skill:",O)}},$z=async(J)=>{if(!await f("Delete this skill?",{confirmText:"Delete",title:"Delete Skill"}))return;try{if(await K(`/api/skills/${J}`,{method:"DELETE"}),v?.id===J)T(null);F()}catch($){console.error("Failed to delete skill:",$)}},Bz=async(J)=>{o(J.id);try{let O=await K(`/api/skills/marketplace/${J.id}/install`,{method:"POST"}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F(),U("installed");else await P($.error||"Failed to install skill",{title:"Installation Failed"})}catch(O){console.error("Failed to install skill:",O),await P("Failed to install skill",{title:"Error"})}o(null)},g=(J)=>B.some((O)=>O.name===J),s=async(J)=>{let O=J||a;if(!O.trim())return;let $="",L="";if(O.includes("github.com")){let A=O.match(/github\.com\/([^/]+)\/([^/]+)/);if(A)$=A[1],L=A[2].replace(/\.git$/,"")}else if(O.includes("/")){let A=O.split("/");$=A[0],L=A[1]}if(!$||!L){b("Invalid repo format. Use 'owner/repo' or GitHub URL");return}u(!0),b(null),t([]),l(null);try{let A=await K(`/api/skills/github/${$}/${L}`),k=await A.json();if(!A.ok){b(k.error||"Failed to fetch repository"),u(!1);return}t(k.skills||[]),l(k.repo||null)}catch(A){b("Failed to fetch repository")}u(!1)},Nz=async(J)=>{if(!q)return;S(J.name);try{let O=await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:J.name,downloadUrl:J.downloadUrl,projectId:x})}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F();else await P($.error||"Failed to install skill",{title:"Installation Failed",variant:"error"})}catch(O){await P("Failed to install skill",{title:"Error",variant:"error"})}S(null)},Uz=async()=>{if(!q||R.length===0)return;let J=R.filter((L)=>!g(L.name));if(J.length===0){await P("All skills are already installed",{title:"Info"});return}if(!await f(`Install ${J.length} skill(s) from ${q.owner}/${q.repo}?`,{confirmText:"Install All",title:"Install Skills"}))return;let $=0;for(let L of J){S(L.name);try{if((await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:L.name,downloadUrl:L.downloadUrl,projectId:x})})).ok)$++}catch(A){}}S(null),F(),await P(`Installed ${$} of ${J.length} skills`,{title:"Installation Complete"})};return z.jsxDEV(z.Fragment,{children:[w,d,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Skills"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage agent skills - instructions that teach agents how to perform tasks."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("button",{onClick:()=>H(!0),className:"bg-[#1a1a1a] hover:bg-[#222] text-white px-4 py-2 rounded font-medium transition border border-[#333]",children:"Import"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>Q(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Create Skill"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>U("installed"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="installed"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:["Installed (",D.length,")"]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>U("github"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="github"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse GitHub"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="marketplace"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV(z.Fragment,{children:y?z.jsxDEV("div",{className:"text-[#666]",children:"Loading skills..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[#666]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills installed"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Create a skill or browse the marketplace"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:"mt-4 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Browse Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No skills match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:D.map((J)=>{let O=_&&J.project_id?Z.find(($)=>$.id===J.project_id):null;return z.jsxDEV(Hz,{skill:J,project:O,onToggle:()=>_z(J.id),onDelete:()=>$z(J.id),onView:()=>T(J)},J.id,!1,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),X==="github"&&z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:(J)=>{J.preventDefault(),s()},className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:a,onChange:(J)=>i(J.target.value),placeholder:"Enter GitHub repo (e.g., WordPress/agent-skills)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:I,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:I?"...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&R.length>0&&z.jsxDEV("div",{className:"flex items-center gap-3 p-3 bg-[#0a0a0a] border border-[#222] rounded-lg",children:[z.jsxDEV("span",{className:"text-sm text-[#666]",children:"Install to:"},void 0,!1,void 0,this),z.jsxDEV(j,{value:x||"",onChange:(J)=>Zz(J||null),options:[{value:"",label:"Global (all projects)"},...Z.map((J)=>({value:J.id,label:J.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:V},void 0,!1,void 0,this),q&&R.length>0&&z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline font-medium",children:[q.owner,"/",q.repo]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"text-sm text-[#666]",children:[R.length," skill",R.length!==1?"s":""," found"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.some((J)=>!g(J.name))&&z.jsxDEV("button",{onClick:Uz,disabled:!!e,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded transition disabled:opacity-50",children:"Install All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Fetching skills from repository..."},void 0,!1,void 0,this),!I&&!q&&!V&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("div",{className:"text-4xl mb-4",children:"\uD83D\uDCE6"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"Browse Skills from GitHub"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"Enter a GitHub repository to browse and install skills. Skills are markdown files with instructions that teach agents how to perform specific tasks."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2 justify-center",children:[{label:"WordPress Skills",repo:"WordPress/agent-skills"}].map(({label:J,repo:O})=>z.jsxDEV("button",{onClick:()=>{i(O),s(O)},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition",children:J},O,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!I&&q&&R.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No skills found in this repository. Skills should be in subdirectories with a SKILL.md file."},void 0,!1,void 0,this),R.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:R.map((J)=>{let O=g(J.name),$=e===J.name;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 transition ${O?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:J.name},void 0,!1,void 0,this),O&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"✓ Installed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:J.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[z.jsxDEV("span",{children:[(J.size/1024).toFixed(1),"KB"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:"GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:O?z.jsxDEV("span",{className:"text-xs text-[#555] px-3 py-1.5",children:"Added"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>Nz(J),disabled:$,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:$?"Installing...":"Install"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},J.name,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Skills are sourced from GitHub repositories. Each skill should be in its own directory with a"," ",z.jsxDEV("code",{className:"text-[#888] bg-[#0a0a0a] px-1 rounded",children:"SKILL.md"},void 0,!1,void 0,this)," file containing instructions."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="marketplace"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"mb-6",children:z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:m,onChange:(J)=>p(J.target.value),onKeyDown:(J)=>J.key==="Enter"&&E(),placeholder:"Search skills...",className:"flex-1 bg-[#111] border border-[#1a1a1a] rounded px-4 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>E(),disabled:c,className:"bg-[#1a1a1a] hover:bg-[#222] text-white px-4 py-2 rounded font-medium transition border border-[#333]",children:c?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c?z.jsxDEV("div",{className:"text-[#666]",children:"Loading..."},void 0,!1,void 0,this):h.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[#666]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Try a different search term"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:h.map((J)=>z.jsxDEV(qz,{skill:J,installed:g(J.name),installing:Yz===J.id,onInstall:()=>Bz(J)},J.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),G&&z.jsxDEV(Az,{authFetch:K,onClose:()=>Q(!1),onCreated:()=>{Q(!1),F()},projects:_?Z:void 0,defaultProjectId:Y&&Y!=="unassigned"?Y:null},void 0,!1,void 0,this),C&&z.jsxDEV(yz,{authFetch:K,onClose:()=>H(!1),onImported:()=>{H(!1),F()}},void 0,!1,void 0,this),v&&z.jsxDEV(Mz,{skill:v,authFetch:K,onClose:()=>T(null),onUpdated:()=>{T(null),F()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Hz({skill:K,project:Z,onToggle:Y,onDelete:B,onView:N}){let y={local:"Local",skillsmp:"SkillsMP",github:"GitHub",import:"Imported"}[K.source],M=()=>{if(Z)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${Z.color}20`,color:Z.color},children:Z.name},void 0,!1,void 0,this);if(K.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] rounded-lg p-5 border transition cursor-pointer ${K.enabled?"border-[#1a1a1a]":"border-[#1a1a1a] opacity-60"} hover:border-[#333]`,onClick:N,children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666] flex items-center gap-2 mt-0.5",children:[z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${K.source==="skillsmp"?"bg-purple-500/20 text-purple-400":K.source==="github"?"bg-blue-500/20 text-blue-400":"bg-[#222] text-[#888]"}`,children:y},void 0,!1,void 0,this),K.metadata?.version&&z.jsxDEV("span",{children:["v",K.metadata.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),Y()},className:`w-10 h-5 rounded-full transition-colors relative ${K.enabled?"bg-[#f97316]":"bg-[#333]"}`,children:z.jsxDEV("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${K.enabled?"left-5":"left-0.5"}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#888] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:[K.allowed_tools.slice(0,2).map((X)=>z.jsxDEV("span",{className:"text-xs bg-[#222] px-2 py-0.5 rounded text-[#666]",children:X},X,!1,void 0,this)),K.allowed_tools.length>2&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:["+",K.allowed_tools.length-2]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),B()},className:"text-red-400 hover:text-red-300 text-sm",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz({skill:K,installed:Z,installing:Y,onInstall:B}){return z.jsxDEV("div",{className:"bg-[#111] rounded-lg p-5 border border-[#1a1a1a] hover:border-[#333] transition",children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666] mt-0.5",children:["by ",K.author," · v",K.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-1 text-yellow-500 text-sm",children:["★ ",K.rating.toFixed(1)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#888] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:K.tags.slice(0,3).map((N)=>z.jsxDEV("span",{className:"text-xs bg-[#222] px-2 py-0.5 rounded text-[#666]",children:N},N,!1,void 0,this))},void 0,!1,void 0,this),Z?z.jsxDEV("span",{className:"text-green-400 text-sm",children:"✓ Installed"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:B,disabled:Y,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-3 py-1 rounded text-sm font-medium transition",children:Y?"Installing...":"Install"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"mt-3 text-xs text-[#555]",children:[K.downloads.toLocaleString()," downloads"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Az({authFetch:K,onClose:Z,onCreated:Y,projects:B,defaultProjectId:N}){let[y,M]=W.useState(""),[X,U]=W.useState(""),[G,Q]=W.useState(""),[C,H]=W.useState(N||null),[v,T]=W.useState(!1),[f,w]=W.useState(null),P=B&&B.length>0,d=async()=>{if(!y||!X||!G){w("All fields are required");return}T(!0),w(null);try{let _={name:y,description:X,content:G,source:"local"};if(C)_.project_id=C;let m=await K("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),p=await m.json();if(!m.ok){w(p.error||"Failed to create skill"),T(!1);return}Y()}catch(_){w("Failed to create skill"),T(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Z,children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:(_)=>_.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[#1a1a1a]",children:z.jsxDEV("h2",{className:"text-xl font-semibold",children:"Create Skill"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-6 space-y-4",children:[f&&z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded p-3 text-red-400 text-sm",children:f},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(_)=>M(_.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"my-skill-name",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Lowercase letters, numbers, and hyphens only"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Description"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(_)=>U(_.target.value),placeholder:"What this skill does and when to use it...",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(j,{value:C||"",onChange:(_)=>H(_||null),options:[{value:"",label:"Global (all projects)"},...B.map((_)=>({value:_.id,label:_.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global skills are available to all agents. Project-scoped skills are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Instructions (Markdown)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(_)=>Q(_.target.value),placeholder:`# Skill Instructions
|
|
1
|
+
import{O as Oz,P as Wz}from"./App.yv87t9m5.js";import{R as j}from"./App.p0fb1pds.js";import{S as n,V as Qz,W as zz,ca as Jz,fa as Kz}from"./App.mvtqv6qc.js";var W=n(Qz(),1);var z=n(zz(),1);function Rz(){let{authFetch:K}=Jz(),{projects:Z,currentProjectId:Y}=Kz(),[B,N]=W.useState([]),[y,M]=W.useState(!0),[X,U]=W.useState("installed"),[G,Q]=W.useState(!1),[C,H]=W.useState(!1),[v,T]=W.useState(null),{confirm:f,ConfirmDialog:w}=Oz(),{alert:P,AlertDialog:d}=Wz(),_=Z.length>0,[m,p]=W.useState(""),[h,Xz]=W.useState([]),[c,r]=W.useState(!1),[Yz,o]=W.useState(null),[a,i]=W.useState(""),[R,t]=W.useState([]),[I,u]=W.useState(!1),[V,b]=W.useState(null),[q,l]=W.useState(null),[e,S]=W.useState(null),[x,Zz]=W.useState(Y&&Y!=="unassigned"?Y:null),D=B.filter((J)=>{if(!Y)return!0;if(Y==="unassigned")return J.project_id===null;return J.project_id===null||J.project_id===Y}),F=async()=>{try{let O=await(await K("/api/skills")).json();N(O.skills||[])}catch(J){console.error("Failed to fetch skills:",J)}M(!1)},E=async(J)=>{r(!0);try{let O=J!==void 0?J:m,$=O?`/api/skills/marketplace/search?q=${encodeURIComponent(O)}`:"/api/skills/marketplace/featured",A=await(await K($)).json();Xz(A.skills||[])}catch(O){console.error("Failed to search marketplace:",O)}r(!1)};W.useEffect(()=>{F()},[K]),W.useEffect(()=>{if(X==="marketplace"&&h.length===0)E("")},[X]);let _z=async(J)=>{try{await K(`/api/skills/${J}/toggle`,{method:"POST"}),F()}catch(O){console.error("Failed to toggle skill:",O)}},$z=async(J)=>{if(!await f("Delete this skill?",{confirmText:"Delete",title:"Delete Skill"}))return;try{if(await K(`/api/skills/${J}`,{method:"DELETE"}),v?.id===J)T(null);F()}catch($){console.error("Failed to delete skill:",$)}},Bz=async(J)=>{o(J.id);try{let O=await K(`/api/skills/marketplace/${J.id}/install`,{method:"POST"}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F(),U("installed");else await P($.error||"Failed to install skill",{title:"Installation Failed"})}catch(O){console.error("Failed to install skill:",O),await P("Failed to install skill",{title:"Error"})}o(null)},g=(J)=>B.some((O)=>O.name===J),s=async(J)=>{let O=J||a;if(!O.trim())return;let $="",L="";if(O.includes("github.com")){let A=O.match(/github\.com\/([^/]+)\/([^/]+)/);if(A)$=A[1],L=A[2].replace(/\.git$/,"")}else if(O.includes("/")){let A=O.split("/");$=A[0],L=A[1]}if(!$||!L){b("Invalid repo format. Use 'owner/repo' or GitHub URL");return}u(!0),b(null),t([]),l(null);try{let A=await K(`/api/skills/github/${$}/${L}`),k=await A.json();if(!A.ok){b(k.error||"Failed to fetch repository"),u(!1);return}t(k.skills||[]),l(k.repo||null)}catch(A){b("Failed to fetch repository")}u(!1)},Nz=async(J)=>{if(!q)return;S(J.name);try{let O=await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:J.name,downloadUrl:J.downloadUrl,projectId:x})}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F();else await P($.error||"Failed to install skill",{title:"Installation Failed",variant:"error"})}catch(O){await P("Failed to install skill",{title:"Error",variant:"error"})}S(null)},Uz=async()=>{if(!q||R.length===0)return;let J=R.filter((L)=>!g(L.name));if(J.length===0){await P("All skills are already installed",{title:"Info"});return}if(!await f(`Install ${J.length} skill(s) from ${q.owner}/${q.repo}?`,{confirmText:"Install All",title:"Install Skills"}))return;let $=0;for(let L of J){S(L.name);try{if((await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:L.name,downloadUrl:L.downloadUrl,projectId:x})})).ok)$++}catch(A){}}S(null),F(),await P(`Installed ${$} of ${J.length} skills`,{title:"Installation Complete"})};return z.jsxDEV(z.Fragment,{children:[w,d,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Skills"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage agent skills - instructions that teach agents how to perform tasks."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("button",{onClick:()=>H(!0),className:"bg-[#1a1a1a] hover:bg-[#222] text-white px-4 py-2 rounded font-medium transition border border-[#333]",children:"Import"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>Q(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Create Skill"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>U("installed"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="installed"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:["Installed (",D.length,")"]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>U("github"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="github"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse GitHub"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="marketplace"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV(z.Fragment,{children:y?z.jsxDEV("div",{className:"text-[#666]",children:"Loading skills..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[#666]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills installed"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Create a skill or browse the marketplace"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:"mt-4 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Browse Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No skills match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:D.map((J)=>{let O=_&&J.project_id?Z.find(($)=>$.id===J.project_id):null;return z.jsxDEV(Hz,{skill:J,project:O,onToggle:()=>_z(J.id),onDelete:()=>$z(J.id),onView:()=>T(J)},J.id,!1,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),X==="github"&&z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:(J)=>{J.preventDefault(),s()},className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:a,onChange:(J)=>i(J.target.value),placeholder:"Enter GitHub repo (e.g., WordPress/agent-skills)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:I,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:I?"...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&R.length>0&&z.jsxDEV("div",{className:"flex items-center gap-3 p-3 bg-[#0a0a0a] border border-[#222] rounded-lg",children:[z.jsxDEV("span",{className:"text-sm text-[#666]",children:"Install to:"},void 0,!1,void 0,this),z.jsxDEV(j,{value:x||"",onChange:(J)=>Zz(J||null),options:[{value:"",label:"Global (all projects)"},...Z.map((J)=>({value:J.id,label:J.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:V},void 0,!1,void 0,this),q&&R.length>0&&z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline font-medium",children:[q.owner,"/",q.repo]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"text-sm text-[#666]",children:[R.length," skill",R.length!==1?"s":""," found"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.some((J)=>!g(J.name))&&z.jsxDEV("button",{onClick:Uz,disabled:!!e,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded transition disabled:opacity-50",children:"Install All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Fetching skills from repository..."},void 0,!1,void 0,this),!I&&!q&&!V&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("div",{className:"text-4xl mb-4",children:"\uD83D\uDCE6"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"Browse Skills from GitHub"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"Enter a GitHub repository to browse and install skills. Skills are markdown files with instructions that teach agents how to perform specific tasks."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2 justify-center",children:[{label:"WordPress Skills",repo:"WordPress/agent-skills"}].map(({label:J,repo:O})=>z.jsxDEV("button",{onClick:()=>{i(O),s(O)},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition",children:J},O,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!I&&q&&R.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No skills found in this repository. Skills should be in subdirectories with a SKILL.md file."},void 0,!1,void 0,this),R.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:R.map((J)=>{let O=g(J.name),$=e===J.name;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 transition ${O?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:J.name},void 0,!1,void 0,this),O&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"✓ Installed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:J.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[z.jsxDEV("span",{children:[(J.size/1024).toFixed(1),"KB"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:"GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:O?z.jsxDEV("span",{className:"text-xs text-[#555] px-3 py-1.5",children:"Added"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>Nz(J),disabled:$,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:$?"Installing...":"Install"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},J.name,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Skills are sourced from GitHub repositories. Each skill should be in its own directory with a"," ",z.jsxDEV("code",{className:"text-[#888] bg-[#0a0a0a] px-1 rounded",children:"SKILL.md"},void 0,!1,void 0,this)," file containing instructions."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="marketplace"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"mb-6",children:z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:m,onChange:(J)=>p(J.target.value),onKeyDown:(J)=>J.key==="Enter"&&E(),placeholder:"Search skills...",className:"flex-1 bg-[#111] border border-[#1a1a1a] rounded px-4 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>E(),disabled:c,className:"bg-[#1a1a1a] hover:bg-[#222] text-white px-4 py-2 rounded font-medium transition border border-[#333]",children:c?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c?z.jsxDEV("div",{className:"text-[#666]",children:"Loading..."},void 0,!1,void 0,this):h.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[#666]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Try a different search term"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:h.map((J)=>z.jsxDEV(qz,{skill:J,installed:g(J.name),installing:Yz===J.id,onInstall:()=>Bz(J)},J.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),G&&z.jsxDEV(Az,{authFetch:K,onClose:()=>Q(!1),onCreated:()=>{Q(!1),F()},projects:_?Z:void 0,defaultProjectId:Y&&Y!=="unassigned"?Y:null},void 0,!1,void 0,this),C&&z.jsxDEV(yz,{authFetch:K,onClose:()=>H(!1),onImported:()=>{H(!1),F()}},void 0,!1,void 0,this),v&&z.jsxDEV(Mz,{skill:v,authFetch:K,onClose:()=>T(null),onUpdated:()=>{T(null),F()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Hz({skill:K,project:Z,onToggle:Y,onDelete:B,onView:N}){let y={local:"Local",skillsmp:"SkillsMP",github:"GitHub",import:"Imported"}[K.source],M=()=>{if(Z)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${Z.color}20`,color:Z.color},children:Z.name},void 0,!1,void 0,this);if(K.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] rounded-lg p-5 border transition cursor-pointer ${K.enabled?"border-[#1a1a1a]":"border-[#1a1a1a] opacity-60"} hover:border-[#333]`,onClick:N,children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666] flex items-center gap-2 mt-0.5",children:[z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${K.source==="skillsmp"?"bg-purple-500/20 text-purple-400":K.source==="github"?"bg-blue-500/20 text-blue-400":"bg-[#222] text-[#888]"}`,children:y},void 0,!1,void 0,this),K.metadata?.version&&z.jsxDEV("span",{children:["v",K.metadata.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),Y()},className:`w-10 h-5 rounded-full transition-colors relative ${K.enabled?"bg-[#f97316]":"bg-[#333]"}`,children:z.jsxDEV("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${K.enabled?"left-5":"left-0.5"}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#888] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:[K.allowed_tools.slice(0,2).map((X)=>z.jsxDEV("span",{className:"text-xs bg-[#222] px-2 py-0.5 rounded text-[#666]",children:X},X,!1,void 0,this)),K.allowed_tools.length>2&&z.jsxDEV("span",{className:"text-xs text-[#666]",children:["+",K.allowed_tools.length-2]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),B()},className:"text-red-400 hover:text-red-300 text-sm",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz({skill:K,installed:Z,installing:Y,onInstall:B}){return z.jsxDEV("div",{className:"bg-[#111] rounded-lg p-5 border border-[#1a1a1a] hover:border-[#333] transition",children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#666] mt-0.5",children:["by ",K.author," · v",K.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-1 text-yellow-500 text-sm",children:["★ ",K.rating.toFixed(1)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#888] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:K.tags.slice(0,3).map((N)=>z.jsxDEV("span",{className:"text-xs bg-[#222] px-2 py-0.5 rounded text-[#666]",children:N},N,!1,void 0,this))},void 0,!1,void 0,this),Z?z.jsxDEV("span",{className:"text-green-400 text-sm",children:"✓ Installed"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:B,disabled:Y,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-3 py-1 rounded text-sm font-medium transition",children:Y?"Installing...":"Install"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"mt-3 text-xs text-[#555]",children:[K.downloads.toLocaleString()," downloads"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Az({authFetch:K,onClose:Z,onCreated:Y,projects:B,defaultProjectId:N}){let[y,M]=W.useState(""),[X,U]=W.useState(""),[G,Q]=W.useState(""),[C,H]=W.useState(N||null),[v,T]=W.useState(!1),[f,w]=W.useState(null),P=B&&B.length>0,d=async()=>{if(!y||!X||!G){w("All fields are required");return}T(!0),w(null);try{let _={name:y,description:X,content:G,source:"local"};if(C)_.project_id=C;let m=await K("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),p=await m.json();if(!m.ok){w(p.error||"Failed to create skill"),T(!1);return}Y()}catch(_){w("Failed to create skill"),T(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Z,children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:(_)=>_.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[#1a1a1a]",children:z.jsxDEV("h2",{className:"text-xl font-semibold",children:"Create Skill"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-6 space-y-4",children:[f&&z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded p-3 text-red-400 text-sm",children:f},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(_)=>M(_.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"my-skill-name",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Lowercase letters, numbers, and hyphens only"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Description"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(_)=>U(_.target.value),placeholder:"What this skill does and when to use it...",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(j,{value:C||"",onChange:(_)=>H(_||null),options:[{value:"",label:"Global (all projects)"},...B.map((_)=>({value:_.id,label:_.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global skills are available to all agents. Project-scoped skills are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#888] mb-1",children:"Instructions (Markdown)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(_)=>Q(_.target.value),placeholder:`# Skill Instructions
|
|
2
2
|
|
|
3
3
|
Write detailed instructions here...`,rows:12,className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316] font-mono text-sm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6 border-t border-[#1a1a1a] flex justify-end gap-3",children:[z.jsxDEV("button",{onClick:Z,className:"px-4 py-2 text-[#888] hover:text-white transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:d,disabled:v,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:v?"Creating...":"Create Skill"},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 yz({authFetch:K,onClose:Z,onImported:Y}){let[B,N]=W.useState(""),[y,M]=W.useState(!1),[X,U]=W.useState(null);return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Z,children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:(Q)=>Q.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[#1a1a1a]",children:[z.jsxDEV("h2",{className:"text-xl font-semibold",children:"Import Skill"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1",children:"Paste the contents of a SKILL.md file"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6 space-y-4",children:[X&&z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded p-3 text-red-400 text-sm",children:X},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:B,onChange:(Q)=>N(Q.target.value),placeholder:`---
|
|
4
4
|
name: skill-name
|