import "./paths-D4_LjrY7.js";
import "./utils-BnlaT0eO.js";
import "./theme-CG-K7m8u.js";
import "./subsystem-ocBR131w.js";
import "./runtime-CRvfzclG.js";
import "./exec-CZr_EJHt.js";
import "./agent-scope-CVnlY0oG.js";
import "./model-selection-p6J3l4qF.js";
import "./github-copilot-token-CjSKohyA.js";
import "./emitter-oHo8y9ow.js";
import "./sqlite-wYNyDR1B.js";
import "./reliability-Dl7hbRzF.js";
import "./boolean-DGGu1sGA.js";
import "./env-CvUd308i.js";
import "./validation-p1IK70TM.js";
import { o as loadConfig } from "./config-DJ3A5x_1.js";
import "./manifest-registry-U2EDFVP4.js";
import "./pi-model-discovery-4-XyjjxG.js";
import "./image-ops-C0D77XHD.js";
import "./normalize-DgwtBdm-.js";
import "./accounts-BZv5WxME.js";
import "./bindings-BbaWTQJM.js";
import "./logging-wfRfbMvt.js";
import "./plugins-DYgcd4QJ.js";
import "./tool-images-CRPqucMe.js";
import { n as SILENT_REPLY_TOKEN } from "./tokens-DuLZdp8u.js";
import { x as textToSpeech } from "./tts-pLGM3rbp.js";
import "./audio-Cf4_M2_g.js";
import "./model-p-v6-khS.js";
import { u as readStringParam } from "./common-oaZdjdal.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 };