/** * Runtime registry for user-defined ("custom") LLM providers. * * Built-in providers live in the compile-time `providerIds` tuple, so their * `ProviderId` values are part of the type system. Custom providers are added * at runtime by the user (via the `/provider` "Add custom provider" flow) and * are plain strings. This module is the single source of truth for those. */ import { type LlmProvider } from "./provider.js"; import type { CompatibleUsageAliases } from "./token-usage.js"; import { type CustomProviderProfileSpec } from "./custom-provider-profile.js"; /** Persisted shape of one user-defined provider (JSON-serialisable). */ export interface CustomProviderDef { readonly id: string; readonly displayName: string; /** Normalised base URL ending in `/v1`. */ readonly baseUrl: string; readonly envVar?: string | undefined; /** Separate API-key environment; takes precedence over `envVar`. */ readonly keyEnv?: string | undefined; /** Separate endpoint environment; `envVar` never doubles as one. */ readonly baseUrlEnv?: string | undefined; readonly defaultModel: string; /** Optional telemetry-only aliases relative to a compatible `usage` object. */ readonly usageAliases?: CompatibleUsageAliases | undefined; /** Optional validated wire-profile declaration. */ readonly profile?: CustomProviderProfileSpec | undefined; } /** Validation errors for a definition's declared profile, if any. */ export declare function customProviderProfileErrors(def: CustomProviderDef): string[]; /** Build an OpenAI-compatible `LlmProvider` for a custom definition. */ export declare function buildCustomProvider(def: CustomProviderDef): LlmProvider; /** All custom provider ids currently registered in config. */ export declare function getCustomProviderIds(): Promise; /** Resolve a custom definition by id (sync, against a provided defs list). */ export declare function findCustomProviderDef(id: string, defs: readonly CustomProviderDef[]): CustomProviderDef | undefined; /** Resolve a custom definition by id. */ export declare function getCustomProvider(id: string): Promise; export declare function getCustomProviderSync(id: string): LlmProvider | undefined; /** Invalidate the in-memory provider cache for one id (or all when omitted). */ export declare function invalidateCustomProviderCache(id?: string): void; /** Build an `LlmProvider` from a definition without config (for the add flow). */ export declare function materializeCustomProvider(def: CustomProviderDef): LlmProvider; /** Validate + normalise a candidate custom provider id. Returns `""` on invalid. */ export declare function normalizeCustomProviderId(raw: string, existing: readonly string[]): string; /** Normalise a base URL the way the OpenAI helpers expect (`/v1` suffix). */ export declare function normalizeCustomBaseUrl(raw: string): string;