This commit is contained in:
kacper 2026-03-12 09:25:15 -04:00
parent b7614eb3f8
commit db4ce8b14f
22 changed files with 3557 additions and 823 deletions

View file

@ -1,23 +1,62 @@
// Shared TypeScript types for the Nanobot UI
export type AgentState = "idle" | "listening" | "thinking" | "speaking";
export type CardLane = "attention" | "work" | "context" | "history";
export type CardState = "active" | "stale" | "resolved" | "superseded" | "archived";
export type JsonValue =
| string
| number
| boolean
| null
| { [key: string]: JsonValue }
| JsonValue[];
export interface CardMessageMetadata {
card_id?: string;
card_slot?: string;
card_title?: string;
card_lane?: CardLane;
card_template_key?: string;
card_context_summary?: string;
card_response_value?: string;
card_live_content?: JsonValue;
}
// 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: "message";
role: string;
content: string;
is_progress: boolean;
is_tool_hint: boolean;
timestamp: string;
}
| {
type: "card";
id: string;
kind: "text" | "question";
title: string;
content: string;
question: string;
choices: string[];
response_value: string;
slot: string;
lane: CardLane;
priority: number;
state: CardState;
template_key: string;
context_summary: string;
created_at: string;
updated_at: string;
}
| { type: "error"; error: string }
| { type: "pong" }
// Legacy wire format still used by backend (role-based)
| { role: string; text: string; timestamp?: string };
| { type: "pong" };
// Messages sent FROM frontend TO backend via DataChannel
export type ClientMessage =
| { type: "voice-ptt"; pressed: boolean }
| { type: "voice-ptt"; pressed: boolean; metadata?: CardMessageMetadata }
| { type: "command"; command: string }
| { type: "ui-response"; request_id: string; value: string }
| { type: "card-response"; card_id: string; value: string }
| { type: "ping" };
export interface LogLine {
@ -27,19 +66,21 @@ export interface LogLine {
timestamp: string;
}
export interface ToastItem {
export interface CardItem {
id: number;
kind: "text" | "image" | "choice";
serverId?: string;
kind: "text" | "question";
content: string;
title: string;
durationMs: number;
// For choice toasts
requestId?: string;
question?: string;
choices?: string[];
}
export interface RTCState {
connected: boolean;
connecting: boolean;
responseValue?: string;
slot?: string;
lane: CardLane;
priority: number;
state: CardState;
templateKey?: string;
contextSummary?: string;
createdAt: string;
updatedAt: string;
}