903d649a0f
- New ai_ui_control plugin: WS endpoint /ws/ai-ui-control, REST API (POST /command, GET /command/{id}/status, GET /online-users)
- UI-Command-Protocol: 6 command types (navigate, filter, open_contact, modal, tab, settings) with Pydantic schemas
- WebSocket manager: per-user connections, command delivery, feedback storage, stale cleanup
- Frontend useAIUIControl hook: WS client with auto-reconnect, command dispatch, feedback sending
- aiUIControlStore: Zustand store for command state, active modal/tab, pending filter/settings
- AIUIControlIndicator: visual KI indication (Bot icon, toast, pulse animation)
- ContactDetail integration: syncs activeTab and personModalOpen from AI control store
- AppShell integration: useAIUIControl hook + AIUIControlIndicator
- i18n keys for DE/EN
- 18 Vitest tests: command protocol, store actions, feedback, visual indication
- TSC: 0 new errors (only 2 pre-existing Dms.tsx errors)
71 lines
1.6 KiB
TypeScript
71 lines
1.6 KiB
TypeScript
/**
|
|
* 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<string, unknown> | 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<string, unknown> | null;
|
|
} | null;
|
|
}
|
|
|
|
export async function sendUICommand(
|
|
body: UICommandCreate,
|
|
): Promise<UICommandResponse> {
|
|
const res = await apiClient.post<UICommandResponse>(
|
|
'/ai-ui-control/command',
|
|
body,
|
|
);
|
|
return res.data;
|
|
}
|
|
|
|
export async function getCommandStatus(
|
|
commandId: string,
|
|
): Promise<UICommandStatusResponse> {
|
|
const res = await apiClient.get<UICommandStatusResponse>(
|
|
`/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;
|
|
}
|