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

推荐订阅源

小众软件
小众软件
C
Check Point Blog
Vercel News
Vercel News
Y
Y Combinator Blog
G
Google Developers Blog
P
Proofpoint News Feed
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
L
LangChain Blog
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
博客园_首页
B
Blog RSS Feed
The Cloudflare Blog
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog

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
Gate QQBot streaming command auth [AI] (#76375) · opencla...
pgondhi987 · 2026-05-04 · via Recent Commits to openclaw:main

@@ -0,0 +1,113 @@

1+

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";

2+

import type {

3+

OpenClawPluginApi,

4+

OpenClawPluginCommandDefinition,

5+

PluginCommandContext,

6+

} from "openclaw/plugin-sdk/plugin-entry";

7+

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

8+

import {

9+

getWrittenQQBotConfig,

10+

installCommandRuntime,

11+

} from "../../engine/commands/slash-command-test-support.js";

12+

import { ensurePlatformAdapter } from "../bootstrap.js";

13+

import { registerQQBotFrameworkCommands } from "./framework-registration.js";

14+15+

function createConfig(): OpenClawConfig {

16+

return {

17+

channels: {

18+

qqbot: {

19+

appId: "app",

20+

allowFrom: ["TRUSTED_OPENID"],

21+

streaming: false,

22+

accounts: {

23+

default: {

24+

allowFrom: ["TRUSTED_OPENID"],

25+

streaming: false,

26+

},

27+

},

28+

},

29+

},

30+

};

31+

}

32+33+

function registerCommands(): OpenClawPluginCommandDefinition[] {

34+

ensurePlatformAdapter();

35+

const commands: OpenClawPluginCommandDefinition[] = [];

36+

const api = {

37+

logger: {},

38+

registerCommand: (command: OpenClawPluginCommandDefinition) => {

39+

commands.push(command);

40+

},

41+

} as unknown as OpenClawPluginApi;

42+43+

registerQQBotFrameworkCommands(api);

44+

return commands;

45+

}

46+47+

function findCommand(

48+

commands: OpenClawPluginCommandDefinition[],

49+

name: string,

50+

): OpenClawPluginCommandDefinition {

51+

const command = commands.find((entry) => entry.name === name);

52+

expect(command).toBeDefined();

53+

return command as OpenClawPluginCommandDefinition;

54+

}

55+56+

function createCommandContext(

57+

config: OpenClawConfig,

58+

from: string | undefined,

59+

): PluginCommandContext {

60+

return {

61+

senderId: "TRUSTED_OPENID",

62+

channel: "qqbot",

63+

isAuthorizedSender: true,

64+

args: "on",

65+

commandBody: "/bot-streaming on",

66+

config,

67+

from,

68+

requestConversationBinding: async () => undefined,

69+

detachConversationBinding: async () => ({ removed: false }),

70+

getCurrentConversationBinding: async () => null,

71+

} as unknown as PluginCommandContext;

72+

}

73+74+

describe("registerQQBotFrameworkCommands", () => {

75+

it("registers bot-streaming as an auth-gated framework command", () => {

76+

const command = findCommand(registerCommands(), "bot-streaming");

77+78+

expect(command.requireAuth).toBe(true);

79+

});

80+81+

it("preserves the private-chat guard for bot-streaming on generic framework calls", async () => {

82+

const config = createConfig();

83+

const writes: OpenClawConfig[] = [];

84+

installCommandRuntime(config, writes);

85+

const command = findCommand(registerCommands(), "bot-streaming");

86+87+

const missingFromResult = await command.handler(createCommandContext(config, undefined));

88+

const nonQQBotResult = await command.handler(createCommandContext(config, "generic:dm:user"));

89+

const groupResult = await command.handler(

90+

createCommandContext(config, "qqbot:group:GROUP_OPENID"),

91+

);

92+93+

expect(missingFromResult).toEqual({ text: "💡 请在私聊中使用此指令" });

94+

expect(nonQQBotResult).toEqual({ text: "💡 请在私聊中使用此指令" });

95+

expect(groupResult).toEqual({ text: "💡 请在私聊中使用此指令" });

96+

expect(writes).toHaveLength(0);

97+

});

98+99+

it("allows bot-streaming on explicit QQBot private-chat framework calls", async () => {

100+

const config = createConfig();

101+

const writes: OpenClawConfig[] = [];

102+

installCommandRuntime(config, writes);

103+

const command = findCommand(registerCommands(), "bot-streaming");

104+105+

const result = await command.handler(createCommandContext(config, "qqbot:c2c:TRUSTED_OPENID"));

106+107+

const qqbot = getWrittenQQBotConfig(writes[0]);

108+

expect(result).toMatchObject({ text: expect.stringContaining("已开启") });

109+

expect(writes).toHaveLength(1);

110+

expect(qqbot?.streaming).toBe(true);

111+

expect(qqbot?.accounts?.default?.streaming).toBe(true);

112+

});

113+

});