import type { RuntimeEventBus } from '../runtime/events/index.js'; import type { LLMProvider } from './interface.js'; import type { ModelDefinition } from './registry.js'; import { LocalContextIngestionService } from './local-context-ingestion.js'; /** * JSON schema for a custom provider configuration file. * Place a *.json file in the configured providers directory to define a custom provider. */ export interface CustomProviderConfig { /** Unique provider identifier, e.g. 'ollama' */ name: string; /** Human-friendly display name, e.g. 'Ollama' */ displayName: string; /** Provider protocol adapter. */ type: 'openai-compat' | 'anthropic-compat'; /** Base URL for the API, e.g. 'http://localhost:11434/v1' */ baseURL: string; /** Optional env var name whose value is used as the API key */ apiKeyEnv?: string | undefined; /** Optional explicit API key (takes precedence over apiKeyEnv) */ apiKey?: string | undefined; /** Optional extra HTTP headers sent with every request */ defaultHeaders?: Record | undefined; /** How to send reasoning params. Default: 'none' (don't send). */ reasoningFormat?: 'mercury' | 'openrouter' | 'llamacpp' | 'none' | undefined; /** List of models exposed by this provider */ models: Array<{ id: string; displayName: string; description?: string | undefined; contextWindow: number; selectable?: boolean | undefined; capabilities: { toolCalling: boolean; codeEditing: boolean; reasoning: boolean; multimodal: boolean; }; reasoningEffort?: string[] | undefined; /** Model capability tier, controls system prompt verbosity. */ tier?: 'free' | 'standard' | 'premium' | undefined; /** * Optional rates in USD per 1M tokens. Omitting it means this model's * price is UNKNOWN (not free): cost surfaces report its usage as * unpriced unless a manual config price or catalog entry covers it. */ pricing?: { input: number; output: number; cacheRead?: number | undefined; cacheWrite?: number | undefined; } | undefined; }>; } /** Result of loading all custom providers from disk. */ export interface LoadCustomProvidersResult { providers: Array<{ config: CustomProviderConfig; provider: LLMProvider; }>; models: ModelDefinition[]; warnings: string[]; } /** Options for loadCustomProviders. */ export interface LoadCustomProvidersOptions { /** Directory that owns custom provider JSON files. */ providersDir: string; /** * When true, attempts to fetch max_context_length from each provider's * /v1/models endpoint and uses the reported value with 'provider_api' * provenance. Falls back to the configured contextWindow or DEFAULT_CONTEXT_WINDOW. * Defaults to false. */ ingestContextWindows?: boolean | undefined; contextIngestion?: Pick | undefined; } /** * Load all custom providers from an owned providers directory. * Auto-creates the directory if it does not exist. * Invalid files are skipped with a warning rather than failing the whole load. * * When `options.ingestContextWindows` is true, each provider's /v1/models * endpoint is queried concurrently (via Promise.allSettled) to resolve * `max_context_length` with `provider_api` provenance. */ export declare function loadCustomProviders(options: LoadCustomProvidersOptions): Promise; /** * Start watching an owned providers directory for file changes. * Debounces rapid events by 300ms before invoking the onChange callback. * Emits typed provider warnings if the watcher cannot be started. * Returns a handle with a `close()` method to stop watching. */ export declare function watchCustomProviders(runtimeBus: RuntimeEventBus | null, onChange: () => void, providersDir: string): { close: () => void; }; //# sourceMappingURL=custom-loader.d.ts.map