Skip to content

Commit cbc1c57

Browse files
committed
fix(qqbot): align #69546 fix with merged main
Two follow-ups after merging upstream main into the PR: 1. Switch the qqbot gateway off the deprecated `openclaw/plugin-sdk/config-types` subpath. `extensions/qqbot/src/engine/gateway/active-cfg.ts` and `extensions/qqbot/src/engine/gateway/types.ts` now import `OpenClawConfig` from the public `openclaw/plugin-sdk/core` entrypoint, matching the sanctioned surface kept by the package contract guardrails. 2. Update the new #69546 regression test for the async ResolvedChannelMessageIngress refactor (a0fb7fb): await every `runAccessStage` call, stub the new `session` and `turn` runtime channel surfaces, and provide an allow-decision access adapter so the post-route access check resolves.
1 parent 21ddbc9 commit cbc1c57

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

extensions/qqbot/src/engine/gateway/active-cfg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Issue #69546.
1111
*/
1212

13-
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
13+
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
1414
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
1515

1616
export type GatewayCfg = OpenClawConfig;

extensions/qqbot/src/engine/gateway/stages/access-stage.test.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
import { describe, expect, it, vi } from "vitest";
12+
import type { QQBotInboundAccess } from "../../adapter/index.js";
1213
import type { InboundPipelineDeps } from "../inbound-context.js";
1314
import type { QueuedMessage } from "../message-queue.js";
1415
import type { GatewayAccount, GatewayPluginRuntime } from "../types.js";
@@ -61,12 +62,23 @@ function buildRuntime(
6162
formatInboundEnvelope: vi.fn(() => ""),
6263
resolveEnvelopeFormatOptions: vi.fn(() => ({})),
6364
},
65+
session: {
66+
resolveStorePath: vi.fn(() => ""),
67+
recordInboundSession: vi.fn(async () => undefined),
68+
},
69+
turn: { run: vi.fn(async () => undefined) },
6470
text: { chunkMarkdownText: vi.fn(() => []) },
6571
},
6672
tts: { textToSpeech: vi.fn() },
6773
};
6874
}
6975

76+
function buildAllowAccess(): QQBotInboundAccess {
77+
return {
78+
senderAccess: { decision: "allow" },
79+
} as unknown as QQBotInboundAccess;
80+
}
81+
7082
function buildDeps(
7183
cfg: unknown,
7284
runtime: GatewayPluginRuntime,
@@ -77,12 +89,17 @@ function buildDeps(
7789
cfg,
7890
runtime,
7991
startTyping: vi.fn(),
80-
adapters: {} as InboundPipelineDeps["adapters"],
92+
adapters: {
93+
access: {
94+
resolveInboundAccess: vi.fn(() => buildAllowAccess()),
95+
resolveSlashCommandAuthorization: vi.fn(() => true),
96+
},
97+
} as unknown as InboundPipelineDeps["adapters"],
8198
};
8299
}
83100

84101
describe("runAccessStage — dynamic cfg routing (#69546)", () => {
85-
it("re-evaluates resolveAgentRoute against the cfg supplied on each call", () => {
102+
it("re-evaluates resolveAgentRoute against the cfg supplied on each call", async () => {
86103
const account = buildAccount();
87104
const peerId = "480562E9913A985D4A79822A643E27B6";
88105

@@ -111,13 +128,13 @@ describe("runAccessStage — dynamic cfg routing (#69546)", () => {
111128

112129
const event = buildEvent(peerId);
113130

114-
const first = runAccessStage(event, buildDeps(accountOnly, runtime, account));
131+
const first = await runAccessStage(event, buildDeps(accountOnly, runtime, account));
115132
expect(first.kind).toBe("allow");
116133
if (first.kind === "allow") {
117134
expect(first.route.agentId).toBe("study");
118135
}
119136

120-
const second = runAccessStage(event, buildDeps(withPeer, runtime, account));
137+
const second = await runAccessStage(event, buildDeps(withPeer, runtime, account));
121138
expect(second.kind).toBe("allow");
122139
if (second.kind === "allow") {
123140
expect(second.route.agentId).toBe("tutor");
@@ -128,7 +145,7 @@ describe("runAccessStage — dynamic cfg routing (#69546)", () => {
128145
expect(captured[1]?.cfg).toBe(withPeer);
129146
});
130147

131-
it("never reads bindings from a previous cfg reference", () => {
148+
it("never reads bindings from a previous cfg reference", async () => {
132149
const account = buildAccount();
133150
const seenCfgs = new Set<unknown>();
134151
const runtime = buildRuntime((params) => {
@@ -140,9 +157,9 @@ describe("runAccessStage — dynamic cfg routing (#69546)", () => {
140157
const cfgB: StubCfg = { bindings: [] };
141158
const cfgC: StubCfg = { bindings: [] };
142159

143-
runAccessStage(buildEvent("a"), buildDeps(cfgA, runtime, account));
144-
runAccessStage(buildEvent("b"), buildDeps(cfgB, runtime, account));
145-
runAccessStage(buildEvent("c"), buildDeps(cfgC, runtime, account));
160+
await runAccessStage(buildEvent("a"), buildDeps(cfgA, runtime, account));
161+
await runAccessStage(buildEvent("b"), buildDeps(cfgB, runtime, account));
162+
await runAccessStage(buildEvent("c"), buildDeps(cfgC, runtime, account));
146163

147164
expect(seenCfgs.size).toBe(3);
148165
expect(seenCfgs.has(cfgA)).toBe(true);

extensions/qqbot/src/engine/gateway/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
// ============ Logger ============
10-
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
10+
import type { OpenClawConfig } from "openclaw/plugin-sdk/core";
1111
import type { EngineLogger } from "../types.js";
1212
export type { EngineLogger };
1313

0 commit comments

Comments
 (0)