export type AiChatMessageRole = 'assistant' | 'system' | 'user';
export type AiChatMessageStatus = 'done' | 'error' | 'pending' | 'streaming';

export interface AiKnowledgeHit {
  id?: string;
  title?: string;
  content?: string;
  score?: number | string;
  source?: string;
  [key: string]: any;
}

export interface AiToolApprovalPayload {
  requestId: string;
  resumeToken: string;
  toolName: string;
  toolDisplayName?: string;
  toolCallId?: string;
  toolType?: string;
  input?: unknown;
  expiresAt?: string;
  metadata?: unknown;
}

export type AiChatMessagePart =
  | (AiToolApprovalPayload & { type: 'tool_approval' })
  | { collapsed?: boolean; text: string; type: 'reasoning' }
  | {
      input?: unknown;
      output?: unknown;
      status?: string;
      toolName: string;
      type: 'tool_call';
    }
  | { items: AiKnowledgeHit[]; type: 'knowledge' }
  | { message: string; type: 'error' }
  | { text: string; type: 'text' };

export interface AiChatMessage {
  id: string;
  role: AiChatMessageRole;
  status?: AiChatMessageStatus;
  parts: AiChatMessagePart[];
  createdAt?: number;
}
