import type { LLMProvider, ProviderRuntimeMetadata } from './interface.js';
import { type ProviderCapability, type RequestProfile, type RouteExplanation } from './capabilities.js';
import type { DiscoveredServer } from '../discovery/scanner.js';
import type { RuntimeEventBus } from '../runtime/events/index.js';
import { type CatalogModel, type MinimalModelDefinition } from './model-catalog.js';
import type { CanonicalModel } from './synthetic.js';
import type { ModelDefinition, ProviderRegistryOptions, RuntimeProviderRegistration, TokenLimits } from './registry-types.js';
export type { ContextWindowProvenance, ModelDefinition, ModelTier, ProviderRegistryOptions, RuntimeProviderRegistration, TokenLimits, } from './registry-types.js';
/**
 * ProviderRegistry — manages LLM provider instances and model selection.
 * Lazily instantiates providers on first use.
 */
export declare class ProviderRegistry {
    private providers;
    private currentModelRegistryKey;
    private discoveredProviderNames;
    private runtimeProviderNames;
    private customModels;
    private runtimeModels;
    private discoveredModels;
    private readonly runtimeCatalogSuppressedRegistryKeys;
    private _watcher;
    private _readyPromise;
    private readonly configManager;
    private readonly subscriptionManager;
    private readonly capabilityRegistry;
    private readonly cacheHitTracker;
    private readonly featureFlags;
    private readonly favoritesStore;
    private readonly benchmarkStore;
    private readonly modelLimitsService;
    private readonly runtimeMetadataDeps;
    private readonly runtimeBus;
    private readonly localContextIngestionService;
    private catalogModels;
    private pricingCatalog;
    private syntheticCanonicalModels;
    private _cachedModelRegistry;
    private _modelRegistryRevision;
    constructor(options: ProviderRegistryOptions);
    private readConfiguredModelRegistryKey;
    private registerBuiltins;
    private getPersistenceRoot;
    private getCustomProvidersDir;
    private getCatalogCachePaths;
    private getCatalogBuiltins;
    private getSyntheticBuiltins;
    private updateCatalogState;
    private getSuppressedCatalogModelRegistryKeys;
    private _invalidateModelRegistry;
    private getModelRegistry;
    /** Register a provider. Overwrites any existing entry with the same name. */
    register(provider: LLMProvider): void;
    /**
     * Register a runtime/plugin-owned provider and optional model definitions.
     * Returns an unregister callback so plugin cleanup can remove the provider and
     * its runtime model/catalog contributions.
     */
    registerRuntimeProvider(registration: RuntimeProviderRegistration): () => void;
    listProviders(): readonly LLMProvider[];
    /**
     * Register providers discovered by the local LLM scanner.
     * Clears previously discovered providers before re-registering.
     * Does not overwrite built-in or custom-loaded providers/models.
     */
    registerDiscoveredProviders(servers: DiscoveredServer[]): void;
    /**
     * Returns `true` if a provider with the given name (or its catalog alias) is registered.
     *
     * @param id - Provider name as registered (e.g. `'anthropic'`, `'openai'`).
     */
    has(id: string): boolean;
    /**
     * Retrieve a provider by name, applying subscription route aliasing.
     * Throws a {@link ProviderNotFoundError} if no provider with that name is registered.
     *
     * The error message includes the list of all currently registered provider IDs
     * to aid discoverability.
     *
     * @param id - Provider name as registered (e.g. `'anthropic'`, `'openai'`).
     * @throws {ProviderNotFoundError} When no matching provider is registered.
     */
    require(id: string): LLMProvider;
    /**
     * Retrieve a provider by name, applying subscription route aliasing.
     * Returns `undefined` if no provider with that name (or its catalog alias) is registered.
     *
     * Prefer {@link require} when you know the provider must exist and want a clear
     * error when it does not.
     *
     * @param name - Provider name as registered (e.g. `'anthropic'`, `'openai'`).
     */
    tryGet(name: string): LLMProvider | undefined;
    get(name: string): LLMProvider | undefined;
    /**
     * Retrieve the directly-registered provider without subscription route aliasing.
     * Throws if no provider with that name (or its catalog alias) is registered.
     *
     * Note: Unlike {@link require}, this method does NOT apply subscription route aliasing
     * (e.g. the openai-subscriber redirect). Prefer {@link require} for general use.
     */
    getRegistered(name: string): LLMProvider;
    describeRuntime(name: string): Promise<ProviderRuntimeMetadata | null>;
    /**
     * Return the provider responsible for a model. Callers without an explicit
     * provider must pass a provider-qualified registryKey (`provider:modelId`).
     */
    getForModel(modelId: string, provider?: string): LLMProvider;
    /** All registered model definitions. */
    listModels(): ModelDefinition[];
    getCostFromCatalog(modelId: string): {
        input: number;
        output: number;
    };
    getContextWindowForModel(modelDef: ModelDefinition): number;
    getTokenLimitsForModel(modelDef: ModelDefinition): Required<TokenLimits>;
    getPricingForModel(modelId: string, provider: string): {
        prompt: number;
        completion: number;
    } | null;
    getToolResultMaxCharsForModel(model: ModelDefinition | null | undefined): number;
    initModelLimits(): void;
    refreshModelLimits(): Promise<number>;
    getRawCatalogModels(): readonly CatalogModel[];
    getCatalogModelDefinitions(): readonly MinimalModelDefinition[];
    getSyntheticModelDefinitions(): readonly MinimalModelDefinition[];
    getSyntheticCanonicalModels(): readonly CanonicalModel[];
    getSyntheticBackendModelIds(): Set<string>;
    getSyntheticModelInfoFromCatalog(modelId: string): import("./model-catalog-synthetic.js").SyntheticModelInfo | null;
    getConfiguredProviderIds(): string[];
    /** Only the models the user can switch to. */
    getSelectableModels(): ModelDefinition[];
    /** Currently active model definition. */
    getCurrentModel(): ModelDefinition;
    /**
     * Override the context window cap for a custom or discovered (local) model.
     * Mutates the live model entry in customModels or discoveredModels so the change
     * is reflected immediately without requiring a full provider reload.
     *
     * @param registryKey - The model's registryKey (`provider:id`).
     * @param cap         - New context window value in tokens.
     * @remarks Context cap is session-only. Not persisted to config — lost on restart.
     */
    setModelContextCap(registryKey: string, cap: number): void;
    /** Switch to a different model. Requires the model registryKey (`provider:modelId`). */
    setCurrentModel(registryKey: string): void;
    /**
     * Load custom providers from the configured providers directory and merge them
     * into the live model registry. Returns any warnings collected during loading.
     * Call this after construction to populate custom providers.
     */
    loadCustomProviders(): Promise<{
        warnings: string[];
        added: string[];
        removed: string[];
        updated: string[];
    }>;
    /**
     * Start watching the configured providers directory for file changes.
     * On change, reloads custom providers and emits typed provider runtime events.
     * Safe to call multiple times — stops the previous watcher first.
     */
    startWatching(runtimeBus?: RuntimeEventBus | null): void;
    /** Stop the file watcher started by startWatching(). */
    stopWatching(): void;
    /**
     * Returns a promise that resolves when the initial custom provider load
     * completes. Callers can await this before looking up a custom registryKey.
     */
    ready(): Promise<void>;
    /**
     * Find an alternative model when the current provider fails non-transiently.
     * Prefers a synthetic failover wrapper; falls back to same-tier model on a different provider.
     */
    findAlternativeModel(currentRegistryKey: string): ModelDefinition | null;
    /**
     * Resolve the full capability record for a model.
     * Requires a provider-qualified registryKey.
     *
     * @param registryKey - Provider-qualified registryKey (`provider:modelId`).
     * @returns A fully-resolved, immutable `ProviderCapability`.
     */
    getCapabilityForModel(registryKey: string): ProviderCapability;
    /**
     * Check whether a model can handle a request described by `profile`.
     * Fails early with a typed explanation when unsupported — avoids mid-stream errors.
     *
     * @param registryKey - Provider-qualified registryKey.
     * @param profile - The capability requirements for this request.
     * @returns A `RouteExplanation` with `accepted` flag, rejections, and capability.
     */
    explainRoute(registryKey: string, profile: RequestProfile): RouteExplanation;
    /**
     * Resolve the provider identity and instance for a registryKey.
     * Shared by `getCapabilityForModel` and `explainRoute` to avoid duplication.
     *
     * @param registryKey - Provider-qualified registryKey (`provider:modelId`).
     */
    private _resolveModelContext;
    /** Kick off async custom provider loading. Called once from bootstrap-owned construction. */
    initCustomProviders(): void;
    initCatalog(): void;
    refreshCatalog(): Promise<void>;
    private _catalogLifecycleCtx;
}
//# sourceMappingURL=registry.d.ts.map