This commit is contained in:
kacper 2026-03-06 22:51:19 -05:00
parent 6acf267d48
commit b7614eb3f8
4794 changed files with 1280808 additions and 1546 deletions

45
frontend/src/types.ts Normal file
View file

@ -0,0 +1,45 @@
// 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;
}