nanobot-voice-interface/frontend/src/types.ts
2026-03-12 09:25:15 -04:00

86 lines
2 KiB
TypeScript

// 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;
}
export type ServerMessage =
| { type: "agent_state"; state: AgentState }
| {
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" };
export type ClientMessage =
| { type: "voice-ptt"; pressed: boolean; metadata?: CardMessageMetadata }
| { type: "command"; command: string }
| { type: "card-response"; card_id: string; value: string }
| { type: "ping" };
export interface LogLine {
id: number;
role: string;
text: string;
timestamp: string;
}
export interface CardItem {
id: number;
serverId?: string;
kind: "text" | "question";
content: string;
title: string;
question?: string;
choices?: string[];
responseValue?: string;
slot?: string;
lane: CardLane;
priority: number;
state: CardState;
templateKey?: string;
contextSummary?: string;
createdAt: string;
updatedAt: string;
}