/** Runtime-side provider discovery and provider registration resolution helpers. */ import { createLazyImportLoader } from "../shared/lazy-promise.js"; type ProviderRuntimeModule = typeof import("./provider-runtime.js"); type AugmentModelCatalogWithProviderPlugins = ProviderRuntimeModule["augmentModelCatalogWithProviderPlugins"]; type BuildProviderAuthDoctorHintWithPlugin = ProviderRuntimeModule["buildProviderAuthDoctorHintWithPlugin"]; type BuildProviderMissingAuthMessageWithPlugin = ProviderRuntimeModule["buildProviderMissingAuthMessageWithPlugin"]; type FormatProviderAuthProfileApiKeyWithPlugin = ProviderRuntimeModule["formatProviderAuthProfileApiKeyWithPlugin"]; type PrepareProviderRuntimeAuth = ProviderRuntimeModule["prepareProviderRuntimeAuth"]; type RefreshProviderOAuthCredentialWithPlugin = ProviderRuntimeModule["refreshProviderOAuthCredentialWithPlugin"]; const providerRuntimeLoader = createLazyImportLoader( () => import("./provider-runtime.js"), ); async function loadProviderRuntime(): Promise { // Keep the heavy provider runtime behind an actual async boundary so callers // can import this wrapper eagerly without collapsing the lazy chunk. return await providerRuntimeLoader.load(); } /** Lazily augments the model catalog with provider plugin metadata. */ export async function augmentModelCatalogWithProviderPlugins( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.augmentModelCatalogWithProviderPlugins(...args); } /** Lazily builds doctor hint text for provider auth problems. */ export async function buildProviderAuthDoctorHintWithPlugin( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.buildProviderAuthDoctorHintWithPlugin(...args); } /** Lazily builds missing-auth messages with provider plugin context. */ export async function buildProviderMissingAuthMessageWithPlugin( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.buildProviderMissingAuthMessageWithPlugin(...args); } /** Lazily formats API-key auth profile display text with provider plugin rules. */ export async function formatProviderAuthProfileApiKeyWithPlugin( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.formatProviderAuthProfileApiKeyWithPlugin(...args); } /** Lazily prepares provider runtime auth for model execution. */ export async function prepareProviderRuntimeAuth( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.prepareProviderRuntimeAuth(...args); } /** Lazily refreshes OAuth credentials through provider plugin runtime hooks. */ export async function refreshProviderOAuthCredentialWithPlugin( ...args: Parameters ): Promise>> { const runtime = await loadProviderRuntime(); return runtime.refreshProviderOAuthCredentialWithPlugin(...args); }