

























@@ -10,6 +10,7 @@ import type {
1010import type { OpenClawConfig } from "../../config/config.js";
1111import { getActivePluginRegistry, setActivePluginRegistry } from "../../plugins/runtime.js";
1212import { createTestRegistry } from "../../test-utils/channel-plugins.js";
13+import { GATEWAY_CLIENT_MODES, GATEWAY_CLIENT_NAMES } from "../../utils/message-channel.js";
1314import { runMessageAction } from "./message-action-runner.js";
1415import { extractToolPayload } from "./tool-payload.js";
1516@@ -439,6 +440,66 @@ describe("runMessageAction plugin dispatch", () => {
439440});
440441});
441442443+it("ignores gateway url overrides for backend plugin actions", async () => {
444+const gatewayPlugin = createGatewayActionPlugin({
445+pluginId: "gatewaychat",
446+label: "Gateway Chat",
447+blurb: "Gateway Chat backend action test plugin.",
448+actions: ["react"],
449+capabilities: { chatTypes: ["direct"], reactions: true },
450+handleAction: vi.fn(async () => jsonResult({ ok: true, local: true })),
451+});
452+setActivePluginRegistry(
453+createTestRegistry([
454+{
455+pluginId: "gatewaychat",
456+source: "test",
457+plugin: gatewayPlugin,
458+},
459+]),
460+);
461+mocks.callGatewayLeastPrivilege.mockResolvedValue({
462+ok: true,
463+added: "ok",
464+});
465+466+await runMessageAction({
467+cfg: {
468+channels: {
469+gatewaychat: {
470+enabled: true,
471+},
472+},
473+} as OpenClawConfig,
474+action: "react",
475+params: {
476+channel: "gatewaychat",
477+to: "+15551234567",
478+chatJid: "+15551234567",
479+messageId: "wamid.1",
480+emoji: "ok",
481+},
482+gateway: {
483+url: "ws://127.0.0.1:18789",
484+token: "configured-token",
485+timeoutMs: 5000,
486+clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
487+mode: GATEWAY_CLIENT_MODES.BACKEND,
488+},
489+dryRun: false,
490+});
491+492+expect(mocks.callGatewayLeastPrivilege).toHaveBeenCalledWith(
493+expect.objectContaining({
494+url: undefined,
495+token: "configured-token",
496+timeoutMs: 5000,
497+clientName: GATEWAY_CLIENT_NAMES.GATEWAY_CLIENT,
498+mode: GATEWAY_CLIENT_MODES.BACKEND,
499+}),
500+);
501+});
502+442503it("routes gateway-executed plugin sends through gateway RPC instead of local dispatch", async () => {
443504const handleAction = vi.fn(async () => jsonResult({ ok: true, local: true }));
444505const gatewayPlugin = createGatewayActionPlugin({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。