/** * Shared base for the "single active backend" registries (speech-to-text, * text-to-speech, embeddings). Each one is a Map of named defs with at most one * *active* at a time: * - plugins call `register(def)` at load time * - the host / CLI / agent calls `setActive(name, config)` to pick one * - call sites read `getActive()` / `tryGetActive()` to use it (degrading * gracefully when none is active) * * The three concrete registries differ only along a few axes, expressed via * {@link BackendRegistryOptions}: * - how a def becomes an instance (`build`) — `createClient(config)` for * STT/embeddings, `create({ config, getSecret })` for TTS * - whether the first registered def auto-becomes active (`autoAdoptFirst`, * TTS only — STT/embeddings require an explicit `setActive`) * - whether the active instance is (re)built lazily on read (`buildOnRead`, * TTS only — needed because `autoAdoptFirst` can set `active` without ever * building an instance; it also makes `setActive` rebuild when handed a * fresh config) * * `ProviderRegistry` deliberately stays separate: it is the core LLM path and * carries its own ready-state semantics. */ export interface BackendRegistryOptions { /** Capitalised singular noun for error messages, e.g. `'Synthesizer'`. */ readonly noun: string; /** Turn a def + (possibly empty) config into a runtime instance. */ readonly build: (def: TDef, config: Record) => TInstance; /** Adopt the first registered def as active when nothing is active yet. */ readonly autoAdoptFirst?: boolean; /** (Re)build the active instance lazily on read rather than requiring it to * have been built at `setActive` time. Also makes `setActive` rebuild when a * config is supplied. Pair with {@link autoAdoptFirst}. */ readonly buildOnRead?: boolean; } export declare class ActiveBackendRegistry { private readonly opts; private readonly defs; private readonly instances; private active; constructor(opts: BackendRegistryOptions); register(def: TDef, instance?: TInstance): void; /** Overwrite an existing def, dropping the cached instance so the next build * uses the new def. */ replace(def: TDef, instance?: TInstance): void; unregister(name: string): void; list(): ReadonlyArray; has(name: string): boolean; setActive(name: string, config?: Record): TInstance; /** Deactivate the current backend (callers fall back to their default). */ clearActive(): void; getActive(): TInstance; /** Active backend, or null when none is configured. Lets call sites degrade * gracefully (keyword recall, the OS voice, "no transcriber configured"). */ tryGetActive(): TInstance | null; getActiveName(): string | null; /** Cached instance for `name`, building it from its def on first use. */ private instantiate; private buildInstance; } //# sourceMappingURL=active-backend-registry.d.ts.map