import type { LLMProvider, LLMProviderConstructor, LazyProviderLoader, ProviderCapabilities, ProviderConfigRegistry, ProviderFactoryConfig, ProviderFactoryResult, ProviderType, RegisterLazyOptions, RegisterOptions } from '../types/provider/index.js'; export declare class UnknownProviderError extends Error { readonly providerType: string; constructor(providerType: string); } export declare class DuplicateProviderError extends Error { readonly providerType: string; constructor(providerType: string); } /** * The loader passed to `ProviderRegistry.registerLazy()` rejected (or * resolved to something without a `create(config)` function). Wraps the * original failure as `cause`. The failed load is NOT cached — the next * `createAsync()` for the type re-invokes the loader, so a transient * failure (network hiccup during a dynamic import) does not permanently * poison the type. */ export declare class LazyProviderLoadError extends Error { readonly providerType: string; constructor(providerType: string, cause: unknown); } /** * A synchronous `create()`/`createProvider()` was called for a type * registered via `registerLazy()`. Lazy types are only constructible * through the async path — deterministically, even after the loader has * resolved, so calling code never depends on load-order timing. */ export declare class LazyProviderSyncCreateError extends Error { readonly providerType: string; constructor(providerType: string); } /** * Central registry for LLM providers. * * Provider packages (@namzu/bedrock, @namzu/openai, etc.) export a * `register()` function that calls `ProviderRegistry.register()` * with a vendor-specific type string, provider class, and capabilities. * * The core sdk pre-registers `MockLLMProvider` under type `'mock'`. * * @example * ```ts * import { ProviderRegistry } from '@namzu/sdk' * import { registerBedrock } from '@namzu/bedrock' * * registerBedrock() * * const { provider, capabilities } = ProviderRegistry.create({ * type: 'bedrock', * region: 'us-east-1', * }) * ``` * * Hosts that must not eagerly bundle every provider client register a * LOADER instead and construct through the async path: * * @example * ```ts * ProviderRegistry.registerLazy( * 'anthropic', * async () => { * const m = await import('@namzu/anthropic') * return { create: (c) => new m.AnthropicProvider(c), capabilities: m.ANTHROPIC_CAPABILITIES } * }, * { capabilities: { supportsTools: true, supportsStreaming: true, supportsFunctionCalling: true } }, * ) * * const { provider } = await ProviderRegistry.createAsync({ type: 'anthropic', apiKey }) * ``` */ export declare class ProviderRegistry { static register(type: K, ctor: LLMProviderConstructor, caps: ProviderCapabilities, options?: RegisterOptions): void; /** * Register a provider type WITHOUT importing its implementation. The * loader is not invoked here; the first `createAsync()` for the type * awaits it, validates the resolved `{ create }` module, and caches it. * Subsequent creates reuse the cached factory. Only SUCCESS is cached: * a rejected load surfaces as `LazyProviderLoadError` and the next * `createAsync()` retries the loader. Concurrent first-creates share a * single in-flight load. * * Capability precedence (weakest first): * 1. `options.capabilities` — pre-load HINT so `getCapabilities(type)` * answers without loading (absent hint ⇒ permissive default, matching * `resolveProviderCapabilities`'s treatment of undeclared providers). * 2. the loaded module's `capabilities` — replaces the hint on load. * 3. the constructed instance's own `LLMProvider.capabilities` — the * query runtime negotiates against the INSTANCE * (`resolveProviderCapabilities(provider)`), so if it differs from * both of the above, the instance wins where it matters. * * Lazy types are deliberately NOT constructible via the sync * `create()`/`createProvider()` (throws `LazyProviderSyncCreateError`), * even after the loader has resolved — sync behavior must not depend on * whether some earlier call happened to load the module. */ static registerLazy(type: K, loader: LazyProviderLoader, options?: RegisterLazyOptions): void; static create(config: ProviderFactoryConfig): ProviderFactoryResult; /** * Async twin of `create()`. Works for BOTH eager and lazy registrations, * so hosts can use one code path; for lazy types it performs the * load-on-first-use described on `registerLazy()`. */ static createAsync(config: ProviderFactoryConfig): Promise; static createProvider(config: ProviderFactoryConfig): LLMProvider; static createProviderAsync(config: ProviderFactoryConfig): Promise; /** * Type-level capabilities. For a lazily-registered type this answers * WITHOUT invoking the loader: the registration hint if one was given, * otherwise the permissive default (assume everything — consistent with * how `resolveProviderCapabilities` treats an undeclared provider). Once * loaded, a module-shipped declaration replaces the hint. Note the query * runtime negotiates against the constructed INSTANCE's own * `capabilities`, which wins over anything stored here. */ static getCapabilities(type: string): ProviderCapabilities; static isSupported(type: string): type is ProviderType; static unregister(type: ProviderType): boolean; static listTypes(): ProviderType[]; } /** * @internal — not exported from the package barrel. Do not use in production code. * Available to in-tree tests via relative import (`./provider/registry.js`). * External consumers cannot reach this because `@namzu/sdk` only exports `.`. */ export declare function __resetProviderRegistryInternal(): void; //# sourceMappingURL=registry.d.ts.map