/** A normalized document drawn from any dataset-collection source. */ export interface SourceDoc { /** Stable id: `:` */ id: string; /** Free text content (question+answer flattened for QA records). */ text: string; /** Short title when the source has one. */ title?: string; /** Dataset family: corpus | qa_pairs | medical_qa | europe_pmc | deduped | training_merged */ source: string; /** Topic label when available (e.g. neonatal_jaundice). */ topic?: string; } /** A chunk of a SourceDoc — the retrieval unit. */ export interface Chunk { /** `#` */ id: string; docId: string; text: string; title?: string; source: string; topic?: string; } export interface ScoredChunk extends Chunk { score: number; /** Which retriever(s) surfaced it. */ via: string[]; } export interface ChatMessage { role: "system" | "user" | "assistant"; content: string; } export type ProviderName = "openrouter" | "openai" | "anthropic"; export interface ChatOptions { /** Use the cheap/fast model tier (rewriting, reranking, judging). */ fast?: boolean; maxTokens?: number; /** Ask the provider for a JSON object response when supported. */ json?: boolean; /** Called with text deltas when streaming to a terminal. */ onDelta?: (text: string) => void; } export interface ChatResult { text: string; provider: ProviderName; model: string; } export interface RagAnswer { answer: string; provider: ProviderName; model: string; /** Queries actually used for retrieval (original + rewrites). */ queries: string[]; sources: ScoredChunk[]; } export interface IndexManifest { embeddingModel: string; dims: number; count: number; createdAt: string; sources: Record; }