@sleep2agi/agent-network-dashboard 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/diagnostics/route-bundle-stats.json +7 -7
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/admin.html +1 -1
- package/.next/server/app/admin.rsc +1 -1
- package/.next/server/app/admin.segments/_full.segment.rsc +1 -1
- package/.next/server/app/admin.segments/_head.segment.rsc +1 -1
- package/.next/server/app/admin.segments/_index.segment.rsc +1 -1
- package/.next/server/app/admin.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/admin.segments/admin/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/admin.segments/admin.segment.rsc +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.rsc +1 -1
- package/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/index.html +2 -2
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +1 -1
- package/.next/server/app/login.segments/_full.segment.rsc +1 -1
- package/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/server/app/login.segments/_index.segment.rsc +1 -1
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/server/app/logs.html +1 -1
- package/.next/server/app/logs.rsc +1 -1
- package/.next/server/app/logs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/logs.segments/logs.segment.rsc +1 -1
- package/.next/server/app/messages.html +1 -1
- package/.next/server/app/messages.rsc +1 -1
- package/.next/server/app/messages.segments/_full.segment.rsc +1 -1
- package/.next/server/app/messages.segments/_head.segment.rsc +1 -1
- package/.next/server/app/messages.segments/_index.segment.rsc +1 -1
- package/.next/server/app/messages.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/messages.segments/messages/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/messages.segments/messages.segment.rsc +1 -1
- package/.next/server/app/node/page_client-reference-manifest.js +1 -1
- package/.next/server/app/node.html +2 -2
- package/.next/server/app/node.rsc +2 -2
- package/.next/server/app/node.segments/_full.segment.rsc +2 -2
- package/.next/server/app/node.segments/_head.segment.rsc +1 -1
- package/.next/server/app/node.segments/_index.segment.rsc +1 -1
- package/.next/server/app/node.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/node.segments/node/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/node.segments/node.segment.rsc +1 -1
- package/.next/server/app/nodes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/nodes.html +2 -2
- package/.next/server/app/nodes.rsc +2 -2
- package/.next/server/app/nodes.segments/_full.segment.rsc +2 -2
- package/.next/server/app/nodes.segments/_head.segment.rsc +1 -1
- package/.next/server/app/nodes.segments/_index.segment.rsc +1 -1
- package/.next/server/app/nodes.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/nodes.segments/nodes/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/nodes.segments/nodes.segment.rsc +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/networks.html +1 -1
- package/.next/server/app/settings/networks.rsc +1 -1
- package/.next/server/app/settings/networks.segments/_full.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/settings/networks/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/settings/networks.segment.rsc +1 -1
- package/.next/server/app/settings/networks.segments/settings.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.html +1 -1
- package/.next/server/app/settings/tokens.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/_full.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/settings/tokens/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/settings/tokens.segment.rsc +1 -1
- package/.next/server/app/settings/tokens.segments/settings.segment.rsc +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +1 -1
- package/.next/server/app/settings.segments/_full.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/app/tasks.html +1 -1
- package/.next/server/app/tasks.rsc +1 -1
- package/.next/server/app/tasks.segments/_full.segment.rsc +1 -1
- package/.next/server/app/tasks.segments/_head.segment.rsc +1 -1
- package/.next/server/app/tasks.segments/_index.segment.rsc +1 -1
- package/.next/server/app/tasks.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/tasks.segments/tasks/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/tasks.segments/tasks.segment.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__0nsfjkb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0nsfjkb._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0xm3h9x._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__0xm3h9x._.js.map +1 -1
- package/.next/server/chunks/ssr/app_page_tsx_0es_sk2._.js +1 -1
- package/.next/server/chunks/ssr/app_page_tsx_0es_sk2._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/0ep9nej0rnar-.js +1 -0
- package/.next/static/chunks/{0krweyme4bfjm.js → 0wkxts8wri2er.js} +1 -1
- package/.next/trace +2 -2
- package/.next/trace-build +1 -1
- package/app/api/hub/events/route.ts +28 -7
- package/app/components/TaskChatPanel.tsx +32 -19
- package/package.json +1 -1
- package/.next/static/chunks/0p96.fb-gibzj.js +0 -1
- /package/.next/static/{UaT8UC89b6VNckokigCV- → q-j-l-aUCzasmkiiHyEOp}/_buildManifest.js +0 -0
- /package/.next/static/{UaT8UC89b6VNckokigCV- → q-j-l-aUCzasmkiiHyEOp}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{UaT8UC89b6VNckokigCV- → q-j-l-aUCzasmkiiHyEOp}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[60350,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(43515);function f({online:a,working:c,total:d,version:e,uptime:h}){let i=d>0?Math.round(a/d*100):0;return(0,b.jsxs)("div",{className:"mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[(0,b.jsx)("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"Agent Network"}),(0,b.jsxs)("span",{className:"text-xs text-gray-500",children:["CommHub ",e," · ",h]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,b.jsx)(g,{value:a,label:"Online",sub:`${i}% of fleet`,color:"text-green-400",accent:"from-green-500/20 to-green-500/0",border:"border-green-500/15"}),(0,b.jsx)(g,{value:c,label:"Working",sub:a>0?`${Math.round(c/a*100)}% utilization`:"--",color:"text-cyan-400",accent:"from-cyan-500/20 to-cyan-500/0",border:"border-cyan-500/15"}),(0,b.jsx)(g,{value:d-a,label:"Offline",sub:d-a==0?"All systems go":`${d-a} disconnected`,color:"text-gray-400",accent:"from-gray-500/10 to-gray-500/0",border:"border-gray-500/15"}),(0,b.jsx)(g,{value:d,label:"Total",sub:"Registered nodes",color:"text-white",accent:"from-blue-500/15 to-blue-500/0",border:"border-blue-500/15"})]})]})}function g({value:a,label:c,sub:d,color:e,accent:f,border:h}){return(0,b.jsxs)("div",{className:`relative overflow-hidden rounded-xl border ${h} bg-[#111128] px-4 py-3`,children:[(0,b.jsx)("div",{className:`absolute inset-0 bg-gradient-to-br ${f} pointer-events-none`}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:`text-3xl font-bold ${e} tabular-nums leading-tight`,children:a}),(0,b.jsx)("div",{className:"text-sm text-gray-300 mt-0.5",children:c}),(0,b.jsx)("div",{className:"text-xs text-gray-600 mt-1",children:d})]})]})}function h(){let[a,d]=(0,c.useState)(""),[e,f]=(0,c.useState)(!1),[g,h]=(0,c.useState)(""),i=async()=>{if(a.trim()){f(!0),h("");try{let b=await fetch("/api/hub/broadcast",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:a})}),c=await b.json();c.ok?(h(`Broadcast sent to ${c.recipients} node(s)`),d("")):h(`Failed: ${c.error||"Send error"}`)}catch(a){h(`Failed: ${a instanceof Error?a.message:"Send error"}`)}f(!1),setTimeout(()=>h(""),5e3)}};return(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("input",{type:"text",value:a,onChange:a=>d(a.target.value),onKeyDown:a=>"Enter"===a.key&&i(),placeholder:"Broadcast message to all online agents...",maxLength:500,"aria-label":"Broadcast message",className:"flex-1 bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/20 focus:outline-none transition-colors"}),(0,b.jsx)("button",{onClick:i,disabled:e||!a.trim(),"aria-label":"Send broadcast",className:"px-5 py-2.5 bg-blue-600 hover:bg-blue-500 disabled:bg-gray-800 disabled:text-gray-600 text-white text-sm rounded-lg transition-all font-medium cursor-pointer disabled:cursor-not-allowed",children:e?"Sending...":"Broadcast"})]}),a.length>0&&(0,b.jsxs)("div",{className:"text-right text-xs text-gray-600 mt-1",children:[a.length,"/500"]}),g&&(0,b.jsx)("div",{className:`mt-3 text-sm text-center ${g.startsWith("Failed")?"text-red-400":"text-green-400/80"} animate-fade-in`,children:g})]})}function i(a,b,c){let d=b<=2?Math.PI:1.78*Math.PI,e=-Math.PI/2-d/2,f=b<=1?-Math.PI/2:e+d*a/(b-1);return{x:500+c*Math.cos(f),y:330+c*Math.sin(f)}}function j(a,b,c=0){let d=(a.x+b.x)/2,e=(a.y+b.y)/2,f=b.x-a.x,g=b.y-a.y,h=Math.hypot(f,g)||1,i={x:d+-g/h*c,y:e+f/h*c};return`M${a.x},${a.y} Q${i.x},${i.y} ${b.x},${b.y}`}function k(a,b){return a.length>b?`${a.slice(0,b-1)}...`:a}function l({sessions:a,sseSessions:d}){let[e,f]=(0,c.useState)([]);(0,c.useEffect)(()=>{let a=async()=>{try{let a=await fetch("/api/hub/messages?limit=50");if(401===a.status)return void window.location.assign("/login");let b=await a.json();f(b.messages||[])}catch{}};a();let b=setInterval(a,5e3);return()=>clearInterval(b)},[]);let{onlineNodes:g,offlineNodes:h,nodePositions:m,flowLinks:n,activeAliases:o}=(0,c.useMemo)(()=>{let b,c=a.filter(a=>"offline"!==a.status||d[a.alias]),f=a.filter(a=>"offline"===a.status&&!d[a.alias]),g={};c.forEach((a,b)=>{g[a.alias]=i(b,Math.max(c.length,1),220)}),f.forEach((a,b)=>{g[a.alias]=i(b,Math.max(f.length,1),315)});let h=(b=new Map,e.forEach(a=>{if(!g[a.from_alias]||!g[a.to_alias]||a.from_alias===a.to_alias)return;let c=`${a.from_alias}->${a.to_alias}`,d=b.get(c);b.set(c,{key:c,from:a.from_alias,to:a.to_alias,count:(d?.count||0)+1,content:d?.content||a.content})}),[...b.values()].slice(0,18)),j=new Set;return h.forEach(a=>{j.add(a.from),j.add(a.to)}),{onlineNodes:c,offlineNodes:f,nodePositions:g,flowLinks:h,activeAliases:j}},[e,a,d]),p=g.filter(a=>"working"===a.status).length;return(0,b.jsxs)("section",{className:"w-full max-w-6xl mx-auto mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between mb-3 px-1",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-xs uppercase text-gray-600 tracking-wider",children:"Network Topology"}),(0,b.jsx)("h2",{className:"text-lg text-white font-semibold",children:"Command mesh"})]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-green-500/10 text-green-300 border border-green-500/20",children:[p," working"]}),(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-cyan-500/10 text-cyan-300 border border-cyan-500/20",children:[g.length," online"]}),(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20",children:[n.length," active links"]})]})]}),(0,b.jsxs)("div",{className:"relative overflow-hidden rounded-lg border border-[#2a2a4a] bg-[#080814] shadow-2xl shadow-cyan-950/30",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-cyan-400/70 to-transparent"}),(0,b.jsxs)("svg",{viewBox:"0 0 1000 680",className:"w-full h-auto block",preserveAspectRatio:"xMidYMid meet",children:[(0,b.jsxs)("defs",{children:[(0,b.jsxs)("linearGradient",{id:"topo-panel",x1:"0",x2:"1",y1:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"0%",stopColor:"#0b1220"}),(0,b.jsx)("stop",{offset:"48%",stopColor:"#080814"}),(0,b.jsx)("stop",{offset:"100%",stopColor:"#101018"})]}),(0,b.jsxs)("radialGradient",{id:"topo-radar",cx:"50%",cy:"50%",r:"55%",children:[(0,b.jsx)("stop",{offset:"0%",stopColor:"#22d3ee",stopOpacity:"0.18"}),(0,b.jsx)("stop",{offset:"45%",stopColor:"#22c55e",stopOpacity:"0.045"}),(0,b.jsx)("stop",{offset:"100%",stopColor:"#020617",stopOpacity:"0"})]}),(0,b.jsxs)("filter",{id:"topo-glow",children:[(0,b.jsx)("feGaussianBlur",{stdDeviation:"4",result:"blur"}),(0,b.jsxs)("feMerge",{children:[(0,b.jsx)("feMergeNode",{in:"blur"}),(0,b.jsx)("feMergeNode",{in:"SourceGraphic"})]})]}),(0,b.jsx)("marker",{id:"topo-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto-start-reverse",children:(0,b.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#67e8f9"})})]}),(0,b.jsx)("rect",{width:"1000",height:"680",fill:"url(#topo-panel)"}),(0,b.jsx)("circle",{cx:500,cy:330,r:"330",fill:"url(#topo-radar)"}),[90,170,250,330].map(a=>(0,b.jsx)("circle",{cx:500,cy:330,r:a,fill:"none",stroke:"#164e63",strokeWidth:"1",opacity:"0.35"},a)),[0,30,60,90,120,150].map(a=>(0,b.jsx)("line",{x1:500-360*Math.cos(a*Math.PI/180),y1:330-360*Math.sin(a*Math.PI/180),x2:500+360*Math.cos(a*Math.PI/180),y2:330+360*Math.sin(a*Math.PI/180),stroke:"#164e63",strokeWidth:"1",opacity:"0.18"},a)),g.map(a=>{let c=m[a.alias];if(!c)return null;let d=j({x:500,y:330},c,0);return(0,b.jsx)("path",{d:d,fill:"none",stroke:o.has(a.alias)?"#22d3ee":"#155e75",strokeWidth:o.has(a.alias)?2:1,strokeDasharray:o.has(a.alias)?"none":"8 10",opacity:o.has(a.alias)?.65:.35},`hub-${a.alias}`)}),n.map((a,c)=>{let d=m[a.from],e=m[a.to];if(!d||!e)return null;let f=j(d,e,c%2==0?36:-36),g=Math.min(2+a.count,7);return(0,b.jsxs)("g",{children:[(0,b.jsx)("path",{d:f,fill:"none",stroke:"#67e8f9",strokeWidth:g,opacity:"0.28",filter:"url(#topo-glow)",markerEnd:"url(#topo-arrow)"}),(0,b.jsx)("path",{id:`flow-path-${c}`,d:f,fill:"none",stroke:"#e0f2fe",strokeWidth:"1",strokeDasharray:"2 12",opacity:"0.75"}),(0,b.jsx)("circle",{r:"4",fill:"#fef08a",filter:"url(#topo-glow)",children:(0,b.jsx)("animateMotion",{dur:`${2.2+c%5*.32}s`,repeatCount:"indefinite",path:f})})]},a.key)}),(0,b.jsxs)("g",{filter:"url(#topo-glow)",children:[(0,b.jsx)("circle",{cx:500,cy:330,r:"56",fill:"#020617",stroke:"#67e8f9",strokeWidth:"2"}),(0,b.jsxs)("circle",{cx:500,cy:330,r:"42",fill:"none",stroke:"#22c55e",strokeWidth:"1.5",opacity:"0.8",children:[(0,b.jsx)("animate",{attributeName:"r",values:"42;52;42",dur:"3s",repeatCount:"indefinite"}),(0,b.jsx)("animate",{attributeName:"opacity",values:"0.8;0.2;0.8",dur:"3s",repeatCount:"indefinite"})]}),(0,b.jsx)("path",{d:"M470 330 h60 M500 300 v60",stroke:"#e0f2fe",strokeWidth:"5",strokeLinecap:"round",opacity:"0.9"}),(0,b.jsx)("text",{x:500,y:408,textAnchor:"middle",fill:"#e5e7eb",fontSize:"16",fontFamily:"monospace",fontWeight:"700",children:"DASHBOARD"}),(0,b.jsx)("text",{x:500,y:426,textAnchor:"middle",fill:"#64748b",fontSize:"10",fontFamily:"monospace",children:"command relay"})]}),[...g,...h].map(a=>{let c=m[a.alias];if(!c)return null;let e="offline"!==a.status||!!d[a.alias],f=e?"working"===a.status?{label:"working",primary:"#22c55e",halo:"#14532d",text:"#dcfce7"}:"idle"===a.status?{label:"idle",primary:"#2dd4bf",halo:"#134e4a",text:"#ccfbf1"}:{label:a.status||"online",primary:"#38bdf8",halo:"#0c4a6e",text:"#e0f2fe"}:{label:"offline",primary:"#6b7280",halo:"#111827",text:"#9ca3af"},g=o.has(a.alias),h=e?26:18;return(0,b.jsxs)("g",{className:"transition-opacity",children:[g&&(0,b.jsxs)("circle",{cx:c.x,cy:c.y,r:h+14,fill:f.primary,opacity:"0.12",children:[(0,b.jsx)("animate",{attributeName:"r",values:`${h+8};${h+22};${h+8}`,dur:"2.4s",repeatCount:"indefinite"}),(0,b.jsx)("animate",{attributeName:"opacity",values:"0.18;0.04;0.18",dur:"2.4s",repeatCount:"indefinite"})]}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:h+8,fill:f.halo,opacity:e?.55:.25}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:h,fill:e?"#020617":"#080814",stroke:f.primary,strokeWidth:e?3:1.5,strokeDasharray:e?"none":"5 5",filter:e?"url(#topo-glow)":void 0}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:e?8:5,fill:f.primary}),"working"===a.status&&(0,b.jsx)("path",{d:`M${c.x-9},${c.y+11} h18`,stroke:"#fef08a",strokeWidth:"3",strokeLinecap:"round",children:(0,b.jsx)("animate",{attributeName:"opacity",values:"1;0.25;1",dur:"1.1s",repeatCount:"indefinite"})}),(0,b.jsxs)("g",{transform:`translate(${c.x}, ${c.y+h+22})`,children:[(0,b.jsx)("rect",{x:"-62",y:"-14",width:"124",height:"42",rx:"6",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("text",{x:"0",y:"1",textAnchor:"middle",fill:f.text,fontSize:"12",fontFamily:"monospace",fontWeight:"700",children:k(a.alias,14)}),(0,b.jsxs)("text",{x:"0",y:"17",textAnchor:"middle",fill:f.primary,fontSize:"9",fontFamily:"monospace",children:[f.label," ",e?`sse:${d[a.alias]}`:""]})]})]},a.alias)}),(0,b.jsxs)("g",{transform:"translate(28, 34)",children:[(0,b.jsx)("rect",{x:"0",y:"0",width:"285",height:60+20*Math.min(n.length,4),rx:"8",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("text",{x:"16",y:"26",fill:"#e5e7eb",fontSize:"13",fontFamily:"monospace",fontWeight:"700",children:"recent signal"}),(0,b.jsxs)("text",{x:"178",y:"26",fill:"#67e8f9",fontSize:"11",fontFamily:"monospace",children:[e.length," messages"]}),n.slice(0,4).map((a,c)=>(0,b.jsxs)("text",{x:"16",y:54+20*c,fill:"#94a3b8",fontSize:"10",fontFamily:"monospace",children:[k(a.from,8)," ","->"," ",k(a.to,8)," / ",a.count," / ",k(a.content,18)]},a.key))]}),(0,b.jsxs)("g",{transform:"translate(720, 34)",children:[(0,b.jsx)("rect",{x:"0",y:"0",width:"250",height:"112",rx:"8",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("circle",{cx:"18",cy:"26",r:"6",fill:"#22c55e"}),(0,b.jsx)("text",{x:"34",y:"30",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"working node"}),(0,b.jsx)("circle",{cx:"18",cy:"52",r:"6",fill:"#2dd4bf"}),(0,b.jsx)("text",{x:"34",y:"56",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"online idle"}),(0,b.jsx)("circle",{cx:"18",cy:"78",r:"6",fill:"#6b7280"}),(0,b.jsx)("text",{x:"34",y:"82",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"offline / no SSE"}),(0,b.jsx)("path",{d:"M150,78 Q176,52 210,78",fill:"none",stroke:"#67e8f9",strokeWidth:"3",markerEnd:"url(#topo-arrow)"})]})]})]})]})}let m={working:{bg:"bg-green-900/30 border-green-800/30",text:"text-green-300",dot:"bg-green-500",glow:"shadow-green-500/10"},idle:{bg:"bg-cyan-900/30 border-cyan-800/30",text:"text-cyan-300",dot:"bg-cyan-400",glow:"shadow-cyan-500/5"},blocked:{bg:"bg-yellow-900/30 border-yellow-800/30",text:"text-yellow-300",dot:"bg-yellow-500",glow:""},error:{bg:"bg-red-900/30 border-red-800/30",text:"text-red-300",dot:"bg-red-500",glow:""}},n={bg:"bg-gray-800/50 border-gray-700/30",text:"text-gray-500",dot:"bg-gray-500",glow:""};function o({session:a,hasSse:c,sseCount:f,onChat:g}){let h=c&&m[a.status]||n;return(0,b.jsxs)(d.default,{href:`/node?alias=${encodeURIComponent(a.alias)}`,prefetch:!1,className:`block rounded-xl border p-4 transition-all duration-300 cursor-pointer ${c?`bg-[#111128] border-[#2a2a4a] hover:border-cyan-500/30 hover:shadow-lg ${h.glow}`:"bg-[#0d0d1a] border-[#1a1a2a] opacity-40"}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${h.dot} ${c&&"working"===a.status?"animate-pulse":""}`}),(0,b.jsx)("span",{className:"font-semibold text-white truncate text-sm",title:a.alias,children:a.alias})]}),(0,b.jsx)("span",{className:`text-[11px] px-2 py-0.5 rounded-md border shrink-0 ${h.bg} ${h.text}`,children:c?a.status:"offline"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,b.jsx)("span",{className:"text-xs text-gray-600 bg-[#0a0a15] px-2 py-0.5 rounded border border-[#1a1a2a]",children:a.agent||"unknown"}),c&&(0,b.jsxs)("span",{className:"text-[10px] text-green-500",children:["SSE:",f]})]}),a.task?(0,b.jsx)("div",{className:"text-xs text-gray-400 bg-[#0a0a15] rounded-lg px-3 py-2 border border-[#1a1a2a] line-clamp-2",title:a.task,children:a.task}):(0,b.jsx)("div",{className:"text-xs text-gray-700 italic",children:"No active task"}),a.progress>0&&(0,b.jsxs)("div",{className:"mt-3",children:[(0,b.jsxs)("div",{className:"flex justify-between text-[10px] mb-1",children:[(0,b.jsx)("span",{className:"text-gray-600",children:"Progress"}),(0,b.jsxs)("span",{className:h.text,children:[a.progress,"%"]})]}),(0,b.jsx)("div",{className:"w-full bg-gray-800 rounded-full h-1.5 overflow-hidden",children:(0,b.jsx)("div",{className:`h-1.5 rounded-full transition-all duration-700 ${"working"===a.status?"bg-green-500":"bg-cyan-500"}`,style:{width:`${Math.min(a.progress,100)}%`}})})]}),(0,b.jsxs)("div",{className:"mt-3 flex justify-between items-center text-[10px] text-gray-600",children:[(0,b.jsx)("span",{children:a.server||"--"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[g&&c&&(0,b.jsx)("button",{onClick:b=>{b.preventDefault(),b.stopPropagation(),g(a.alias)},className:"text-cyan-400 hover:text-cyan-300 px-1.5 py-0.5 rounded border border-cyan-500/20 hover:bg-cyan-500/10 transition-colors",children:"Chat"}),(0,b.jsx)("span",{children:(0,e.timeAgo)(a.updated_at)})]})]})]})}function p({messages:a}){return 0===a.length?null:(0,b.jsxs)("div",{className:"mt-8",children:[(0,b.jsxs)("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-gray-500",children:"Inbox"}),(0,b.jsx)("span",{className:"text-xs bg-blue-900/30 text-blue-400 px-2 py-0.5 rounded-full border border-blue-800/30",children:a.length})]}),(0,b.jsx)("div",{className:"space-y-2 max-h-96 overflow-y-auto pr-1 scrollbar-thin",children:a.map(a=>(0,b.jsxs)("div",{className:"bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-3 text-sm transition-colors hover:border-[#3a3a5a]",children:[(0,b.jsxs)("div",{className:"flex justify-between text-xs text-gray-500 mb-1.5",children:[(0,b.jsx)("span",{className:"text-blue-400 font-medium",children:a.from_session}),(0,b.jsx)("span",{children:a.created_at})]}),(0,b.jsx)("div",{className:"text-gray-300 leading-relaxed",children:a.content})]},a.id))})]})}function q(){return(0,b.jsxs)("div",{className:"min-h-screen bg-[#0a0a1a] text-gray-100 p-6 font-mono animate-pulse",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"h-7 w-48 bg-gray-800 rounded mb-2"}),(0,b.jsx)("div",{className:"h-4 w-64 bg-gray-800/60 rounded"})]}),(0,b.jsx)("div",{className:"flex gap-3",children:[1,2,3].map(a=>(0,b.jsx)("div",{className:"w-[72px] h-[60px] bg-gray-800/40 rounded-lg border border-gray-800"},a))})]}),(0,b.jsxs)("div",{className:"mb-6 flex gap-2",children:[(0,b.jsx)("div",{className:"flex-1 h-10 bg-gray-800/40 rounded-lg"}),(0,b.jsx)("div",{className:"w-28 h-10 bg-gray-800/40 rounded-lg"})]}),(0,b.jsx)("div",{className:"w-full max-w-4xl mx-auto mb-8 h-64 bg-gray-800/20 rounded-xl"}),(0,b.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(a=>(0,b.jsxs)("div",{className:"rounded-xl border border-gray-800/40 p-4 bg-gray-800/20",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,b.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-gray-700"}),(0,b.jsx)("div",{className:"h-4 w-24 bg-gray-700 rounded"})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("div",{className:"h-3 w-full bg-gray-800/60 rounded"}),(0,b.jsx)("div",{className:"h-3 w-3/4 bg-gray-800/60 rounded"}),(0,b.jsx)("div",{className:"h-3 w-1/2 bg-gray-800/60 rounded"})]})]},a))})]})}function r({hint:a}){return(0,b.jsxs)("div",{className:"text-center py-16",children:[(0,b.jsx)("div",{className:"text-gray-600 text-4xl mb-4",children:"--"}),(0,b.jsx)("h3",{className:"text-gray-400 text-lg font-medium mb-2",children:"No agents in this network"}),a?.global_count?(0,b.jsxs)("p",{className:"text-gray-500 text-sm max-w-md mx-auto",children:["Server has ",(0,b.jsx)("span",{className:"text-cyan-400 font-medium",children:a.global_count})," nodes globally, but none are registered to the current network. Switch network or contact admin."]}):(0,b.jsx)("p",{className:"text-gray-600 text-sm max-w-md mx-auto",children:"Agent sessions will appear here once they connect to the CommHub."})]})}var s=a.i(22397);function t(){let{setNetworkId:a}=(0,s.useNetworkId)(),[d,e]=(0,c.useState)({user:null,networks:[],currentNetwork:"",token:""}),[f,g]=(0,c.useState)(!1),[h,i]=(0,c.useState)(""),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=sessionStorage.getItem("anet_v3_auth");if(a)try{e(JSON.parse(a))}catch{}},[]);let[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(""),[u,v]=(0,c.useState)(""),w=async()=>{try{await fetch(`/api/hub/auth?token=${d.token}&endpoint=/api/auth/me`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update_profile",token:d.token,display_name:r,email:u})});let a=await fetch("/api/hub/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update_profile",token:d.token,display_name:r,email:u})}),b=await a.json();if(b.ok&&b.user){let a={...d,user:b.user};e(a),sessionStorage.setItem("anet_v3_auth",JSON.stringify(a)),q(!1)}}catch{}};if(!d.user)return null;let x=(d.user.display_name||d.user.username).slice(0,2).toUpperCase();return(0,b.jsxs)("div",{className:"flex items-center justify-between bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-2.5 mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center text-xs font-bold text-white",children:x}),(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm text-white font-medium",children:d.user.display_name||d.user.username}),(0,b.jsxs)("div",{className:"text-[10px] text-gray-500",children:[d.user.role," · ",d.user.user_id]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[d.networks.length>0&&(0,b.jsx)("select",{value:d.currentNetwork,onChange:b=>{let c={...d,currentNetwork:b.target.value};e(c),a(b.target.value),sessionStorage.setItem("anet_v3_auth",JSON.stringify(c))},className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white focus:outline-none",children:d.networks.map(a=>(0,b.jsx)("option",{value:a.network_id,children:a.network_name},a.network_id))}),(0,b.jsx)("button",{onClick:()=>{t(d.user?.display_name||""),v(""),q(!p)},className:"text-xs text-gray-500 hover:text-gray-300",children:"Edit"}),(0,b.jsx)("button",{onClick:()=>{e({user:null,networks:[],currentNetwork:"",token:""}),sessionStorage.removeItem("anet_v3_auth")},className:"text-xs text-gray-500 hover:text-gray-300",children:"Sign out"})]}),p&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-2 pt-2 border-t border-[#2a2a4a]",children:[(0,b.jsx)("input",{type:"text",value:r,onChange:a=>t(a.target.value),placeholder:"Display name",className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white placeholder-gray-600 focus:outline-none w-32"}),(0,b.jsx)("input",{type:"email",value:u,onChange:a=>v(a.target.value),placeholder:"Email",className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white placeholder-gray-600 focus:outline-none w-40"}),(0,b.jsx)("button",{onClick:w,className:"px-2 py-1 bg-cyan-600 hover:bg-cyan-500 text-white text-xs rounded",children:"Save"})]})]})}var u=a.i(31626),v=a.i(15261);function w({tabs:a,activeTab:c,onOpenTab:d,onCloseTab:e,onSetActive:f,onClose:g}){return 0===a.length?null:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{onClick:g,className:"jsx-f7cf3d1a6fdfc074 fixed inset-0 bg-black/30 z-40 lg:hidden"}),(0,b.jsxs)("div",{className:"jsx-f7cf3d1a6fdfc074 fixed top-0 right-0 h-full w-full lg:w-[500px] bg-[#0a0a1a] border-l border-[#2a2a4a] z-50 flex flex-col shadow-2xl shadow-black/60 animate-slide-in",children:[(0,b.jsxs)("div",{className:"jsx-f7cf3d1a6fdfc074 flex items-center border-b border-[#2a2a4a] bg-[#0d0d1a] overflow-x-auto",children:[(0,b.jsx)("div",{className:"jsx-f7cf3d1a6fdfc074 flex-1 flex min-w-0",children:a.map(a=>(0,b.jsxs)("button",{onClick:()=>f(a),className:`jsx-f7cf3d1a6fdfc074 flex items-center gap-1.5 px-3 py-2.5 text-xs border-b-2 transition-colors shrink-0 ${c===a?"border-cyan-400 text-cyan-300 bg-cyan-500/5":"border-transparent text-gray-500 hover:text-gray-300"}`,children:[(0,b.jsx)("div",{className:`jsx-f7cf3d1a6fdfc074 w-2 h-2 rounded-full ${c===a?"bg-cyan-400":"bg-gray-600"}`}),(0,b.jsx)("span",{className:"jsx-f7cf3d1a6fdfc074 max-w-[80px] truncate",children:a}),(0,b.jsx)("button",{onClick:b=>{b.stopPropagation(),e(a)},className:"jsx-f7cf3d1a6fdfc074 ml-1 text-gray-600 hover:text-gray-300 p-0.5",children:"×"})]},a))}),(0,b.jsx)("button",{onClick:g,className:"jsx-f7cf3d1a6fdfc074 text-gray-500 hover:text-white px-3 py-2.5 shrink-0 border-l border-[#2a2a4a]",children:(0,b.jsx)("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,className:"jsx-f7cf3d1a6fdfc074 w-4 h-4",children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12",className:"jsx-f7cf3d1a6fdfc074"})})})]}),(0,b.jsx)("div",{className:"jsx-f7cf3d1a6fdfc074 flex-1 relative overflow-hidden",children:a.map(a=>(0,b.jsx)("div",{className:`jsx-f7cf3d1a6fdfc074 absolute inset-0 ${c===a?"block":"hidden"}`,children:(0,b.jsx)(x,{alias:a})},a))})]}),(0,b.jsx)(u.default,{id:"f7cf3d1a6fdfc074",children:"@keyframes slide-in{0%{transform:translate(100%)}to{transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}"})]})}function x({alias:a}){return(0,b.jsx)(v.TaskChatPanel,{alias:a,onClose:()=>{},inline:!0})}function y({sessions:a,onClose:d}){let[e,f]=(0,c.useState)(new Set),[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)("normal"),[k,l]=(0,c.useState)(!1),[m,n]=(0,c.useState)([]),[o,p]=(0,c.useState)(""),q=a.filter(a=>"offline"!==a.status).filter(a=>!o||a.alias.toLowerCase().includes(o.toLowerCase())||(a.agent||"").toLowerCase().includes(o.toLowerCase())),r=async()=>{if(!g.trim()||0===e.size||k)return;l(!0),n([]);let a=[...e].map(async a=>{try{let b=await fetch("/api/hub/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({alias:a,task:g,priority:i})}),c=await b.json();return{alias:a,ok:!!c.ok,error:c.error}}catch(b){return{alias:a,ok:!1,error:"send failed"}}});n(await Promise.all(a)),l(!1)},s=m.filter(a=>a.ok).length;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:d}),(0,b.jsxs)("div",{className:"fixed inset-4 lg:inset-x-[15%] lg:inset-y-[5%] bg-[#0a0a1a] border border-[#2a2a4a] rounded-2xl z-50 flex flex-col shadow-2xl shadow-black/70 overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[#2a2a4a] bg-[#0d0d1a]",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-lg font-bold text-white",children:"Dispatch Task"}),(0,b.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Send a task to one or more agents"})]}),(0,b.jsx)("button",{onClick:d,className:"text-gray-500 hover:text-white p-1.5 rounded-lg hover:bg-[#1a1a2a]",children:(0,b.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col lg:flex-row overflow-hidden",children:[(0,b.jsxs)("div",{className:"lg:w-[280px] border-b lg:border-b-0 lg:border-r border-[#2a2a4a] flex flex-col",children:[(0,b.jsxs)("div",{className:"px-4 py-3 border-b border-[#2a2a4a]",children:[(0,b.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:"Filter agents...",className:"w-full bg-[#111128] border border-[#2a2a4a] rounded-lg px-3 py-2 text-xs text-white placeholder-gray-600 focus:border-cyan-500/40 focus:outline-none"}),(0,b.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,b.jsx)("button",{onClick:()=>{e.size===q.length?f(new Set):f(new Set(q.map(a=>a.alias)))},className:"text-[10px] text-cyan-400 hover:text-cyan-300",children:e.size===q.length?"Deselect all":`Select all (${q.length})`}),(0,b.jsxs)("span",{className:"text-[10px] text-gray-600",children:[e.size," selected"]})]})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto px-2 py-2 space-y-0.5 max-h-[200px] lg:max-h-none",children:[q.map(a=>(0,b.jsxs)("button",{onClick:()=>{var b;return b=a.alias,void f(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-xs text-left transition-colors ${e.has(a.alias)?"bg-cyan-500/10 text-cyan-300 border border-cyan-500/20":"text-gray-400 hover:bg-[#1a1a2a]"}`,children:[(0,b.jsx)("div",{className:`w-2 h-2 rounded-full shrink-0 ${"working"===a.status?"bg-green-400":"idle"===a.status?"bg-cyan-400":"bg-gray-500"}`}),(0,b.jsx)("span",{className:"truncate flex-1",children:a.alias}),(0,b.jsx)("span",{className:"text-[9px] text-gray-600",children:a.agent||"--"})]},a.alias)),0===q.length&&(0,b.jsx)("div",{className:"text-center text-xs text-gray-600 py-4",children:"No online agents"})]})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsxs)("div",{className:"flex-1 px-6 py-4 flex flex-col",children:[(0,b.jsx)("label",{className:"text-xs text-gray-500 uppercase mb-2",children:"Task Prompt"}),(0,b.jsx)("textarea",{value:g,onChange:a=>h(a.target.value),placeholder:"Enter the task you want to dispatch...",className:"flex-1 min-h-[120px] bg-[#111128] border border-[#2a2a4a] rounded-xl px-4 py-3 text-sm text-white placeholder-gray-600 focus:border-cyan-500/40 focus:outline-none resize-none"}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mt-4",children:[(0,b.jsxs)("select",{value:i,onChange:a=>j(a.target.value),className:"bg-[#111128] border border-[#2a2a4a] rounded-lg px-3 py-2 text-xs text-white focus:outline-none",children:[(0,b.jsx)("option",{value:"normal",children:"Normal priority"}),(0,b.jsx)("option",{value:"high",children:"High priority"}),(0,b.jsx)("option",{value:"low",children:"Low priority"})]}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsx)("button",{onClick:r,disabled:k||!g.trim()||0===e.size,className:"px-6 py-2.5 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-500 hover:to-blue-500 disabled:from-gray-800 disabled:to-gray-800 disabled:text-gray-600 text-white text-sm font-medium rounded-xl transition-all shadow-lg shadow-cyan-500/10 disabled:shadow-none active:scale-95",children:k?(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Sending..."]}):`Dispatch to ${e.size} agent${e.size>1?"s":""}`})]})]}),m.length>0&&(0,b.jsxs)("div",{className:"px-6 py-3 border-t border-[#2a2a4a] bg-[#0d0d1a]",children:[(0,b.jsxs)("div",{className:"text-xs text-gray-500 mb-2",children:[s,"/",m.length," dispatched successfully"]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m.map(a=>(0,b.jsxs)("span",{className:`text-[10px] px-2 py-0.5 rounded-full border ${a.ok?"text-green-300 border-green-500/20 bg-green-500/5":"text-red-300 border-red-500/20 bg-red-500/5"}`,children:[a.alias,": ",a.ok?"✓":a.error||"✗"]},a.alias))})]})]})]})]})]})}var z=a.i(44332),A=a.i(64565);a.s(["default",0,function(){(0,c.useEffect)(()=>{sessionStorage.getItem("anet_v3_auth")||(fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),window.location.assign("/login"))},[]);let{sessions:a,hint:g,error:i,isLoading:j}=(0,z.useSessions)(),{health:k}=(0,z.useHealth)(),{config:m}=(0,z.useAnetConfig)(),{tasks:n}=(0,z.useTasks)({limit:"500"}),{stats:s}=(0,z.useStats)(),{license:u}=(0,z.useLicense)(),[v,x]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),D=function(){let[a,b]=(0,c.useState)([]),[d,e]=(0,c.useState)("");return{tabs:a,activeTab:d,openTab:a=>{b(b=>b.includes(a)?b:[...b,a]),e(a)},closeTab:a=>{b(b=>{let c=b.filter(b=>b!==a);return d===a&&e(c[c.length-1]||""),c})},closeAll:()=>{b([]),e("")},setActiveTab:e}}(),[E,F]=(0,c.useState)(!1),[G,H]=(0,c.useState)([]),{mutate:I}=(0,A.useSWRConfig)(),{connected:J,supported:K}=function({url:a,onEvent:b,reconnectDelay:d=3e3,enabled:e=!0}){let[f,g]=(0,c.useState)(!1),[h,i]=(0,c.useState)(null),[j,k]=(0,c.useState)(null),l=(0,c.useRef)(null),m=(0,c.useRef)(void 0),n=(0,c.useRef)(!1),o=(0,c.useRef)(null),p=(0,c.useRef)(!1),q=(0,c.useCallback)(()=>{if(!e||!a||n.current||p.current)return;l.current&&(l.current.close(),l.current=null),o.current&&o.current.abort();let c=a.includes("?")?`${a}&probe=1`:`${a}?probe=1`,f=new AbortController;o.current=f;let h=setTimeout(()=>f.abort(),5e3);fetch(c,{method:"HEAD",cache:"no-store",signal:f.signal}).finally(()=>clearTimeout(h)).then(c=>{if(p.current)return;if("true"!==c.headers.get("x-anet-sse-available")){n.current=!0,g(!1),k(!1);return}k(!0);let e=new EventSource(a);l.current=e,e.onopen=()=>g(!0),e.onmessage=a=>{try{let c=JSON.parse(a.data);i(c),b?.(c)}catch{}},e.onerror=()=>{g(!1),e.close(),l.current=null,p.current||(m.current=setTimeout(q,d))}}).catch(()=>{p.current||(g(!1),k(!1))})},[a,b,d,e]);return(0,c.useEffect)(()=>(n.current=!1,p.current=!1,k(!!e&&null),q(),()=>{p.current=!0,o.current&&(o.current.abort(),o.current=null),l.current&&(l.current.close(),l.current=null),m.current&&clearTimeout(m.current)}),[q]),{connected:f,lastEvent:h,supported:j}}({url:"/api/hub/events",enabled:"1"!==process.env.NEXT_PUBLIC_DISABLE_SSE,onEvent:a=>{["new_task","new_message","new_reply","node_status_changed","broadcast"].includes(a.type)&&(I("/api/hub/status"),I(a=>"string"==typeof a&&a.startsWith("/api/hub/tasks"),void 0,{revalidate:!0}))}});if((0,c.useEffect)(()=>{let a=()=>{fetch("/api/hub/inbox").then(a=>a.json()).then(a=>{a.messages?.length&&H(b=>{let c=new Set(b.map(a=>a.id));return[...a.messages.filter(a=>!c.has(a.id)),...b].slice(0,100)})}).catch(()=>{})};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),j)return(0,b.jsx)(q,{});let L=k?.sse_sessions||{},M=a=>"offline"!==a.status||!!L[a.alias],N=a.filter(M).length,O=a.length,P=a.filter(a=>"working"===a.status).length,Q=k?(0,e.formatUptime)(k.uptime):"--",R=k?.version||"--",S=!!(m?.hub&&m.tokenConfigured),T=m?.source==="file"?"Local config":m?.source==="runtime-env"?"Runtime env":"Config missing",U={};if(s?.tasks?.by_status?.length)for(let a of s.tasks.by_status)U[a.status]=a.count;else for(let a of n)U[a.status]=(U[a.status]||0)+1;let V=[...a].sort((a,b)=>{let c=+!!M(a),d=+!!M(b);if(c!==d)return d-c;let e=+("working"===a.status);return("working"===b.status)-e});return(0,b.jsxs)("div",{className:"min-h-screen bg-[#0a0a1a] text-gray-100 p-4 sm:p-6 font-mono",children:[(0,b.jsx)("div",{className:"lg:ml-0 ml-10",children:(0,b.jsx)(f,{online:N,working:P,total:O,version:R,uptime:Q})}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,b.jsx)("button",{onClick:()=>F(!0),className:"px-4 py-2 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-500 hover:to-blue-500 text-white text-sm font-medium rounded-xl shadow-lg shadow-cyan-500/10 transition-all active:scale-95 shrink-0",children:"⚡ Dispatch"}),(0,b.jsx)("div",{className:"flex-1",children:(0,b.jsx)(t,{})})]}),(0,b.jsxs)("section",{className:"mb-6 rounded-lg border border-[#2a2a4a] bg-[#111128] px-4 py-3 shadow-lg shadow-black/20",children:[(0,b.jsxs)("button",{onClick:()=>C(!B),className:"w-full flex items-center justify-between text-left",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"uppercase text-gray-600",children:"Config"}),(0,b.jsx)("span",{className:`w-2 h-2 rounded-full ${S?"bg-green-400":"bg-red-400"}`}),(0,b.jsx)("span",{className:"text-gray-500",children:T})]}),(0,b.jsx)("svg",{className:`w-4 h-4 text-gray-600 transition-transform ${B?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),B&&(0,b.jsxs)("div",{className:"mt-3 pt-3 border-t border-[#2a2a4a]",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsx)("div",{className:"min-w-0",children:(0,b.jsxs)("div",{className:"text-gray-100 truncate text-sm",title:m?.hub||void 0,children:["Hub: ",(0,b.jsx)("span",{className:m?.hub?"text-cyan-300":"text-red-300",children:m?.hub?.trim()||"not configured"})]})}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 text-xs",children:(0,b.jsxs)("span",{className:`px-2.5 py-1 rounded-md border ${m?.tokenConfigured?"bg-blue-500/5 text-blue-300 border-blue-500/20":"bg-gray-500/5 text-gray-400 border-gray-500/20"}`,children:["Token: ",m?.tokenPreview||"not configured"]})})]}),m?.error&&(0,b.jsx)("div",{className:"mt-2 text-xs text-gray-600",children:m.error})]})]}),Object.keys(U).length>0&&(0,b.jsxs)("section",{className:"mb-6 rounded-lg border border-[#2a2a4a] bg-[#111128] px-4 py-3 shadow-lg shadow-black/20",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("div",{className:"text-xs uppercase text-gray-600",children:"Task Status"}),(0,b.jsx)(d.default,{href:"/tasks",prefetch:!1,className:"text-xs text-cyan-400 hover:text-cyan-300",children:"View all →"})]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2",children:[{key:"running",color:"bg-green-500/10 text-green-300 border-green-500/20"},{key:"delivered",color:"bg-blue-500/10 text-blue-300 border-blue-500/20"},{key:"acked",color:"bg-cyan-500/10 text-cyan-300 border-cyan-500/20"},{key:"replied",color:"bg-purple-500/10 text-purple-300 border-purple-500/20"},{key:"failed",color:"bg-red-500/10 text-red-300 border-red-500/20"},{key:"cancelled",color:"bg-yellow-500/10 text-yellow-300 border-yellow-500/20"},{key:"expired",color:"bg-orange-500/10 text-orange-300 border-orange-500/20"},{key:"closed",color:"bg-gray-500/10 text-gray-500 border-gray-500/20"}].filter(({key:a})=>U[a]).map(({key:a,color:c})=>(0,b.jsxs)(d.default,{href:`/tasks?status=${a}`,prefetch:!1,className:`px-2.5 py-1 rounded-md border text-xs ${c} hover:opacity-80 transition-opacity`,children:[a,": ",U[a]]},a))})]}),(0,b.jsx)("section",{className:"mb-6 grid grid-cols-3 sm:grid-cols-6 gap-2",children:[{href:"/nodes",label:"Nodes",value:`${N}/${O}`,color:"text-green-400 border-green-500/15"},{href:"/tasks",label:"Tasks",value:String(Object.values(U).reduce((a,b)=>a+b,0)||"--"),color:"text-cyan-400 border-cyan-500/15"},{href:"/tasks?status=failed",label:"Failed",value:String(U.failed||0),color:U.failed?"text-red-400 border-red-500/20":"text-gray-600 border-gray-700/30"},{href:"/messages",label:"Messages",value:"→",color:"text-blue-400 border-blue-500/15"},{href:"/logs",label:"Logs",value:"→",color:"text-purple-400 border-purple-500/15"},{href:"/admin",label:"Admin",value:"→",color:"text-gray-400 border-gray-500/15"}].map(a=>(0,b.jsxs)(d.default,{href:a.href,prefetch:!1,className:`text-center rounded-xl border ${a.color} bg-[#111128] px-3 py-2.5 hover:bg-[#161630] transition-colors`,children:[(0,b.jsx)("div",{className:`text-lg font-bold tabular-nums ${a.color.split(" ")[0]}`,children:a.value}),(0,b.jsx)("div",{className:"text-[10px] text-gray-500",children:a.label})]},a.href))}),(0,b.jsx)(h,{}),n.length>0&&(0,b.jsxs)("section",{className:"mb-6 bg-[#111128] border border-[#2a2a4a] rounded-xl p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-gray-300",children:"Recent Activity"}),(0,b.jsx)(d.default,{href:"/tasks",className:"text-xs text-cyan-400 hover:text-cyan-300",children:"All tasks →"})]}),(0,b.jsx)("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:n.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${"replied"===a.status?"bg-purple-400":"running"===a.status?"bg-green-400":"failed"===a.status?"bg-red-400":"bg-blue-400"}`}),(0,b.jsx)("span",{className:"text-blue-400 shrink-0",children:a.from_name||"?"}),(0,b.jsx)("span",{className:"text-gray-600",children:"→"}),(0,b.jsx)("span",{className:"text-cyan-400 shrink-0",children:a.to_name||"?"}),(0,b.jsx)("span",{className:"text-gray-500 truncate flex-1",children:a.content?.slice(0,40)||"--"}),(0,b.jsx)("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] border ${"replied"===a.status?"text-purple-300 border-purple-500/20":"failed"===a.status?"text-red-300 border-red-500/20":"text-gray-500 border-gray-700/30"}`,children:a.status})]},a.task_id))})]}),i&&(0,b.jsxs)("div",{className:"bg-red-900/20 border border-red-800/40 text-red-300 px-4 py-3 rounded-lg mb-6 text-sm flex items-center justify-between",role:"alert",children:[(0,b.jsx)("span",{children:String(i)}),(0,b.jsx)("span",{className:"text-gray-500 text-xs",children:"Check CommHub connection"})]}),a.length>0&&(0,b.jsx)("div",{className:"flex justify-center mb-4",children:(0,b.jsx)("button",{onClick:()=>x(!v),className:"text-xs text-gray-500 hover:text-gray-300 border border-gray-700/50 px-4 py-1.5 rounded-lg transition-colors hover:border-gray-600 cursor-pointer",children:v?"Hide Topology":"Show Topology"})}),!v&&a.length>0&&(0,b.jsx)("div",{className:"lg:hidden text-center text-xs text-gray-600 mb-4",children:"Topology hidden on mobile for better readability"}),v&&a.length>0&&(0,b.jsx)(l,{sessions:a,sseSessions:L}),0!==a.length||i?(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3 sm:gap-4",children:V.map(a=>(0,b.jsx)(o,{session:a,hasSse:M(a),sseCount:L[a.alias]||0,onChat:D.openTab},a.alias))}):(0,b.jsx)(r,{hint:g}),(0,b.jsx)(p,{messages:G}),(0,b.jsxs)("div",{className:"mt-8 text-center text-xs text-gray-600 flex items-center justify-center gap-2 flex-wrap",children:[K&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${J?"bg-green-400":"bg-gray-600"}`}),J?"SSE live":"SWR polling"]}),u?.license&&(0,b.jsxs)(b.Fragment,{children:[K&&(0,b.jsx)(b.Fragment,{children:"·"}),(0,b.jsxs)("span",{className:u.license.days_left<=7?"text-red-400":"pro"===u.license.type?"text-green-400":"text-yellow-400",children:[u.license.type," (",u.license.days_left,"d left)"]})]})]}),E&&(0,b.jsx)(y,{sessions:a,onClose:()=>F(!1)}),D.tabs.length>0&&(0,b.jsx)(w,{tabs:D.tabs,activeTab:D.activeTab,onOpenTab:D.openTab,onCloseTab:D.closeTab,onSetActive:D.setActiveTab,onClose:D.closeAll})]})}],60350)}];
|
|
1
|
+
module.exports=[60350,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(43515);function f({online:a,working:c,total:d,version:e,uptime:h}){let i=d>0?Math.round(a/d*100):0;return(0,b.jsxs)("div",{className:"mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[(0,b.jsx)("h1",{className:"text-2xl font-bold text-white tracking-tight",children:"Agent Network"}),(0,b.jsxs)("span",{className:"text-xs text-gray-500",children:["CommHub ",e," · ",h]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[(0,b.jsx)(g,{value:a,label:"Online",sub:`${i}% of fleet`,color:"text-green-400",accent:"from-green-500/20 to-green-500/0",border:"border-green-500/15"}),(0,b.jsx)(g,{value:c,label:"Working",sub:a>0?`${Math.round(c/a*100)}% utilization`:"--",color:"text-cyan-400",accent:"from-cyan-500/20 to-cyan-500/0",border:"border-cyan-500/15"}),(0,b.jsx)(g,{value:d-a,label:"Offline",sub:d-a==0?"All systems go":`${d-a} disconnected`,color:"text-gray-400",accent:"from-gray-500/10 to-gray-500/0",border:"border-gray-500/15"}),(0,b.jsx)(g,{value:d,label:"Total",sub:"Registered nodes",color:"text-white",accent:"from-blue-500/15 to-blue-500/0",border:"border-blue-500/15"})]})]})}function g({value:a,label:c,sub:d,color:e,accent:f,border:h}){return(0,b.jsxs)("div",{className:`relative overflow-hidden rounded-xl border ${h} bg-[#111128] px-4 py-3`,children:[(0,b.jsx)("div",{className:`absolute inset-0 bg-gradient-to-br ${f} pointer-events-none`}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:`text-3xl font-bold ${e} tabular-nums leading-tight`,children:a}),(0,b.jsx)("div",{className:"text-sm text-gray-300 mt-0.5",children:c}),(0,b.jsx)("div",{className:"text-xs text-gray-600 mt-1",children:d})]})]})}function h(){let[a,d]=(0,c.useState)(""),[e,f]=(0,c.useState)(!1),[g,h]=(0,c.useState)(""),i=async()=>{if(a.trim()){f(!0),h("");try{let b=await fetch("/api/hub/broadcast",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:a})}),c=await b.json();c.ok?(h(`Broadcast sent to ${c.recipients} node(s)`),d("")):h(`Failed: ${c.error||"Send error"}`)}catch(a){h(`Failed: ${a instanceof Error?a.message:"Send error"}`)}f(!1),setTimeout(()=>h(""),5e3)}};return(0,b.jsxs)("div",{className:"mb-6",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("input",{type:"text",value:a,onChange:a=>d(a.target.value),onKeyDown:a=>"Enter"===a.key&&i(),placeholder:"Broadcast message to all online agents...",maxLength:500,"aria-label":"Broadcast message",className:"flex-1 bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-2.5 text-sm text-white placeholder-gray-600 focus:border-blue-500/50 focus:ring-1 focus:ring-blue-500/20 focus:outline-none transition-colors"}),(0,b.jsx)("button",{onClick:i,disabled:e||!a.trim(),"aria-label":"Send broadcast",className:"px-5 py-2.5 bg-blue-600 hover:bg-blue-500 disabled:bg-gray-800 disabled:text-gray-600 text-white text-sm rounded-lg transition-all font-medium cursor-pointer disabled:cursor-not-allowed",children:e?"Sending...":"Broadcast"})]}),a.length>0&&(0,b.jsxs)("div",{className:"text-right text-xs text-gray-600 mt-1",children:[a.length,"/500"]}),g&&(0,b.jsx)("div",{className:`mt-3 text-sm text-center ${g.startsWith("Failed")?"text-red-400":"text-green-400/80"} animate-fade-in`,children:g})]})}function i(a,b,c){let d=b<=2?Math.PI:1.78*Math.PI,e=-Math.PI/2-d/2,f=b<=1?-Math.PI/2:e+d*a/(b-1);return{x:500+c*Math.cos(f),y:330+c*Math.sin(f)}}function j(a,b,c=0){let d=(a.x+b.x)/2,e=(a.y+b.y)/2,f=b.x-a.x,g=b.y-a.y,h=Math.hypot(f,g)||1,i={x:d+-g/h*c,y:e+f/h*c};return`M${a.x},${a.y} Q${i.x},${i.y} ${b.x},${b.y}`}function k(a,b){return a.length>b?`${a.slice(0,b-1)}...`:a}function l({sessions:a,sseSessions:d}){let[e,f]=(0,c.useState)([]);(0,c.useEffect)(()=>{let a=async()=>{try{let a=await fetch("/api/hub/messages?limit=50");if(401===a.status)return void window.location.assign("/login");let b=await a.json();f(b.messages||[])}catch{}};a();let b=setInterval(a,5e3);return()=>clearInterval(b)},[]);let{onlineNodes:g,offlineNodes:h,nodePositions:m,flowLinks:n,activeAliases:o}=(0,c.useMemo)(()=>{let b,c=a.filter(a=>"offline"!==a.status||d[a.alias]),f=a.filter(a=>"offline"===a.status&&!d[a.alias]),g={};c.forEach((a,b)=>{g[a.alias]=i(b,Math.max(c.length,1),220)}),f.forEach((a,b)=>{g[a.alias]=i(b,Math.max(f.length,1),315)});let h=(b=new Map,e.forEach(a=>{if(!g[a.from_alias]||!g[a.to_alias]||a.from_alias===a.to_alias)return;let c=`${a.from_alias}->${a.to_alias}`,d=b.get(c);b.set(c,{key:c,from:a.from_alias,to:a.to_alias,count:(d?.count||0)+1,content:d?.content||a.content})}),[...b.values()].slice(0,18)),j=new Set;return h.forEach(a=>{j.add(a.from),j.add(a.to)}),{onlineNodes:c,offlineNodes:f,nodePositions:g,flowLinks:h,activeAliases:j}},[e,a,d]),p=g.filter(a=>"working"===a.status).length;return(0,b.jsxs)("section",{className:"w-full max-w-6xl mx-auto mb-8",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between mb-3 px-1",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-xs uppercase text-gray-600 tracking-wider",children:"Network Topology"}),(0,b.jsx)("h2",{className:"text-lg text-white font-semibold",children:"Command mesh"})]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-green-500/10 text-green-300 border border-green-500/20",children:[p," working"]}),(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-cyan-500/10 text-cyan-300 border border-cyan-500/20",children:[g.length," online"]}),(0,b.jsxs)("span",{className:"px-2.5 py-1 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20",children:[n.length," active links"]})]})]}),(0,b.jsxs)("div",{className:"relative overflow-hidden rounded-lg border border-[#2a2a4a] bg-[#080814] shadow-2xl shadow-cyan-950/30",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-cyan-400/70 to-transparent"}),(0,b.jsxs)("svg",{viewBox:"0 0 1000 680",className:"w-full h-auto block",preserveAspectRatio:"xMidYMid meet",children:[(0,b.jsxs)("defs",{children:[(0,b.jsxs)("linearGradient",{id:"topo-panel",x1:"0",x2:"1",y1:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"0%",stopColor:"#0b1220"}),(0,b.jsx)("stop",{offset:"48%",stopColor:"#080814"}),(0,b.jsx)("stop",{offset:"100%",stopColor:"#101018"})]}),(0,b.jsxs)("radialGradient",{id:"topo-radar",cx:"50%",cy:"50%",r:"55%",children:[(0,b.jsx)("stop",{offset:"0%",stopColor:"#22d3ee",stopOpacity:"0.18"}),(0,b.jsx)("stop",{offset:"45%",stopColor:"#22c55e",stopOpacity:"0.045"}),(0,b.jsx)("stop",{offset:"100%",stopColor:"#020617",stopOpacity:"0"})]}),(0,b.jsxs)("filter",{id:"topo-glow",children:[(0,b.jsx)("feGaussianBlur",{stdDeviation:"4",result:"blur"}),(0,b.jsxs)("feMerge",{children:[(0,b.jsx)("feMergeNode",{in:"blur"}),(0,b.jsx)("feMergeNode",{in:"SourceGraphic"})]})]}),(0,b.jsx)("marker",{id:"topo-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto-start-reverse",children:(0,b.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#67e8f9"})})]}),(0,b.jsx)("rect",{width:"1000",height:"680",fill:"url(#topo-panel)"}),(0,b.jsx)("circle",{cx:500,cy:330,r:"330",fill:"url(#topo-radar)"}),[90,170,250,330].map(a=>(0,b.jsx)("circle",{cx:500,cy:330,r:a,fill:"none",stroke:"#164e63",strokeWidth:"1",opacity:"0.35"},a)),[0,30,60,90,120,150].map(a=>(0,b.jsx)("line",{x1:500-360*Math.cos(a*Math.PI/180),y1:330-360*Math.sin(a*Math.PI/180),x2:500+360*Math.cos(a*Math.PI/180),y2:330+360*Math.sin(a*Math.PI/180),stroke:"#164e63",strokeWidth:"1",opacity:"0.18"},a)),g.map(a=>{let c=m[a.alias];if(!c)return null;let d=j({x:500,y:330},c,0);return(0,b.jsx)("path",{d:d,fill:"none",stroke:o.has(a.alias)?"#22d3ee":"#155e75",strokeWidth:o.has(a.alias)?2:1,strokeDasharray:o.has(a.alias)?"none":"8 10",opacity:o.has(a.alias)?.65:.35},`hub-${a.alias}`)}),n.map((a,c)=>{let d=m[a.from],e=m[a.to];if(!d||!e)return null;let f=j(d,e,c%2==0?36:-36),g=Math.min(2+a.count,7);return(0,b.jsxs)("g",{children:[(0,b.jsx)("path",{d:f,fill:"none",stroke:"#67e8f9",strokeWidth:g,opacity:"0.28",filter:"url(#topo-glow)",markerEnd:"url(#topo-arrow)"}),(0,b.jsx)("path",{id:`flow-path-${c}`,d:f,fill:"none",stroke:"#e0f2fe",strokeWidth:"1",strokeDasharray:"2 12",opacity:"0.75"}),(0,b.jsx)("circle",{r:"4",fill:"#fef08a",filter:"url(#topo-glow)",children:(0,b.jsx)("animateMotion",{dur:`${2.2+c%5*.32}s`,repeatCount:"indefinite",path:f})})]},a.key)}),(0,b.jsxs)("g",{filter:"url(#topo-glow)",children:[(0,b.jsx)("circle",{cx:500,cy:330,r:"56",fill:"#020617",stroke:"#67e8f9",strokeWidth:"2"}),(0,b.jsxs)("circle",{cx:500,cy:330,r:"42",fill:"none",stroke:"#22c55e",strokeWidth:"1.5",opacity:"0.8",children:[(0,b.jsx)("animate",{attributeName:"r",values:"42;52;42",dur:"3s",repeatCount:"indefinite"}),(0,b.jsx)("animate",{attributeName:"opacity",values:"0.8;0.2;0.8",dur:"3s",repeatCount:"indefinite"})]}),(0,b.jsx)("path",{d:"M470 330 h60 M500 300 v60",stroke:"#e0f2fe",strokeWidth:"5",strokeLinecap:"round",opacity:"0.9"}),(0,b.jsx)("text",{x:500,y:408,textAnchor:"middle",fill:"#e5e7eb",fontSize:"16",fontFamily:"monospace",fontWeight:"700",children:"DASHBOARD"}),(0,b.jsx)("text",{x:500,y:426,textAnchor:"middle",fill:"#64748b",fontSize:"10",fontFamily:"monospace",children:"command relay"})]}),[...g,...h].map(a=>{let c=m[a.alias];if(!c)return null;let e="offline"!==a.status||!!d[a.alias],f=e?"working"===a.status?{label:"working",primary:"#22c55e",halo:"#14532d",text:"#dcfce7"}:"idle"===a.status?{label:"idle",primary:"#2dd4bf",halo:"#134e4a",text:"#ccfbf1"}:{label:a.status||"online",primary:"#38bdf8",halo:"#0c4a6e",text:"#e0f2fe"}:{label:"offline",primary:"#6b7280",halo:"#111827",text:"#9ca3af"},g=o.has(a.alias),h=e?26:18;return(0,b.jsxs)("g",{className:"transition-opacity",children:[g&&(0,b.jsxs)("circle",{cx:c.x,cy:c.y,r:h+14,fill:f.primary,opacity:"0.12",children:[(0,b.jsx)("animate",{attributeName:"r",values:`${h+8};${h+22};${h+8}`,dur:"2.4s",repeatCount:"indefinite"}),(0,b.jsx)("animate",{attributeName:"opacity",values:"0.18;0.04;0.18",dur:"2.4s",repeatCount:"indefinite"})]}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:h+8,fill:f.halo,opacity:e?.55:.25}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:h,fill:e?"#020617":"#080814",stroke:f.primary,strokeWidth:e?3:1.5,strokeDasharray:e?"none":"5 5",filter:e?"url(#topo-glow)":void 0}),(0,b.jsx)("circle",{cx:c.x,cy:c.y,r:e?8:5,fill:f.primary}),"working"===a.status&&(0,b.jsx)("path",{d:`M${c.x-9},${c.y+11} h18`,stroke:"#fef08a",strokeWidth:"3",strokeLinecap:"round",children:(0,b.jsx)("animate",{attributeName:"opacity",values:"1;0.25;1",dur:"1.1s",repeatCount:"indefinite"})}),(0,b.jsxs)("g",{transform:`translate(${c.x}, ${c.y+h+22})`,children:[(0,b.jsx)("rect",{x:"-62",y:"-14",width:"124",height:"42",rx:"6",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("text",{x:"0",y:"1",textAnchor:"middle",fill:f.text,fontSize:"12",fontFamily:"monospace",fontWeight:"700",children:k(a.alias,14)}),(0,b.jsxs)("text",{x:"0",y:"17",textAnchor:"middle",fill:f.primary,fontSize:"9",fontFamily:"monospace",children:[f.label," ",e?`sse:${d[a.alias]}`:""]})]})]},a.alias)}),(0,b.jsxs)("g",{transform:"translate(28, 34)",children:[(0,b.jsx)("rect",{x:"0",y:"0",width:"285",height:60+20*Math.min(n.length,4),rx:"8",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("text",{x:"16",y:"26",fill:"#e5e7eb",fontSize:"13",fontFamily:"monospace",fontWeight:"700",children:"recent signal"}),(0,b.jsxs)("text",{x:"178",y:"26",fill:"#67e8f9",fontSize:"11",fontFamily:"monospace",children:[e.length," messages"]}),n.slice(0,4).map((a,c)=>(0,b.jsxs)("text",{x:"16",y:54+20*c,fill:"#94a3b8",fontSize:"10",fontFamily:"monospace",children:[k(a.from,8)," ","->"," ",k(a.to,8)," / ",a.count," / ",k(a.content,18)]},a.key))]}),(0,b.jsxs)("g",{transform:"translate(720, 34)",children:[(0,b.jsx)("rect",{x:"0",y:"0",width:"250",height:"112",rx:"8",fill:"#020617",stroke:"#1f2937",opacity:"0.94"}),(0,b.jsx)("circle",{cx:"18",cy:"26",r:"6",fill:"#22c55e"}),(0,b.jsx)("text",{x:"34",y:"30",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"working node"}),(0,b.jsx)("circle",{cx:"18",cy:"52",r:"6",fill:"#2dd4bf"}),(0,b.jsx)("text",{x:"34",y:"56",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"online idle"}),(0,b.jsx)("circle",{cx:"18",cy:"78",r:"6",fill:"#6b7280"}),(0,b.jsx)("text",{x:"34",y:"82",fill:"#94a3b8",fontSize:"11",fontFamily:"monospace",children:"offline / no SSE"}),(0,b.jsx)("path",{d:"M150,78 Q176,52 210,78",fill:"none",stroke:"#67e8f9",strokeWidth:"3",markerEnd:"url(#topo-arrow)"})]})]})]})]})}let m={working:{bg:"bg-green-900/30 border-green-800/30",text:"text-green-300",dot:"bg-green-500",glow:"shadow-green-500/10"},idle:{bg:"bg-cyan-900/30 border-cyan-800/30",text:"text-cyan-300",dot:"bg-cyan-400",glow:"shadow-cyan-500/5"},blocked:{bg:"bg-yellow-900/30 border-yellow-800/30",text:"text-yellow-300",dot:"bg-yellow-500",glow:""},error:{bg:"bg-red-900/30 border-red-800/30",text:"text-red-300",dot:"bg-red-500",glow:""}},n={bg:"bg-gray-800/50 border-gray-700/30",text:"text-gray-500",dot:"bg-gray-500",glow:""};function o({session:a,hasSse:c,sseCount:f,onChat:g}){let h=c&&m[a.status]||n;return(0,b.jsxs)(d.default,{href:`/node?alias=${encodeURIComponent(a.alias)}`,prefetch:!1,className:`block rounded-xl border p-4 transition-all duration-300 cursor-pointer ${c?`bg-[#111128] border-[#2a2a4a] hover:border-cyan-500/30 hover:shadow-lg ${h.glow}`:"bg-[#0d0d1a] border-[#1a1a2a] opacity-40"}`,children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 ${h.dot} ${c&&"working"===a.status?"animate-pulse":""}`}),(0,b.jsx)("span",{className:"font-semibold text-white truncate text-sm",title:a.alias,children:a.alias})]}),(0,b.jsx)("span",{className:`text-[11px] px-2 py-0.5 rounded-md border shrink-0 ${h.bg} ${h.text}`,children:c?a.status:"offline"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,b.jsx)("span",{className:"text-xs text-gray-600 bg-[#0a0a15] px-2 py-0.5 rounded border border-[#1a1a2a]",children:a.agent||"unknown"}),c&&(0,b.jsxs)("span",{className:"text-[10px] text-green-500",children:["SSE:",f]})]}),a.task?(0,b.jsx)("div",{className:"text-xs text-gray-400 bg-[#0a0a15] rounded-lg px-3 py-2 border border-[#1a1a2a] line-clamp-2",title:a.task,children:a.task}):(0,b.jsx)("div",{className:"text-xs text-gray-700 italic",children:"No active task"}),a.progress>0&&(0,b.jsxs)("div",{className:"mt-3",children:[(0,b.jsxs)("div",{className:"flex justify-between text-[10px] mb-1",children:[(0,b.jsx)("span",{className:"text-gray-600",children:"Progress"}),(0,b.jsxs)("span",{className:h.text,children:[a.progress,"%"]})]}),(0,b.jsx)("div",{className:"w-full bg-gray-800 rounded-full h-1.5 overflow-hidden",children:(0,b.jsx)("div",{className:`h-1.5 rounded-full transition-all duration-700 ${"working"===a.status?"bg-green-500":"bg-cyan-500"}`,style:{width:`${Math.min(a.progress,100)}%`}})})]}),(0,b.jsxs)("div",{className:"mt-3 flex justify-between items-center text-[10px] text-gray-600",children:[(0,b.jsx)("span",{children:a.server||"--"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[g&&c&&(0,b.jsx)("button",{onClick:b=>{b.preventDefault(),b.stopPropagation(),g(a.alias)},className:"text-cyan-400 hover:text-cyan-300 px-1.5 py-0.5 rounded border border-cyan-500/20 hover:bg-cyan-500/10 transition-colors",children:"Chat"}),(0,b.jsx)("span",{children:(0,e.timeAgo)(a.updated_at)})]})]})]})}function p({messages:a}){return 0===a.length?null:(0,b.jsxs)("div",{className:"mt-8",children:[(0,b.jsxs)("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-gray-500",children:"Inbox"}),(0,b.jsx)("span",{className:"text-xs bg-blue-900/30 text-blue-400 px-2 py-0.5 rounded-full border border-blue-800/30",children:a.length})]}),(0,b.jsx)("div",{className:"space-y-2 max-h-96 overflow-y-auto pr-1 scrollbar-thin",children:a.map(a=>(0,b.jsxs)("div",{className:"bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-3 text-sm transition-colors hover:border-[#3a3a5a]",children:[(0,b.jsxs)("div",{className:"flex justify-between text-xs text-gray-500 mb-1.5",children:[(0,b.jsx)("span",{className:"text-blue-400 font-medium",children:a.from_session}),(0,b.jsx)("span",{children:a.created_at})]}),(0,b.jsx)("div",{className:"text-gray-300 leading-relaxed",children:a.content})]},a.id))})]})}function q(){return(0,b.jsxs)("div",{className:"min-h-screen bg-[#0a0a1a] text-gray-100 p-6 font-mono animate-pulse",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-8",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"h-7 w-48 bg-gray-800 rounded mb-2"}),(0,b.jsx)("div",{className:"h-4 w-64 bg-gray-800/60 rounded"})]}),(0,b.jsx)("div",{className:"flex gap-3",children:[1,2,3].map(a=>(0,b.jsx)("div",{className:"w-[72px] h-[60px] bg-gray-800/40 rounded-lg border border-gray-800"},a))})]}),(0,b.jsxs)("div",{className:"mb-6 flex gap-2",children:[(0,b.jsx)("div",{className:"flex-1 h-10 bg-gray-800/40 rounded-lg"}),(0,b.jsx)("div",{className:"w-28 h-10 bg-gray-800/40 rounded-lg"})]}),(0,b.jsx)("div",{className:"w-full max-w-4xl mx-auto mb-8 h-64 bg-gray-800/20 rounded-xl"}),(0,b.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(a=>(0,b.jsxs)("div",{className:"rounded-xl border border-gray-800/40 p-4 bg-gray-800/20",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,b.jsx)("div",{className:"w-2.5 h-2.5 rounded-full bg-gray-700"}),(0,b.jsx)("div",{className:"h-4 w-24 bg-gray-700 rounded"})]}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)("div",{className:"h-3 w-full bg-gray-800/60 rounded"}),(0,b.jsx)("div",{className:"h-3 w-3/4 bg-gray-800/60 rounded"}),(0,b.jsx)("div",{className:"h-3 w-1/2 bg-gray-800/60 rounded"})]})]},a))})]})}function r({hint:a}){return(0,b.jsxs)("div",{className:"text-center py-16",children:[(0,b.jsx)("div",{className:"text-gray-600 text-4xl mb-4",children:"--"}),(0,b.jsx)("h3",{className:"text-gray-400 text-lg font-medium mb-2",children:"No agents in this network"}),a?.global_count?(0,b.jsxs)("p",{className:"text-gray-500 text-sm max-w-md mx-auto",children:["Server has ",(0,b.jsx)("span",{className:"text-cyan-400 font-medium",children:a.global_count})," nodes globally, but none are registered to the current network. Switch network or contact admin."]}):(0,b.jsx)("p",{className:"text-gray-600 text-sm max-w-md mx-auto",children:"Agent sessions will appear here once they connect to the CommHub."})]})}var s=a.i(22397);function t(){let{setNetworkId:a}=(0,s.useNetworkId)(),[d,e]=(0,c.useState)({user:null,networks:[],currentNetwork:"",token:""}),[f,g]=(0,c.useState)(!1),[h,i]=(0,c.useState)(""),[j,k]=(0,c.useState)(""),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=sessionStorage.getItem("anet_v3_auth");if(a)try{e(JSON.parse(a))}catch{}},[]);let[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(""),[u,v]=(0,c.useState)(""),w=async()=>{try{await fetch(`/api/hub/auth?token=${d.token}&endpoint=/api/auth/me`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update_profile",token:d.token,display_name:r,email:u})});let a=await fetch("/api/hub/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"update_profile",token:d.token,display_name:r,email:u})}),b=await a.json();if(b.ok&&b.user){let a={...d,user:b.user};e(a),sessionStorage.setItem("anet_v3_auth",JSON.stringify(a)),q(!1)}}catch{}};if(!d.user)return null;let x=(d.user.display_name||d.user.username).slice(0,2).toUpperCase();return(0,b.jsxs)("div",{className:"flex items-center justify-between bg-[#111128] border border-[#2a2a4a] rounded-lg px-4 py-2.5 mb-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-cyan-500 to-blue-600 flex items-center justify-center text-xs font-bold text-white",children:x}),(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm text-white font-medium",children:d.user.display_name||d.user.username}),(0,b.jsxs)("div",{className:"text-[10px] text-gray-500",children:[d.user.role," · ",d.user.user_id]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[d.networks.length>0&&(0,b.jsx)("select",{value:d.currentNetwork,onChange:b=>{let c={...d,currentNetwork:b.target.value};e(c),a(b.target.value),sessionStorage.setItem("anet_v3_auth",JSON.stringify(c))},className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white focus:outline-none",children:d.networks.map(a=>(0,b.jsx)("option",{value:a.network_id,children:a.network_name},a.network_id))}),(0,b.jsx)("button",{onClick:()=>{t(d.user?.display_name||""),v(""),q(!p)},className:"text-xs text-gray-500 hover:text-gray-300",children:"Edit"}),(0,b.jsx)("button",{onClick:()=>{e({user:null,networks:[],currentNetwork:"",token:""}),sessionStorage.removeItem("anet_v3_auth")},className:"text-xs text-gray-500 hover:text-gray-300",children:"Sign out"})]}),p&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mt-2 pt-2 border-t border-[#2a2a4a]",children:[(0,b.jsx)("input",{type:"text",value:r,onChange:a=>t(a.target.value),placeholder:"Display name",className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white placeholder-gray-600 focus:outline-none w-32"}),(0,b.jsx)("input",{type:"email",value:u,onChange:a=>v(a.target.value),placeholder:"Email",className:"bg-[#0a0a15] border border-[#2a2a4a] rounded px-2 py-1 text-xs text-white placeholder-gray-600 focus:outline-none w-40"}),(0,b.jsx)("button",{onClick:w,className:"px-2 py-1 bg-cyan-600 hover:bg-cyan-500 text-white text-xs rounded",children:"Save"})]})]})}var u=a.i(31626),v=a.i(15261);function w({tabs:a,activeTab:c,onOpenTab:d,onCloseTab:e,onSetActive:f,onClose:g}){return 0===a.length?null:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{onClick:g,className:"jsx-f7cf3d1a6fdfc074 fixed inset-0 bg-black/30 z-40 lg:hidden"}),(0,b.jsxs)("div",{className:"jsx-f7cf3d1a6fdfc074 fixed top-0 right-0 h-full w-full lg:w-[500px] bg-[#0a0a1a] border-l border-[#2a2a4a] z-50 flex flex-col shadow-2xl shadow-black/60 animate-slide-in",children:[(0,b.jsxs)("div",{className:"jsx-f7cf3d1a6fdfc074 flex items-center border-b border-[#2a2a4a] bg-[#0d0d1a] overflow-x-auto",children:[(0,b.jsx)("div",{className:"jsx-f7cf3d1a6fdfc074 flex-1 flex min-w-0",children:a.map(a=>(0,b.jsxs)("button",{onClick:()=>f(a),className:`jsx-f7cf3d1a6fdfc074 flex items-center gap-1.5 px-3 py-2.5 text-xs border-b-2 transition-colors shrink-0 ${c===a?"border-cyan-400 text-cyan-300 bg-cyan-500/5":"border-transparent text-gray-500 hover:text-gray-300"}`,children:[(0,b.jsx)("div",{className:`jsx-f7cf3d1a6fdfc074 w-2 h-2 rounded-full ${c===a?"bg-cyan-400":"bg-gray-600"}`}),(0,b.jsx)("span",{className:"jsx-f7cf3d1a6fdfc074 max-w-[80px] truncate",children:a}),(0,b.jsx)("button",{onClick:b=>{b.stopPropagation(),e(a)},className:"jsx-f7cf3d1a6fdfc074 ml-1 text-gray-600 hover:text-gray-300 p-0.5",children:"×"})]},a))}),(0,b.jsx)("button",{onClick:g,className:"jsx-f7cf3d1a6fdfc074 text-gray-500 hover:text-white px-3 py-2.5 shrink-0 border-l border-[#2a2a4a]",children:(0,b.jsx)("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,className:"jsx-f7cf3d1a6fdfc074 w-4 h-4",children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12",className:"jsx-f7cf3d1a6fdfc074"})})})]}),(0,b.jsx)("div",{className:"jsx-f7cf3d1a6fdfc074 flex-1 relative overflow-hidden",children:a.map(a=>(0,b.jsx)("div",{className:`jsx-f7cf3d1a6fdfc074 absolute inset-0 ${c===a?"block":"hidden"}`,children:(0,b.jsx)(x,{alias:a})},a))})]}),(0,b.jsx)(u.default,{id:"f7cf3d1a6fdfc074",children:"@keyframes slide-in{0%{transform:translate(100%)}to{transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}"})]})}function x({alias:a}){return(0,b.jsx)(v.TaskChatPanel,{alias:a,onClose:()=>{},inline:!0})}function y({sessions:a,onClose:d}){let[e,f]=(0,c.useState)(new Set),[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)("normal"),[k,l]=(0,c.useState)(!1),[m,n]=(0,c.useState)([]),[o,p]=(0,c.useState)(""),q=a.filter(a=>"offline"!==a.status).filter(a=>!o||a.alias.toLowerCase().includes(o.toLowerCase())||(a.agent||"").toLowerCase().includes(o.toLowerCase())),r=async()=>{if(!g.trim()||0===e.size||k)return;l(!0),n([]);let a=[...e].map(async a=>{try{let b=await fetch("/api/hub/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({alias:a,task:g,priority:i})}),c=await b.json();return{alias:a,ok:!!c.ok,error:c.error}}catch(b){return{alias:a,ok:!1,error:"send failed"}}});n(await Promise.all(a)),l(!1)},s=m.filter(a=>a.ok).length;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40",onClick:d}),(0,b.jsxs)("div",{className:"fixed inset-4 lg:inset-x-[15%] lg:inset-y-[5%] bg-[#0a0a1a] border border-[#2a2a4a] rounded-2xl z-50 flex flex-col shadow-2xl shadow-black/70 overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-[#2a2a4a] bg-[#0d0d1a]",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-lg font-bold text-white",children:"Dispatch Task"}),(0,b.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Send a task to one or more agents"})]}),(0,b.jsx)("button",{onClick:d,className:"text-gray-500 hover:text-white p-1.5 rounded-lg hover:bg-[#1a1a2a]",children:(0,b.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col lg:flex-row overflow-hidden",children:[(0,b.jsxs)("div",{className:"lg:w-[280px] border-b lg:border-b-0 lg:border-r border-[#2a2a4a] flex flex-col",children:[(0,b.jsxs)("div",{className:"px-4 py-3 border-b border-[#2a2a4a]",children:[(0,b.jsx)("input",{type:"text",value:o,onChange:a=>p(a.target.value),placeholder:"Filter agents...",className:"w-full bg-[#111128] border border-[#2a2a4a] rounded-lg px-3 py-2 text-xs text-white placeholder-gray-600 focus:border-cyan-500/40 focus:outline-none"}),(0,b.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,b.jsx)("button",{onClick:()=>{e.size===q.length?f(new Set):f(new Set(q.map(a=>a.alias)))},className:"text-[10px] text-cyan-400 hover:text-cyan-300",children:e.size===q.length?"Deselect all":`Select all (${q.length})`}),(0,b.jsxs)("span",{className:"text-[10px] text-gray-600",children:[e.size," selected"]})]})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto px-2 py-2 space-y-0.5 max-h-[200px] lg:max-h-none",children:[q.map(a=>(0,b.jsxs)("button",{onClick:()=>{var b;return b=a.alias,void f(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-xs text-left transition-colors ${e.has(a.alias)?"bg-cyan-500/10 text-cyan-300 border border-cyan-500/20":"text-gray-400 hover:bg-[#1a1a2a]"}`,children:[(0,b.jsx)("div",{className:`w-2 h-2 rounded-full shrink-0 ${"working"===a.status?"bg-green-400":"idle"===a.status?"bg-cyan-400":"bg-gray-500"}`}),(0,b.jsx)("span",{className:"truncate flex-1",children:a.alias}),(0,b.jsx)("span",{className:"text-[9px] text-gray-600",children:a.agent||"--"})]},a.alias)),0===q.length&&(0,b.jsx)("div",{className:"text-center text-xs text-gray-600 py-4",children:"No online agents"})]})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsxs)("div",{className:"flex-1 px-6 py-4 flex flex-col",children:[(0,b.jsx)("label",{className:"text-xs text-gray-500 uppercase mb-2",children:"Task Prompt"}),(0,b.jsx)("textarea",{value:g,onChange:a=>h(a.target.value),placeholder:"Enter the task you want to dispatch...",className:"flex-1 min-h-[120px] bg-[#111128] border border-[#2a2a4a] rounded-xl px-4 py-3 text-sm text-white placeholder-gray-600 focus:border-cyan-500/40 focus:outline-none resize-none"}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mt-4",children:[(0,b.jsxs)("select",{value:i,onChange:a=>j(a.target.value),className:"bg-[#111128] border border-[#2a2a4a] rounded-lg px-3 py-2 text-xs text-white focus:outline-none",children:[(0,b.jsx)("option",{value:"normal",children:"Normal priority"}),(0,b.jsx)("option",{value:"high",children:"High priority"}),(0,b.jsx)("option",{value:"low",children:"Low priority"})]}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsx)("button",{onClick:r,disabled:k||!g.trim()||0===e.size,className:"px-6 py-2.5 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-500 hover:to-blue-500 disabled:from-gray-800 disabled:to-gray-800 disabled:text-gray-600 text-white text-sm font-medium rounded-xl transition-all shadow-lg shadow-cyan-500/10 disabled:shadow-none active:scale-95",children:k?(0,b.jsxs)("span",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),"Sending..."]}):`Dispatch to ${e.size} agent${e.size>1?"s":""}`})]})]}),m.length>0&&(0,b.jsxs)("div",{className:"px-6 py-3 border-t border-[#2a2a4a] bg-[#0d0d1a]",children:[(0,b.jsxs)("div",{className:"text-xs text-gray-500 mb-2",children:[s,"/",m.length," dispatched successfully"]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m.map(a=>(0,b.jsxs)("span",{className:`text-[10px] px-2 py-0.5 rounded-full border ${a.ok?"text-green-300 border-green-500/20 bg-green-500/5":"text-red-300 border-red-500/20 bg-red-500/5"}`,children:[a.alias,": ",a.ok?"✓":a.error||"✗"]},a.alias))})]})]})]})]})]})}var z=a.i(44332),A=a.i(58224),B=a.i(64565);a.s(["default",0,function(){(0,c.useEffect)(()=>{sessionStorage.getItem("anet_v3_auth")||(fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),window.location.assign("/login"))},[]);let{sessions:a,hint:g,error:i,isLoading:j}=(0,z.useSessions)(),{health:k}=(0,z.useHealth)(),{config:m}=(0,z.useAnetConfig)(),{tasks:n}=(0,z.useTasks)({limit:"500"}),{stats:s}=(0,z.useStats)(),{license:u}=(0,z.useLicense)(),[v,x]=(0,c.useState)(!1),[C,D]=(0,c.useState)(!1),E=function(){let[a,b]=(0,c.useState)([]),[d,e]=(0,c.useState)("");return{tabs:a,activeTab:d,openTab:a=>{b(b=>b.includes(a)?b:[...b,a]),e(a)},closeTab:a=>{b(b=>{let c=b.filter(b=>b!==a);return d===a&&e(c[c.length-1]||""),c})},closeAll:()=>{b([]),e("")},setActiveTab:e}}(),[F,G]=(0,c.useState)(!1),[H,I]=(0,c.useState)([]),{mutate:J}=(0,B.useSWRConfig)(),K="1"!==process.env.NEXT_PUBLIC_DISABLE_SSE,{connected:L,supported:M}=(0,A.useSSE)({url:"/api/hub/events",enabled:K,onEvent:a=>{["new_task","new_message","new_reply","node_status_changed","broadcast"].includes(a.type)&&(J("/api/hub/status"),J(a=>"string"==typeof a&&a.startsWith("/api/hub/tasks"),void 0,{revalidate:!0}))}});if((0,c.useEffect)(()=>{let a=()=>{fetch("/api/hub/inbox").then(a=>a.json()).then(a=>{a.messages?.length&&I(b=>{let c=new Set(b.map(a=>a.id));return[...a.messages.filter(a=>!c.has(a.id)),...b].slice(0,100)})}).catch(()=>{})};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),j)return(0,b.jsx)(q,{});let N=k?.sse_sessions||{},O=a=>"offline"!==a.status||!!N[a.alias],P=a.filter(O).length,Q=a.length,R=a.filter(a=>"working"===a.status).length,S=k?(0,e.formatUptime)(k.uptime):"--",T=k?.version||"--",U=!!(m?.hub&&m.tokenConfigured),V=m?.source==="file"?"Local config":m?.source==="runtime-env"?"Runtime env":"Config missing",W={};if(s?.tasks?.by_status?.length)for(let a of s.tasks.by_status)W[a.status]=a.count;else for(let a of n)W[a.status]=(W[a.status]||0)+1;let X=[...a].sort((a,b)=>{let c=+!!O(a),d=+!!O(b);if(c!==d)return d-c;let e=+("working"===a.status);return("working"===b.status)-e});return(0,b.jsxs)("div",{className:"min-h-screen bg-[#0a0a1a] text-gray-100 p-4 sm:p-6 font-mono",children:[(0,b.jsx)("div",{className:"lg:ml-0 ml-10",children:(0,b.jsx)(f,{online:P,working:R,total:Q,version:T,uptime:S})}),(0,b.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,b.jsx)("button",{onClick:()=>G(!0),className:"px-4 py-2 bg-gradient-to-r from-cyan-600 to-blue-600 hover:from-cyan-500 hover:to-blue-500 text-white text-sm font-medium rounded-xl shadow-lg shadow-cyan-500/10 transition-all active:scale-95 shrink-0",children:"⚡ Dispatch"}),(0,b.jsx)("div",{className:"flex-1",children:(0,b.jsx)(t,{})})]}),(0,b.jsxs)("section",{className:"mb-6 rounded-lg border border-[#2a2a4a] bg-[#111128] px-4 py-3 shadow-lg shadow-black/20",children:[(0,b.jsxs)("button",{onClick:()=>D(!C),className:"w-full flex items-center justify-between text-left",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"uppercase text-gray-600",children:"Config"}),(0,b.jsx)("span",{className:`w-2 h-2 rounded-full ${U?"bg-green-400":"bg-red-400"}`}),(0,b.jsx)("span",{className:"text-gray-500",children:V})]}),(0,b.jsx)("svg",{className:`w-4 h-4 text-gray-600 transition-transform ${C?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,b.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),C&&(0,b.jsxs)("div",{className:"mt-3 pt-3 border-t border-[#2a2a4a]",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,b.jsx)("div",{className:"min-w-0",children:(0,b.jsxs)("div",{className:"text-gray-100 truncate text-sm",title:m?.hub||void 0,children:["Hub: ",(0,b.jsx)("span",{className:m?.hub?"text-cyan-300":"text-red-300",children:m?.hub?.trim()||"not configured"})]})}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 text-xs",children:(0,b.jsxs)("span",{className:`px-2.5 py-1 rounded-md border ${m?.tokenConfigured?"bg-blue-500/5 text-blue-300 border-blue-500/20":"bg-gray-500/5 text-gray-400 border-gray-500/20"}`,children:["Token: ",m?.tokenPreview||"not configured"]})})]}),m?.error&&(0,b.jsx)("div",{className:"mt-2 text-xs text-gray-600",children:m.error})]})]}),Object.keys(W).length>0&&(0,b.jsxs)("section",{className:"mb-6 rounded-lg border border-[#2a2a4a] bg-[#111128] px-4 py-3 shadow-lg shadow-black/20",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,b.jsx)("div",{className:"text-xs uppercase text-gray-600",children:"Task Status"}),(0,b.jsx)(d.default,{href:"/tasks",prefetch:!1,className:"text-xs text-cyan-400 hover:text-cyan-300",children:"View all →"})]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2",children:[{key:"running",color:"bg-green-500/10 text-green-300 border-green-500/20"},{key:"delivered",color:"bg-blue-500/10 text-blue-300 border-blue-500/20"},{key:"acked",color:"bg-cyan-500/10 text-cyan-300 border-cyan-500/20"},{key:"replied",color:"bg-purple-500/10 text-purple-300 border-purple-500/20"},{key:"failed",color:"bg-red-500/10 text-red-300 border-red-500/20"},{key:"cancelled",color:"bg-yellow-500/10 text-yellow-300 border-yellow-500/20"},{key:"expired",color:"bg-orange-500/10 text-orange-300 border-orange-500/20"},{key:"closed",color:"bg-gray-500/10 text-gray-500 border-gray-500/20"}].filter(({key:a})=>W[a]).map(({key:a,color:c})=>(0,b.jsxs)(d.default,{href:`/tasks?status=${a}`,prefetch:!1,className:`px-2.5 py-1 rounded-md border text-xs ${c} hover:opacity-80 transition-opacity`,children:[a,": ",W[a]]},a))})]}),(0,b.jsx)("section",{className:"mb-6 grid grid-cols-3 sm:grid-cols-6 gap-2",children:[{href:"/nodes",label:"Nodes",value:`${P}/${Q}`,color:"text-green-400 border-green-500/15"},{href:"/tasks",label:"Tasks",value:String(Object.values(W).reduce((a,b)=>a+b,0)||"--"),color:"text-cyan-400 border-cyan-500/15"},{href:"/tasks?status=failed",label:"Failed",value:String(W.failed||0),color:W.failed?"text-red-400 border-red-500/20":"text-gray-600 border-gray-700/30"},{href:"/messages",label:"Messages",value:"→",color:"text-blue-400 border-blue-500/15"},{href:"/logs",label:"Logs",value:"→",color:"text-purple-400 border-purple-500/15"},{href:"/admin",label:"Admin",value:"→",color:"text-gray-400 border-gray-500/15"}].map(a=>(0,b.jsxs)(d.default,{href:a.href,prefetch:!1,className:`text-center rounded-xl border ${a.color} bg-[#111128] px-3 py-2.5 hover:bg-[#161630] transition-colors`,children:[(0,b.jsx)("div",{className:`text-lg font-bold tabular-nums ${a.color.split(" ")[0]}`,children:a.value}),(0,b.jsx)("div",{className:"text-[10px] text-gray-500",children:a.label})]},a.href))}),(0,b.jsx)(h,{}),n.length>0&&(0,b.jsxs)("section",{className:"mb-6 bg-[#111128] border border-[#2a2a4a] rounded-xl p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-gray-300",children:"Recent Activity"}),(0,b.jsx)(d.default,{href:"/tasks",className:"text-xs text-cyan-400 hover:text-cyan-300",children:"All tasks →"})]}),(0,b.jsx)("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:n.slice(0,5).map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${"replied"===a.status?"bg-purple-400":"running"===a.status?"bg-green-400":"failed"===a.status?"bg-red-400":"bg-blue-400"}`}),(0,b.jsx)("span",{className:"text-blue-400 shrink-0",children:a.from_name||"?"}),(0,b.jsx)("span",{className:"text-gray-600",children:"→"}),(0,b.jsx)("span",{className:"text-cyan-400 shrink-0",children:a.to_name||"?"}),(0,b.jsx)("span",{className:"text-gray-500 truncate flex-1",children:a.content?.slice(0,40)||"--"}),(0,b.jsx)("span",{className:`shrink-0 px-1.5 py-0.5 rounded text-[10px] border ${"replied"===a.status?"text-purple-300 border-purple-500/20":"failed"===a.status?"text-red-300 border-red-500/20":"text-gray-500 border-gray-700/30"}`,children:a.status})]},a.task_id))})]}),i&&(0,b.jsxs)("div",{className:"bg-red-900/20 border border-red-800/40 text-red-300 px-4 py-3 rounded-lg mb-6 text-sm flex items-center justify-between",role:"alert",children:[(0,b.jsx)("span",{children:String(i)}),(0,b.jsx)("span",{className:"text-gray-500 text-xs",children:"Check CommHub connection"})]}),a.length>0&&(0,b.jsx)("div",{className:"flex justify-center mb-4",children:(0,b.jsx)("button",{onClick:()=>x(!v),className:"text-xs text-gray-500 hover:text-gray-300 border border-gray-700/50 px-4 py-1.5 rounded-lg transition-colors hover:border-gray-600 cursor-pointer",children:v?"Hide Topology":"Show Topology"})}),!v&&a.length>0&&(0,b.jsx)("div",{className:"lg:hidden text-center text-xs text-gray-600 mb-4",children:"Topology hidden on mobile for better readability"}),v&&a.length>0&&(0,b.jsx)(l,{sessions:a,sseSessions:N}),0!==a.length||i?(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3 sm:gap-4",children:X.map(a=>(0,b.jsx)(o,{session:a,hasSse:O(a),sseCount:N[a.alias]||0,onChat:E.openTab},a.alias))}):(0,b.jsx)(r,{hint:g}),(0,b.jsx)(p,{messages:H}),(0,b.jsxs)("div",{className:"mt-8 text-center text-xs text-gray-600 flex items-center justify-center gap-2 flex-wrap",children:[M&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${L?"bg-green-400":"bg-gray-600"}`}),L?"SSE live":"SWR polling"]}),u?.license&&(0,b.jsxs)(b.Fragment,{children:[M&&(0,b.jsx)(b.Fragment,{children:"·"}),(0,b.jsxs)("span",{className:u.license.days_left<=7?"text-red-400":"pro"===u.license.type?"text-green-400":"text-yellow-400",children:[u.license.type," (",u.license.days_left,"d left)"]})]})]}),F&&(0,b.jsx)(y,{sessions:a,onClose:()=>G(!1)}),E.tabs.length>0&&(0,b.jsx)(w,{tabs:E.tabs,activeTab:E.activeTab,onOpenTab:E.openTab,onCloseTab:E.closeTab,onSetActive:E.setActiveTab,onClose:E.closeAll})]})}],60350)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=app_page_tsx_0es_sk2._.js.map
|