import { create } from "zustand"; import { agentApiService } from "@/modules/agent/api/agent.api.service"; import type { AgentInfo } from "@/modules/agent/types/agent.types"; interface AgentState { agents: AgentInfo[]; isLoading: boolean; error: string | null; fetchAgents: () => Promise; removeAgent: (name: string) => void; } export const useAgentStore = create()((set, get) => ({ agents: [], isLoading: false, error: null, fetchAgents: async () => { set({ isLoading: true, error: null }); try { const agents = await agentApiService.getAgents(); set({ agents, isLoading: false }); } catch (error) { set({ error: error instanceof Error ? error.message : "Failed to fetch agents", isLoading: false, }); } }, removeAgent: (name: string) => { set({ agents: get().agents.filter((a) => a.name !== name) }); }, }));