Merge c369f490dd18bbff3c4c19611d0a3dd571204a19 into 43513cd1df63af0704dfb351ee7864607f955dcc
This commit is contained in:
commit
9a75cebbe7
@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user