From 8d3bd4859ee527793782f47552448c5fb8d71dcc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 14 Apr 2026 17:27:01 +0100 Subject: [PATCH] perf(whatsapp): add doctor contract fast path --- extensions/whatsapp/doctor-contract-api.ts | 8 ++++++++ .../doctor-contract-api.fast-path.test.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 extensions/whatsapp/doctor-contract-api.ts diff --git a/extensions/whatsapp/doctor-contract-api.ts b/extensions/whatsapp/doctor-contract-api.ts new file mode 100644 index 00000000000..b7bd10f049b --- /dev/null +++ b/extensions/whatsapp/doctor-contract-api.ts @@ -0,0 +1,8 @@ +import type { ChannelDoctorLegacyConfigRule } from "openclaw/plugin-sdk/channel-contract"; + +export { normalizeCompatibilityConfig } from "./src/doctor-contract.js"; + +// WhatsApp currently exposes doctor compatibility fixes without extra legacy +// rule scans. Keep that empty answer on a lightweight contract surface so +// config validation stays off the broad contract-api import path. +export const legacyConfigRules: ChannelDoctorLegacyConfigRule[] = []; diff --git a/src/channels/plugins/doctor-contract-api.fast-path.test.ts b/src/channels/plugins/doctor-contract-api.fast-path.test.ts index f49f5836c94..c7d3818d960 100644 --- a/src/channels/plugins/doctor-contract-api.fast-path.test.ts +++ b/src/channels/plugins/doctor-contract-api.fast-path.test.ts @@ -13,6 +13,11 @@ const { loadBundledPluginPublicArtifactModuleSyncMock } = vi.hoisted(() => ({ ], }; } + if (dirName === "whatsapp" && artifactBasename === "doctor-contract-api.js") { + return { + legacyConfigRules: [], + }; + } if (dirName === "telegram" && artifactBasename === "contract-api.js") { return { legacyConfigRules: [ @@ -52,6 +57,20 @@ describe("channel doctor contract api fast path", () => { }); }); + it("treats empty explicit doctor contract rules as authoritative", () => { + const api = loadBundledChannelDoctorContractApi("whatsapp"); + + expect(api?.legacyConfigRules).toEqual([]); + expect(loadBundledPluginPublicArtifactModuleSyncMock).toHaveBeenCalledWith({ + dirName: "whatsapp", + artifactBasename: "doctor-contract-api.js", + }); + expect(loadBundledPluginPublicArtifactModuleSyncMock).not.toHaveBeenCalledWith({ + dirName: "whatsapp", + artifactBasename: "contract-api.js", + }); + }); + it("falls back to the generic contract artifact when the doctor artifact is absent", () => { const api = loadBundledChannelDoctorContractApi("telegram");