"use client"; import { useMemo } from "react"; import { useOrchestratorStatus, useWaitingAgents, useAgentDefinitions, } from "@/hooks/use-agents"; import { AgentStatusResponse } from "@/types"; import { Button } from "@/components/ui/button"; import { RefreshCw } from "lucide-react"; import { OfflineState } from "@/components/ui/offline-state"; import { getBoardAgents, getMainPm, getBackendAgents, getFrontendAgents, getUxAgents, } from "@/lib/agent-definitions"; import { OrchestratorStatusCards, WaitingAgentsAlert, AgentGrid, } from "@/components/agents"; export default function AgentsPage() { const { data: agents = [], isLoading: agentsLoading } = useAgentDefinitions(); const { data: status, isLoading, error, refetch } = useOrchestratorStatus(); const { data: waitingAgents } = useWaitingAgents(); // Check if it's a connection error (backend not running) const isOffline = error && ( error.message?.includes("Network Error") || error.message?.includes("ECONNREFUSED") || (error as { code?: string })?.code === "ERR_NETWORK" ); // Convert agents array to a record keyed by agent_id for easy lookup const agentStatuses = useMemo(() => { const result: Record = {}; if (status?.agents) { for (const agent of status.agents) { result[agent.agent_id] = agent; } } return result; }, [status]); return (
{/* Header */}

Agents

Monitor and control your AI workforce

{isOffline ? ( refetch()} /> ) : ( <> {/* Status Overview */} {/* Waiting Agents Alert */} {waitingAgents && } )} {/* Agent Grids - Dynamically loaded from API */}
); }