// frontend/src/lib/models/AgentChatTypes.ts
// #region AgentChat.Types [C:1] [TYPE Module] [SEMANTICS agent-chat,types]
// @ingroup AgentChat
// @BRIEF Shared type definitions for AgentChat model family.
// @RELATION CALLED_BY -> [AgentChat.Model]

export type StreamingState =
  | "idle"
  | "streaming"
  | "awaiting_confirmation"
  | "error"
  | "disconnected"
  | "disconnected_permanent";

export type ConnectionState =
  | "connected"
  | "disconnected"
  | "disconnected_permanent";

export interface StreamMetadata {
  type?: "stream_token" | "tool_start" | "tool_end" | "tool_error"
       | "confirm_required" | "confirm_resolved" | "error";
  token?: string;
  tool?: string;
  input?: Record<string, unknown>;
  output?: Record<string, unknown>;
  error?: string;
  prompt?: string;
  thread_id?: string;
  result?: "confirmed" | "denied";
  code?: string;
  detail?: string;
}

export interface ToolCall {
  tool: string;
  input: Record<string, unknown>;
  output?: Record<string, unknown>;
  error?: string;
  status: "executing" | "completed" | "failed";
}

export interface AgentMessage {
  id: string;
  conversation_id: string;
  role: "user" | "assistant" | "system" | "tool";
  text: string;
  metadata?: StreamMetadata;
  state?: string;
  task_id?: string;
  toolCalls: ToolCall[];
  created_at: string;
}

export interface Conversation {
  id: string;
  title: string;
  updated_at: string;
  message_count: number;
}
// #endregion AgentChat.Types
