apteva 0.4.44 → 0.4.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/{ActivityPage.c48n83h2.js → ActivityPage.sw9p594m.js} +1 -1
  2. package/dist/{ApiDocsPage.yzcxx5ax.js → ApiDocsPage.90e03bz7.js} +1 -1
  3. package/dist/App.3vnrera5.js +4 -0
  4. package/dist/App.94x6mh7f.js +20 -0
  5. package/dist/{App.qzbx5wtj.js → App.9sryp183.js} +1 -1
  6. package/dist/App.9t1zc5r7.js +53 -0
  7. package/dist/{App.r5serxkt.js → App.jhb45d7r.js} +1 -1
  8. package/dist/App.k4nmqgek.js +221 -0
  9. package/dist/App.p7jjw1zf.js +4 -0
  10. package/dist/App.pfbdzrhh.js +4 -0
  11. package/dist/App.stgng5bx.js +13 -0
  12. package/dist/{App.152mbs1r.js → App.tm3k7h4b.js} +1 -1
  13. package/dist/App.vkg121c6.js +4 -0
  14. package/dist/App.vza4fxg0.js +4 -0
  15. package/dist/App.wghtdzsk.js +1 -0
  16. package/dist/App.xva0tfzh.js +4 -0
  17. package/dist/App.ysxy7akk.js +61 -0
  18. package/dist/App.yzkh4gq2.js +4 -0
  19. package/dist/ConnectionsPage.q5f9fd37.js +3 -0
  20. package/dist/McpPage.f3ccrezb.js +3 -0
  21. package/dist/SettingsPage.q1pqcc93.js +3 -0
  22. package/dist/SkillsPage.whxnez67.js +3 -0
  23. package/dist/TasksPage.zp4jfevw.js +3 -0
  24. package/dist/TelemetryPage.an0ky78c.js +3 -0
  25. package/dist/TestsPage.18krj0d1.js +3 -0
  26. package/dist/ThreadsPage.nnphgy98.js +3 -0
  27. package/dist/apteva-kit.css +1 -1
  28. package/dist/index.html +1 -1
  29. package/dist/styles.css +1 -1
  30. package/package.json +10 -9
  31. package/src/db.ts +60 -22
  32. package/src/providers.ts +14 -9
  33. package/src/routes/api/agent-utils.ts +25 -3
  34. package/src/routes/api/telemetry.ts +21 -2
  35. package/src/server.ts +53 -1
  36. package/src/web/App.tsx +2 -2
  37. package/src/web/components/agents/AgentCard.tsx +9 -7
  38. package/src/web/components/agents/AgentPanel.tsx +205 -44
  39. package/src/web/components/agents/CreateAgentModal.tsx +5 -5
  40. package/src/web/components/auth/LoginPage.tsx +2 -2
  41. package/src/web/components/common/LoadingSpinner.tsx +1 -1
  42. package/src/web/components/common/Modal.tsx +6 -6
  43. package/src/web/components/common/Select.tsx +2 -2
  44. package/src/web/components/connections/ConnectionsPage.tsx +1 -1
  45. package/src/web/components/connections/IntegrationsTab.tsx +3 -3
  46. package/src/web/components/connections/OverviewTab.tsx +3 -3
  47. package/src/web/components/connections/TriggersTab.tsx +8 -8
  48. package/src/web/components/dashboard/Dashboard.tsx +4 -4
  49. package/src/web/components/layout/Header.tsx +3 -3
  50. package/src/web/components/layout/Sidebar.tsx +6 -5
  51. package/src/web/components/mcp/McpPage.tsx +13 -13
  52. package/src/web/components/onboarding/OnboardingWizard.tsx +2 -2
  53. package/src/web/components/settings/SettingsPage.tsx +59 -26
  54. package/src/web/components/skills/SkillsPage.tsx +7 -7
  55. package/src/web/components/tasks/TasksPage.tsx +212 -36
  56. package/src/web/components/telemetry/TelemetryPage.tsx +414 -94
  57. package/src/web/components/tests/TestsPage.tsx +2 -2
  58. package/src/web/components/threads/ThreadsPage.tsx +2 -2
  59. package/src/web/context/TelemetryContext.tsx +1 -0
  60. package/src/web/context/ThemeContext.tsx +31 -10
  61. package/src/web/index.html +1 -6
  62. package/src/web/styles.css +47 -0
  63. package/src/web/themes.ts +68 -5
  64. package/src/web/types.ts +1 -1
  65. package/dist/App.09yb8t0b.js +0 -1
  66. package/dist/App.3a67nx9w.js +0 -4
  67. package/dist/App.9epx6785.js +0 -4
  68. package/dist/App.d8955awp.js +0 -4
  69. package/dist/App.drwb57jq.js +0 -4
  70. package/dist/App.gssbmajb.js +0 -4
  71. package/dist/App.qw70pc29.js +0 -53
  72. package/dist/App.tpmp9020.js +0 -20
  73. package/dist/App.v2wb4d7d.js +0 -61
  74. package/dist/App.vxmaaj0m.js +0 -13
  75. package/dist/App.w4p2tda9.js +0 -4
  76. package/dist/App.wv2ng55q.js +0 -221
  77. package/dist/App.yncnrn0f.js +0 -4
  78. package/dist/ConnectionsPage.k6cspyqq.js +0 -3
  79. package/dist/McpPage.cdxm48xj.js +0 -3
  80. package/dist/SettingsPage.evpv7c2y.js +0 -3
  81. package/dist/SkillsPage.pvzp6c1a.js +0 -3
  82. package/dist/TasksPage.6jnvbpsy.js +0 -3
  83. package/dist/TelemetryPage.t7vk24zc.js +0 -3
  84. package/dist/TestsPage.5x6658aa.js +0 -3
  85. package/dist/ThreadsPage.3fvhtevh.js +0 -3
