import { api } from "@/lib/api-client"; import type { AIAgent, AIAgentSummary, AIAgentTestRequest, AIAgentTestResponse, AIAgentUpdateInput, AIToolSummary, } from "@/types/aiAgent"; /** * REST helpers for the AI Agent configurator. * * Backend: `backend/custom_addons/encoach_ai/controllers/agents_controller.py`. * Mount point: `/api/ai/agents`. */ export const aiAgentService = { async list(params?: { search?: string }): Promise { const res = await api.get<{ items?: AIAgentSummary[]; data?: AIAgentSummary[] }>( "/ai/agents", params, ); return res.items ?? res.data ?? []; }, async get(id: number): Promise { return api.get(`/ai/agents/${id}`); }, async update(id: number, input: AIAgentUpdateInput): Promise { return api.patch(`/ai/agents/${id}`, input); }, async test(id: number, body: AIAgentTestRequest): Promise { return api.post(`/ai/agents/${id}/test`, body); }, async listTools(): Promise { const res = await api.get<{ items?: AIToolSummary[]; data?: AIToolSummary[] }>( "/ai/agents/tools", ); return res.items ?? res.data ?? []; }, async updateTool( id: number, input: Partial> & { schema?: Record; }, ): Promise { return api.patch(`/ai/agents/tools/${id}`, input); }, };