From a512b5dde9a87e57cec48f8db570ae2fa3304e25 Mon Sep 17 00:00:00 2001 From: "openclaw-clawsweeper[bot]" <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 15:59:56 +0000 Subject: [PATCH] fix: The commit introduces imports from `src/channels/plugins/dm-acces --- .../monitor/inbound-dispatch.test.ts | 2 +- src/plugin-sdk/channel-config-helpers.test.ts | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts b/extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts index 1f1b09785bf..2b367f38ce9 100644 --- a/extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts +++ b/extensions/whatsapp/src/auto-reply/monitor/inbound-dispatch.test.ts @@ -720,7 +720,7 @@ describe("whatsapp inbound dispatch", () => { warn: vi.fn(), error: vi.fn(), debug: vi.fn(), - } as BufferedReplyParams["replyLogger"]; + } as unknown as BufferedReplyParams["replyLogger"]; const error = new Error("send failed"); await dispatchBufferedReply({ diff --git a/src/plugin-sdk/channel-config-helpers.test.ts b/src/plugin-sdk/channel-config-helpers.test.ts index c5e23f1e4f8..cf46fed35f2 100644 --- a/src/plugin-sdk/channel-config-helpers.test.ts +++ b/src/plugin-sdk/channel-config-helpers.test.ts @@ -14,10 +14,14 @@ import { createHybridChannelConfigBase, ensureOpenDmPolicyAllowFromWildcard, mapAllowFromEntries, + normalizeChannelDmPolicy, normalizeLegacyDmAliases, resolveChannelDmAccess, + resolveChannelDmAllowFrom, + resolveChannelDmPolicy, resolveChannelConfigWrites, resolveOptionalConfigString, + setCanonicalDmAllowFrom, } from "./channel-config-helpers.js"; const resolveDefaultAccountId = () => DEFAULT_ACCOUNT_ID; @@ -123,6 +127,38 @@ describe("resolveOptionalConfigString", () => { }); describe("channel DM access helpers", () => { + it("re-exports centralized DM access helpers from the SDK entrypoint", () => { + const entry = { dm: { policy: "allowlist", allowFrom: ["U1"] } }; + const changes: string[] = []; + + expect(normalizeChannelDmPolicy("allowlist")).toBe("allowlist"); + expect( + resolveChannelDmPolicy({ + account: entry, + }), + ).toBe("allowlist"); + expect( + resolveChannelDmAllowFrom({ + account: entry, + }), + ).toEqual(["U1"]); + + setCanonicalDmAllowFrom({ + entry, + mode: "topOnly", + allowFrom: ["U2"], + pathPrefix: "channels.demo", + changes, + reason: "normalized by SDK helper", + }); + + expect(entry).toEqual({ dm: { policy: "allowlist" }, allowFrom: ["U2"] }); + expect(changes).toEqual([ + "- channels.demo.dm.allowFrom: removed after moving allowlist to channels.demo.allowFrom", + "- channels.demo.allowFrom: normalized by SDK helper", + ]); + }); + it("resolves account legacy allowFrom before inherited root allowFrom", () => { expect( resolveChannelDmAccess({