import type { ProviderCallContext } from '../types/lifecycle.js'; import type { CompletionRequest, Message, ToolDefinition } from '../types/messages.js'; import type { NexusResponse, NexusStream, StreamChunk } from '../types/response.js'; import { type NexusProviderErrorOptions } from './errors.js'; /** What a provider says about itself. */ export interface ProviderInfo { /** Provider name. */ name: string; /** True when it runs on this machine, which privacy routing prefers. */ isLocal: boolean; } /** Base class for chat providers: complete, stream, and a health check. */ export declare abstract class BaseProvider { /** Provider name and locality. */ abstract readonly info: ProviderInfo; /** * Runs one completion. `context` carries the operation's id, its deadline, its trace headers, and * its idempotency key; `request.signal` and `context.signal` are the same signal. */ abstract complete(request: CompletionRequest, context?: ProviderCallContext): Promise; /** Streams one completion, with the same `context` as `complete()`. */ abstract stream(request: CompletionRequest, context?: ProviderCallContext): NexusStream; /** * Whether the provider is reachable. Defaults to true; adapters override it with a real check. */ healthCheck(): Promise; protected createBaseResponse(provider: string, model: string): NexusResponse; protected extractTextContent(messages: Message[]): Array<{ role: string; content: string; }>; protected formatTools(tools?: ToolDefinition[]): unknown[] | undefined; protected normalizeProviderError(error: unknown, request: CompletionRequest, overrides?: Partial): Error; protected throwIfAborted(request: CompletionRequest): void; protected createStream(generator: () => AsyncGenerator, signal?: AbortSignal): NexusStream; } export { NexusProviderError, type NexusProviderErrorCategory, type NexusProviderErrorOptions, } from './errors.js';