'use client'; import { useEffect, useState } from 'react'; import { Activity, Cpu, Globe, Zap, CheckCircle, AlertCircle, RefreshCw } from 'lucide-react'; interface ServiceStatus { name: string; status: 'operational' | 'degraded' | 'down'; latency?: number; } interface StatusData { status: string; services: ServiceStatus[]; timestamp: string; } interface FleetNode { name: string; ip: string; role: string; capacity: number; status: string; } interface FleetData { nodes: FleetNode[]; summary: { total_nodes: number; online_nodes: number; total_capacity: number; }; timestamp: string; } interface AgentData { agents: { id: string; name: string; role: string; status: string; node: string; color: string }[]; fleet?: { total_capacity: number; online_nodes: number }; } const STATUS_COLOR = { operational: '#22c55e', degraded: '#F5A623', down: '#ef4444', online: '#22c55e', offline: '#ef4444', unknown: '#555', }; function StatusDot({ status }: { status: string }) { const color = STATUS_COLOR[status as keyof typeof STATUS_COLOR] || '#555'; return ( ); } export default function MonitoringPage() { const [statusData, setStatusData] = useState(null); const [fleetData, setFleetData] = useState(null); const [agentData, setAgentData] = useState(null); const [refreshing, setRefreshing] = useState(false); const [lastRefresh, setLastRefresh] = useState(new Date()); async function refresh() { setRefreshing(true); try { const [s, f, a] = await Promise.all([ fetch('/api/status').then(r => r.json()), fetch('/api/fleet').then(r => r.json()), fetch('/api/agents').then(r => r.json()), ]); setStatusData(s); setFleetData(f); setAgentData(a); setLastRefresh(new Date()); } catch { /* ignore */ } finally { setRefreshing(false); } } useEffect(() => { refresh(); const interval = setInterval(refresh, 30000); return () => clearInterval(interval); }, []); const overallColor = statusData?.status === 'operational' ? '#22c55e' : statusData?.status === 'partial_outage' ? '#F5A623' : '#ef4444'; return ( {/* Header */} Monitoring Live fleet status · refreshes every 30s · last updated {lastRefresh.toLocaleTimeString()} Refresh {/* Infra stats bar */} {[ { label: 'CF Workers', value: '499', color: '#F5A623' }, { label: 'CF Zones', value: '20', color: '#2979FF' }, { label: 'Agent Capacity', value: '30,000', color: '#FF1D6C' }, { label: 'Online Nodes', value: fleetData?.summary?.online_nodes?.toString() ?? '3', color: '#22c55e' }, ].map(s => ( {s.value} {s.label} ))} {/* Overall status banner */} {statusData?.status === 'operational' ? 'All systems operational' : statusData?.status === 'partial_outage' ? 'Partial outage detected' : 'Checking...'} {statusData?.timestamp ? new Date(statusData.timestamp).toLocaleTimeString() : '—'} {/* Fleet nodes */} Pi Fleet Nodes {(fleetData?.nodes || [ { name: 'aria64', ip: '192.168.4.38', role: 'PRIMARY', capacity: 22500, status: 'online' }, { name: 'alice', ip: '192.168.4.49', role: 'SECONDARY', capacity: 7500, status: 'online' }, ]).map((node) => ( {node.name} {node.role} {node.ip} {node.capacity.toLocaleString()} agent slots {node.status} {/* Capacity bar */} ))} {/* Services */} Platform Services {(statusData?.services || [ { name: 'api', status: 'operational', latency: 12 }, { name: 'database', status: 'operational', latency: 8 }, { name: 'auth', status: 'operational', latency: 15 }, { name: 'agents', status: 'operational', latency: 45 }, { name: 'monitoring', status: 'operational', latency: 22 }, ]).map((svc, i, arr) => ( {svc.status === 'operational' ? : } {svc.name} {svc.latency && ( {svc.latency}ms )} {svc.status} ))} {/* Agent activity */} Agent Activity {(agentData?.agents || [ { id: 'lucidia', name: 'Lucidia', role: 'Coordinator', status: 'active', node: 'aria64', color: '#2979FF' }, { id: 'alice', name: 'Alice', role: 'Operator', status: 'active', node: 'alice', color: '#22c55e' }, { id: 'octavia', name: 'Octavia', role: 'Architect', status: 'active', node: 'aria64', color: '#F5A623' }, { id: 'cecilia', name: 'Cecilia', role: 'Core', status: 'active', node: 'aria64', color: '#9C27B0' }, { id: 'aria', name: 'Aria', role: 'Interface', status: 'idle', node: 'alice', color: '#FF1D6C' }, { id: 'shellfish', name: 'Shellfish', role: 'Security', status: 'active', node: 'aria64', color: '#ef4444' }, ]).map((agent) => ( {agent.name} {agent.node} {agent.status} ))} {/* Quick links */} {[ { label: 'Status Page', href: 'https://status.blackroad.io' }, { label: 'Agent Status', href: 'https://agents-status.blackroad.io' }, { label: 'Worlds API', href: 'https://worlds.blackroad.io' }, { label: 'Gateway', href: 'http://127.0.0.1:8787' }, ].map((link) => ( {link.label} ↗ ))} ); }
Live fleet status · refreshes every 30s · last updated {lastRefresh.toLocaleTimeString()}