/** * pi-loom: Shared Model Utilities * * resolveModel, resolveMcpAuth, callLLMForJSON, and resolveModelForLLM. * Used by Dream Engine (dream.ts) and Extraction Engine (extract.ts). */ import type { Model } from "@earendil-works/pi-ai"; import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; /** Resolve a model string ("provider/id" or just "id") via ctx.modelRegistry. */ export declare function resolveModel(ctx: ExtensionContext | null, modelStr: string, defaultProvider?: string): Model | undefined; /** Auth for MCP standalone: read API keys from environment variables. */ export declare function resolveMcpAuth(model: Model): { ok: boolean; apiKey?: string; headers?: Record; }; export interface LLMCallConfig { apiKey: string; headers?: Record; maxTokens?: number; } /** * Call an LLM, parse a JSON array from its response. * Shared by dream.ts (insight generation) and extract.ts (fact extraction). * * Returns parsed JSON array, or null if parsing fails. * Handles the common pattern: * complete(model, ctx, opts) → filter text → match /\[[\s\S]*\]/ → JSON.parse */ export declare function callLLMForJSON(model: Model, prompt: string, auth: LLMCallConfig): Promise; /** * Resolve which model to use for LLM calls, with a priority chain: * 1. Explicit model string from config/params (e.g. "deepseek/deepseek-v3.1") * 2. PI_DREAM_MODEL / PI_FACT_MODEL env var * 3. ctx.model (the currently active model in the session) * 4. Hard-coded default (provider + modelId) */ export declare function resolveModelForLLM(ctx: ExtensionContext | null, config: { modelProvider?: string; modelId?: string; }, envVar: string, defaultModel: string): Model | undefined; /** * Check whether any LLM is available (API key + model or session context). * Used to decide whether to run LLM-dependent operations or use local fallbacks. */ export declare function hasLLM(ctx: ExtensionContext | null): boolean;