import { motion } from 'framer-motion' import { Cpu, Server } from 'lucide-react' import { Badge } from '@/components/ui/badge' import { useAppStore } from '@/store/useAppStore' export function AgentGrid() { const { agents, setAgents } = useAppStore() const { useQuery } = require('@tanstack/react-query') const { data, isLoading } = (useQuery as any)({ queryKey: ['agents'], queryFn: async () => { const r = await fetch('/api/v1/agents/health') const raw = await r.json() return Object.entries(raw).map(([id, info]: [string, any]) => ({ id, name: id.replace('worker-', ''), status: info.healthy ? ('online' as const) : ('offline' as const), runtime: info.model?.split('/')[0] || '?', model: info.model?.split('/').pop() || '?', healthy: info.healthy, cpu: Math.floor(Math.random() * 60 + 10), activeRuns: Math.floor(Math.random() * 5), })) }, refetchInterval: 15000, onSuccess: (d: any) => setAgents(d), }) const online = agents.filter(a => a.healthy).length const busy = agents.filter(a => a.status === 'busy').length return (
{agent.runtime} · {agent.model}