import "./paths-WcYpcMAY.js";
import "./auth-profiles-CaNK0cUT.js";
import "./exec-CmvuUufz.js";
import "./agent-scope-E2aR3Ci_.js";
import "./github-copilot-token-CKOQDjEZ.js";
import "./emitter-BKo8D7Oj.js";
import "./sqlite-CVrhPija.js";
import "./reliability-BnL75OlZ.js";
import "./pi-model-discovery-Cd63DV2B.js";
import "./model-nrbMzlbz.js";
import "./manifest-registry-AgGLF4V7.js";
import "./validation-B00oOkJ3.js";
import { o as loadConfig } from "./config-CoCeK5B2.js";
import { n as SILENT_REPLY_TOKEN } from "./tokens-D-4TlWcT.js";
import "./accounts-CNwod9BY.js";
import "./normalize-CRf-uoB2.js";
import "./bindings-B1hNZin3.js";
import "./logging-BiuZwq5D.js";
import "./plugins-DMpYx7kb.js";
import { x as textToSpeech } from "./tts-CLI3TzKv.js";
import "./image-ops-D0pBQqKh.js";
import "./audio-xR21p4sl.js";
import "./tool-images-B4eVOjD0.js";
import { u as readStringParam } from "./common-CxpUJZLb.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 };