@@ -0,0 +1,4 @@
1
+ import{$ as b,X as s,aa as d}from"./App.94x6mh7f.js";var r=s(b(),1),e=s(d(),1);function h({value:o,options:i,onChange:v,placeholder:m="Select...",compact:u}){let[a,l]=r.useState(!1),c=r.useRef(null),n=i.find((t)=>t.value===o);return r.useEffect(()=>{function t(f){if(c.current&&!c.current.contains(f.target))l(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]),e.jsxDEV("div",{ref:c,className:"relative",children:[e.jsxDEV("button",{type:"button",onClick:()=>l(!a),className:`w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] btn ${u?"px-2.5 py-1.5 text-sm":"px-3 py-2"} text-left flex items-center justify-between focus:outline-none focus:border-[var(--color-accent)] text-[var(--color-text)] hover:border-[var(--color-border-light)] transition`,children:[e.jsxDEV("span",{className:n?"text-[var(--color-text)]":"text-[var(--color-text-muted)]",children:n?e.jsxDEV(e.Fragment,{children:[n.label,n.recommended&&e.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):m},void 0,!1,void 0,this),e.jsxDEV(p,{isOpen:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&e.jsxDEV("div",{className:"absolute z-50 w-full min-w-max mt-1 bg-[var(--color-surface)] border border-[var(--color-border-light)] shadow-lg max-h-60 overflow-y-auto scrollbar-hide",style:{borderRadius:"var(--radius-button)"},children:i.map((t)=>e.jsxDEV("button",{type:"button",onClick:()=>{v(t.value),l(!1)},className:`w-full ${u?"px-2.5 py-1.5 text-sm":"px-3 py-2"} text-left flex items-center justify-between hover:bg-[var(--color-surface-raised)] transition ${t.value===o?"bg-[var(--color-surface-raised)] text-[var(--color-accent)]":"text-[var(--color-text)]"}`,children:[e.jsxDEV("span",{children:[t.label,t.recommended&&e.jsxDEV("span",{className:"text-[var(--color-accent)] text-xs ml-2",children:"(Recommended)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t.value===o&&e.jsxDEV("svg",{className:"w-4 h-4 text-[var(--color-accent)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},t.value,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function p({isOpen:o}){return e.jsxDEV("svg",{className:`w-4 h-4 text-[var(--color-text-muted)] transition-transform ${o?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"},void 0,!1,void 0,this)},void 0,!1,void 0,this)}
2
+ export{h as U};
3
+
4
+ //# debugId=A830E20FD61DEFBB64756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{O as V}from"./App.vkg121c6.js";import{U as D}from"./App.p7jjw1zf.js";import{$ as Kk,X as P,aa as v,da as i,ja as o,ma as d}from"./App.94x6mh7f.js";var J=P(Kk(),1);var q=P(v(),1);function Yk(){let{authFetch:K}=o(),{currentProjectId:X}=d(),{confirm:j,ConfirmDialog:E}=V(),[$,x]=J.useState([]),[A,c]=J.useState([]),[a,u]=J.useState(!0),[r,Y]=J.useState(!1),[H,C]=J.useState(null),[T,Q]=J.useState(new Set),[F,R]=J.useState(!1),[y,I]=J.useState(null),[w,f]=J.useState(null),[S,U]=J.useState({}),[M,N]=J.useState(""),[b,L]=J.useState(""),[g,B]=J.useState(""),Z=X&&X!=="all"&&X!=="unassigned"?X:null,n=Z?A.filter((k)=>k.projectId===Z):A,{events:p}=i({category:"test",limit:50}),_=J.useRef(new Set);J.useEffect(()=>{for(let k of p){if(_.current.has(k.id))continue;_.current.add(k.id);let z=k.data?.test_case_id;if(!z)continue;if(k.type==="test_started")U((G)=>({...G,[z]:{phase:"starting"}})),Q((G)=>new Set(G).add(z));else if(k.type==="test_planning")U((G)=>({...G,[z]:{phase:"planning"}}));else if(k.type==="test_executing"){let G=k.data?.agent_name;U((O)=>({...O,[z]:{phase:"executing",detail:G}}))}else if(k.type==="test_judging")U((G)=>({...G,[z]:{phase:"judging"}}));else if(k.type==="test_completed")U((G)=>{let O={...G};return delete O[z],O}),Q((G)=>{let O=new Set(G);return O.delete(z),O}),W()}if(_.current.size>500)_.current=new Set([..._.current].slice(-200))},[p]);let W=async()=>{try{let k=Z?`?project_id=${Z}`:"",z=await K(`/api/tests${k}`);if(z.ok)x(await z.json())}catch{}u(!1)},s=async()=>{try{let k=await K("/api/agents");if(k.ok){let z=await k.json();c((z.agents||z).map((G)=>({id:G.id,name:G.name,status:G.status,provider:G.provider,model:G.model,projectId:G.projectId||null})))}}catch{}};J.useEffect(()=>{Promise.all([W(),s()])},[X]);let l=()=>{C(null),N(""),L(""),B(""),Y(!0)},t=(k)=>{C(k),N(k.name),L(k.behavior||""),B(k.agent_id||""),Y(!0)},e=async()=>{if(!M||!b)return;let k={name:M,behavior:b,agent_id:g||null,project_id:Z||void 0};if(H)await K(`/api/tests/${H.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});else await K("/api/tests",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k)});Y(!1),W()},kk=async(k)=>{if(!await j("Delete this test case? Run history will also be deleted."))return;await K(`/api/tests/${k}`,{method:"DELETE"}),W()},qk=async(k)=>{Q((z)=>new Set(z).add(k));try{await K(`/api/tests/${k}/run`,{method:"POST"}),await W()}catch{}Q((z)=>{let G=new Set(z);return G.delete(k),G}),U((z)=>{let G={...z};return delete G[k],G})},zk=async()=>{R(!0);try{let k=$.map((z)=>z.id);Q(new Set(k)),await K("/api/tests/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({test_case_ids:k})}),await W()}catch{}Q(new Set),R(!1)},Gk=async(k)=>{try{let z=await K(`/api/tests/${k}/runs`);if(z.ok)I({testId:k,runs:await z.json()})}catch{}},h={starting:{label:"Starting",color:"bg-blue-900/50 text-blue-400 border-blue-500/30"},planning:{label:"Planning",color:"bg-purple-900/50 text-purple-400 border-purple-500/30"},executing:{label:"Executing",color:"bg-cyan-900/50 text-cyan-400 border-cyan-500/30"},judging:{label:"Judging",color:"bg-amber-900/50 text-amber-400 border-amber-500/30"}},m=(k)=>{return q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${{passed:"bg-green-900/50 text-green-400",failed:"bg-red-900/50 text-red-400",error:"bg-yellow-900/50 text-yellow-400",running:"bg-blue-900/50 text-blue-400"}[k]||"bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`,children:k.toUpperCase()},void 0,!1,void 0,this)},Jk=(k)=>{let z=S[k];if(!z)return null;let G=h[z.phase]||h.starting;return q.jsxDEV("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-medium border ${G.color} animate-pulse`,children:[q.jsxDEV("span",{className:"w-1.5 h-1.5 rounded-full bg-current"},void 0,!1,void 0,this),G.label,z.detail?` · ${z.detail}`:""]},void 0,!0,void 0,this)};return q.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[E,q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-xl font-bold",children:"Tests"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:"Describe behavior, AI handles the rest"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[$.length>0&&q.jsxDEV("button",{onClick:zk,disabled:F,className:"px-4 py-2 bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] rounded text-sm font-medium transition disabled:opacity-50",children:F?"Running...":"Run All"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white rounded text-sm font-medium transition",children:"+ New Test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),a?q.jsxDEV("div",{className:"text-[var(--color-text-muted)] text-sm",children:"Loading..."},void 0,!1,void 0,this):$.length===0?q.jsxDEV("div",{className:"text-center py-16",children:[q.jsxDEV("div",{className:"text-[var(--color-border-light)] text-4xl mb-4",children:q.jsxDEV("svg",{className:"w-12 h-12 mx-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-2",children:"No tests yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mb-4",children:"Describe what your agents should do and let AI verify it"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:l,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white rounded text-sm font-medium transition",children:"Create your first test"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:$.map((k)=>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("span",{className:"font-medium text-sm",children:k.name},void 0,!1,void 0,this),S[k.id]?Jk(k.id):k.last_run&&q.jsxDEV(q.Fragment,{children:[m(k.last_run.status),k.last_run.score!=null&&q.jsxDEV("span",{className:"text-xs text-[var(--color-text-secondary)] font-mono",children:[k.last_run.score,"/10"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.behavior&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-secondary)] mb-1.5 line-clamp-2",children:k.behavior},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] space-y-0.5",children:[q.jsxDEV("div",{children:["Agent:"," ",q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",children:k.agent_name||(k.last_run?.selected_agent_name?`${k.last_run.selected_agent_name} (auto-selected)`:"Auto (AI picks)")},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",children:['"',k.last_run.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.input_message&&!k.last_run?.generated_message&&q.jsxDEV("div",{className:"truncate",children:["Message: ",q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",children:['"',k.input_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.last_run&&q.jsxDEV("div",{children:["Last run:"," ",q.jsxDEV("span",{className:"text-[var(--color-text-secondary)]",children:[k.last_run.duration_ms?`${(k.last_run.duration_ms/1000).toFixed(1)}s`:"---",k.last_run.judge_reasoning&&` --- "${k.last_run.judge_reasoning.slice(0,80)}${k.last_run.judge_reasoning.length>80?"...":""}"`]},void 0,!0,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:"flex items-center gap-1 ml-3 shrink-0",children:[q.jsxDEV("button",{onClick:()=>Gk(k.id),className:"px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] rounded transition",title:"View run history",children:"History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>qk(k.id),disabled:T.has(k.id),className:"px-3 py-1 text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] rounded transition disabled:opacity-50",children:T.has(k.id)?"Running...":"Run"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>t(k),className:"px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] rounded transition",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>kk(k.id),className:"px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-red-400 hover:bg-[var(--color-surface-raised)] rounded transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},k.id,!1,void 0,this))},void 0,!1,void 0,this),y&&q.jsxDEV("div",{className:"mt-6",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[q.jsxDEV("h2",{className:"text-sm font-bold text-[var(--color-text-secondary)]",children:"Run History"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{I(null),f(null)},className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]",children:"Close"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y.runs.length===0?q.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)]",children:"No runs yet"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-2",children:y.runs.map((k)=>q.jsxDEV("div",{className:"bg-[var(--color-bg-secondary)] border border-[var(--color-border)] rounded p-3",children:[q.jsxDEV("div",{className:"flex items-center justify-between cursor-pointer",onClick:()=>f(w===k.id?null:k.id),children:[q.jsxDEV("div",{className:"flex items-center gap-3",children:[m(k.status),q.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:k.duration_ms?`${(k.duration_ms/1000).toFixed(1)}s`:"---"},void 0,!1,void 0,this),k.score!=null&&q.jsxDEV("span",{className:"text-xs text-[var(--color-text-secondary)] font-mono",children:[k.score,"/10"]},void 0,!0,void 0,this),k.selected_agent_name&&q.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:["Agent: ",k.selected_agent_name]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:new Date(k.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)]",children:w===k.id?"---":"+"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w===k.id&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[k.planner_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mb-1",children:"Planner:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded",children:[k.selected_agent_name&&q.jsxDEV("span",{className:"text-[var(--color-accent)]",children:k.selected_agent_name},void 0,!1,void 0,this),k.selected_agent_name&&" --- ",k.planner_reasoning]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.generated_message&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mb-1",children:"Generated Message:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded",children:['"',k.generated_message,'"']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k.judge_reasoning&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mb-1",children:"Judge:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded",children:k.judge_reasoning},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.error&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-red-400 mb-1",children:"Error:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-red-300 bg-[var(--color-bg)] p-2 rounded",children:k.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),k.agent_response&&q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mb-1",children:"Agent Response (Thread):"},void 0,!1,void 0,this),q.jsxDEV("pre",{className:"text-xs text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded overflow-auto max-h-64",children:k.agent_response},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},k.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/60 z-50 flex items-center justify-center",onClick:()=>Y(!1),children:q.jsxDEV("div",{className:"bg-[var(--color-surface)] card w-full max-w-lg mx-4 p-6",onClick:(k)=>k.stopPropagation(),children:[q.jsxDEV("h2",{className:"text-lg font-bold mb-4",children:H?"Edit Test":"New Test"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-muted)] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{value:M,onChange:(k)=>N(k.target.value),placeholder:"e.g. Social Media Posting",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:"Behavior"},void 0,!1,void 0,this),q.jsxDEV("textarea",{value:b,onChange:(k)=>L(k.target.value),placeholder:"Describe what should happen, e.g. 'When asked to post on social media, the agent creates a proper post with relevant hashtags and confirms it was published'",rows:3,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)] resize-none"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"AI will generate the test message and evaluate results based on this"},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(D,{value:g,onChange:B,placeholder:"Auto (AI picks the best agent)",options:n.map((k)=>({value:k.id,label:`${k.name} (${k.status})`}))},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"Leave empty to let AI choose the right agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-end gap-2 mt-6",children:[q.jsxDEV("button",{onClick:()=>Y(!1),className:"px-4 py-2 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:e,disabled:!M||!b,className:"px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-white rounded text-sm font-medium transition",children:H?"Save":"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)]},void 0,!0,void 0,this)}
2
+ export{Yk as M};
3
+
4
+ //# debugId=2D14C6A7BC29E53364756E2164756E21
@@ -0,0 +1,13 @@
1
+ import{O as Oz,P as Wz}from"./App.vkg121c6.js";import{U as j}from"./App.p7jjw1zf.js";import{$ as Qz,X as n,aa as zz,ja as Jz,ma as Kz}from"./App.94x6mh7f.js";var W=n(Qz(),1);var z=n(zz(),1);function Rz(){let{authFetch:K}=Jz(),{projects:Z,currentProjectId:Y}=Kz(),[B,N]=W.useState([]),[y,M]=W.useState(!0),[X,U]=W.useState("installed"),[G,Q]=W.useState(!1),[C,H]=W.useState(!1),[v,T]=W.useState(null),{confirm:f,ConfirmDialog:w}=Oz(),{alert:P,AlertDialog:d}=Wz(),_=Z.length>0,[m,p]=W.useState(""),[h,Xz]=W.useState([]),[c,r]=W.useState(!1),[Yz,o]=W.useState(null),[a,i]=W.useState(""),[R,t]=W.useState([]),[I,u]=W.useState(!1),[V,b]=W.useState(null),[q,l]=W.useState(null),[e,S]=W.useState(null),[x,Zz]=W.useState(Y&&Y!=="unassigned"?Y:null),D=B.filter((J)=>{if(!Y)return!0;if(Y==="unassigned")return J.project_id===null;return J.project_id===null||J.project_id===Y}),F=async()=>{try{let O=await(await K("/api/skills")).json();N(O.skills||[])}catch(J){console.error("Failed to fetch skills:",J)}M(!1)},E=async(J)=>{r(!0);try{let O=J!==void 0?J:m,$=O?`/api/skills/marketplace/search?q=${encodeURIComponent(O)}`:"/api/skills/marketplace/featured",A=await(await K($)).json();Xz(A.skills||[])}catch(O){console.error("Failed to search marketplace:",O)}r(!1)};W.useEffect(()=>{F()},[K]),W.useEffect(()=>{if(X==="marketplace"&&h.length===0)E("")},[X]);let _z=async(J)=>{try{await K(`/api/skills/${J}/toggle`,{method:"POST"}),F()}catch(O){console.error("Failed to toggle skill:",O)}},$z=async(J)=>{if(!await f("Delete this skill?",{confirmText:"Delete",title:"Delete Skill"}))return;try{if(await K(`/api/skills/${J}`,{method:"DELETE"}),v?.id===J)T(null);F()}catch($){console.error("Failed to delete skill:",$)}},Bz=async(J)=>{o(J.id);try{let O=await K(`/api/skills/marketplace/${J.id}/install`,{method:"POST"}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F(),U("installed");else await P($.error||"Failed to install skill",{title:"Installation Failed"})}catch(O){console.error("Failed to install skill:",O),await P("Failed to install skill",{title:"Error"})}o(null)},g=(J)=>B.some((O)=>O.name===J),s=async(J)=>{let O=J||a;if(!O.trim())return;let $="",L="";if(O.includes("github.com")){let A=O.match(/github\.com\/([^/]+)\/([^/]+)/);if(A)$=A[1],L=A[2].replace(/\.git$/,"")}else if(O.includes("/")){let A=O.split("/");$=A[0],L=A[1]}if(!$||!L){b("Invalid repo format. Use 'owner/repo' or GitHub URL");return}u(!0),b(null),t([]),l(null);try{let A=await K(`/api/skills/github/${$}/${L}`),k=await A.json();if(!A.ok){b(k.error||"Failed to fetch repository"),u(!1);return}t(k.skills||[]),l(k.repo||null)}catch(A){b("Failed to fetch repository")}u(!1)},Nz=async(J)=>{if(!q)return;S(J.name);try{let O=await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:J.name,downloadUrl:J.downloadUrl,projectId:x})}),$=await O.json();if(O.ok)await P(`Installed "${J.name}" successfully!`,{title:"Skill Installed"}),F();else await P($.error||"Failed to install skill",{title:"Installation Failed",variant:"error"})}catch(O){await P("Failed to install skill",{title:"Error",variant:"error"})}S(null)},Uz=async()=>{if(!q||R.length===0)return;let J=R.filter((L)=>!g(L.name));if(J.length===0){await P("All skills are already installed",{title:"Info"});return}if(!await f(`Install ${J.length} skill(s) from ${q.owner}/${q.repo}?`,{confirmText:"Install All",title:"Install Skills"}))return;let $=0;for(let L of J){S(L.name);try{if((await K("/api/skills/github/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:q.owner,repo:q.repo,skillName:L.name,downloadUrl:L.downloadUrl,projectId:x})})).ok)$++}catch(A){}}S(null),F(),await P(`Installed ${$} of ${J.length} skills`,{title:"Installation Complete"})};return z.jsxDEV(z.Fragment,{children:[w,d,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Skills"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"Manage agent skills - instructions that teach agents how to perform tasks."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("button",{onClick:()=>H(!0),className:"bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-white px-4 py-2 rounded font-medium transition border border-[var(--color-border-light)]",children:"Import"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>Q(!0),className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition",children:"+ Create Skill"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[var(--color-surface)] card p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>U("installed"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="installed"?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:["Installed (",D.length,")"]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:()=>U("github"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="github"?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:"Browse GitHub"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:`px-4 py-2 rounded text-sm font-medium transition ${X==="marketplace"?"bg-[var(--color-surface-raised)] text-white":"text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)]"}`,children:"Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="installed"&&z.jsxDEV(z.Fragment,{children:y?z.jsxDEV("div",{className:"text-[var(--color-text-muted)]",children:"Loading skills..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[var(--color-text-muted)]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills installed"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Create a skill or browse the marketplace"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>U("marketplace"),className:"mt-4 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-black px-4 py-2 rounded font-medium transition",children:"Browse Marketplace"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):D.length===0?z.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 text-center",children:z.jsxDEV("p",{className:"text-[var(--color-text-muted)]",children:"No skills match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:D.map((J)=>{let O=_&&J.project_id?Z.find(($)=>$.id===J.project_id):null;return z.jsxDEV(Hz,{skill:J,project:O,onToggle:()=>_z(J.id),onDelete:()=>$z(J.id),onView:()=>T(J)},J.id,!1,void 0,this)})},void 0,!1,void 0,this)},void 0,!1,void 0,this),X==="github"&&z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:(J)=>{J.preventDefault(),s()},className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:a,onChange:(J)=>i(J.target.value),placeholder:"Enter GitHub repo (e.g., WordPress/agent-skills)",className:"flex-1 bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg px-4 py-3 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:I,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:I?"...":"Browse"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&R.length>0&&z.jsxDEV("div",{className:"flex items-center gap-3 p-3 bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg",children:[z.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:"Install to:"},void 0,!1,void 0,this),z.jsxDEV(j,{value:x||"",onChange:(J)=>Zz(J||null),options:[{value:"",label:"Global (all projects)"},...Z.map((J)=>({value:J.id,label:J.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:V},void 0,!1,void 0,this),q&&R.length>0&&z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-accent)] hover:underline font-medium",children:[q.owner,"/",q.repo]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:[R.length," skill",R.length!==1?"s":""," found"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),R.some((J)=>!g(J.name))&&z.jsxDEV("button",{onClick:Uz,disabled:!!e,className:"text-sm bg-[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:"Install All"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I&&z.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Fetching skills from repository..."},void 0,!1,void 0,this),!I&&!q&&!V&&z.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-8 text-center",children:[z.jsxDEV("div",{className:"text-4xl mb-4",children:"\uD83D\uDCE6"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"Browse Skills from GitHub"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[var(--color-text-muted)] mb-6 max-w-md mx-auto",children:"Enter a GitHub repository to browse and install skills. Skills are markdown files with instructions that teach agents how to perform specific tasks."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2 justify-center",children:[{label:"WordPress Skills",repo:"WordPress/agent-skills"}].map(({label:J,repo:O})=>z.jsxDEV("button",{onClick:()=>{i(O),s(O)},className:"text-sm bg-[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:J},O,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!I&&q&&R.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"No skills found in this repository. Skills should be in subdirectories with a SKILL.md file."},void 0,!1,void 0,this),R.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:R.map((J)=>{let O=g(J.name),$=e===J.name;return z.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-4 transition ${O?"border-green-500/30":"border-[var(--color-border)] hover:border-[var(--color-border-light)]"}`,children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:J.name},void 0,!1,void 0,this),O&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"✓ Installed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mt-1 line-clamp-2",children:J.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[var(--color-text-faint)]",children:[z.jsxDEV("span",{children:[(J.size/1024).toFixed(1),"KB"]},void 0,!0,void 0,this),z.jsxDEV("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-400",children:"GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:O?z.jsxDEV("span",{className:"text-xs text-[var(--color-text-faint)] px-3 py-1.5",children:"Added"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>Nz(J),disabled:$,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-3 py-1.5 rounded transition disabled:opacity-50",children:$?"Installing...":"Install"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},J.name,!1,void 0,this)})},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[var(--color-surface)] card text-sm text-[var(--color-text-muted)]",children:z.jsxDEV("p",{children:["Skills are sourced from GitHub repositories. Each skill should be in its own directory with a"," ",z.jsxDEV("code",{className:"text-[var(--color-text-secondary)] bg-[var(--color-bg)] px-1 rounded",children:"SKILL.md"},void 0,!1,void 0,this)," file containing instructions."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X==="marketplace"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"mb-6",children:z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:m,onChange:(J)=>p(J.target.value),onKeyDown:(J)=>J.key==="Enter"&&E(),placeholder:"Search skills...",className:"flex-1 bg-[var(--color-surface)] border border-[var(--color-border)] rounded px-4 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>E(),disabled:c,className:"bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-white px-4 py-2 rounded font-medium transition border border-[var(--color-border-light)]",children:c?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c?z.jsxDEV("div",{className:"text-[var(--color-text-muted)]",children:"Loading..."},void 0,!1,void 0,this):h.length===0?z.jsxDEV("div",{className:"text-center py-20 text-[var(--color-text-muted)]",children:[z.jsxDEV("p",{className:"text-lg",children:"No skills found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm mt-1",children:"Try a different search term"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:h.map((J)=>z.jsxDEV(qz,{skill:J,installed:g(J.name),installing:Yz===J.id,onInstall:()=>Bz(J)},J.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G&&z.jsxDEV(Az,{authFetch:K,onClose:()=>Q(!1),onCreated:()=>{Q(!1),F()},projects:_?Z:void 0,defaultProjectId:Y&&Y!=="unassigned"?Y:null},void 0,!1,void 0,this),C&&z.jsxDEV(yz,{authFetch:K,onClose:()=>H(!1),onImported:()=>{H(!1),F()}},void 0,!1,void 0,this),v&&z.jsxDEV(Mz,{skill:v,authFetch:K,onClose:()=>T(null),onUpdated:()=>{T(null),F()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Hz({skill:K,project:Z,onToggle:Y,onDelete:B,onView:N}){let y={local:"Local",skillsmp:"SkillsMP",github:"GitHub",import:"Imported"}[K.source],M=()=>{if(Z)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${Z.color}20`,color:Z.color},children:Z.name},void 0,!1,void 0,this);if(K.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)] bg-[var(--color-surface-raised)] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[var(--color-surface)] rounded-lg p-5 border transition cursor-pointer ${K.enabled?"border-[var(--color-border)]":"border-[var(--color-border)] opacity-60"} hover:border-[var(--color-border-light)]`,onClick:N,children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-2 mt-0.5",children:[z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${K.source==="skillsmp"?"bg-purple-500/20 text-purple-400":K.source==="github"?"bg-blue-500/20 text-blue-400":"bg-[var(--color-surface-raised)] text-[var(--color-text-secondary)]"}`,children:y},void 0,!1,void 0,this),K.metadata?.version&&z.jsxDEV("span",{children:["v",K.metadata.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),Y()},className:`w-10 h-5 rounded-full transition-colors relative ${K.enabled?"bg-[var(--color-accent)]":"bg-[var(--color-surface-raised)]"}`,children:z.jsxDEV("span",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${K.enabled?"left-5":"left-0.5"}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:[K.allowed_tools.slice(0,2).map((X)=>z.jsxDEV("span",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-0.5 rounded text-[var(--color-text-muted)]",children:X},X,!1,void 0,this)),K.allowed_tools.length>2&&z.jsxDEV("span",{className:"text-xs text-[var(--color-text-muted)]",children:["+",K.allowed_tools.length-2]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:(X)=>{X.stopPropagation(),B()},className:"text-red-400 hover:text-red-300 text-sm",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz({skill:K,installed:Z,installing:Y,onInstall:B}){return z.jsxDEV("div",{className:"bg-[var(--color-surface)] rounded-lg p-5 border border-[var(--color-border)] hover:border-[var(--color-border-light)] transition",children:[z.jsxDEV("div",{className:"flex items-start justify-between mb-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-semibold text-lg truncate",children:K.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:["by ",K.author," · v",K.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-1 text-yellow-500 text-sm",children:["★ ",K.rating.toFixed(1)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] line-clamp-2 mb-4",children:K.description},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 flex-wrap",children:K.tags.slice(0,3).map((N)=>z.jsxDEV("span",{className:"text-xs bg-[var(--color-surface-raised)] px-2 py-0.5 rounded text-[var(--color-text-muted)]",children:N},N,!1,void 0,this))},void 0,!1,void 0,this),Z?z.jsxDEV("span",{className:"text-green-400 text-sm",children:"✓ Installed"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:B,disabled:Y,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-3 py-1 rounded text-sm font-medium transition",children:Y?"Installing...":"Install"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"mt-3 text-xs text-[var(--color-text-faint)]",children:[K.downloads.toLocaleString()," downloads"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Az({authFetch:K,onClose:Z,onCreated:Y,projects:B,defaultProjectId:N}){let[y,M]=W.useState(""),[X,U]=W.useState(""),[G,Q]=W.useState(""),[C,H]=W.useState(N||null),[v,T]=W.useState(!1),[f,w]=W.useState(null),P=B&&B.length>0,d=async()=>{if(!y||!X||!G){w("All fields are required");return}T(!0),w(null);try{let _={name:y,description:X,content:G,source:"local"};if(C)_.project_id=C;let m=await K("/api/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),p=await m.json();if(!m.ok){w(p.error||"Failed to create skill"),T(!1);return}Y()}catch(_){w("Failed to create skill"),T(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Z,children:z.jsxDEV("div",{className:"bg-[var(--color-surface)] card w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:(_)=>_.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[var(--color-border)]",children:z.jsxDEV("h2",{className:"text-xl font-semibold",children:"Create Skill"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-6 space-y-4",children:[f&&z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded p-3 text-red-400 text-sm",children:f},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(_)=>M(_.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"my-skill-name",className:"w-full bg-[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),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"Lowercase letters, numbers, and hyphens only"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Description"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(_)=>U(_.target.value),placeholder:"What this skill does and when to use it...",className:"w-full bg-[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),P&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(j,{value:C||"",onChange:(_)=>H(_||null),options:[{value:"",label:"Global (all projects)"},...B.map((_)=>({value:_.id,label:_.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"Global skills are available to all agents. Project-scoped skills are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[var(--color-text-secondary)] mb-1",children:"Instructions (Markdown)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:G,onChange:(_)=>Q(_.target.value),placeholder:`# Skill Instructions
2
+
3
+ Write detailed instructions here...`,rows:12,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)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6 border-t border-[var(--color-border)] flex justify-end gap-3",children:[z.jsxDEV("button",{onClick:Z,className:"px-4 py-2 text-[var(--color-text-secondary)] hover:text-white transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:d,disabled:v,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:v?"Creating...":"Create Skill"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function yz({authFetch:K,onClose:Z,onImported:Y}){let[B,N]=W.useState(""),[y,M]=W.useState(!1),[X,U]=W.useState(null);return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Z,children:z.jsxDEV("div",{className:"bg-[var(--color-surface)] card w-full max-w-2xl max-h-[90vh] overflow-auto",onClick:(Q)=>Q.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[var(--color-border)]",children:[z.jsxDEV("h2",{className:"text-xl font-semibold",children:"Import Skill"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:"Paste the contents of a SKILL.md file"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6 space-y-4",children:[X&&z.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded p-3 text-red-400 text-sm",children:X},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:B,onChange:(Q)=>N(Q.target.value),placeholder:`---
4
+ name: skill-name
5
+ description: What this skill does...
6
+ ---
7
+
8
+ # Instructions
9
+
10
+ Your skill instructions here...`,rows:16,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)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6 border-t border-[var(--color-border)] flex justify-end gap-3",children:[z.jsxDEV("button",{onClick:Z,className:"px-4 py-2 text-[var(--color-text-secondary)] hover:text-white transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:async()=>{if(!B.trim()){U("Paste SKILL.md content");return}M(!0),U(null);try{let Q=await K("/api/skills/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:B})}),C=await Q.json();if(!Q.ok){U(C.error||"Failed to import skill"),M(!1);return}Y()}catch(Q){U("Failed to import skill"),M(!1)}},disabled:y,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:y?"Importing...":"Import Skill"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Mz({skill:K,authFetch:Z,onClose:Y,onUpdated:B}){let[N,y]=W.useState(!1),[M,X]=W.useState(K.content),[U,G]=W.useState(!1),Q=async()=>{G(!0);try{await Z(`/api/skills/${K.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:M})}),B()}catch(H){console.error("Failed to save:",H)}G(!1)},C=async()=>{try{let v=await(await Z(`/api/skills/${K.id}/export`)).text(),T=new Blob([v],{type:"text/markdown"}),f=URL.createObjectURL(T),w=document.createElement("a");w.href=f,w.download=`${K.name}-SKILL.md`,w.click(),URL.revokeObjectURL(f)}catch(H){console.error("Failed to export:",H)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:Y,children:z.jsxDEV("div",{className:"bg-[var(--color-surface)] card w-full max-w-3xl max-h-[90vh] overflow-auto",onClick:(H)=>H.stopPropagation(),children:[z.jsxDEV("div",{className:"p-6 border-b border-[var(--color-border)] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h2",{className:"text-xl font-semibold",children:K.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[var(--color-text-muted)] mt-0.5",children:K.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("button",{onClick:C,className:"text-sm text-[var(--color-text-secondary)] hover:text-white transition px-3 py-1 rounded border border-[var(--color-border-light)]",children:"Export"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>y(!N),className:"text-sm text-[var(--color-text-secondary)] hover:text-white transition px-3 py-1 rounded border border-[var(--color-border-light)]",children:N?"View":"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-6",children:N?z.jsxDEV("textarea",{value:M,onChange:(H)=>X(H.target.value),rows:20,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):z.jsxDEV("pre",{className:"bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded p-4 font-mono text-sm overflow-auto max-h-[60vh] whitespace-pre-wrap",children:K.content},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-6 border-t border-[var(--color-border)] flex justify-between",children:[z.jsxDEV("div",{className:"text-xs text-[var(--color-text-faint)]",children:K.source!=="local"&&K.source_url&&z.jsxDEV("a",{href:K.source_url,target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-accent)] hover:underline",children:"View source →"},void 0,!1,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-3",children:[z.jsxDEV("button",{onClick:Y,className:"px-4 py-2 text-[var(--color-text-secondary)] hover:text-white transition",children:"Close"},void 0,!1,void 0,this),N&&z.jsxDEV("button",{onClick:Q,disabled:U,className:"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:U?"Saving...":"Save Changes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
11
+ export{Rz as L};
12
+
13
+ //# debugId=F89C130753CEA5A864756E2164756E21
@@ -1,4 +1,4 @@
1
- import{$ as Rq,X as c,aa as Gq,ja as Jq}from"./App.tpmp9020.js";var Q=c(Rq(),1);var q=c(Gq(),1);function C(H){return H.authSchemes.some((J)=>J.toUpperCase()==="API_KEY")}function Qq(H){return H.authSchemes.some((J)=>J.toUpperCase()==="OAUTH2")}function Lq(H){return C(H)&&Qq(H)}function wq({providerId:H="composio",projectId:J,onConnectionComplete:U,onBrowseTriggers:F,hideMcpConfig:y}){let{authFetch:Z}=Jq(),[A,I]=Q.useState([]),[k,P]=Q.useState([]),[S,h]=Q.useState(!0),[R,Wq]=Q.useState(""),[g,O]=Q.useState(null),[b,D]=Q.useState(null),[s,_]=Q.useState(null),[L,M]=Q.useState(null),[X,w]=Q.useState(null),[f,u]=Q.useState(""),[V,x]=Q.useState({}),[T,E]=Q.useState(null),[v,n]=Q.useState(""),[o,l]=Q.useState(!1),[t,j]=Q.useState(null),[r,i]=Q.useState(null),N=Q.useCallback(async()=>{h(!0),_(null);let z=J&&J!=="unassigned"?`?project_id=${J}`:"";try{let[G,W]=await Promise.all([Z(`/api/integrations/${H}/apps${z}`),Z(`/api/integrations/${H}/connected${z}`)]),Y=await G.json(),$=await W.json();I(Y.apps||[]),P($.accounts||[])}catch(G){console.error("Failed to fetch integrations:",G),_("Failed to load integrations")}h(!1)},[Z,H,J]);Q.useEffect(()=>{N()},[N]),Q.useEffect(()=>{if(new URLSearchParams(window.location.search).get("connected"))window.history.replaceState({},"",window.location.pathname),N(),U?.()},[N,U]),Q.useEffect(()=>{if(!b?.connectionId)return;let z=J&&J!=="unassigned"?`?project_id=${J}`:"",G=setInterval(async()=>{try{let Y=await(await Z(`/api/integrations/${H}/connection/${b.connectionId}${z}`)).json();if(Y.connection?.status==="active")D(null),O(null),N(),U?.();else if(Y.connection?.status==="failed")D(null),O(null),_(`Connection to ${b.appSlug} failed`)}catch(W){}},2000);return()=>clearInterval(G)},[b,Z,H,J,N,U]);let m=async(z,G,W,Y)=>{if(Lq(z)&&!G&&!Y&&!W){M({app:z});return}if(C(z)&&!G&&!Y&&!W){w({app:z}),u(""),x({});return}O(z.slug),_(null);try{let $={appSlug:z.slug};if(Y&&Object.keys(Y).length>0)$.credentials={authScheme:"API_KEY",fields:Y};else if(G)$.credentials={authScheme:"API_KEY",apiKey:G};let kq=J&&J!=="unassigned"?`?project_id=${J}`:"",qq=await Z(`/api/integrations/${H}/connect${kq}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),B=await qq.json();if(!qq.ok){_(B.error||"Failed to initiate connection"),O(null),w(null);return}if(B.status==="active"||!B.redirectUrl){O(null),w(null),N(),U?.();return}if(B.redirectUrl){D({appSlug:z.slug,connectionId:B.connectionId});let zq=window.open(B.redirectUrl,`connect-${z.slug}`,"width=600,height=700,left=200,top=100");if(!zq||zq.closed)window.location.href=B.redirectUrl}}catch($){_(`Failed to connect: ${$}`),O(null),w(null)}},Xq=(z)=>{if(z.preventDefault(),!X)return;if(X.app.credentialFields&&X.app.credentialFields.length>0){if(!X.app.credentialFields.filter(($)=>$.required!==!1).every(($)=>V[$.name]?.trim()))return;m(X.app,void 0,!1,V)}else{if(!f.trim())return;m(X.app,f.trim())}},Yq=async(z)=>{let G=J&&J!=="unassigned"?`?project_id=${J}`:"";try{let W=await Z(`/api/integrations/${H}/connection/${z.id}${G}`,{method:"DELETE"});if(W.ok)N();else{let Y=await W.json();_(Y.error||"Failed to disconnect")}}catch(W){_(`Failed to disconnect: ${W}`)}},Zq=(z)=>{E({app:z}),n(`${z.name} MCP`),j(null)},_q=async()=>{if(!T||!v.trim())return;l(!0),_(null);try{let z=J&&J!=="unassigned"?`?project_id=${J}`:"",G=await Z(`/api/integrations/${H}/configs${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.replace(/[^a-zA-Z0-9\s-]/g,"").substring(0,30),toolkitSlug:T.app.slug})}),W=await G.json();if(!G.ok){_(W.error||"Failed to create MCP config"),l(!1);return}let Y=!1;if(W.config?.id)try{Y=(await Z(`/api/integrations/${H}/configs/${W.config.id}/add${z}`,{method:"POST"})).ok}catch{}j(v),U?.()}catch(z){_(`Failed to create MCP config: ${z}`)}finally{l(!1)}},$q=(z)=>{i({message:`Disconnect ${z.appName}?`,onConfirm:()=>{Yq(z),i(null)}})},a=(z)=>{return k.some((G)=>G.status==="active"&&(G.appId===z.slug||z.providerSlug&&G.appId===z.providerSlug))},p=(z)=>{return k.find((G)=>G.appId===z.slug&&G.status==="active")||z.providerSlug&&k.find((G)=>G.appId===z.providerSlug&&G.status==="active")||k.find((G)=>G.appId===z.slug)||z.providerSlug&&k.find((G)=>G.appId===z.providerSlug)||void 0},e=A.filter((z)=>{if(!R)return!0;let G=R.toLowerCase();return z.name.toLowerCase().includes(G)||z.slug.toLowerCase().includes(G)||z.description?.toLowerCase().includes(G)||z.categories.some((W)=>W.toLowerCase().includes(G))}),d=e.filter((z)=>a(z)),K=e.filter((z)=>!a(z));if(S)return q.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading apps..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"space-y-6",children:[L&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[L.app.logo&&q.jsxDEV("img",{src:L.app.logo,alt:L.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",L.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Choose how to authenticate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("button",{onClick:()=>{M(null),w({app:L.app}),u(""),x({})},className:"w-full text-left p-3 bg-[var(--color-bg)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:["Enter your ",L.app.name," API key directly"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{M(null),m(L.app,void 0,!0)},className:"w-full text-left p-3 bg-[var(--color-bg)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"OAuth"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:["Sign in with your ",L.app.name," account"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>M(null),className:"w-full text-sm text-[var(--color-text-muted)] hover:text-white mt-4 py-2 transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[X.app.logo&&q.jsxDEV("img",{src:X.app.logo,alt:X.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",X.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:X.app.credentialFields?.length?"Enter your credentials to connect":"Enter your API key to connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:Xq,children:[X.app.credentialFields&&X.app.credentialFields.length>0?q.jsxDEV("div",{className:"space-y-3 mb-4",children:X.app.credentialFields.map((z,G)=>q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:[z.name.replace(/([A-Z])/g," $1").replace(/[-_]/g," ").replace(/\b\w/g,(W)=>W.toUpperCase()).trim(),z.required!==!1&&q.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.description&&q.jsxDEV("p",{className:"text-[10px] text-[var(--color-text-faint)] mb-1",children:z.description},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:V[z.name]||"",onChange:(W)=>x((Y)=>({...Y,[z.name]:W.target.value})),placeholder:`Enter ${z.name}...`,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:G===0},void 0,!1,void 0,this)]},z.name,!0,void 0,this))},void 0,!1,void 0,this):q.jsxDEV("input",{type:"password",value:f,onChange:(z)=>u(z.target.value),placeholder:"Enter API Key...",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>w(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),q.jsxDEV("button",{type:"submit",disabled:g===X.app.slug||(X.app.credentialFields?.length?!X.app.credentialFields.filter((z)=>z.required!==!1).every((z)=>V[z.name]?.trim()):!f.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:g===X.app.slug?"Connecting...":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),T&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:t?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"text-center mb-4",children:[q.jsxDEV("div",{className:"w-12 h-12 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3",children:q.jsxDEV("span",{className:"text-green-400 text-2xl",children:"✓"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("h3",{className:"font-medium text-lg",children:"MCP Config Created!"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mt-2",children:['"',t,'" has been created and added to your servers.']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{E(null),j(null)},className:"w-full text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white px-4 py-2 rounded transition",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[T.app.logo&&q.jsxDEV("img",{src:T.app.logo,alt:T.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:"Create MCP Config"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Create an MCP config for ",T.app.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:(z)=>{z.preventDefault(),_q()},children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:"Config Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:v,onChange:(z)=>n(z.target.value),placeholder:"Enter config name...",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0,maxLength:30},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>E(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),q.jsxDEV("button",{type:"submit",disabled:!v.trim()||o,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:o?"Creating...":"Create Config"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),r&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg p-6 w-full max-w-sm mx-4",children:[q.jsxDEV("p",{className:"text-center mb-4",children:r.message},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>i(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),q.jsxDEV("button",{onClick:r.onConfirm,className:"flex-1 text-sm bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition",children:"Confirm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),s&&q.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[q.jsxDEV("span",{children:s},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>_(null),className:"text-red-400 hover:text-red-300",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&q.jsxDEV("div",{className:"text-yellow-400 text-sm p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg flex items-center gap-2",children:[q.jsxDEV("span",{className:"animate-spin",children:"⟳"},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Waiting for ",b.appSlug," authorization..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:q.jsxDEV("input",{type:"text",value:R,onChange:(z)=>Wq(z.target.value),placeholder:"Search apps...",className:"w-full bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),d.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:["Connected (",d.length,")"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:d.map((z)=>q.jsxDEV(Hq,{app:z,connection:p(z),onConnect:()=>m(z),onDisconnect:()=>{let G=p(z);if(G)$q(G)},onCreateMcpConfig:y?void 0:()=>Zq(z),onBrowseTriggers:F?()=>F(z.slug):void 0,onUpdateKey:C(z)?()=>{w({app:z}),u(""),x({})}:void 0,connecting:g===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:["Available Apps (",K.length,")"]},void 0,!0,void 0,this),K.length===0?q.jsxDEV("p",{className:"text-[var(--color-text-muted)] text-sm",children:R?"No apps match your search":"No apps available"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:K.slice(0,50).map((z)=>q.jsxDEV(Hq,{app:z,onConnect:()=>m(z),connecting:g===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this),K.length>50&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-3 text-center",children:["Showing first 50 of ",K.length," apps. Use search to find more."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hq({app:H,connection:J,onConnect:U,onDisconnect:F,onCreateMcpConfig:y,onBrowseTriggers:Z,onUpdateKey:A,connecting:I}){let k=J?.status==="active",P=C(H),S=Qq(H),h=P&&S;return q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-3 transition ${k?"border-green-500/30":"border-[var(--color-border)] hover:border-[var(--color-border-light)]"}`,children:[q.jsxDEV("div",{className:"flex items-start gap-3",children:[q.jsxDEV("div",{className:"w-10 h-10 rounded bg-[var(--color-surface-raised)] flex items-center justify-center flex-shrink-0 overflow-hidden",children:H.logo?q.jsxDEV("img",{src:H.logo,alt:H.name,className:"w-8 h-8 object-contain",onError:(R)=>{R.target.style.display="none"}},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-lg",children:H.name[0]?.toUpperCase()},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("h4",{className:"font-medium text-sm truncate",children:H.name},void 0,!1,void 0,this),k&&q.jsxDEV("span",{className:"text-xs text-green-400",children:"✓"},void 0,!1,void 0,this),!k&&P&&!S&&q.jsxDEV("span",{className:"text-[10px] bg-[var(--color-surface-raised)] text-[var(--color-text-secondary)] px-1.5 py-0.5 rounded",title:"Requires API Key",children:"API Key"},void 0,!1,void 0,this),!k&&h&&q.jsxDEV("span",{className:"text-[10px] bg-[#1a2a1a] text-[#6a6] px-1.5 py-0.5 rounded",title:"Supports API Key or OAuth",children:"API Key / OAuth"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.description&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] line-clamp-2 mt-0.5",children:H.description},void 0,!1,void 0,this),H.categories.length>0&&q.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:H.categories.slice(0,2).map((R)=>q.jsxDEV("span",{className:"text-[10px] bg-[var(--color-surface-raised)] text-[var(--color-text-faint)] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 flex gap-2",children:k?q.jsxDEV(q.Fragment,{children:[y&&q.jsxDEV("button",{onClick:y,className:"flex-1 text-xs bg-[#1a2a1a] hover:bg-[#1a3a1a] border border-green-500/30 hover:border-green-500/50 text-green-400 px-3 py-1.5 rounded transition",children:"Create MCP Config"},void 0,!1,void 0,this),Z&&q.jsxDEV("button",{onClick:Z,className:"flex-1 text-xs bg-[#1a1a2a] hover:bg-[#1a1a3a] border border-blue-500/30 hover:border-blue-500/50 text-blue-400 px-3 py-1.5 rounded transition",children:"Browse Triggers"},void 0,!1,void 0,this),A&&q.jsxDEV("button",{onClick:A,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-accent)] transition px-2",title:"Update API Key",children:"Key"},void 0,!1,void 0,this),F&&q.jsxDEV("button",{onClick:F,className:"text-xs text-[var(--color-text-muted)] hover:text-red-400 transition px-2",title:"Disconnect",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("button",{onClick:U,disabled:I,className:"w-full 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 disabled:opacity-50",children:I?"Connecting...":P&&!S?"Enter API Key":"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
1
+ import{$ as Rq,X as c,aa as Gq,ja as Jq}from"./App.94x6mh7f.js";var Q=c(Rq(),1);var q=c(Gq(),1);function C(H){return H.authSchemes.some((J)=>J.toUpperCase()==="API_KEY")}function Qq(H){return H.authSchemes.some((J)=>J.toUpperCase()==="OAUTH2")}function Lq(H){return C(H)&&Qq(H)}function wq({providerId:H="composio",projectId:J,onConnectionComplete:U,onBrowseTriggers:F,hideMcpConfig:y}){let{authFetch:Z}=Jq(),[A,I]=Q.useState([]),[k,P]=Q.useState([]),[S,h]=Q.useState(!0),[R,Wq]=Q.useState(""),[g,O]=Q.useState(null),[b,D]=Q.useState(null),[s,_]=Q.useState(null),[L,M]=Q.useState(null),[X,w]=Q.useState(null),[f,u]=Q.useState(""),[V,x]=Q.useState({}),[T,E]=Q.useState(null),[v,n]=Q.useState(""),[o,l]=Q.useState(!1),[t,j]=Q.useState(null),[r,i]=Q.useState(null),N=Q.useCallback(async()=>{h(!0),_(null);let z=J&&J!=="unassigned"?`?project_id=${J}`:"";try{let[G,W]=await Promise.all([Z(`/api/integrations/${H}/apps${z}`),Z(`/api/integrations/${H}/connected${z}`)]),Y=await G.json(),$=await W.json();I(Y.apps||[]),P($.accounts||[])}catch(G){console.error("Failed to fetch integrations:",G),_("Failed to load integrations")}h(!1)},[Z,H,J]);Q.useEffect(()=>{N()},[N]),Q.useEffect(()=>{if(new URLSearchParams(window.location.search).get("connected"))window.history.replaceState({},"",window.location.pathname),N(),U?.()},[N,U]),Q.useEffect(()=>{if(!b?.connectionId)return;let z=J&&J!=="unassigned"?`?project_id=${J}`:"",G=setInterval(async()=>{try{let Y=await(await Z(`/api/integrations/${H}/connection/${b.connectionId}${z}`)).json();if(Y.connection?.status==="active")D(null),O(null),N(),U?.();else if(Y.connection?.status==="failed")D(null),O(null),_(`Connection to ${b.appSlug} failed`)}catch(W){}},2000);return()=>clearInterval(G)},[b,Z,H,J,N,U]);let m=async(z,G,W,Y)=>{if(Lq(z)&&!G&&!Y&&!W){M({app:z});return}if(C(z)&&!G&&!Y&&!W){w({app:z}),u(""),x({});return}O(z.slug),_(null);try{let $={appSlug:z.slug};if(Y&&Object.keys(Y).length>0)$.credentials={authScheme:"API_KEY",fields:Y};else if(G)$.credentials={authScheme:"API_KEY",apiKey:G};let kq=J&&J!=="unassigned"?`?project_id=${J}`:"",qq=await Z(`/api/integrations/${H}/connect${kq}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)}),B=await qq.json();if(!qq.ok){_(B.error||"Failed to initiate connection"),O(null),w(null);return}if(B.status==="active"||!B.redirectUrl){O(null),w(null),N(),U?.();return}if(B.redirectUrl){D({appSlug:z.slug,connectionId:B.connectionId});let zq=window.open(B.redirectUrl,`connect-${z.slug}`,"width=600,height=700,left=200,top=100");if(!zq||zq.closed)window.location.href=B.redirectUrl}}catch($){_(`Failed to connect: ${$}`),O(null),w(null)}},Xq=(z)=>{if(z.preventDefault(),!X)return;if(X.app.credentialFields&&X.app.credentialFields.length>0){if(!X.app.credentialFields.filter(($)=>$.required!==!1).every(($)=>V[$.name]?.trim()))return;m(X.app,void 0,!1,V)}else{if(!f.trim())return;m(X.app,f.trim())}},Yq=async(z)=>{let G=J&&J!=="unassigned"?`?project_id=${J}`:"";try{let W=await Z(`/api/integrations/${H}/connection/${z.id}${G}`,{method:"DELETE"});if(W.ok)N();else{let Y=await W.json();_(Y.error||"Failed to disconnect")}}catch(W){_(`Failed to disconnect: ${W}`)}},Zq=(z)=>{E({app:z}),n(`${z.name} MCP`),j(null)},_q=async()=>{if(!T||!v.trim())return;l(!0),_(null);try{let z=J&&J!=="unassigned"?`?project_id=${J}`:"",G=await Z(`/api/integrations/${H}/configs${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:v.replace(/[^a-zA-Z0-9\s-]/g,"").substring(0,30),toolkitSlug:T.app.slug})}),W=await G.json();if(!G.ok){_(W.error||"Failed to create MCP config"),l(!1);return}let Y=!1;if(W.config?.id)try{Y=(await Z(`/api/integrations/${H}/configs/${W.config.id}/add${z}`,{method:"POST"})).ok}catch{}j(v),U?.()}catch(z){_(`Failed to create MCP config: ${z}`)}finally{l(!1)}},$q=(z)=>{i({message:`Disconnect ${z.appName}?`,onConfirm:()=>{Yq(z),i(null)}})},a=(z)=>{return k.some((G)=>G.status==="active"&&(G.appId===z.slug||z.providerSlug&&G.appId===z.providerSlug))},p=(z)=>{return k.find((G)=>G.appId===z.slug&&G.status==="active")||z.providerSlug&&k.find((G)=>G.appId===z.providerSlug&&G.status==="active")||k.find((G)=>G.appId===z.slug)||z.providerSlug&&k.find((G)=>G.appId===z.providerSlug)||void 0},e=A.filter((z)=>{if(!R)return!0;let G=R.toLowerCase();return z.name.toLowerCase().includes(G)||z.slug.toLowerCase().includes(G)||z.description?.toLowerCase().includes(G)||z.categories.some((W)=>W.toLowerCase().includes(G))}),d=e.filter((z)=>a(z)),K=e.filter((z)=>!a(z));if(S)return q.jsxDEV("div",{className:"text-center py-8 text-[var(--color-text-muted)]",children:"Loading apps..."},void 0,!1,void 0,this);return q.jsxDEV("div",{className:"space-y-6",children:[L&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[L.app.logo&&q.jsxDEV("img",{src:L.app.logo,alt:L.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",L.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:"Choose how to authenticate"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("button",{onClick:()=>{M(null),w({app:L.app}),u(""),x({})},className:"w-full text-left p-3 bg-[var(--color-bg)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"API Key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:["Enter your ",L.app.name," API key directly"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{M(null),m(L.app,void 0,!0)},className:"w-full text-left p-3 bg-[var(--color-bg)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] hover:border-[var(--color-accent)] rounded-lg transition",children:[q.jsxDEV("div",{className:"font-medium text-sm",children:"OAuth"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:["Sign in with your ",L.app.name," account"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>M(null),className:"w-full text-sm text-[var(--color-text-muted)] hover:text-white mt-4 py-2 transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),X&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[X.app.logo&&q.jsxDEV("img",{src:X.app.logo,alt:X.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:["Connect ",X.app.name]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:X.app.credentialFields?.length?"Enter your credentials to connect":"Enter your API key to connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:Xq,children:[X.app.credentialFields&&X.app.credentialFields.length>0?q.jsxDEV("div",{className:"space-y-3 mb-4",children:X.app.credentialFields.map((z,G)=>q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:[z.name.replace(/([A-Z])/g," $1").replace(/[-_]/g," ").replace(/\b\w/g,(W)=>W.toUpperCase()).trim(),z.required!==!1&&q.jsxDEV("span",{className:"text-red-400 ml-0.5",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.description&&q.jsxDEV("p",{className:"text-[10px] text-[var(--color-text-faint)] mb-1",children:z.description},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:V[z.name]||"",onChange:(W)=>x((Y)=>({...Y,[z.name]:W.target.value})),placeholder:`Enter ${z.name}...`,className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:G===0},void 0,!1,void 0,this)]},z.name,!0,void 0,this))},void 0,!1,void 0,this):q.jsxDEV("input",{type:"password",value:f,onChange:(z)=>u(z.target.value),placeholder:"Enter API Key...",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>w(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),q.jsxDEV("button",{type:"submit",disabled:g===X.app.slug||(X.app.credentialFields?.length?!X.app.credentialFields.filter((z)=>z.required!==!1).every((z)=>V[z.name]?.trim()):!f.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:g===X.app.slug?"Connecting...":"Connect"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),T&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.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:t?q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"text-center mb-4",children:[q.jsxDEV("div",{className:"w-12 h-12 bg-green-500/20 rounded-full flex items-center justify-center mx-auto mb-3",children:q.jsxDEV("span",{className:"text-green-400 text-2xl",children:"✓"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("h3",{className:"font-medium text-lg",children:"MCP Config Created!"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[var(--color-text-secondary)] mt-2",children:['"',t,'" has been created and added to your servers.']},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{E(null),j(null)},className:"w-full text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white px-4 py-2 rounded transition",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV("div",{className:"flex items-center gap-3 mb-4",children:[T.app.logo&&q.jsxDEV("img",{src:T.app.logo,alt:T.app.name,className:"w-10 h-10 object-contain"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:"Create MCP Config"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)]",children:["Create an MCP config for ",T.app.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("form",{onSubmit:(z)=>{z.preventDefault(),_q()},children:[q.jsxDEV("label",{className:"block text-xs text-[var(--color-text-secondary)] mb-1",children:"Config Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:v,onChange:(z)=>n(z.target.value),placeholder:"Enter config name...",className:"w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 mb-4 focus:outline-none focus:border-[var(--color-accent)]",autoFocus:!0,maxLength:30},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{type:"button",onClick:()=>E(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),q.jsxDEV("button",{type:"submit",disabled:!v.trim()||o,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:o?"Creating...":"Create Config"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),r&&q.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:q.jsxDEV("div",{className:"bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg p-6 w-full max-w-sm mx-4",children:[q.jsxDEV("p",{className:"text-center mb-4",children:r.message},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>i(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),q.jsxDEV("button",{onClick:r.onConfirm,className:"flex-1 text-sm bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded transition",children:"Confirm"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),s&&q.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg flex items-center justify-between",children:[q.jsxDEV("span",{children:s},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>_(null),className:"text-red-400 hover:text-red-300",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&q.jsxDEV("div",{className:"text-yellow-400 text-sm p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg flex items-center gap-2",children:[q.jsxDEV("span",{className:"animate-spin",children:"⟳"},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Waiting for ",b.appSlug," authorization..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:q.jsxDEV("input",{type:"text",value:R,onChange:(z)=>Wq(z.target.value),placeholder:"Search apps...",className:"w-full bg-[var(--color-surface)] border border-[var(--color-border-light)] rounded-lg px-4 py-2 focus:outline-none focus:border-[var(--color-accent)]"},void 0,!1,void 0,this)},void 0,!1,void 0,this),d.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:["Connected (",d.length,")"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:d.map((z)=>q.jsxDEV(Hq,{app:z,connection:p(z),onConnect:()=>m(z),onDisconnect:()=>{let G=p(z);if(G)$q(G)},onCreateMcpConfig:y?void 0:()=>Zq(z),onBrowseTriggers:F?()=>F(z.slug):void 0,onUpdateKey:C(z)?()=>{w({app:z}),u(""),x({})}:void 0,connecting:g===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[var(--color-text-secondary)] mb-3",children:["Available Apps (",K.length,")"]},void 0,!0,void 0,this),K.length===0?q.jsxDEV("p",{className:"text-[var(--color-text-muted)] text-sm",children:R?"No apps match your search":"No apps available"},void 0,!1,void 0,this):q.jsxDEV("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:K.slice(0,50).map((z)=>q.jsxDEV(Hq,{app:z,onConnect:()=>m(z),connecting:g===z.slug},z.id,!1,void 0,this))},void 0,!1,void 0,this),K.length>50&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-3 text-center",children:["Showing first 50 of ",K.length," apps. Use search to find more."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hq({app:H,connection:J,onConnect:U,onDisconnect:F,onCreateMcpConfig:y,onBrowseTriggers:Z,onUpdateKey:A,connecting:I}){let k=J?.status==="active",P=C(H),S=Qq(H),h=P&&S;return q.jsxDEV("div",{className:`bg-[var(--color-surface)] border rounded-lg p-3 transition ${k?"border-green-500/30":"border-[var(--color-border)] hover:border-[var(--color-border-light)]"}`,children:[q.jsxDEV("div",{className:"flex items-start gap-3",children:[q.jsxDEV("div",{className:"w-10 h-10 rounded bg-[var(--color-surface-raised)] flex items-center justify-center flex-shrink-0 overflow-hidden",children:H.logo?q.jsxDEV("img",{src:H.logo,alt:H.name,className:"w-8 h-8 object-contain",onError:(R)=>{R.target.style.display="none"}},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-lg",children:H.name[0]?.toUpperCase()},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("h4",{className:"font-medium text-sm truncate",children:H.name},void 0,!1,void 0,this),k&&q.jsxDEV("span",{className:"text-xs text-green-400",children:"✓"},void 0,!1,void 0,this),!k&&P&&!S&&q.jsxDEV("span",{className:"text-[10px] bg-[var(--color-surface-raised)] text-[var(--color-text-secondary)] px-1.5 py-0.5 rounded",title:"Requires API Key",children:"API Key"},void 0,!1,void 0,this),!k&&h&&q.jsxDEV("span",{className:"text-[10px] bg-[#1a2a1a] text-[#6a6] px-1.5 py-0.5 rounded",title:"Supports API Key or OAuth",children:"API Key / OAuth"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.description&&q.jsxDEV("p",{className:"text-xs text-[var(--color-text-muted)] line-clamp-2 mt-0.5",children:H.description},void 0,!1,void 0,this),H.categories.length>0&&q.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:H.categories.slice(0,2).map((R)=>q.jsxDEV("span",{className:"text-[10px] bg-[var(--color-surface-raised)] text-[var(--color-text-faint)] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 flex gap-2",children:k?q.jsxDEV(q.Fragment,{children:[y&&q.jsxDEV("button",{onClick:y,className:"flex-1 text-xs bg-[#1a2a1a] hover:bg-[#1a3a1a] border border-green-500/30 hover:border-green-500/50 text-green-400 px-3 py-1.5 rounded transition",children:"Create MCP Config"},void 0,!1,void 0,this),Z&&q.jsxDEV("button",{onClick:Z,className:"flex-1 text-xs bg-[#1a1a2a] hover:bg-[#1a1a3a] border border-blue-500/30 hover:border-blue-500/50 text-blue-400 px-3 py-1.5 rounded transition",children:"Browse Triggers"},void 0,!1,void 0,this),A&&q.jsxDEV("button",{onClick:A,className:"text-xs text-[var(--color-text-muted)] hover:text-[var(--color-accent)] transition px-2",title:"Update API Key",children:"Key"},void 0,!1,void 0,this),F&&q.jsxDEV("button",{onClick:F,className:"text-xs text-[var(--color-text-muted)] hover:text-red-400 transition px-2",title:"Disconnect",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("button",{onClick:U,disabled:I,className:"w-full 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 disabled:opacity-50",children:I?"Connecting...":P&&!S?"Enter API Key":"Connect"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}
2
2
  export{wq as j};
3
3
 
4
4
  //# debugId=5A2FB95F167B84D164756E2164756E21
@@ -0,0 +1,4 @@
1
+ import{$ as P,X as L,aa as N}from"./App.94x6mh7f.js";var z=L(P(),1),w=L(N(),1);function U({children:q,onClose:y}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 w-full max-w-xl lg:max-w-2xl max-h-[90vh] overflow-y-auto",children:q},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Q({title:q,message:y,confirmText:F="Confirm",cancelText:B="Cancel",confirmVariant:G="danger",onConfirm:I,onCancel:J}){return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 w-full max-w-sm",children:[q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("div",{className:"flex gap-2",children:[w.jsxDEV("button",{onClick:J,className:"flex-1 text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] btn px-4 py-2 transition",children:B},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:I,className:`flex-1 text-sm text-white px-4 py-2 btn transition ${G==="danger"?"bg-red-500 hover:bg-red-600":"bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)]"}`,children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function R({title:q,message:y,buttonText:F="OK",variant:B="info",onClose:G}){let I={error:"bg-red-500/20 text-red-400",success:"bg-green-500/20 text-green-400",info:"bg-blue-500/20 text-blue-400"},J={error:"✕",success:"✓",info:"ℹ"};return w.jsxDEV("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:w.jsxDEV("div",{className:"bg-[var(--color-surface)] card p-6 w-full max-w-sm text-center",children:[w.jsxDEV("div",{className:`w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3 ${I[B]}`,children:w.jsxDEV("span",{className:"text-xl",children:J[B]},void 0,!1,void 0,this)},void 0,!1,void 0,this),q&&w.jsxDEV("h3",{className:"font-medium mb-2",children:q},void 0,!1,void 0,this),w.jsxDEV("p",{className:"text-sm text-[var(--color-text)] mb-4",children:y},void 0,!1,void 0,this),w.jsxDEV("button",{onClick:G,className:"w-full text-sm bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] border border-[var(--color-border-light)] px-4 py-2 btn transition",children:F},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function W(){let[q,y]=z.useState(null),F=z.useCallback((J,K={})=>{return new Promise((O)=>{y({message:J,options:K,resolve:O})})},[]),B=z.useCallback(()=>{q?.resolve(!0),y(null)},[q]),G=z.useCallback(()=>{q?.resolve(!1),y(null)},[q]),I=q?w.jsxDEV(Q,{title:q.options.title,message:q.message,confirmText:q.options.confirmText,cancelText:q.options.cancelText,confirmVariant:q.options.confirmVariant,onConfirm:B,onCancel:G},void 0,!1,void 0,this):null;return{confirm:F,ConfirmDialog:I}}function X(){let[q,y]=z.useState(null),F=z.useCallback((I,J={})=>{return new Promise((K)=>{y({message:I,options:J,resolve:K})})},[]),B=z.useCallback(()=>{q?.resolve(),y(null)},[q]),G=q?w.jsxDEV(R,{title:q.options.title,message:q.message,buttonText:q.options.buttonText,variant:q.options.variant,onClose:B},void 0,!1,void 0,this):null;return{alert:F,AlertDialog:G}}
2
+ export{U as N,W as O,X as P};
3
+
4
+ //# debugId=47B6BB0942493C6364756E2164756E21
@@ -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 analytics data? This cannot be undone.",{confirmText:"Clear All",title:"Clear Analytics 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 analytics."},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:"Analytics 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 Analytics"},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=B51B57B1DB46C7B064756E2164756E21