Merge c369f490dd18bbff3c4c19611d0a3dd571204a19 into 43513cd1df63af0704dfb351ee7864607f955dcc

This commit is contained in:
Hiago Silva 2026-03-20 22:36:14 -07:00 committed by GitHub
commit 9a75cebbe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 2 deletions

View File

@ -9,8 +9,15 @@ const { createTtsTool } = await import("./tts-tool.js");
describe("createTtsTool", () => {
it("uses SILENT_REPLY_TOKEN in guidance text", () => {
const tool = createTtsTool();
expect(tool.description).toContain("QUIET_TOKEN");
expect(tool.description).not.toContain("NO_REPLY");
});
it("returns error even when channel arg is provided but no agentChannel", async () => {
const tool = createTtsTool();
const result = await tool.execute("test-call", { text: "hello world", channel: "telegram" });
const firstContent = result.content[0] as { type: string; text: string };
expect(firstContent.text).toContain("requires a bound");
expect((result.details as Record<string, unknown>).error).toBe("no_channel");
});
});

View File

@ -27,11 +27,25 @@ export function createTtsTool(opts?: {
const params = args as Record<string, unknown>;
const text = readStringParam(params, "text", { required: true });
const channel = readStringParam(params, "channel");
const resolvedChannel = channel ?? opts?.agentChannel;
if (!opts?.agentChannel) {
return {
content: [
{
type: "text",
text: 'TTS requires a bound session channel for audio delivery. Use sessionTarget: "main" instead of "isolated".',
},
],
details: { error: "no_channel" },
};
}
const cfg = opts?.config ?? loadConfig();
const result = await textToSpeech({
text,
cfg,
channel: channel ?? opts?.agentChannel,
channel: resolvedChannel,
});
if (result.success && result.audioPath) {