import { useState, useEffect } from 'react'; import { Link, useLocation } from 'react-router-dom'; import { agentApi } from '../utils/api'; function Home() { const [stats, setStats] = useState({ agents: [], agentCount: 0, actions: 0, connectors: 0, status: {}, }); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const location = useLocation(); // Update document title useEffect(() => { document.title = 'Agent Dashboard - LocalAGI'; return () => { document.title = 'LocalAGI'; // Reset title when component unmounts }; }, []); // Fetch dashboard data useEffect(() => { const fetchData = async () => { setLoading(true); try { const agents = await agentApi.getAgents(); setStats({ agents: agents.agents || [], agentCount: agents.agentCount || 0, actions: agents.actions || 0, connectors: agents.connectors || 0, status: agents.statuses || {}, }); } catch (err) { console.error('Error fetching dashboard data:', err); setError('Failed to load dashboard data'); } finally { setLoading(false); } }; fetchData(); }, []); if (loading) { return
Loading dashboard data...
; } if (error) { return
{error}
; } return (
LocalAGI Logo
{/*

LocalAGI

*/} {/* Dashboard Stats */}
{stats.actions}
Available Actions
{stats.connectors}
Available Connectors
{stats.agentCount}
Agents
{/* Cards Container */}
{/* Card for Agent List Page */}

Agent List

View and manage your list of agents, including detailed profiles and statistics.

{/* Card for Create Agent */}

Create Agent

Create a new intelligent agent with custom behaviors, connectors, and actions.

{/* Card for Actions Playground */}

Actions Playground

Explore and test available actions for your agents.

{/* Card for Group Create */}

Create Group

Create a group of agents with shared configurations and behaviors.

{/* Card for Import Agent */}

Import Agent

Import an existing agent configuration from a file.

{stats.agents.length > 0 && (

Your Agents

{stats.agents.map((agent) => (
{stats.status[agent] ? 'Active' : 'Paused'}

{agent}

Chat Settings Status
))}
)}
); } export default Home;