惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
量子位
腾讯CDC
A
About on SuperTechFans
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
V
V2EX
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
罗磊的独立博客
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
有赞技术团队
有赞技术团队

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat(discord): control active realtime voice runs · openc...
steipete · 2026-05-24 · via Recent Commits to openclaw:main

@@ -0,0 +1,81 @@

1+

import { beforeEach, describe, expect, it, vi } from "vitest";

2+

import { maybeControlDiscordVoiceAgentRun } from "./agent-control.js";

3+4+

const mocks = vi.hoisted(() => ({

5+

controlRealtimeVoiceAgentRun: vi.fn(),

6+

shouldAutoControlRealtimeVoiceAgentText: vi.fn(),

7+

}));

8+9+

vi.mock("openclaw/plugin-sdk/realtime-voice", () => ({

10+

controlRealtimeVoiceAgentRun: mocks.controlRealtimeVoiceAgentRun,

11+

shouldAutoControlRealtimeVoiceAgentText: mocks.shouldAutoControlRealtimeVoiceAgentText,

12+

}));

13+14+

function createEntry() {

15+

return { route: { sessionKey: "discord:g1:c1" } } as Parameters<

16+

typeof maybeControlDiscordVoiceAgentRun

17+

>[0]["entry"];

18+

}

19+20+

describe("maybeControlDiscordVoiceAgentRun", () => {

21+

beforeEach(() => {

22+

vi.clearAllMocks();

23+

mocks.shouldAutoControlRealtimeVoiceAgentText.mockReturnValue(true);

24+

});

25+26+

it("falls back for inactive cancel-like phrases", async () => {

27+

const result = {

28+

ok: true,

29+

active: false,

30+

mode: "cancel",

31+

sessionKey: "discord:g1:c1",

32+

message: "There is no active OpenClaw run to cancel.",

33+

speak: true,

34+

suppress: false,

35+

};

36+

mocks.controlRealtimeVoiceAgentRun.mockResolvedValue(result);

37+38+

await expect(

39+

maybeControlDiscordVoiceAgentRun({

40+

entry: createEntry(),

41+

text: "cancel my meeting tomorrow",

42+

}),

43+

).resolves.toEqual({ handled: false, result });

44+

});

45+46+

it("handles active cancel requests", async () => {

47+

const result = {

48+

ok: true,

49+

active: true,

50+

mode: "cancel",

51+

sessionKey: "discord:g1:c1",

52+

message: "Cancelled the active OpenClaw run.",

53+

speak: true,

54+

suppress: false,

55+

};

56+

mocks.controlRealtimeVoiceAgentRun.mockResolvedValue(result);

57+58+

await expect(

59+

maybeControlDiscordVoiceAgentRun({

60+

entry: createEntry(),

61+

text: "cancel that",

62+

}),

63+

).resolves.toEqual({

64+

handled: true,

65+

result,

66+

speakText: "Cancelled the active OpenClaw run.",

67+

});

68+

});

69+70+

it("ignores non-control phrases", async () => {

71+

mocks.shouldAutoControlRealtimeVoiceAgentText.mockReturnValue(false);

72+73+

await expect(

74+

maybeControlDiscordVoiceAgentRun({

75+

entry: createEntry(),

76+

text: "what is next",

77+

}),

78+

).resolves.toEqual({ handled: false });

79+

expect(mocks.controlRealtimeVoiceAgentRun).not.toHaveBeenCalled();

80+

});

81+

});