'use client'; import { useEffect, useState } from 'react'; interface LiveStats { total_repos?: number; online_count?: number; active_agents?: number; updated_at?: string; } const LIVE_API = 'https://blackroad-live-data.blackroad.workers.dev'; export function LiveStatsBar() { const [stats, setStats] = useState({}); const [loading, setLoading] = useState(true); async function refresh() { try { const [gh, agents] = await Promise.allSettled([ fetch(`${LIVE_API}/github/stats`).then(r => r.json()), fetch(`${LIVE_API}/agents/status`).then(r => r.json()), ]); setStats({ total_repos: gh.status === 'fulfilled' ? gh.value.total_repos : undefined, online_count: agents.status === 'fulfilled' ? agents.value.online_count : undefined, active_agents: agents.status === 'fulfilled' ? agents.value.active_agents : undefined, updated_at: new Date().toISOString(), }); } catch {} setLoading(false); } useEffect(() => { refresh(); const id = setInterval(refresh, 60_000); return () => clearInterval(id); }, []); if (loading) return null; return (
BlackRoad-OS {stats.total_repos && {stats.total_repos.toLocaleString()} repos} · 🤖 Agents: {stats.online_count ?? '?'}/4 Pi nodes · {(stats.active_agents ?? 30000).toLocaleString()} active · ☁️ 58 CF Pages · 🚂 14 Railway {stats.updated_at && ( Live · {new Date(stats.updated_at).toLocaleTimeString()} )}
); } export function RecentRepos() { const [repos, setRepos] = useState>([]); useEffect(() => { fetch(`${LIVE_API}/github/stats`) .then(r => r.json()) .then(data => setRepos(data.recent_repos || [])) .catch(() => {}); }, []); if (!repos.length) return null; return (
{repos.map(r => ( {r.language && } {r.name} ))}
); } export function AgentStatusGrid() { const [fleet, setFleet] = useState>([]); useEffect(() => { fetch(`${LIVE_API}/agents/status`) .then(r => r.json()) .then(data => setFleet(data.fleet || [])) .catch(() => {}); }, []); return (
{(fleet.length ? fleet : [ { name: 'octavia', ip: '192.168.4.38', online: true, models: 108 }, { name: 'alice', ip: '192.168.4.49', online: true, models: 0 }, { name: 'aria', ip: '192.168.4.82', online: true, models: 0 }, { name: 'gematria', ip: '159.65.43.12', online: true, type: 'droplet' }, ]).map(node => (
{node.name}
{node.ip}
{node.models != null && node.models > 0 && (
{node.models} models
)}
))}
); }