/**
 * 对话消息
 */
export interface ChatMessage {
  id: string;
  role: 'user' | 'assistant';
  content: string;
  timestamp: number;
  toolCalls?: ToolCallInfo[];
  metadata?: ChatMessageMetadata;
  timeline?: TimelineEvent[];
}

/**
 * 消息元数据
 */
export interface ChatMessageMetadata {
  tokenUsage: { input: number; output: number };
  duration: number;
}

/**
 * Tool 调用信息
 */
export interface ToolCallInfo {
  toolName: string;
  input: Record<string, any>;
  output?: string;
  status: 'running' | 'success' | 'error';
  duration?: number;
}

/**
 * 执行时间线事件
 */
export interface TimelineEvent {
  label: string;
  type: 'llm' | 'tool';
  startTime: number;
  duration: number;
}

/**
 * 会话线程
 */
export interface ChatThread {
  id: string;
  agentId: string;
  title: string;
  messageCount: number;
  createdAt: string;
  updatedAt: string;
}

/**
 * SSE 事件类型
 */
export type SseEventType = 'token' | 'tool_start' | 'tool_end' | 'metadata' | 'ping' | 'error' | 'done';

/**
 * SSE 事件数据
 */
export interface SseTokenEvent {
  content: string;
}

export interface SseToolStartEvent {
  toolName: string;
  input: Record<string, any>;
  timestamp: number;
}

export interface SseToolEndEvent {
  toolName: string;
  output: string;
  duration: number;
}

export interface SseMetadataEvent {
  tokenUsage: { input: number; output: number };
  model: string;
}

export interface SseDoneEvent {
  threadId: string;
  messageId: string;
}

export interface SseErrorEvent {
  message: string;
}
