/** * Local-runner preflight: ensure the LLM model the pipeline is about to * call is actually loaded in LM Studio / pulled in Ollama before we spawn * the Python subprocess. * * Why this exists: * - LM Studio's OpenAI-compat `/v1/chat/completions` will JIT-load a * downloaded model on first request, but the request blocks for the * entire load (60-120s for 8B-class quantised models). The pipeline * subprocess sees no progress, the FE sees a stalled "Launching * pipeline" spinner, the agent's first ChatResponse never arrives. * Run d5ead8b8655b47fa hit this exactly: 1 `format openai` span, no * `chat ...` span, no messages. * - Ollama works similarly — first call to a model that isn't pulled * will fail with "model not found"; downloads have to be explicit. * * What we do: * 1. Read the model name + provider from the pipeline's config.json. * 2. For lmstudio: GET /api/v0/models to see {id, state} for every * model. If state="loaded" we're good. If state="not-loaded" we * POST a tiny chat completion to force the JIT load while * surfacing progress to the operator's stderr + emitting a * socket event so the FE can show "Loading qwen/qwen3-vl-8b…". * If model isn't in the list at all → fail fast with a clear * "open LM Studio and download " message. * 3. For ollama: GET /api/tags. If model not present → fail fast with * `ollama pull ` instruction. If present, ollama auto-loads. */ export declare function classifyModel(id: string, lmstudioMeta?: LMStudioModelInfo): ModelProfile; type LMStudioModelState = "loaded" | "not-loaded" | "loading" | string; interface LMStudioModelInfo { id: string; state?: LMStudioModelState; type?: string; arch?: string; params?: string | number; max_context_length?: number; } export type ModelTier = "agentic-capable" | "agentic-marginal" | "text-only"; export interface ModelProfile { schemaVersion: number; id: string; tier: ModelTier; paramsBillion: number | null; family: string | null; supportsToolCalling: boolean; thinkingDefault: "on" | "off" | "n/a"; recommendedMaxTokens: number; recommendedMaxIters: number; contextTokens: number | null; detectedAt: string; reason: string; } export interface ModelPreflightResult { ok: boolean; reason?: string; hint?: string; loaded?: boolean; profile?: ModelProfile; } export declare function preflightLmStudio(modelName: string, onProgress?: (msg: string) => void): Promise; export declare function preflightOllama(modelName: string, onProgress?: (msg: string) => void): Promise; /** * Top-level preflight — resolves the provider/model from the pipeline * config and dispatches to the right helper. Returns immediately for * non-local providers (cloud-spawn shouldn't reach the runner anyway). */ export declare function preflightModel(configJson: string, onProgress?: (msg: string) => void): Promise; export {};