/** * API client for AI UI Control endpoints. * * Task 4.2: REST endpoints for AI agents to send commands and poll status. */ import { apiClient } from './client'; export interface UICommandCreate { action: string; path?: string | null; entity?: string | null; filter?: Record | null; contact_id?: string | null; modal?: string | null; tab?: string | null; section?: string | null; key?: string | null; value?: unknown | null; description?: string | null; } export interface UICommandResponse { command_id: string; status: string; action: string; message?: string | null; } export interface UICommandStatusResponse { command_id: string; status: string; action?: string | null; feedback?: { command_id: string; status: string; action?: string | null; current_path?: string | null; current_tab?: string | null; message?: string | null; error?: string | null; data?: Record | null; } | null; } export async function sendUICommand( body: UICommandCreate, ): Promise { const res = await apiClient.post( '/ai-ui-control/command', body, ); return res.data; } export async function getCommandStatus( commandId: string, ): Promise { const res = await apiClient.get( `/ai-ui-control/command/${commandId}/status`, ); return res.data; } export async function getOnlineUsers(): Promise<{ online_users: string[] }> { const res = await apiClient.get<{ online_users: string[] }>( '/ai-ui-control/online-users', ); return res.data; }