import "./subsystem-B57zAnh3.js";
import "./paths-aMBPuCJR.js";
import "./auth-profiles-vy16iW9a.js";
import "./env-DFfOiqpV.js";
import "./exec-rVpUMUjU.js";
import "./agent-scope-C3vq_G9s.js";
import "./github-copilot-token-5G6j3BB0.js";
import "./reliability-CU83NHOD.js";
import "./sqlite-CbyDDiup.js";
import "./pi-model-discovery-DbR2V53Y.js";
import { n as SILENT_REPLY_TOKEN } from "./tokens-B3tTD53l.js";
import "./accounts-Diz2TIQa.js";
import "./normalize-C804TuMz.js";
import "./bindings-DLG2Bod-.js";
import "./plugins-DqFdJSNb.js";
import { b as textToSpeech } from "./tts-B4gLA27e.js";
import "./image-ops-D6in9bm7.js";
import { n as loadConfig } from "./config-BWfcFg-o.js";
import "./manifest-registry-DOrMVNcS.js";
import "./tool-images-DTeIBF5l.js";
import { u as readStringParam } from "./common-CBZ0Olph.js";
import { Type } from "@sinclair/typebox";

//#region src/agents/tools/media/tts-tool.ts
const TtsToolSchema = Type.Object({
	text: Type.String({ description: "Text to convert to speech." }),
	channel: Type.Optional(Type.String({ description: "Optional channel id to pick output format (e.g. telegram)." }))
});
function createTtsTool(opts) {
	return {
		label: "TTS",
		name: "tts",
		description: `Convert text to speech. Audio is delivered automatically from the tool result — reply with ${SILENT_REPLY_TOKEN} after a successful call to avoid duplicate messages.`,
		parameters: TtsToolSchema,
		execute: async (_toolCallId, args) => {
			const params = args;
			const text = readStringParam(params, "text", { required: true });
			const channel = readStringParam(params, "channel");
			const result = await textToSpeech({
				text,
				cfg: opts?.config ?? loadConfig(),
				channel: channel ?? opts?.agentChannel
			});
			if (result.success && result.audioPath) {
				const lines = [];
				if (result.voiceCompatible) lines.push("[[audio_as_voice]]");
				lines.push(`MEDIA:${result.audioPath}`);
				return {
					content: [{
						type: "text",
						text: lines.join("\n")
					}],
					details: {
						audioPath: result.audioPath,
						provider: result.provider
					}
				};
			}
			return {
				content: [{
					type: "text",
					text: result.error ?? "TTS conversion failed"
				}],
				details: { error: result.error }
			};
		}
	};
}

//#endregion
export { createTtsTool };