import { api } from './http';

export interface GlobalSearchResult {
  agents: { id: string; name: string; description: string; model: string }[];
  sessions: { id: string; agentId: string; agentName: string; title: string; updatedAt: number; archived: boolean }[];
  messages: {
    id: string;
    sessionId: string;
    agentId: string;
    agentName: string;
    sessionTitle: string;
    role: 'user' | 'assistant';
    snippet: string;
    createdAt: number;
  }[];
}

export const SearchAPI = {
  global: (q: string, limit = 8) => api.get<GlobalSearchResult>('/search', { params: { q, limit } }).then((r) => r.data)
};

