import { listMediaUnderstandingProviders } from "../../media-understanding/registry.js";
import { resolveSTTProviderConfig } from "./factory.js";
import { mergeSttConfigFromAppConfig } from "../../channels/attachments/voice-stt-webchat.js";
import { getVoiceProviderMetadata } from "../metadata/registry.js";
import "../metadata/index.js";
//#region src/voice/stt/list-providers.ts
function fallbackMetadata(providerId, aliases) {
	return {
		id: providerId,
		capability: "stt",
		displayName: providerId,
		aliases: [...aliases],
		fields: [
			{
				key: "apiKey",
				label: "API Key",
				type: "password",
				secret: true
			},
			{
				key: "model",
				label: "Model",
				type: "string"
			},
			{
				key: "baseUrl",
				label: "Base URL",
				type: "string"
			}
		],
		diagnostics: {
			requiresApiKey: true,
			configPath: `tools.media.audio.providers.${providerId}`
		}
	};
}
function isSttProviderConfigured(providerId, config) {
	return resolveSTTProviderConfig(providerId, config) !== null;
}
/** List registered audio STT providers with configured state and UI metadata. */
function listSttProvidersForApi(config) {
	const sttConfig = mergeSttConfigFromAppConfig(config?.tools?.media?.audio, config?.tools?.media);
	return {
		providers: listMediaUnderstandingProviders().filter((plugin) => plugin.capabilities?.includes("audio") && typeof plugin.transcribeAudio === "function").map((plugin) => {
			const metadata = getVoiceProviderMetadata("stt", plugin.id) ?? fallbackMetadata(plugin.id, plugin.aliases ?? []);
			return {
				...metadata,
				aliases: [...metadata.aliases ?? plugin.aliases ?? []],
				configured: isSttProviderConfigured(plugin.id, sttConfig)
			};
		}),
		active: sttConfig.provider
	};
}
//#endregion
export { isSttProviderConfigured, listSttProvidersForApi };

//# sourceMappingURL=list-providers.js.map