apteva 0.4.41 → 0.4.48
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.sw9p594m.js +3 -0
- package/dist/ApiDocsPage.90e03bz7.js +4 -0
- package/dist/App.0ws87fpx.js +53 -0
- package/dist/App.3vnrera5.js +4 -0
- package/dist/App.94x6mh7f.js +20 -0
- package/dist/{App.7fb3e7mp.js → App.9sryp183.js} +1 -1
- package/dist/App.d9tny4t0.js +221 -0
- package/dist/App.jhb45d7r.js +8 -0
- package/dist/App.p7jjw1zf.js +4 -0
- package/dist/App.pfbdzrhh.js +4 -0
- package/dist/App.stgng5bx.js +13 -0
- package/dist/App.tm3k7h4b.js +4 -0
- package/dist/App.vkg121c6.js +4 -0
- package/dist/App.wghtdzsk.js +1 -0
- package/dist/App.xf7wsckg.js +4 -0
- package/dist/App.xva0tfzh.js +4 -0
- package/dist/App.ysxy7akk.js +61 -0
- package/dist/App.yzkh4gq2.js +4 -0
- package/dist/ConnectionsPage.q5f9fd37.js +3 -0
- package/dist/McpPage.f3ccrezb.js +3 -0
- package/dist/SettingsPage.3sqx6wm4.js +3 -0
- package/dist/SkillsPage.whxnez67.js +3 -0
- package/dist/TasksPage.zp4jfevw.js +3 -0
- package/dist/TelemetryPage.a9fmxq87.js +3 -0
- package/dist/TestsPage.18krj0d1.js +3 -0
- package/dist/ThreadsPage.nnphgy98.js +3 -0
- package/dist/apteva-kit.css +1 -1
- package/dist/index.html +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -10
- package/src/db.ts +61 -13
- package/src/integrations/agentdojo.ts +1 -0
- package/src/mcp-platform.ts +418 -63
- package/src/openapi.ts +96 -0
- package/src/providers.ts +55 -24
- package/src/routes/api/agent-utils.ts +25 -4
- package/src/routes/api/agents.ts +19 -1
- package/src/routes/api/meta-agent.ts +2 -0
- package/src/routes/api/system.ts +90 -1
- package/src/routes/api/telemetry.ts +38 -2
- package/src/routes/share.ts +85 -0
- package/src/server.ts +64 -1
- package/src/web/App.tsx +89 -11
- package/src/web/components/activity/ActivityPage.tsx +14 -14
- package/src/web/components/agents/AgentCard.tsx +19 -17
- package/src/web/components/agents/AgentPanel.tsx +541 -220
- package/src/web/components/agents/AgentsView.tsx +4 -4
- package/src/web/components/agents/CreateAgentModal.tsx +24 -82
- package/src/web/components/api/ApiDocsPage.tsx +66 -66
- package/src/web/components/auth/CreateAccountStep.tsx +16 -16
- package/src/web/components/auth/LoginPage.tsx +10 -10
- package/src/web/components/common/LoadingSpinner.tsx +2 -2
- package/src/web/components/common/Modal.tsx +9 -9
- package/src/web/components/common/Select.tsx +9 -9
- package/src/web/components/connections/ConnectionsPage.tsx +4 -4
- package/src/web/components/connections/IntegrationsTab.tsx +18 -18
- package/src/web/components/connections/OverviewTab.tsx +13 -13
- package/src/web/components/connections/TriggersTab.tsx +99 -99
- package/src/web/components/dashboard/Dashboard.tsx +32 -32
- package/src/web/components/layout/Header.tsx +50 -34
- package/src/web/components/layout/Sidebar.tsx +35 -15
- package/src/web/components/mcp/IntegrationsPanel.tsx +40 -40
- package/src/web/components/mcp/McpPage.tsx +208 -208
- package/src/web/components/meta-agent/MetaAgent.tsx +12 -10
- package/src/web/components/onboarding/OnboardingWizard.tsx +25 -25
- package/src/web/components/settings/SettingsPage.tsx +291 -175
- package/src/web/components/skills/SkillsPage.tsx +88 -88
- package/src/web/components/tasks/TasksPage.tsx +539 -78
- package/src/web/components/telemetry/TelemetryPage.tsx +405 -65
- package/src/web/components/tests/TestsPage.tsx +50 -50
- package/src/web/components/threads/ThreadsPage.tsx +23 -21
- package/src/web/context/ProjectContext.tsx +6 -1
- package/src/web/context/ThemeContext.tsx +90 -0
- package/src/web/context/index.ts +2 -0
- package/src/web/index.html +1 -6
- package/src/web/styles.css +52 -3
- package/src/web/themes.ts +162 -0
- package/src/web/types.ts +0 -4
- package/dist/ActivityPage.7907h64p.js +0 -3
- package/dist/ApiDocsPage.k3jjenpq.js +0 -4
- package/dist/App.01nq20st.js +0 -4
- package/dist/App.1maqvamf.js +0 -4
- package/dist/App.2yjrh32f.js +0 -4
- package/dist/App.3qw8nben.js +0 -20
- package/dist/App.7sy3wq8c.js +0 -4
- package/dist/App.apjrmctz.js +0 -57
- package/dist/App.av6t2yhe.js +0 -4
- package/dist/App.jqj5a094.js +0 -46
- package/dist/App.mc7xf85h.js +0 -4
- package/dist/App.myxqcj9x.js +0 -4
- package/dist/App.nm91r1mp.js +0 -13
- package/dist/App.p02f4ret.js +0 -1
- package/dist/App.qcknavjz.js +0 -221
- package/dist/App.vc7vfhg4.js +0 -4
- package/dist/App.z4s9zkw5.js +0 -4
- package/dist/ConnectionsPage.z1pw5xe2.js +0 -3
- package/dist/McpPage.8vc97z0b.js +0 -3
- package/dist/SettingsPage.p61bz8kd.js +0 -3
- package/dist/SkillsPage.r9x43g3g.js +0 -3
- package/dist/TasksPage.1e0zkye4.js +0 -3
- package/dist/TelemetryPage.p9vbe4gf.js +0 -3
- package/dist/TestsPage.d4xy504e.js +0 -3
- package/dist/ThreadsPage.m016am3x.js +0 -3
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{F as o,k as l,l as t}from"./App.9sryp183.js";import{N as Xq,O as D}from"./App.vkg121c6.js";import{U as i}from"./App.p7jjw1zf.js";import{$ as Zq,X as r,aa as zq,ja as V,ma as E,oa as Qq}from"./App.94x6mh7f.js";var H=r(Zq(),1);var q=r(zq(),1);function bq(){let{projectsEnabled:z,metaAgentEnabled:$}=E(),[J,L]=H.useState("general"),T=[{key:"general",label:"General"},{key:"providers",label:"Providers"},...z?[{key:"projects",label:"Projects"}]:[],...$?[{key:"assistant",label:"Assistant"}]:[],{key:"channels",label:"Channels"},{key:"api-keys",label:"API Keys"},{key:"account",label:"Account"},{key:"updates",label:"Updates"},{key:"data",label:"Data"}];return q.jsxDEV("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[q.jsxDEV("div",{className:"md:hidden border-b border-[var(--color-border)] bg-[var(--color-bg)]",children:q.jsxDEV("div",{className:"flex overflow-x-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:T.map((X)=>q.jsxDEV("button",{onClick:()=>L(X.key),className:`flex-shrink-0 px-4 py-3 text-sm font-medium border-b-2 transition ${J===X.key?"border-[var(--color-accent)] text-[var(--color-accent)]":"border-transparent text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:X.label},X.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"hidden md:block w-48 border-r border-[var(--color-border)] p-4 flex-shrink-0",children:[q.jsxDEV("h2",{className:"text-sm font-medium text-[var(--color-text-muted)] uppercase tracking-wider mb-3",children:"Settings"},void 0,!1,void 0,this),q.jsxDEV("nav",{className:"space-y-1",children:T.map((X)=>q.jsxDEV($q,{label:X.label,active:J===X.key,onClick:()=>L(X.key)},X.key,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[J==="general"&&q.jsxDEV(Gq,{},void 0,!1,void 0,this),J==="providers"&&q.jsxDEV(Jq,{},void 0,!1,void 0,this),J==="projects"&&z&&q.jsxDEV(Wq,{},void 0,!1,void 0,this),J==="channels"&&q.jsxDEV(Oq,{},void 0,!1,void 0,this),J==="api-keys"&&q.jsxDEV(Nq,{},void 0,!1,void 0,this),J==="account"&&q.jsxDEV(Uq,{},void 0,!1,void 0,this),J==="updates"&&q.jsxDEV(Bq,{},void 0,!1,void 0,this),J==="data"&&q.jsxDEV(Rq,{},void 0,!1,void 0,this),J==="assistant"&&$&&q.jsxDEV(Tq,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $q({label:z,active:$,onClick:J}){return q.jsxDEV("button",{onClick:J,className:`w-full text-left px-3 py-2 rounded text-sm transition ${$?"bg-[var(--color-surface-raised)] text-[var(--color-text)]":"text-[var(--color-text-muted)] hover:bg-[var(--color-surface)] hover:text-[var(--color-text-secondary)]"}`,children:z},void 0,!1,void 0,this)}function Gq(){let{authFetch:z}=V(),{mode:$,style:J,setMode:L,setStyle:T}=Qq(),[X,N]=H.useState(""),[U,O]=H.useState(!0),[W,A]=H.useState(!1),[M,R]=H.useState(null);H.useEffect(()=>{(async()=>{try{let K=await(await z("/api/settings/instance-url")).json();N(K.instance_url||"")}catch{}O(!1)})()},[]);let B=async()=>{A(!0),R(null);try{let Q=await z("/api/settings/instance-url",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instance_url:X})}),I=await Q.json();if(Q.ok)N(I.instance_url||""),R({type:"success",text:"Instance URL saved"});else R({type:"error",text:I.error||"Failed to save"})}catch{R({type:"error",text:"Failed to save"})}A(!1)},Y=[{value:"auto",label:"Auto",description:"Follow system preference"},{value:"dark",label:"Dark",description:"Dark background"},{value:"light",label:"Light",description:"Light background"}],w=[{value:"classic",label:"Classic",description:"Terminal-inspired, sharp"},{value:"professional",label:"Professional",description:"Polished, enterprise"}];return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"General"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Instance configuration and appearance."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4 mb-4",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Appearance"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-2",children:"Color scheme"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3 mb-5",children:Y.map((Q)=>q.jsxDEV("button",{onClick:()=>L(Q.value),className:`flex-1 max-w-[160px] px-4 py-3 border text-left transition ${$===Q.value?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] bg-[var(--color-bg)] hover:border-[var(--color-scrollbar)]"}`,style:{borderRadius:"var(--radius-card)"},children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${$===Q.value?"border-[var(--color-accent)]":"border-[var(--color-scrollbar)]"}`,children:$===Q.value&&q.jsxDEV("div",{className:"w-2 h-2 rounded-full bg-[var(--color-accent)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-sm font-medium",children:Q.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] ml-6",children:Q.description},void 0,!1,void 0,this)]},Q.value,!0,void 0,this))},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-2",children:"Style"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3",children:w.map((Q)=>q.jsxDEV("button",{onClick:()=>T(Q.value),className:`flex-1 max-w-[200px] px-4 py-3 border text-left transition ${J===Q.value?"border-[var(--color-accent)] bg-[var(--color-accent-10)]":"border-[var(--color-border-light)] bg-[var(--color-bg)] hover:border-[var(--color-scrollbar)]"}`,style:{borderRadius:"var(--radius-card)"},children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center ${J===Q.value?"border-[var(--color-accent)]":"border-[var(--color-scrollbar)]"}`,children:J===Q.value&&q.jsxDEV("div",{className:"w-2 h-2 rounded-full bg-[var(--color-accent)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-sm font-medium",children:Q.label},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] ml-6",children:Q.description},void 0,!1,void 0,this)]},Q.value,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Instance URL"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-4",children:"The public HTTPS URL for this instance. Used for webhook callbacks from external services like Composio."},void 0,!1,void 0,this),U?q.jsxDEV("div",{className:"text-[var(--color-text-muted)] text-sm",children:"Loading..."},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-3 max-w-lg",children:[q.jsxDEV("input",{type:"text",value:X,onChange:(Q)=>N(Q.target.value),placeholder:"https://your-domain.com",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] font-mono text-sm"},void 0,!1,void 0,this),M&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${M.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:M.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:B,disabled:W,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black rounded text-sm font-medium transition",children:W?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Jq(){let{authFetch:z}=V(),{projects:$,projectsEnabled:J}=E(),[L,T]=H.useState([]),[X,N]=H.useState(null),[U,O]=H.useState(""),[W,A]=H.useState(""),[M,R]=H.useState(!1),[B,Y]=H.useState(!1),[w,Q]=H.useState(null),[I,K]=H.useState(null),{confirm:b,ConfirmDialog:h}=D(),C=async()=>{let P=await(await z("/api/providers")).json();T(P.providers||[])};H.useEffect(()=>{C()},[]);let S=async()=>{if(!X||!U)return;R(!0),Q(null),K(null);let _=U;if(X==="browserbase"&&W)_=JSON.stringify({api_key:U,project_id:W});try{Y(!0);let u=await(await z(`/api/keys/${X}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})})).json();if(Y(!1),!u.valid){Q(u.error||"API key is invalid"),R(!1);return}let p=await z(`/api/keys/${X}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})}),g=await p.json();if(!p.ok)Q(g.error||"Failed to save key");else{let d="API key saved!";if(g.restartedAgents&&g.restartedAgents.length>0){let m=g.restartedAgents.filter((x)=>x.success).length;if(g.restartedAgents.length-m===0)d+=` Restarted ${m} agent${m>1?"s":""} with new key.`;else d+=` Restarted ${m}/${g.restartedAgents.length} agents.`}K(d),O(""),A(""),N(null),C()}}catch(P){Q("Failed to save key")}R(!1)},f=async(_)=>{if(!await b("Are you sure you want to remove this API key?",{confirmText:"Remove",title:"Remove API Key"}))return;await z(`/api/keys/${_}`,{method:"DELETE"}),C()},G=L.filter((_)=>_.type==="llm"),Z=L.filter((_)=>_.type==="integration"),k=L.filter((_)=>_.type==="browser"),y=G.filter((_)=>_.hasKey).length,c=Z.filter((_)=>_.hasKey).length,n=k.filter((_)=>_.hasKey).length;return H.useEffect(()=>{if(I&&!X){let _=setTimeout(()=>K(null),5000);return()=>clearTimeout(_)}},[I,X]),q.jsxDEV(q.Fragment,{children:[h,q.jsxDEV("div",{className:"space-y-10",children:[I&&!X&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center justify-between",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400",children:[q.jsxDEV(l,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{children:I},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>K(null),className:"text-green-400 hover:text-green-300",children:q.jsxDEV(t,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"AI Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["Manage your API keys for AI providers. ",y," of ",G.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:G.map((_)=>q.jsxDEV(Lq,{provider:_,isEditing:X===_.id,apiKey:U,saving:M,testing:B,error:X===_.id?w:null,success:X===_.id?I:null,onStartEdit:()=>{N(_.id),Q(null),K(null)},onCancelEdit:()=>{N(null),O(""),Q(null)},onApiKeyChange:O,onSave:S,onDelete:()=>f(_.id)},_.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"MCP Integrations"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["Connect to MCP gateways for tool integrations. ",c," of ",Z.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:Z.map((_)=>q.jsxDEV(Hq,{provider:_,isEditing:X===_.id,apiKey:U,saving:M,testing:B,error:X===_.id?w:null,success:X===_.id?I:null,onStartEdit:()=>{N(_.id),Q(null),K(null)},onCancelEdit:()=>{N(null),O(""),Q(null)},onApiKeyChange:O,onSave:S,onDelete:()=>f(_.id),projectsEnabled:J,projects:$,onRefresh:C},_.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Browser Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["Configure browser environments for operator mode (computer use). ",n," of ",k.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:k.map((_)=>q.jsxDEV(Hq,{provider:_,isEditing:X===_.id,apiKey:U,saving:M,testing:B,error:X===_.id?w:null,success:X===_.id?I:null,onStartEdit:()=>{N(_.id),Q(null),K(null)},onCancelEdit:()=>{N(null),O(""),Q(null)},onApiKeyChange:O,onSave:S,onDelete:()=>f(_.id),projectsEnabled:J,projects:$,onRefresh:C},_.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var a=["#f97316","#6366f1","#22c55e","#ef4444","#3b82f6","#a855f7","#14b8a6","#f59e0b"];function Wq(){let{projects:z,createProject:$,updateProject:J,deleteProject:L}=E(),[T,X]=H.useState(!1),[N,U]=H.useState(null),{confirm:O,ConfirmDialog:W}=D(),A=async(Y)=>{if(!await O("Are you sure you want to delete this project? Agents in this project will become unassigned.",{confirmText:"Delete",title:"Delete Project"}))return;await L(Y)},M=()=>{U(null),X(!0)},R=(Y)=>{U(Y),X(!0)},B=()=>{X(!1),U(null)};return q.jsxDEV(q.Fragment,{children:[W,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Projects"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Organize agents into projects for better management."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:M,className:"flex items-center gap-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(o,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Project"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No projects yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create a project to organize your agents."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:z.map((Y)=>q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4 flex items-center gap-4",children:[q.jsxDEV("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:Y.color}},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:Y.name},void 0,!1,void 0,this),Y.description&&q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] truncate",children:Y.description},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:[Y.agentCount," agent",Y.agentCount!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("button",{onClick:()=>R(Y),className:"text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)] px-2 py-1",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>A(Y.id),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Y.id,!0,void 0,this))},void 0,!1,void 0,this),T&&q.jsxDEV(_q,{project:N,onSave:async(Y)=>{if(N){let w=await J(N.id,Y);if(w)B();return!!w}else{let w=await $(Y);if(w)B();return!!w}},onClose:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function _q({project:z,onSave:$,onClose:J}){let[L,T]=H.useState(z?.name||""),[X,N]=H.useState(z?.description||""),[U,O]=H.useState(z?.color||a[Math.floor(Math.random()*a.length)]),[W,A]=H.useState(!1),[M,R]=H.useState(null),B=async()=>{if(!L.trim()){R("Name is required");return}A(!0),R(null);let Y=await $({name:L,description:X||void 0,color:U});if(A(!1),!Y)R(z?"Failed to update project":"Failed to create project")};return q.jsxDEV(Xq,{onClose:J,children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-6",children:z?"Edit Project":"Create New Project"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:L,onChange:(Y)=>T(Y.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]",placeholder:"My Project",autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Description (optional)"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:X,onChange:(Y)=>N(Y.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]",placeholder:"A short description"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Color"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3 flex-wrap",children:a.map((Y)=>q.jsxDEV("button",{type:"button",onClick:()=>O(Y),className:`w-10 h-10 rounded-full transition ${U===Y?"ring-2 ring-white ring-offset-2 ring-offset-[#111]":"hover:scale-110"}`,style:{backgroundColor:Y}},Y,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-3 mt-6",children:[q.jsxDEV("button",{onClick:J,className:"flex-1 border border-[var(--color-border-light)] hover:border-[var(--color-accent)] hover:text-[var(--color-accent)] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:B,disabled:W||!L.trim(),className:"flex-1 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:W?"Saving...":z?"Update":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Bq(){let{authFetch:z}=V(),[$,J]=H.useState(null),[L,T]=H.useState(!1),[X,N]=H.useState(!1),[U,O]=H.useState(null),[W,A]=H.useState(null),[M,R]=H.useState(null),B=async()=>{T(!0),O(null);try{let I=await z("/api/version");if(!I.ok)throw Error("Failed to check for updates");let K=await I.json();J(K)}catch(I){O("Failed to check for updates")}T(!1)},Y=async()=>{N(!0),O(null),A(null);try{let K=await(await z("/api/version/update",{method:"POST"})).json();if(!K.success)O(K.error||"Update failed");else{let b=K.restarted?.length||0,h=b>0?` ${b} running agent${b>1?"s":""} restarted.`:"";A(`Agent binary updated to v${K.version}.${h}`),await B()}}catch(I){O("Failed to update agent")}N(!1)};H.useEffect(()=>{B()},[]);let w=(I,K)=>{navigator.clipboard.writeText(I),R(K),setTimeout(()=>R(null),2000)},Q=$?.apteva.updateAvailable||$?.agent.updateAvailable;return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Updates"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Check for new versions of apteva and the agent binary."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&!$?q.jsxDEV("div",{className:"text-[var(--color-text-muted)]",children:"Checking version info..."},void 0,!1,void 0,this):U&&!$?q.jsxDEV("div",{className:"text-red-400",children:U},void 0,!1,void 0,this):$?.isDocker?q.jsxDEV("div",{className:"space-y-6",children:[q.jsxDEV("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-blue-400 mb-2",children:[q.jsxDEV("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{d:"M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.186.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.186.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.186.186 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.186.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.185-.186H5.136a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"Docker Environment"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)]",children:"Updates are automatic when you pull a new image version."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Current Version"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"apteva + agent binary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:q.jsxDEV("div",{className:"text-xl font-mono",children:["v",$.apteva.installed||"?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q?q.jsxDEV("div",{className:"bg-[var(--color-accent-10)] border border-[var(--color-accent-30)] rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-3",children:["A newer version (v",$.apteva.latest,") is available. To update:"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2",children:[q.jsxDEV("code",{className:"block bg-[var(--color-bg)] px-3 py-2 rounded font-mono text-sm text-[var(--color-text-secondary)]",children:"docker pull apteva/apteva:latest"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[var(--color-bg)] px-3 py-2 rounded font-mono text-sm text-[var(--color-text-secondary)]",children:"docker compose up -d"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText("docker pull apteva/apteva:latest && docker compose up -d"),R("docker"),setTimeout(()=>R(null),2000)},className:"mt-3 px-3 py-1.5 bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] rounded text-sm",children:M==="docker"?"Copied!":"Copy commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(l,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)]",children:"Your data is stored in a Docker volume and persists across updates."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):$?q.jsxDEV("div",{className:"space-y-6",children:[W&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 text-green-400",children:W},void 0,!1,void 0,this),U&&q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-400",children:U},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"apteva"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"The app you're running"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",$.apteva.installed||"?"]},void 0,!0,void 0,this),$.apteva.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[var(--color-accent)]",children:["→ v",$.apteva.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.apteva.updateAvailable?q.jsxDEV("div",{className:"bg-[var(--color-accent-10)] border border-[var(--color-accent-30)] rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-3",children:"Update by running:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[var(--color-bg)] px-3 py-2 rounded font-mono text-sm text-[var(--color-text-secondary)]",children:"npx apteva@latest"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>w("npx apteva@latest","apteva"),className:"px-3 py-2 bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] rounded text-sm",children:M==="apteva"?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(l,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Agent Binary"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"The Go binary that runs agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",$.agent.installed||"?"]},void 0,!0,void 0,this),$.agent.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[var(--color-accent)]",children:["→ v",$.agent.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.agent.updateAvailable?q.jsxDEV("div",{className:"bg-[var(--color-accent-10)] border border-[var(--color-accent-30)] rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-3",children:"A new version is available. Stop all agents before updating."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:q.jsxDEV("button",{onClick:Y,disabled:X,className:"px-4 py-2 bg-[var(--color-accent)] text-black rounded font-medium text-sm disabled:opacity-50",children:X?"Updating...":"Update Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(l,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!Q&&!W&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center gap-2 text-green-400",children:[q.jsxDEV(l,{className:"w-5 h-5"},void 0,!1,void 0,this),"Everything is up to date!"]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:B,disabled:L,className:"text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] disabled:opacity-50",children:L?"Checking...":"Check for updates"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function Lq({provider:z,isEditing:$,apiKey:J,saving:L,testing:T,error:X,success:N,onStartEdit:U,onCancelEdit:O,onApiKeyChange:W,onSave:A,onDelete:M,extraField:R,onExtraFieldChange:B}){let Y=z.id==="ollama",w=z.id==="cdp",Q=Y||w,I=z.type==="browser",K=z.id==="browserbase",[b,h]=H.default.useState(null),[C,S]=H.default.useState(!1),[f,G]=H.default.useState(null),Z=H.default.useCallback(()=>{fetch("/api/providers/ollama/status").then((y)=>y.json()).then((y)=>h({connected:y.connected,modelCount:y.modelCount,isDocker:y.isDocker})).catch(()=>h({connected:!1}))},[]);H.default.useEffect(()=>{if(Y)Z()},[Y,z.hasKey,Z]);let k=async()=>{S(!0),G(null);try{let c=await(await fetch("/api/providers/ollama/install",{method:"POST"})).json();if(c.success)G({success:!0,message:c.message}),Z();else G({success:!1,message:c.error||"Installation failed"})}catch{G({success:!1,message:"Failed to connect to server"})}finally{S(!1)}};return q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-4 ${z.hasKey?"border-green-500/20":"border-[var(--color-border)]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] truncate",children:I?z.description||"Browser automation":z.type==="integration"?z.description||"MCP integration":Y?"Run models locally":`${z.models.length} models`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:`text-xs flex items-center gap-1 px-2 py-1 rounded whitespace-nowrap flex-shrink-0 ${Y&&b?b.connected?"text-green-400 bg-green-500/10":"text-yellow-400 bg-yellow-500/10":"text-green-400 bg-green-500/10"}`,children:Y&&b?b.connected?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(l,{className:"w-3 h-3"},void 0,!1,void 0,this),b.modelCount," models"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:"Not running"},void 0,!1,void 0,this):Q?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(l,{className:"w-3 h-3"},void 0,!1,void 0,this),"Configured"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV(l,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this)},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded whitespace-nowrap flex-shrink-0",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[var(--color-border)]",children:$?q.jsxDEV("div",{className:"space-y-3",children:[K?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:J,onChange:(y)=>W(y.target.value),placeholder:z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:"Project ID"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:R||"",onChange:(y)=>B?.(y.target.value),placeholder:"Enter your Browserbase project ID...",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("input",{type:Q?"text":"password",value:J,onChange:(y)=>W(y.target.value),placeholder:Y?"http://localhost:11434":w?"ws://localhost:9222":z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),Q&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:w?"Enter the CDP URL of your browser (e.g., ws://localhost:9222)":"Enter your Ollama server URL. Default is http://localhost:11434"},void 0,!1,void 0,this),X&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:X},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:O,className:"flex-1 px-3 py-1.5 border border-[var(--color-border-light)] rounded text-sm hover:border-[var(--color-text-muted)]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:A,disabled:!J||L,className:"flex-1 px-3 py-1.5 bg-[var(--color-accent)] text-black rounded text-sm font-medium disabled:opacity-50",children:T?"Validating...":L?"Saving...":Q?"Connect":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{children:[Y&&b&&!b.connected&&!b.isDocker&&q.jsxDEV("div",{className:"mb-3",children:[q.jsxDEV("button",{onClick:k,disabled:C,className:"w-full px-3 py-1.5 bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30 rounded text-sm font-medium transition disabled:opacity-50 disabled:cursor-wait",children:C?"Starting Ollama...":"Start Ollama"},void 0,!1,void 0,this),f&&q.jsxDEV("p",{className:`text-xs mt-1.5 ${f.success?"text-green-400":"text-red-400"}`,children:f.message},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center justify-between",children:[z.docsUrl?q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Ollama docs":"View docs"},void 0,!1,void 0,this):q.jsxDEV("span",{},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:U,className:"text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)]",children:Q?"Change URL":"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{children:[Y&&!b?.isDocker&&q.jsxDEV("div",{className:"mb-3",children:[q.jsxDEV("button",{onClick:k,disabled:C,className:"w-full px-3 py-2 bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30 rounded text-sm font-medium transition disabled:opacity-50 disabled:cursor-wait",children:C?"Installing Ollama...":b?.connected?"Ollama Running":"Install Ollama"},void 0,!1,void 0,this),f&&q.jsxDEV("p",{className:`text-xs mt-1.5 ${f.success?"text-green-400":"text-red-400"}`,children:f.message},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center justify-between",children:[z.docsUrl?q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Manual install":I?"View docs":"Get API key"},void 0,!1,void 0,this):q.jsxDEV("span",{},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:U,className:"text-sm text-[var(--color-accent)] hover:text-[var(--color-accent-hover)]",children:Q?"Configure":"+ Add key"},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)}function Hq({provider:z,isEditing:$,apiKey:J,saving:L,testing:T,error:X,success:N,onStartEdit:U,onCancelEdit:O,onApiKeyChange:W,onSave:A,onDelete:M,projectsEnabled:R,projects:B,onRefresh:Y}){let{authFetch:w}=V(),[Q,I]=H.useState([]),[K,b]=H.useState(""),[h,C]=H.useState(!1),[S,f]=H.useState(null),[G,Z]=H.useState(!1),[k,y]=H.useState(""),{confirm:c,ConfirmDialog:n}=D(),_=z.id==="browserbase",P=async()=>{try{let v=await(await w(`/api/keys/${z.id}`)).json();I(v.keys||[])}catch(F){console.error("Failed to fetch keys:",F)}};H.useEffect(()=>{if(R)P()},[z.id,R]),H.useEffect(()=>{if($)f(null)},[$]);let u=async()=>{if(!J)return;Z(!0),f(null);let F=J;if(_&&k)F=JSON.stringify({api_key:J,project_id:k});try{let v=await w(`/api/keys/${z.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:F,project_id:K||null})}),qq=await v.json();if(v.ok)W(""),y(""),b(""),O(),P(),Y();else f(qq.error||"Failed to save key")}catch(v){console.error("Failed to save key:",v),f("Failed to save key")}Z(!1)},p=async(F,v)=>{if(!await c(`Are you sure you want to remove this API key${v?` (${v})`:""}?`,{confirmText:"Remove",title:"Remove API Key"}))return;try{await w(`/api/keys/by-id/${F}`,{method:"DELETE"}),P(),Y()}catch(Yq){console.error("Failed to delete key:",Yq)}},g=Q.find((F)=>!F.project_id),d=Q.filter((F)=>F.project_id),m=(F)=>B.find((v)=>v.id===F)?.name||"Unknown",j=(F)=>B.find((v)=>v.id===F)?.color||"#666";if(!R)return q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-4 ${z.hasKey?"border-[var(--color-accent-20)]":"border-[var(--color-border)]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs flex items-center gap-1 bg-[var(--color-accent-10)] px-2 py-1 rounded",children:[q.jsxDEV(l,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[var(--color-border)]",children:$?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:s,value:J,onChange:(F)=>W(F.target.value),placeholder:z.hasKey?`Enter new ${x?"URL":"API key"}...`:e,autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),X&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:X},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:O,className:"flex-1 px-3 py-1.5 border border-[var(--color-border-light)] rounded text-sm hover:border-[var(--color-text-muted)]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:A,disabled:!J||L,className:"flex-1 px-3 py-1.5 bg-[var(--color-accent)] text-black rounded text-sm font-medium disabled:opacity-50",children:T?"Validating...":L?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:U,className:"text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)]",children:"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:U,className:"text-sm text-[var(--color-accent)] hover:text-[var(--color-accent-hover)]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let x=z.isLocal,s=x?"text":"password",e=x?z.id==="cdp"?"ws://localhost:9222":"http://localhost:11434":"Enter API key...";return q.jsxDEV(q.Fragment,{children:[n,q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-4 ${Q.length>0?"border-[var(--color-accent-20)]":"border-[var(--color-border)]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.length>0?q.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs flex items-center gap-1 bg-[var(--color-accent-10)] px-2 py-1 rounded",children:[q.jsxDEV(l,{className:"w-3 h-3"},void 0,!1,void 0,this),Q.length," key",Q.length!==1?"s":""]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-xs bg-[var(--color-surface-raised)] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q.length>0&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[g&&q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[var(--color-bg)] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",children:"Global"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[var(--color-text-muted)] font-mono text-xs",children:g.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(g.id,"Global"),className:"text-red-400 hover:text-red-300 text-xs",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.slice(0,h?void 0:2).map((F)=>q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[var(--color-bg)] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 min-w-0",children:[q.jsxDEV("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:j(F.project_id)}},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[var(--color-text-secondary)] truncate",children:F.name||m(F.project_id)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[var(--color-text-muted)] font-mono text-xs",children:F.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(F.id,F.name||m(F.project_id)),className:"text-red-400 hover:text-red-300 text-xs flex-shrink-0 ml-2",children:"Remove"},void 0,!1,void 0,this)]},F.id,!0,void 0,this)),d.length>2&&!h&&q.jsxDEV("button",{onClick:()=>C(!0),className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] w-full text-center py-1",children:["Show ",d.length-2," more..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[var(--color-border)]",children:$?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:s,value:J,onChange:(F)=>W(F.target.value),placeholder:e,autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),_&&q.jsxDEV("input",{type:"text",value:k,onChange:(F)=>y(F.target.value),placeholder:"Browserbase Project ID (optional)",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)] text-sm"},void 0,!1,void 0,this),q.jsxDEV(i,{value:K,onChange:b,placeholder:"Global (all projects)",options:[{value:"",label:"Global (all projects)"},...B.map((F)=>({value:F.id,label:F.name}))]},void 0,!1,void 0,this),S&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:S},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{O(),b(""),f(null)},className:"flex-1 px-3 py-1.5 border border-[var(--color-border-light)] rounded text-sm hover:border-[var(--color-text-muted)]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:u,disabled:!J||G,className:"flex-1 px-3 py-1.5 bg-[var(--color-accent)] text-black rounded text-sm font-medium disabled:opacity-50",children:G?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Q.length>0?"View docs":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:U,className:"text-sm text-[var(--color-accent)] hover:text-[var(--color-accent-hover)]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Nq(){let{authFetch:z}=V(),[$,J]=H.useState([]),[L,T]=H.useState(!1),[X,N]=H.useState(""),[U,O]=H.useState("90"),[W,A]=H.useState(!1),[M,R]=H.useState(null),[B,Y]=H.useState(null),[w,Q]=H.useState(!1),{confirm:I,ConfirmDialog:K}=D(),b=async()=>{try{let k=await(await z("/api/keys/personal")).json();J(k.keys||[])}catch{}};H.useEffect(()=>{b()},[]);let h=async()=>{if(!X.trim()){R("Name is required");return}A(!0),R(null);try{let Z=await z("/api/keys/personal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.trim(),expires_in_days:U?parseInt(U):null})}),k=await Z.json();if(!Z.ok)R(k.error||"Failed to create key");else Y(k.key),N(""),O("90"),b()}catch{R("Failed to create key")}A(!1)},C=async(Z,k)=>{if(!await I(`Delete API key "${k}"? This cannot be undone.`,{confirmText:"Delete",title:"Delete API Key"}))return;try{await z(`/api/keys/personal/${Z}`,{method:"DELETE"}),b()}catch{}},S=()=>{if(B)navigator.clipboard.writeText(B),Q(!0),setTimeout(()=>Q(!1),2000)},f=(Z)=>{if(!Z)return"Never";return new Date(Z).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},G=(Z)=>{if(!Z)return!1;return new Date(Z)<new Date};return q.jsxDEV(q.Fragment,{children:[K,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"API Keys"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:["Create personal API keys for programmatic access. Use them with the ",q.jsxDEV("code",{className:"text-[var(--color-text-secondary)] bg-[var(--color-surface-raised)] px-1 rounded text-xs",children:"X-API-Key"},void 0,!1,void 0,this)," header."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!L&&!B&&q.jsxDEV("button",{onClick:()=>{T(!0),R(null)},className:"flex items-center gap-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(o,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Key"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 mb-6",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 mb-2",children:[q.jsxDEV(l,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"API key created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mb-3",children:"Copy this key now. You won't be able to see it again."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[var(--color-bg)] px-3 py-2 rounded font-mono text-sm text-[var(--color-text)] break-all select-all",children:B},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:S,className:"px-3 py-2 bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] rounded text-sm flex-shrink-0",children:w?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{Y(null),T(!1)},className:"mt-3 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&!B&&q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Create new API key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:X,onChange:(Z)=>N(Z.target.value),placeholder:"e.g. CI Pipeline, My Script",autoFocus:!0,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Expiration"},void 0,!1,void 0,this),q.jsxDEV("select",{value:U,onChange:(Z)=>O(Z.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]",children:[q.jsxDEV("option",{value:"30",children:"30 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"90",children:"90 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"180",children:"180 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"365",children:"1 year"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"",children:"No expiration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{T(!1),R(null),N("")},className:"flex-1 px-3 py-2 border border-[var(--color-border-light)] rounded text-sm hover:border-[var(--color-text-muted)]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:h,disabled:W||!X.trim(),className:"flex-1 px-3 py-2 bg-[var(--color-accent)] text-black rounded text-sm font-medium disabled:opacity-50",children:W?"Creating...":"Create Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),$.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No API keys yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create an API key to access apteva programmatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:$.map((Z)=>q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-4 flex items-center gap-4 ${!Z.is_active||G(Z.expires_at)?"border-[var(--color-border)] opacity-60":"border-[var(--color-border)]"}`,children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:Z.name},void 0,!1,void 0,this),!Z.is_active&&q.jsxDEV("span",{className:"text-xs text-red-400 bg-red-500/10 px-2 py-0.5 rounded",children:"Revoked"},void 0,!1,void 0,this),Z.is_active&&G(Z.expires_at)&&q.jsxDEV("span",{className:"text-xs text-yellow-400 bg-yellow-500/10 px-2 py-0.5 rounded",children:"Expired"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-[var(--color-text-muted)]",children:[q.jsxDEV("code",{className:"font-mono text-xs bg-[var(--color-bg)] px-2 py-0.5 rounded",children:[Z.prefix,"..."]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Created ",f(Z.created_at)]},void 0,!0,void 0,this),Z.expires_at&&q.jsxDEV("span",{children:["Expires ",f(Z.expires_at)]},void 0,!0,void 0,this),Z.last_used_at&&q.jsxDEV("span",{children:["Last used ",f(Z.last_used_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z.is_active&&q.jsxDEV("button",{onClick:()=>C(Z.id,Z.name),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1 flex-shrink-0",children:"Delete"},void 0,!1,void 0,this)]},Z.id,!0,void 0,this))},void 0,!1,void 0,this),$.length>0&&q.jsxDEV("div",{className:"mt-6 bg-[var(--color-surface)] card p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2 text-sm",children:"Usage"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[var(--color-bg)] px-3 py-2 rounded font-mono text-xs text-[var(--color-text-secondary)]",children:'curl -H "X-API-Key: apt_..." http://localhost:4280/api/agents'},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Uq(){let{authFetch:z,user:$}=V(),[J,L]=H.useState(""),[T,X]=H.useState(""),[N,U]=H.useState(""),[O,W]=H.useState(!1),[A,M]=H.useState(null),R=async()=>{if(!J||!T||!N){M({type:"error",text:"All fields are required"});return}if(T!==N){M({type:"error",text:"New passwords do not match"});return}if(T.length<8){M({type:"error",text:"Password must be at least 8 characters"});return}W(!0),M(null);try{let B=await z("/api/auth/password",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:J,newPassword:T})}),Y=await B.json();if(B.ok)M({type:"success",text:"Password updated successfully"}),L(""),X(""),U("");else M({type:"error",text:Y.error||"Failed to update password"})}catch{M({type:"error",text:"Failed to update password"})}W(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Account Settings"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Manage your account and security."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-3",children:"Profile"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Username"},void 0,!1,void 0,this),q.jsxDEV("span",{children:$.username},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$.email&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Email"},void 0,!1,void 0,this),q.jsxDEV("span",{children:$.email},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[var(--color-text-muted)]",children:"Role"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"capitalize",children:$.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Change Password"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Current Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:J,onChange:(B)=>L(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:T,onChange:(B)=>X(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Confirm New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:N,onChange:(B)=>U(B.target.value),className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${A.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:A.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:R,disabled:O||!J||!T||!N,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black rounded text-sm font-medium transition",children:O?"Updating...":"Update Password"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Rq(){let{authFetch:z}=V(),[$,J]=H.useState(!1),[L,T]=H.useState(null),[X,N]=H.useState(null),{confirm:U,ConfirmDialog:O}=D(),W=async()=>{try{let R=await(await z("/api/telemetry/stats")).json();N(R.stats?.total_events||0)}catch{N(null)}};H.useEffect(()=>{W()},[]);let A=async()=>{if(!await U("Are you sure you want to delete all telemetry data? This cannot be undone.",{confirmText:"Clear All",title:"Clear Telemetry Data"}))return;J(!0),T(null);try{let R=await z("/api/telemetry/clear",{method:"POST"}),B=await R.json();if(R.ok)T({type:"success",text:`Cleared ${B.deleted||0} telemetry events.`}),N(0);else T({type:"error",text:B.error||"Failed to clear telemetry"})}catch{T({type:"error",text:"Failed to clear telemetry"})}J(!1)};return q.jsxDEV(q.Fragment,{children:[O,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Data Management"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Manage stored data and telemetry."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Telemetry Data"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-4",children:X!==null?`${X.toLocaleString()} events stored`:"Loading..."},void 0,!1,void 0,this),L&&q.jsxDEV("div",{className:`mb-4 p-3 rounded text-sm ${L.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:L.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:A,disabled:$||X===0,className:"px-4 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm font-medium transition",children:$?"Clearing...":"Clear All Telemetry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Oq(){let{authFetch:z}=V(),[$,J]=H.useState([]),[L,T]=H.useState([]),[X,N]=H.useState(!0),[U,O]=H.useState(!1),[W,A]=H.useState({name:"",agent_id:"",botToken:""}),[M,R]=H.useState(!1),[B,Y]=H.useState(null),{confirm:w,ConfirmDialog:Q}=D(),I=async()=>{try{let Z=await(await z("/api/channels")).json();J(Z.channels||[])}catch{}finally{N(!1)}},K=async()=>{try{let Z=await(await z("/api/agents")).json();T((Z.agents||[]).map((k)=>({id:k.id,name:k.name,status:k.status})))}catch{}};H.useEffect(()=>{I(),K()},[]);let b=async()=>{if(!W.name||!W.agent_id||!W.botToken)return;R(!0),Y(null);try{let G=await z("/api/channels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"telegram",name:W.name,agent_id:W.agent_id,config:{botToken:W.botToken}})});if(!G.ok){let Z=await G.json();Y(Z.error||"Failed to create channel")}else A({name:"",agent_id:"",botToken:""}),O(!1),await I()}catch(G){Y(G.message)}finally{R(!1)}},h=async(G)=>{let Z=G.status==="running"?"stop":"start";try{let k=await z(`/api/channels/${G.id}/${Z}`,{method:"POST"});if(!k.ok){let y=await k.json();Y(y.error||`Failed to ${Z} channel`)}await I()}catch{Y(`Failed to ${Z} channel`)}},C=async(G)=>{if(!await w(`Delete channel "${G.name}"?`,{confirmText:"Delete",title:"Delete Channel"}))return;try{await z(`/api/channels/${G.id}`,{method:"DELETE"}),await I()}catch{}},S={running:"bg-green-500/20 text-green-400",stopped:"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]",error:"bg-red-500/20 text-red-400"},f=(G)=>{return L.find((Z)=>Z.id===G)?.name||G};return q.jsxDEV(q.Fragment,{children:[Q,q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Channels"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"Connect agents to external messaging platforms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>O(!U),className:"flex items-center gap-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-3 py-1.5 rounded text-sm font-medium transition",children:[q.jsxDEV(o,{},void 0,!1,void 0,this)," Add Channel"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),B&&q.jsxDEV("div",{className:"mb-4 bg-red-500/10 text-red-400 border border-red-500/30 px-3 py-2 rounded text-sm flex items-center justify-between",children:[q.jsxDEV("span",{children:B},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>Y(null),className:"text-red-400 hover:text-red-300 ml-2",children:q.jsxDEV(t,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&q.jsxDEV("div",{className:"mb-6 bg-[var(--color-surface)] card p-4 space-y-3",children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-2",children:"New Telegram Channel"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-muted)] mb-1",children:"Channel Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:W.name,onChange:(G)=>A((Z)=>({...Z,name:G.target.value})),placeholder:"e.g. My Telegram Bot",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-muted)] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(i,{value:W.agent_id,options:L.map((G)=>({value:G.id,label:G.name})),onChange:(G)=>A((Z)=>({...Z,agent_id:G})),placeholder:"Select an agent..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-muted)] mb-1",children:"Bot Token"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:W.botToken,onChange:(G)=>A((Z)=>({...Z,botToken:G.target.value})),placeholder:"From @BotFather on Telegram",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:["Create a bot via ",q.jsxDEV("a",{href:"https://t.me/BotFather",target:"_blank",className:"text-[var(--color-accent)] hover:underline",children:"@BotFather"},void 0,!1,void 0,this)," on Telegram to get a token."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 pt-1",children:[q.jsxDEV("button",{onClick:b,disabled:M||!W.name||!W.agent_id||!W.botToken,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-1.5 rounded text-sm font-medium transition",children:M?"Creating...":"Create"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{O(!1),A({name:"",agent_id:"",botToken:""})},className:"border border-[var(--color-border-light)] hover:border-[var(--color-scrollbar)] px-4 py-1.5 rounded text-sm transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X?q.jsxDEV("p",{className:"text-[var(--color-text-muted)] text-sm",children:"Loading channels..."},void 0,!1,void 0,this):$.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No channels configured"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Add a Telegram channel to let users message your agents directly."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:$.map((G)=>q.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${S[G.status]||S.stopped}`,children:G.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:[G.type==="telegram"?"Telegram":G.type," → ",f(G.agent_id)]},void 0,!0,void 0,this),G.status==="error"&&G.error&&q.jsxDEV("p",{className:"text-xs text-red-400 mt-1",children:G.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2 ml-4",children:[q.jsxDEV("button",{onClick:()=>h(G),className:`px-3 py-1 rounded text-xs font-medium transition ${G.status==="running"?"bg-[var(--color-accent-20)] text-[var(--color-accent)] hover:bg-[var(--color-accent-30)]":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:G.status==="running"?"Stop":"Start"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>C(G),className:"text-[var(--color-text-muted)] hover:text-red-400 transition text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},G.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Tq(){let{authFetch:z}=V(),[$,J]=H.useState([]),[L,T]=H.useState(""),[X,N]=H.useState(""),[U,O]=H.useState(""),[W,A]=H.useState("unknown"),[M,R]=H.useState(!0),[B,Y]=H.useState(!1),[w,Q]=H.useState(null),[I,K]=H.useState(!1),[b,h]=H.useState(!1),[C,S]=H.useState(!1),[f,G]=H.useState({provider:"",model:"",systemPrompt:"",webSearch:!1,webFetch:!1});H.useEffect(()=>{(async()=>{try{let[u,p]=await Promise.all([z("/api/meta-agent/status"),z("/api/providers")]),g=await u.json(),d=await p.json();if(J((d.providers||[]).filter((m)=>m.type==="llm"&&m.hasKey)),g.agent){let m=g.agent;T(m.provider||""),N(m.model||""),O(m.systemPrompt||""),A(m.status||"stopped");let j=m.features?.builtinTools?.webSearch||!1,x=m.features?.builtinTools?.webFetch||!1;h(j),S(x),G({provider:m.provider||"",model:m.model||"",systemPrompt:m.systemPrompt||"",webSearch:j,webFetch:x})}}catch{Q({type:"error",text:"Failed to load assistant config"})}finally{R(!1)}})()},[z]);let k=$.find((P)=>P.id===L)?.models||[],y=(P)=>{T(P);let u=$.find((g)=>g.id===P),p=u?.models.find((g)=>g.recommended)?.value||u?.models[0]?.value||"";N(p)},c=L!==f.provider||X!==f.model||U!==f.systemPrompt||b!==f.webSearch||C!==f.webFetch,n=async()=>{Y(!0),Q(null);try{let P=await z("/api/agents/apteva-assistant",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:L,model:X,systemPrompt:U,features:{builtinTools:{webSearch:b,webFetch:C}}})});if(P.ok)G({provider:L,model:X,systemPrompt:U,webSearch:b,webFetch:C}),Q({type:"success",text:"Assistant settings saved"}),setTimeout(()=>Q(null),3000);else{let u=await P.json().catch(()=>({}));Q({type:"error",text:u.error||"Failed to save"})}}catch{Q({type:"error",text:"Failed to save settings"})}finally{Y(!1)}},_=async()=>{K(!0),Q(null);try{let u=await z(W==="running"?"/api/meta-agent/stop":"/api/meta-agent/start",{method:"POST"});if(u.ok)A(W==="running"?"stopped":"running");else{let p=await u.json().catch(()=>({}));Q({type:"error",text:p.error||"Failed to toggle assistant"})}}catch{Q({type:"error",text:"Failed to toggle assistant"})}finally{K(!1)}};if(M)return q.jsxDEV("div",{className:"text-[var(--color-text-muted)]",children:"Loading assistant settings..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("h2",{className:"text-lg font-medium mb-1",children:"Apteva Assistant"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mb-6",children:"Configure the built-in AI assistant that manages your agents and platform."},void 0,!1,void 0,this),w&&q.jsxDEV("div",{className:`mb-4 px-3 py-2 rounded text-sm ${w.type==="success"?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"}`,children:w.text},void 0,!1,void 0,this),q.jsxDEV("div",{className:"mb-6 flex items-center gap-3",children:[q.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:"Status:"},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${W==="running"?"bg-[#3b82f6]/20 text-[#3b82f6]":"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,children:W},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,disabled:I,className:`px-3 py-1.5 rounded text-sm font-medium transition ${W==="running"?"bg-[var(--color-accent-20)] text-[var(--color-accent)] hover:bg-[var(--color-accent-30)]":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"} disabled:opacity-50`,children:I?"...":W==="running"?"Stop":"Start"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Provider"},void 0,!1,void 0,this),q.jsxDEV(i,{value:L,onChange:y,options:$.map((P)=>({value:P.id,label:P.name})),placeholder:"Select provider..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Model"},void 0,!1,void 0,this),q.jsxDEV(i,{value:X,onChange:N,options:k.map((P)=>({value:P.value,label:P.label,recommended:P.recommended})),placeholder:"Select model..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L==="anthropic"&&q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"Built-in Tools"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>h(!b),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${b?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[q.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-sm",children:"Web Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{type:"button",onClick:()=>S(!C),className:`flex items-center gap-2 px-3 py-2 rounded border transition ${C?"border-[var(--color-accent)] bg-[var(--color-accent-10)] text-[var(--color-accent)]":"border-[var(--color-border-light)] hover:border-[var(--color-border-light)] text-[var(--color-text-secondary)]"}`,children:[q.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-sm",children:"Web Fetch"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-2",children:"Provider-native tools for real-time web access"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("label",{className:"block text-sm text-[var(--color-text-muted)] mb-1",children:"System Prompt"},void 0,!1,void 0,this),q.jsxDEV("textarea",{value:U,onChange:(P)=>O(P.target.value),rows:12,className:"w-full bg-[var(--color-surface)] border border-[var(--color-border)] rounded px-3 py-2 text-sm font-mono focus:outline-none focus:border-[var(--color-accent)] resize-y"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:n,disabled:!c||B,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed text-black px-4 py-2 rounded font-medium transition",children:B?"Saving...":"Save Changes"},void 0,!1,void 0,this),W==="running"&&c&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-2",children:"Changes will be applied to the running assistant"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
|
|
2
|
+
export{bq as c};
|
|
3
|
+
|
|
4
|
+
//# debugId=3EC2BB787EBCFE3E64756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{j as fN}from"./App.tm3k7h4b.js";import{U as x}from"./App.p7jjw1zf.js";import{$ as Xv,X as O,aa as I,ja as g,ma as j}from"./App.94x6mh7f.js";var $N=O(Xv(),1);var D=O(Xv(),1);var U=O(I(),1);function NN(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=D.useState([]),[Q,c]=D.useState([]),[W,a]=D.useState(!0);if(D.useEffect(()=>{(async()=>{a(!0);let A=H&&H!=="unassigned"?`?project_id=${H}`:"";try{let[l,S]=await Promise.all([R(`/api/subscriptions${A}`).catch(()=>null),R("/api/agents").catch(()=>null)]);if(l?.ok){let G=await l.json();F(G.subscriptions||[])}if(S?.ok){let G=await S.json();c(G.agents||[])}}catch(l){console.error("Failed to fetch overview data:",l)}a(!1)})()},[R,H]),W)return U.jsxDEV("div",{className:"text-center py-12 text-[var(--color-text-muted)]",children:"Loading..."},void 0,!1,void 0,this);let y=J.filter((Y)=>Y.enabled),T=J.filter((Y)=>!Y.enabled),P=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(bv,{label:"Active",value:y.length},void 0,!1,void 0,this),U.jsxDEV(bv,{label:"Disabled",value:T.length},void 0,!1,void 0,this),U.jsxDEV(bv,{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-[var(--color-text-secondary)] mb-3",children:["Subscriptions (",J.length,")"]},void 0,!0,void 0,this),J.length===0?U.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 text-center text-[var(--color-text-muted)] 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 A=P.get(Y.agent_id);return U.jsxDEV("div",{className:"bg-[var(--color-surface)] card 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-[var(--color-text-faint)]"}`},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-[var(--color-text-muted)]",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-[var(--color-text-secondary)] flex-shrink-0",children:[U.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:"→"},void 0,!1,void 0,this)," ",U.jsxDEV("span",{className:"text-[var(--color-accent)]",children:A?.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-[var(--color-surface-raised)] text-[var(--color-text-faint)]"}`,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 bv({label:R,value:H,valueColor:J}){return U.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-4",children:[U.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mb-1",children:R},void 0,!1,void 0,this),U.jsxDEV("div",{className:`text-2xl font-bold ${J||"text-[var(--color-text)]"}`,children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var $=O(Xv(),1);var i=O(I(),1);function lN({message:R="Loading...",fullScreen:H=!1}){let J=i.jsxDEV("div",{className:"flex items-center gap-3 text-[var(--color-text-muted)]",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-[var(--color-bg)] text-[var(--color-text)] 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 N=O(I(),1);function mN(){let{authFetch:R}=g(),{currentProjectId:H}=j(),[J,F]=$.useState([]),[Q,c]=$.useState(""),[W,a]=$.useState([]),[y,T]=$.useState(!0),[P,Y]=$.useState([]),[A,l]=$.useState([]),[S,G]=$.useState(!1),[w,k]=$.useState(""),[o,Fv]=$.useState(""),[RN,mv]=$.useState(!1),[B,fv]=$.useState(null),[_v,zN]=$.useState([]),[$v,lv]=$.useState(""),[Yv,Rv]=$.useState(!1),[r,Iv]=$.useState(""),[Zv,nv]=$.useState({}),[Pv,GN]=$.useState(""),[HN,qv]=$.useState(!1),[p,JN]=$.useState([]),[KN,kv]=$.useState(!1),[yv,UN]=$.useState([]),[Qv,XN]=$.useState([]),[s,Av]=$.useState(""),[t,Wv]=$.useState(""),[e,hv]=$.useState(""),[iv,av]=$.useState(!1),[Bv,zv]=$.useState({}),[Tv,YN]=$.useState(""),[Sv,Gv]=$.useState(!1),[Mv,pv]=$.useState(""),[uv,Hv]=$.useState(!1),[Ov,xv]=$.useState(""),[ZN,Jv]=$.useState(!1),[V,Lv]=$.useState(""),[Kv,wv]=$.useState(""),[cv,Vv]=$.useState(!1),[h,qN]=$.useState([]),[dv,Z]=$.useState(null),X=H&&H!=="unassigned"?`?project_id=${H}`:"",Ev=$.useCallback(async()=>{try{let v=await R(`/api/triggers/providers${X}`);if(v.ok){let f=((await v.json()).providers||[]).filter((_)=>_.connected);if(F(f),f.length>0)c((_)=>{if(!_||!f.find((K)=>K.id===_))return f[0].id;return _})}}catch(v){console.error("Failed to fetch providers:",v)}},[R]),u=$.useCallback(async()=>{T(!0);try{let v=`provider=${Q}`,m=X?"&":"?",f=X?`/api/triggers${X}&${v}`:`/api/triggers?${v}`,_=await R(f);if(_.ok){let K=await _.json();a(K.triggers||[])}}catch(v){console.error("Failed to fetch triggers:",v)}T(!1)},[R,X,Q]),vv=$.useCallback(async()=>{try{let v=await R(`/api/subscriptions${X}`);if(v.ok){let m=await v.json();Y(m.subscriptions||[])}}catch(v){console.error("Failed to fetch subscriptions:",v)}},[R,X]),Dv=$.useCallback(async()=>{try{let v=await R(`/api/agents${X}`);if(v.ok){let m=await v.json();qN(m.agents||[])}}catch(v){}},[R,X]);$.useEffect(()=>{Ev(),u(),vv(),Dv()},[Ev,u,vv,Dv]);let QN=async(v)=>{G(!0);try{let m=`/api/triggers/types?provider=${Q}`;if(v)m+=`&toolkit_slugs=${v}`;if(H&&H!=="unassigned")m+=`&project_id=${H}`;let f=await R(m);if(f.ok){let _=await f.json();l(_.types||[])}else{let _=await f.json();Z(_.error||"Failed to fetch trigger types")}}catch(m){Z("Failed to fetch trigger types")}G(!1)},WN=async()=>{try{let v=await R(`/api/integrations/${Q}/connected${X}`);if(v.ok){let m=await v.json();zN((m.accounts||[]).filter((f)=>f.status==="active"))}}catch(v){}},BN=(v)=>{fv(v),lv(""),Iv(""),nv({}),GN(""),mv(!0),WN()},b=Q==="agentdojo",MN=async()=>{qv(!0),Wv(""),Av(""),hv(""),zv({}),YN("");let v=async()=>{if(p.length>0)return;kv(!0);try{let _="/api/triggers/types?provider=agentdojo";if(H&&H!=="unassigned")_+=`&project_id=${H}`;let L=await(await R(_)).json();JN(L.types||[])}catch(_){console.error("Failed to load trigger types:",_)}kv(!1)},m=async()=>{try{let _=`/api/integrations/agentdojo/connected${X}`,q=((await(await R(_)).json()).accounts||[]).filter((E)=>E.status==="active");UN(q)}catch(_){console.error("Failed to load connected accounts:",_)}},f=async()=>{if(Qv.length>0)return;try{let _=`/api/integrations/agentdojo/apps${X}`,L=await(await R(_)).json();XN((L.apps||[]).map((q)=>({id:q.id,name:q.name,slug:q.slug,logo:q.logo})))}catch(_){console.error("Failed to load apps:",_)}};await Promise.all([v(),m(),f()])},ON=async()=>{let v=p.find((f)=>f.slug===t),m=Uv;if(!v||!e||!m)return;av(!0),Z(null);try{let f=h.find((FN)=>FN.id===e),_="provider=agentdojo",K=X?`/api/triggers${X}&provider=agentdojo`:"/api/triggers?provider=agentdojo",L={callback_url:`${window.location.origin}/api/webhooks/agentdojo`,title:`${v.name} → ${f?.name||"Agent"}`,server:v.toolkit_slug,agent_id:e,...Bv},q=await R(K,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:v.slug,connectedAccountId:m.id,config:L})}),E=await q.json();if(!q.ok)Z(E.error||"Failed to create subscription");else qv(!1),u()}catch(f){Z(f.message||"Failed to create subscription")}av(!1)},LN=async()=>{if(!B)return;if(b){if(!r||!Nv)return;Rv(!0),Z(null);try{let v=h.find((q)=>q.id===r),m=window.location.origin,f=`provider=${Q}`,_=X?`/api/triggers${X}&${f}`:`/api/triggers?${f}`,K=await R(_,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:Nv.id,config:{callback_url:`${m}/api/webhooks/agentdojo`,title:`${B.name} → ${v?.name||"Agent"}`,server:B.toolkit_slug,agent_id:r,...Zv}})}),L=await K.json();if(!K.ok)Z(L.error||"Failed to create subscription");else mv(!1),fv(null),u()}catch(v){Z(v.message||"Failed to create subscription")}Rv(!1);return}if(!$v)return;Rv(!0),Z(null);try{let v=`provider=${Q}`,m=X?`/api/triggers${X}&${v}`:`/api/triggers?${v}`,f=await R(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:B.slug,connectedAccountId:$v})}),_=await f.json();if(!f.ok)Z(_.error||"Failed to create trigger");else mv(!1),fv(null),u()}catch(v){Z(v.message||"Failed to create trigger")}Rv(!1)},gv=async(v,m)=>{let f=m==="active"?"disable":"enable";try{let _=X?`&provider=${Q}`:`?provider=${Q}`,K=await R(`/api/triggers/${v}/${f}${X}${_}`,{method:"POST"});if(K.ok)u();else{let L=await K.json();Z(L.error||`Failed to ${f} trigger`)}}catch(_){Z(`Failed to ${f} trigger`)}},jv=async(v)=>{try{let m=X?`&provider=${Q}`:`?provider=${Q}`,f=await R(`/api/triggers/${v}${X}${m}`,{method:"DELETE"});if(f.ok)u();else{let _=await f.json();Z(_.error||"Failed to delete trigger")}}catch(m){Z("Failed to delete trigger")}},wN=async()=>{if(!V||!Kv)return;let v=W.find((m)=>m.id===V);if(!v)return;Vv(!0),Z(null);try{let m=await R("/api/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({trigger_slug:v.trigger_slug,trigger_instance_id:v.id,agent_id:Kv,provider:Q,project_id:H&&H!=="unassigned"?H:null,public_url:window.location.origin})}),f=await m.json();if(!m.ok)Z(f.error||"Failed to create subscription");else Jv(!1),Lv(""),wv(""),vv()}catch(m){Z(m.message||"Failed to create subscription")}Vv(!1)},CN=async(v)=>{let m=v.enabled?"disable":"enable";try{if((await R(`/api/subscriptions/${v.id}/${m}`,{method:"POST"})).ok)vv()}catch(f){Z(`Failed to ${m} subscription`)}},bN=async(v)=>{try{if((await R(`/api/subscriptions/${v}`,{method:"DELETE"})).ok)vv()}catch(m){Z("Failed to delete subscription")}},Cv=A.filter((v)=>{if(!o)return!0;let m=o.toLowerCase();return v.name.toLowerCase().includes(m)||v.slug.toLowerCase().includes(m)||v.description.toLowerCase().includes(m)}),ov=(v,m)=>{if(!m||v.length===0)return null;let f=m.toLowerCase().replace(/[-_]/g," "),_=v.find((q)=>q.appId?.toLowerCase()===m.toLowerCase()||q.appName?.toLowerCase()===m.toLowerCase());if(_)return _;let K=v.find((q)=>q.appId?.toLowerCase().includes(f)||q.appName?.toLowerCase().replace(/[-_]/g," ").includes(f)||f.includes(q.appId?.toLowerCase()||"")||f.includes(q.appName?.toLowerCase().replace(/[-_]/g," ")||""));if(K)return K;let L=f.split(/\s+/);return v.find((q)=>{let E=(q.appName||"").toLowerCase().replace(/[-_]/g," ").split(/\s+/);return L[0]&&E[0]&&L[0]===E[0]})||null},M=p.find((v)=>v.slug===t),rv=M?ov(yv,M.toolkit_slug):null,Uv=Tv?yv.find((v)=>v.id===Tv)||rv:rv,sv=B&&b?ov(_v,B.toolkit_slug):null,Nv=Pv?_v.find((v)=>v.id===Pv)||sv:sv,tv=$.default.useMemo(()=>{let v=new Map;for(let f of Qv)if(f.logo)v.set(f.slug,f.logo);let m=new Map;for(let f of p){let _=m.get(f.toolkit_slug);if(_)_.count++;else{let K=v.get(f.toolkit_slug)||f.logo||null;m.set(f.toolkit_slug,{slug:f.toolkit_slug,name:f.toolkit_name,logo:K,count:1})}}return Array.from(m.values()).sort((f,_)=>f.name.localeCompare(_.name))},[p,Qv]),ev=s?p.filter((v)=>v.toolkit_slug===s):[],d=tv.find((v)=>v.slug===s),vN=new Map(h.map((v)=>[v.id,v]));if(J.length===0&&!y)return N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8 text-center",children:[N.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"No trigger providers configured."},void 0,!1,void 0,this),N.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] 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 N.jsxDEV("div",{className:"space-y-6",children:[dv&&N.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:[N.jsxDEV("span",{children:dv},void 0,!1,void 0,this),N.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&&N.jsxDEV("div",{className:"flex items-center gap-2",children:[N.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:"Provider:"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex gap-1 bg-[var(--color-surface)] card p-0.5",children:J.map((v)=>N.jsxDEV("button",{onClick:()=>{c(v.id),l([]),k(""),Fv("")},className:`px-3 py-1 rounded text-xs font-medium transition ${Q===v.id?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:v.name},v.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!b&&N.jsxDEV("section",{children:[N.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[N.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Subscriptions (",P.length,")"]},void 0,!0,void 0,this),N.jsxDEV("button",{onClick:()=>Jv(!0),className:"text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-3 py-1.5 rounded transition",children:"+ Add Subscription"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.length===0?N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 text-center text-[var(--color-text-muted)] text-sm",children:"No subscriptions yet. Add one to route trigger events to an agent."},void 0,!1,void 0,this):N.jsxDEV("div",{className:"space-y-2",children:P.map((v)=>{let m=vN.get(v.agent_id);return N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-3 flex items-center gap-3",children:[N.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${v.enabled?"bg-green-400":"bg-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex-1 min-w-0",children:[N.jsxDEV("div",{className:"text-sm font-medium truncate",children:[v.trigger_slug.replace(/_/g," "),N.jsxDEV("span",{className:"text-[var(--color-text-faint)] mx-1.5",children:"→"},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[var(--color-accent)]",children:m?.name||"Unknown Agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:v.trigger_instance_id?`Instance: ${v.trigger_instance_id.slice(0,12)}...`:"All instances"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[N.jsxDEV("button",{onClick:()=>CN(v),className:`text-xs px-3 py-1 rounded transition ${v.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:v.enabled?"Disable":"Enable"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:()=>bN(v.id),className:"text-xs text-[var(--color-text-muted)] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},v.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!b&&N.jsxDEV("section",{children:[N.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:["Trigger Instances (",W.length,")"]},void 0,!0,void 0,this),y?N.jsxDEV("div",{className:"text-center py-6 text-[var(--color-text-muted)] text-sm",children:"Loading triggers..."},void 0,!1,void 0,this):W.length===0?N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 text-center text-[var(--color-text-muted)] text-sm",children:"No trigger instances. Browse trigger types below to create one."},void 0,!1,void 0,this):N.jsxDEV("div",{className:"space-y-2",children:W.map((v)=>N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-3 flex items-center gap-3",children:[N.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${v.status==="active"?"bg-green-400":"bg-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex-1 min-w-0",children:[N.jsxDEV("div",{className:"text-sm font-medium truncate",children:v.trigger_slug.replace(/_/g," ")},void 0,!1,void 0,this),N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:["ID: ",v.id.slice(0,12),"... | Created: ",new Date(v.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[N.jsxDEV("button",{onClick:()=>gv(v.id,v.status),className:`text-xs px-3 py-1 rounded transition ${v.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:v.status==="active"?"Disable":"Enable"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:()=>jv(v.id),className:"text-xs text-[var(--color-text-muted)] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},v.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&N.jsxDEV("section",{children:[N.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[N.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)]",children:["Active Subscriptions (",W.length,")"]},void 0,!0,void 0,this),N.jsxDEV("button",{onClick:MN,className:"text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-3 py-1.5 rounded transition",children:"+ Add Subscription"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y?N.jsxDEV("div",{className:"text-center py-6 text-[var(--color-text-muted)] text-sm",children:"Loading subscriptions..."},void 0,!1,void 0,this):W.length===0?N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 text-center text-[var(--color-text-muted)] text-sm",children:"No active subscriptions. Browse trigger types below to create one."},void 0,!1,void 0,this):N.jsxDEV("div",{className:"space-y-2",children:W.map((v)=>{let m=P.find((_)=>_.trigger_instance_id===v.id),f=m?vN.get(m.agent_id):null;return N.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-3 flex items-center gap-3",children:[N.jsxDEV("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${v.status==="active"?"bg-green-400":"bg-[var(--color-text-muted)]"}`},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex-1 min-w-0",children:[N.jsxDEV("div",{className:"text-sm font-medium truncate",children:[v.config?.title||v.trigger_slug.replace(/_/g," "),f&&N.jsxDEV(N.Fragment,{children:[N.jsxDEV("span",{className:"text-[var(--color-text-faint)] mx-1.5",children:"→"},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[var(--color-accent)]",children:f.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:[v.config?.server&&N.jsxDEV("span",{children:[String(v.config.server)," | "]},void 0,!0,void 0,this),"ID: ",String(v.id).slice(0,8)," | Created: ",new Date(v.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"flex items-center gap-2 flex-shrink-0",children:[N.jsxDEV("button",{onClick:()=>gv(v.id,v.status),className:`text-xs px-3 py-1 rounded transition ${v.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:v.status==="active"?"Disable":"Enable"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:()=>jv(v.id),className:"text-xs text-[var(--color-text-muted)] hover:text-red-400 transition px-2",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},v.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("section",{children:[N.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:"Browse Trigger Types"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex gap-2 mb-3",children:[N.jsxDEV("input",{type:"text",value:w,onChange:(v)=>k(v.target.value),placeholder:"Toolkit filter (e.g. github, gmail, slack)",className:"flex-1 bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:()=>QN(w||void 0),disabled:S,className:"text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-4 py-2 rounded transition disabled:opacity-50",children:S?"Loading...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),A.length>0&&N.jsxDEV(N.Fragment,{children:[N.jsxDEV("input",{type:"text",value:o,onChange:(v)=>Fv(v.target.value),placeholder:"Search trigger types...",className:"w-full bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm mb-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Cv.slice(0,30).map((v)=>N.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border)] hover:border-[var(--color-border-light)] rounded-lg p-3 transition",children:[N.jsxDEV("div",{className:"flex items-start gap-3",children:[v.logo?N.jsxDEV("img",{src:v.logo,alt:v.toolkit_name,className:"w-8 h-8 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):N.jsxDEV("div",{className:"w-8 h-8 rounded bg-[var(--color-surface-raised)] flex items-center justify-center text-xs flex-shrink-0",children:v.toolkit_name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"flex-1 min-w-0",children:[N.jsxDEV("div",{className:"text-sm font-medium truncate",children:v.name},void 0,!1,void 0,this),N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)]",children:v.toolkit_name},void 0,!1,void 0,this),N.jsxDEV("div",{className:"text-xs text-[var(--color-text-faint)] mt-1 line-clamp-2",children:v.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("button",{onClick:()=>BN(v),className:"w-full mt-3 text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] px-3 py-1.5 rounded transition",children:b?"Subscribe":"Create Trigger"},void 0,!1,void 0,this)]},v.slug,!0,void 0,this))},void 0,!1,void 0,this),Cv.length>30&&N.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-3 text-center",children:["Showing first 30 of ",Cv.length," types. Use search to filter."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),RN&&B&&N.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:N.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg p-6 w-full max-w-md mx-4",children:[N.jsxDEV("h3",{className:"font-medium mb-1",children:b?"Create Subscription":"Create Trigger"},void 0,!1,void 0,this),N.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mb-4",children:[B.name,B.toolkit_name&&N.jsxDEV("span",{className:"text-[var(--color-text-faint)]",children:[" (",B.toolkit_name,")"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"space-y-4",children:[!b&&N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),_v.length===0?N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] bg-[var(--color-bg)] rounded p-3",children:"No connected accounts available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):N.jsxDEV(x,{value:$v,onChange:lv,placeholder:"Select account...",options:_v.map((v)=>({value:v.id,label:`${v.appName} (${v.id.slice(0,8)}...)`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Route to Agent"},void 0,!1,void 0,this),h.length===0?N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] bg-[var(--color-bg)] rounded p-3",children:"No agents available. Create an agent first."},void 0,!1,void 0,this):N.jsxDEV(x,{value:r,onChange:Iv,placeholder:"Select agent...",options:h.map((v)=>({value:v.id,label:`${v.name} (${v.status})`}))},void 0,!1,void 0,this),N.jsxDEV("div",{className:"mt-3",children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),Nv?N.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",Nv.appName]},void 0,!0,void 0,this):N.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&&N.jsxDEV("div",{className:"mt-3",children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"space-y-2",children:Object.entries(B.config_schema.properties||{}).map(([v,m])=>{let f=(B.config_schema.required||[]).includes(v);return N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-[11px] text-[var(--color-text-secondary)] mb-1",children:[m.title||v,f&&N.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("input",{type:"text",value:Zv[v]||"",onChange:(_)=>nv((K)=>({...K,[v]:_.target.value})),placeholder:m.description||`Enter ${m.title||v}...`,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},v,!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),N.jsxDEV("div",{className:"flex gap-2 mt-4",children:[N.jsxDEV("button",{onClick:()=>{mv(!1),fv(null)},className:"flex-1 text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:LN,disabled:b?!r||!Nv||Yv||B?.config_schema&&(B.config_schema.required||[]).some((v)=>!Zv[v]?.trim()):!$v||Yv,className:"flex-1 text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white px-4 py-2 rounded transition disabled:opacity-50",children:Yv?"Creating...":b?"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),ZN&&N.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:N.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg p-6 w-full max-w-md mx-4",children:[N.jsxDEV("h3",{className:"font-medium mb-1",children:"Route Trigger to Agent"},void 0,!1,void 0,this),N.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] 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?N.jsxDEV(N.Fragment,{children:[N.jsxDEV("div",{className:"space-y-4",children:[N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Trigger Instance"},void 0,!1,void 0,this),N.jsxDEV(x,{value:V,onChange:Lv,placeholder:"Select trigger...",options:W.map((v)=>({value:v.id,label:`${v.trigger_slug.replace(/_/g," ")}`}))},void 0,!1,void 0,this),V&&N.jsxDEV("div",{className:"text-xs text-[var(--color-text-faint)] mt-1 font-mono",children:["ID: ",V.slice(0,16),"..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),N.jsxDEV(x,{value:Kv,onChange:wv,placeholder:"Select agent...",options:h.map((v)=>({value:v.id,label:`${v.name} (${v.status})`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"flex gap-2 mt-5",children:[N.jsxDEV("button",{onClick:()=>{Jv(!1),Lv(""),wv("")},className:"flex-1 text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:wN,disabled:!V||!Kv||cv,className:"flex-1 text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white px-4 py-2 rounded transition disabled:opacity-50",children:cv?"Adding...":"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):N.jsxDEV("div",{className:"flex gap-2 mt-4",children:N.jsxDEV("button",{onClick:()=>Jv(!1),className:"flex-1 text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] 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),HN&&N.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:N.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg p-6 w-full max-w-lg mx-4",children:[N.jsxDEV("h3",{className:"font-medium mb-1",children:"Add Subscription"},void 0,!1,void 0,this),N.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mb-4",children:"Select an app and trigger, then route it to an agent."},void 0,!1,void 0,this),KN?N.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)] text-sm",children:"Loading..."},void 0,!1,void 0,this):p.length===0?N.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)] text-sm",children:"No triggers available. Connect an app first in the Integrations tab."},void 0,!1,void 0,this):N.jsxDEV("div",{className:"space-y-4",children:[N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"App"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"relative",children:[N.jsxDEV("button",{onClick:()=>{Gv(!Sv),Hv(!1),pv("")},className:"w-full flex items-center gap-2 bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm text-left hover:border-[var(--color-text-faint)] transition",children:[d?N.jsxDEV(N.Fragment,{children:[d.logo?N.jsxDEV("img",{src:d.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):N.jsxDEV("div",{className:"w-5 h-5 rounded bg-[var(--color-surface-raised)] flex items-center justify-center text-[10px] flex-shrink-0",children:d.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),N.jsxDEV("span",{className:"flex-1 truncate",children:d.name},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:[d.count," triggers"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):N.jsxDEV("span",{className:"text-[var(--color-text-muted)] flex-1",children:"Select app..."},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Sv&&N.jsxDEV(N.Fragment,{children:[N.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>Gv(!1)},void 0,!1,void 0,this),N.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[N.jsxDEV("div",{className:"p-2 border-b border-[var(--color-border)] flex-shrink-0",children:N.jsxDEV("input",{type:"text",value:Mv,onChange:(v)=>pv(v.target.value),placeholder:"Search apps...",className:"w-full bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),N.jsxDEV("div",{className:"overflow-y-auto flex-1",children:tv.filter((v)=>{if(!Mv)return!0;let m=Mv.toLowerCase();return v.name.toLowerCase().includes(m)||v.slug.toLowerCase().includes(m)}).map((v)=>N.jsxDEV("button",{onClick:()=>{Av(v.slug),Wv(""),zv({}),Gv(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[var(--color-surface-raised)] ${s===v.slug?"bg-[var(--color-surface-raised)] text-[var(--color-accent)]":""}`,children:[v.logo?N.jsxDEV("img",{src:v.logo,alt:"",className:"w-5 h-5 rounded object-contain flex-shrink-0"},void 0,!1,void 0,this):N.jsxDEV("div",{className:"w-5 h-5 rounded bg-[var(--color-surface-raised)] flex items-center justify-center text-[10px] flex-shrink-0",children:v.name?.[0]?.toUpperCase()||"?"},void 0,!1,void 0,this),N.jsxDEV("span",{className:"flex-1 truncate",children:v.name},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:v.count},void 0,!1,void 0,this)]},v.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&&N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Trigger"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"relative",children:[N.jsxDEV("button",{onClick:()=>{Hv(!uv),Gv(!1),xv("")},className:"w-full flex items-center gap-2 bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm text-left hover:border-[var(--color-text-faint)] transition",children:[M?N.jsxDEV(N.Fragment,{children:[N.jsxDEV("span",{className:"flex-1 truncate",children:M.name},void 0,!1,void 0,this),N.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):N.jsxDEV("span",{className:"text-[var(--color-text-muted)] flex-1",children:"Select trigger..."},void 0,!1,void 0,this),N.jsxDEV("span",{className:"text-[var(--color-text-muted)] text-xs ml-1",children:"▾"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),uv&&N.jsxDEV(N.Fragment,{children:[N.jsxDEV("div",{className:"fixed inset-0 z-10",onClick:()=>Hv(!1)},void 0,!1,void 0,this),N.jsxDEV("div",{className:"absolute left-0 right-0 top-full mt-1 bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg shadow-xl z-20 max-h-64 flex flex-col",children:[ev.length>3&&N.jsxDEV("div",{className:"p-2 border-b border-[var(--color-border)] flex-shrink-0",children:N.jsxDEV("input",{type:"text",value:Ov,onChange:(v)=>xv(v.target.value),placeholder:"Search triggers...",className:"w-full bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded px-2 py-1.5 text-sm focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0},void 0,!1,void 0,this)},void 0,!1,void 0,this),N.jsxDEV("div",{className:"overflow-y-auto flex-1",children:ev.filter((v)=>{if(!Ov)return!0;let m=Ov.toLowerCase();return v.name.toLowerCase().includes(m)||v.slug.toLowerCase().includes(m)||v.description.toLowerCase().includes(m)}).map((v)=>N.jsxDEV("button",{onClick:()=>{Wv(v.slug),zv({}),Hv(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition hover:bg-[var(--color-surface-raised)] ${t===v.slug?"bg-[var(--color-surface-raised)] text-[var(--color-accent)]":""}`,children:[N.jsxDEV("div",{className:"flex-1 min-w-0",children:[N.jsxDEV("div",{className:"truncate",children:v.name},void 0,!1,void 0,this),N.jsxDEV("div",{className:"text-[10px] text-[var(--color-text-muted)] truncate",children:v.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${v.type==="webhook"?"bg-blue-500/10 text-blue-400":"bg-yellow-500/10 text-yellow-400"}`,children:v.type},void 0,!1,void 0,this)]},v.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&&N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Connected Account"},void 0,!1,void 0,this),Uv?N.jsxDEV("div",{className:"text-xs text-green-400 bg-green-500/10 border border-green-500/20 rounded p-3",children:["Connected: ",Uv.appName]},void 0,!0,void 0,this):N.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&&N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Configuration"},void 0,!1,void 0,this),N.jsxDEV("div",{className:"space-y-2",children:Object.entries(M.config_schema.properties||{}).map(([v,m])=>{let f=(M.config_schema.required||[]).includes(v);return N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-[11px] text-[var(--color-text-secondary)] mb-1",children:[m.title||v,f&&N.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("input",{type:"text",value:Bv[v]||"",onChange:(_)=>zv((K)=>({...K,[v]:_.target.value})),placeholder:m.description||`Enter ${m.title||v}...`,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)]},v,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{children:[N.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1.5",children:"Target Agent"},void 0,!1,void 0,this),h.length===0?N.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] bg-[var(--color-bg)] rounded p-3",children:"No agents available. Create an agent first."},void 0,!1,void 0,this):N.jsxDEV(x,{value:e,onChange:hv,placeholder:"Select agent...",options:h.map((v)=>({value:v.id,label:`${v.name} (${v.status})`}))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N.jsxDEV("div",{className:"flex gap-2 mt-5",children:[N.jsxDEV("button",{onClick:()=>qv(!1),className:"flex-1 text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] px-4 py-2 rounded transition",children:"Cancel"},void 0,!1,void 0,this),N.jsxDEV("button",{onClick:ON,disabled:!t||!e||!Uv||iv||M?.config_schema&&(M.config_schema.required||[]).some((v)=>!Bv[v]?.trim()),className:"flex-1 text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white px-4 py-2 rounded transition disabled:opacity-50",children:iv?"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 n=O(Xv(),1);var z=O(I(),1);function _N(){let{authFetch:R}=g(),{currentProjectId:H}=j(),J=H&&H!=="unassigned"?H:null,F=J?`?project_id=${J}`:"",[Q,c]=n.useState([]),[W,a]=n.useState("");n.useEffect(()=>{R(`/api/triggers/providers${F}`).then((G)=>G.json()).then((G)=>{let w=(G.providers||[]).filter((k)=>k.connected);if(c(w),w.length>0&&!w.find((k)=>k.id===W))a(w[0].id)}).catch(()=>{})},[R]);let[y,T]=n.useState(null),[P,Y]=n.useState([]),[A,l]=n.useState(!1),S=n.useCallback(async(G)=>{T(G),l(!0);try{let w=`/api/triggers/types?provider=${W}&toolkit_slugs=${G}`;if(J)w+=`&project_id=${J}`;let k=await R(w);if(k.ok){let o=await k.json();Y(o.types||[])}}catch(w){console.error("Failed to fetch trigger types:",w)}l(!1)},[R,J,W]);return z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] 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-[var(--color-text-muted)]",children:"Provider:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[var(--color-surface)] card p-0.5",children:Q.map((G)=>z.jsxDEV("button",{onClick:()=>a(G.id),className:`px-3 py-1 rounded text-xs font-medium transition ${W===G.id?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,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-[var(--color-surface)] card p-8 text-center",children:[z.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"No integration providers configured."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-faint)] 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(fN,{providerId:W,projectId:J,hideMcpConfig:!0,onBrowseTriggers:S},void 0,!1,void 0,this),y&&z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:z.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] 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-[var(--color-border)] 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-[var(--color-text-muted)]",children:y},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>{T(null),Y([])},className:"text-[var(--color-text-muted)] 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:A?z.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading trigger types..."},void 0,!1,void 0,this):P.length===0?z.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"No trigger types available for this app."},void 0,!1,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:P.map((G)=>z.jsxDEV("div",{className:"bg-[var(--color-bg)] card 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-[var(--color-surface-raised)] 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-[var(--color-text-muted)] 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-[var(--color-surface-raised)] text-[var(--color-text-faint)] 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 C=O(I(),1);function J0(){let[R,H]=$N.useState("overview");return C.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:C.jsxDEV("div",{className:"max-w-6xl",children:[C.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:C.jsxDEV("div",{children:[C.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Connections"},void 0,!1,void 0,this),C.jsxDEV("p",{className:"text-[var(--color-text-muted)]",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),C.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[var(--color-surface)] card p-1 w-fit",children:[{id:"overview",label:"Overview"},{id:"triggers",label:"Triggers"},{id:"integrations",label:"Integrations"}].map((F)=>C.jsxDEV("button",{onClick:()=>H(F.id),className:`px-4 py-2 rounded text-sm font-medium transition ${R===F.id?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:F.label},F.id,!1,void 0,this))},void 0,!1,void 0,this),R==="overview"&&C.jsxDEV(NN,{},void 0,!1,void 0,this),R==="triggers"&&C.jsxDEV(mN,{},void 0,!1,void 0,this),R==="integrations"&&C.jsxDEV(_N,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
2
|
+
export{lN as a,J0 as b};
|
|
3
|
+
|
|
4
|
+
//# debugId=45AC14297BEFA8DD64756E2164756E21
|