/** * @purpose AI Legacy Model initialization config: name, URL, optional key and additional parameters. * @consumer AiLegacyModel, AiLegacyCore, GennadyRc */ export type AiLegacyModelInit = { /** @purpose Model name identifier (e.g. "llama3.1:8b"). */ model: string; /** @purpose API endpoint URL for generation requests. */ url: string; /** @purpose Optional API key for authorization. */ key?: string; /** @purpose Extra parameters merged into the request body. */ extra?: Record; }; /** * @purpose Legacy AI Model (LLM) — single point for API generation requests (Ollama/OpenAI-compatible). * @invariant Error Policy: network/timeout errors are returned as [null, Error]; does not throw. * @invariant Retry Policy: no built-in retries; responsibility on the caller. * @consumer AiLegacyCore, cmd/agent */ export declare class AiLegacyModel { /** * @purpose Create an instance with default settings (Ollama local). * @returns Instance with model=llama3.1:8b, url=localhost:11434. */ static getDefault(): AiLegacyModel; /** @purpose Model initialization config with name, URL, and key. */ protected _init: AiLegacyModelInit; /** @purpose Cached ping promise to avoid duplicate pings. */ protected _pingPromise: Promise<[boolean, null] | [null, Error]> | null; /** * @purpose Create an AI model instance with the given configuration. * @param init Partial initialization config (model, url, key, extra). */ constructor(init: Partial); /** * @purpose Model name (for logs and headers). * @returns Model name string. */ get name(): string; /** * @purpose API endpoint URL. * @returns API URL string. */ get url(): string; /** * @purpose API key (if authorization is required). * @returns API key string or undefined. */ get key(): string | undefined; /** * @purpose Check model availability with a short request. * @param [timeout] Timeout in ms (default 10e3). * @returns Tuple [true, null] on success, [null, Error] on failure. * @sideEffect Network: single request to API; Logs: debug/error. */ ping(timeout?: number): Promise<[boolean, null] | [null, Error]>; /** * @purpose Send a prompt to the LLM and get a response (with __KEY__ substitution and think-block removal). * @param prompt User prompt text. * @param [init] system, temperature, timeout, replacements for substitution in prompt/system. * @returns Tuple [response text, null] on success, [null, Error] on network/parsing error. * @sideEffect Network: POST to this.url. */ generate(prompt: string, init?: { system?: string; temperature?: number; timeout?: number; replacements?: Record; }): Promise<[string, null] | [null, Error]>; /** * @purpose Execute a POST request to the API and return JSON or an error. * @param params Request body (Ollama or OpenAI format). * @param [timeout] Timeout in ms. * @returns Tuple [parsed JSON, null] or [null, Error]. * @sideEffect Network: fetch with AbortController. */ protected _fetchAsJson(params: unknown, timeout?: number): Promise<[unknown, null] | [null, Error]>; }