import "./subsystem-Ci61Iebe.js";
import "./paths-aMBPuCJR.js";
import "./auth-profiles-CRqdowVc.js";
import "./env-3oW17BWM.js";
import "./exec-B5OgjUV4.js";
import "./agent-scope-CCFV2dzL.js";
import "./github-copilot-token-sMZoP3ZH.js";
import "./reliability-B6TVU4OW.js";
import "./sqlite-CbyDDiup.js";
import "./pi-model-discovery-BSu-IJqG.js";
import { n as SILENT_REPLY_TOKEN } from "./tokens-Bvij_SSC.js";
import "./accounts-TaYXhwSR.js";
import "./normalize-Dz9m5w2g.js";
import "./bindings-jC2ZutIF.js";
import "./plugins-6aUfx6Yt.js";
import { b as textToSpeech } from "./tts-DIvxcZRf.js";
import "./image-ops-DfgorOBP.js";
import { n as loadConfig } from "./config-i4b9k_EZ.js";
import "./manifest-registry-BPLS_vpk.js";
import "./tool-images-D39TNWEi.js";
import { u as readStringParam } from "./common-BkBiFnII.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 };