import type { ReactNode } from 'react'; /** * @file types.ts * Shared TypeScript types for the XerticaAssistant component and related hooks/contexts. * * These types are the single source of truth — imported by: * - `xertica-assistant.tsx` * - `use-assistant.ts` * - `contexts/AssistenteContext.tsx` */ // ───────────────────────────────────────────────────────────────────────────── // Primitive union types // ───────────────────────────────────────────────────────────────────────────── /** Supported message sender types in the assistant */ export type MessageType = 'user' | 'assistant' | 'system'; /** Supported attachment types that can be included in messages */ export type AttachmentType = | 'file' | 'audio' | 'image' | 'video' | 'document' | 'podcast' | 'search'; /** Supported search result categories */ export type SearchResultType = 'document' | 'project' | 'conversation' | 'file' | 'contact'; /** Layout mode for the assistant panel */ export type AssistantMode = 'collapsed' | 'expanded' | 'fullPage'; /** Available tabs in the assistant panel */ export type AssistantTab = 'chat' | 'historico' | 'favoritos'; // ───────────────────────────────────────────────────────────────────────────── // Domain interfaces // ───────────────────────────────────────────────────────────────────────────── /** * Individual search result item returned by an assistant search query. */ export interface SearchResult { id: string; type: SearchResultType; title: string; description: string; path: string; relevance: number; lastModified?: string; } /** * Metadata about a search source (e.g., a document repository or knowledge base). */ export interface SearchSource { name: string; count: number; } /** * A quick-action command shown below a search result message. */ export interface SearchCommand { id: string; icon: string; label: string; description: string; } /** * A single chat message in the assistant conversation. */ export interface Message { id: string; type: MessageType; content: string; timestamp: Date; isFavorite?: boolean; attachmentType?: AttachmentType; attachmentName?: string; documentContent?: string; documentTitle?: string; audioUrl?: string; searchResults?: SearchResult[]; searchSources?: SearchSource[]; searchCommands?: SearchCommand[]; chartData?: any[]; chartConfig?: any; tableData?: { caption?: string; headers: string[]; rows: (string | ReactNode)[][]; }; evaluation?: 'like' | 'dislike'; evaluationReason?: string; } /** * A saved conversation entry shown in the history panel. */ export interface Conversation { id: string; title: string; lastMessage?: string; timestamp: string; isFavorite: boolean; messages: Message[]; } /** * A suggested prompt shown to the user in the chat input area. */ export interface Suggestion { id: string; text: string; icon?: ReactNode; } /** * A mock response entry used in demo mode. * Matches a user message via `trigger` and returns a predefined `response`. */ export interface MockResponse { /** String or regex to match against the user's message */ trigger: string | RegExp; /** Response content — either a plain string or a partial Message object */ response: string | Partial; /** Optional delay in milliseconds before the response appears */ delay?: number; }