46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
|
|
// Shared TypeScript types for the Nanobot UI
|
||
|
|
|
||
|
|
export type AgentState = "idle" | "listening" | "thinking" | "speaking";
|
||
|
|
|
||
|
|
// Messages sent FROM backend TO frontend via DataChannel
|
||
|
|
export type ServerMessage =
|
||
|
|
| { type: "agent_state"; state: AgentState }
|
||
|
|
| { type: "message"; content: string; is_progress: boolean }
|
||
|
|
| { type: "toast"; kind: "text" | "image"; content: string; title: string; duration_ms: number }
|
||
|
|
| { type: "choice"; request_id: string; question: string; choices: string[]; title: string }
|
||
|
|
| { type: "error"; error: string }
|
||
|
|
| { type: "pong" }
|
||
|
|
// Legacy wire format still used by backend (role-based)
|
||
|
|
| { role: string; text: string; timestamp?: string };
|
||
|
|
|
||
|
|
// Messages sent FROM frontend TO backend via DataChannel
|
||
|
|
export type ClientMessage =
|
||
|
|
| { type: "voice-ptt"; pressed: boolean }
|
||
|
|
| { type: "command"; command: string }
|
||
|
|
| { type: "ui-response"; request_id: string; value: string }
|
||
|
|
| { type: "ping" };
|
||
|
|
|
||
|
|
export interface LogLine {
|
||
|
|
id: number;
|
||
|
|
role: string;
|
||
|
|
text: string;
|
||
|
|
timestamp: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface ToastItem {
|
||
|
|
id: number;
|
||
|
|
kind: "text" | "image" | "choice";
|
||
|
|
content: string;
|
||
|
|
title: string;
|
||
|
|
durationMs: number;
|
||
|
|
// For choice toasts
|
||
|
|
requestId?: string;
|
||
|
|
question?: string;
|
||
|
|
choices?: string[];
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface RTCState {
|
||
|
|
connected: boolean;
|
||
|
|
connecting: boolean;
|
||
|
|
}
|