export interface ChatMessage { role: "system" | "user" | "assistant"; content: string; } export interface DriverModel { /** Fully-qualified id, e.g. "ollama:llama3.1" */ id: string; /** Short model name, e.g. "llama3.1" */ name: string; /** Driver name, e.g. "ollama" */ driver: string; label: string; } export interface ChatOptions { model: string; // short name within the driver signal?: AbortSignal; onToken?: (token: string) => void; } /** * Driver interface (class-oriented as per spec). * Each LLM backend (ollama, mistral, puppeteer, ...) implements this. */ export interface LLMDriver { readonly name: string; readonly enabled: boolean; /** List models exposed by this driver. */ listModels(): Promise; /** Non-streaming chat completion. */ chat(messages: ChatMessage[], opts: ChatOptions): Promise; /** Streaming chat completion (SSE tokens). */ chatStream(messages: ChatMessage[], opts: ChatOptions): AsyncGenerator; } export class DriverDisabledError extends Error { constructor(driver: string) { super(`driver "${driver}" is disabled / not configured`); this.name = "DriverDisabledError"; } }