Plugin SDK: add public WhatsApp runtime subpaths

This commit is contained in:
Vincent Koc 2026-03-18 11:13:19 -07:00
parent 8240fd900a
commit 152d179302
12 changed files with 49 additions and 80 deletions

View File

@ -210,6 +210,14 @@
"types": "./dist/plugin-sdk/whatsapp.d.ts",
"default": "./dist/plugin-sdk/whatsapp.js"
},
"./plugin-sdk/whatsapp-action-runtime": {
"types": "./dist/plugin-sdk/whatsapp-action-runtime.d.ts",
"default": "./dist/plugin-sdk/whatsapp-action-runtime.js"
},
"./plugin-sdk/whatsapp-login-qr": {
"types": "./dist/plugin-sdk/whatsapp-login-qr.d.ts",
"default": "./dist/plugin-sdk/whatsapp-login-qr.js"
},
"./plugin-sdk/whatsapp-core": {
"types": "./dist/plugin-sdk/whatsapp-core.d.ts",
"default": "./dist/plugin-sdk/whatsapp-core.js"

View File

@ -42,6 +42,8 @@
"imessage",
"imessage-core",
"whatsapp",
"whatsapp-action-runtime",
"whatsapp-login-qr",
"whatsapp-core",
"line",
"line-core",

View File

@ -29,6 +29,8 @@ import * as telegramSdk from "openclaw/plugin-sdk/telegram";
import * as testingSdk from "openclaw/plugin-sdk/testing";
import * as voiceCallSdk from "openclaw/plugin-sdk/voice-call";
import * as whatsappSdk from "openclaw/plugin-sdk/whatsapp";
import * as whatsappActionRuntimeSdk from "openclaw/plugin-sdk/whatsapp-action-runtime";
import * as whatsappLoginQrSdk from "openclaw/plugin-sdk/whatsapp-login-qr";
import { describe, expect, expectTypeOf, it } from "vitest";
import type { ChannelMessageActionContext } from "../channels/plugins/types.js";
import type { PluginRuntime } from "../plugins/runtime/types.js";
@ -297,6 +299,15 @@ describe("plugin-sdk subpath exports", () => {
expect("resolveWhatsAppMentionStripPatterns" in whatsappSdk).toBe(false);
});
it("exports WhatsApp QR login helpers from the dedicated subpath", () => {
expect(typeof whatsappLoginQrSdk.startWebLoginWithQr).toBe("function");
expect(typeof whatsappLoginQrSdk.waitForWebLogin).toBe("function");
});
it("exports WhatsApp action runtime helpers from the dedicated subpath", () => {
expect(typeof whatsappActionRuntimeSdk.handleWhatsAppAction).toBe("function");
});
it("exports Feishu helpers", async () => {
expect(typeof feishuSdk.feishuSetupWizard).toBe("object");
expect(typeof feishuSdk.feishuSetupAdapter).toBe("object");

View File

@ -0,0 +1 @@
export { handleWhatsAppAction } from "../../extensions/whatsapp/action-runtime-api.js";

View File

@ -0,0 +1 @@
export { startWebLoginWithQr, waitForWebLogin } from "../../extensions/whatsapp/login-qr-api.js";

View File

@ -71,10 +71,13 @@ export {
resolveWhatsAppAccount,
} from "../../extensions/whatsapp/api.js";
export {
getActiveWebListener,
getWebAuthAgeMs,
WA_WEB_AUTH_DIR,
logWebSelfId,
logoutWeb,
pickWebChannel,
readWebSelfId,
webAuthExists,
} from "../../extensions/whatsapp/runtime-api.js";
export {

View File

@ -1 +1 @@
export { createWhatsAppLoginTool as createRuntimeWhatsAppLoginTool } from "../../../extensions/whatsapp/runtime-api.js";
export { createWhatsAppLoginTool as createRuntimeWhatsAppLoginTool } from "openclaw/plugin-sdk/whatsapp";

View File

@ -1,4 +1,4 @@
import { loginWeb as loginWebImpl } from "../../../extensions/whatsapp/runtime-api.js";
import { loginWeb as loginWebImpl } from "openclaw/plugin-sdk/whatsapp";
import type { PluginRuntime } from "./types.js";
type RuntimeWhatsAppLogin = Pick<PluginRuntime["channel"]["whatsapp"], "loginWeb">;

View File

@ -1,7 +1,7 @@
import {
sendMessageWhatsApp as sendMessageWhatsAppImpl,
sendPollWhatsApp as sendPollWhatsAppImpl,
} from "../../../extensions/whatsapp/runtime-api.js";
} from "openclaw/plugin-sdk/whatsapp";
import type { PluginRuntime } from "./types.js";
type RuntimeWhatsAppOutbound = Pick<

View File

@ -1,11 +1,11 @@
import { getActiveWebListener } from "../../../extensions/whatsapp/runtime-api.js";
import { getActiveWebListener } from "openclaw/plugin-sdk/whatsapp";
import {
getWebAuthAgeMs,
logoutWeb,
logWebSelfId,
logoutWeb,
readWebSelfId,
webAuthExists,
} from "../../../extensions/whatsapp/runtime-api.js";
} from "openclaw/plugin-sdk/whatsapp";
import {
createLazyRuntimeMethodBinder,
createLazyRuntimeSurface,
@ -63,16 +63,15 @@ const handleWhatsAppActionLazy: PluginRuntime["channel"]["whatsapp"]["handleWhat
return handleWhatsAppAction(...args);
};
let webLoginQrPromise: Promise<
typeof import("../../../extensions/whatsapp/login-qr-api.js")
> | null = null;
let webLoginQrPromise: Promise<typeof import("openclaw/plugin-sdk/whatsapp-login-qr")> | null =
null;
let webChannelPromise: Promise<typeof import("../../channels/web/index.js")> | null = null;
let whatsappActionsPromise: Promise<
typeof import("../../../extensions/whatsapp/action-runtime-api.js")
typeof import("openclaw/plugin-sdk/whatsapp-action-runtime")
> | null = null;
function loadWebLoginQr() {
webLoginQrPromise ??= import("../../../extensions/whatsapp/login-qr-api.js");
webLoginQrPromise ??= import("openclaw/plugin-sdk/whatsapp-login-qr");
return webLoginQrPromise;
}
@ -82,7 +81,7 @@ function loadWebChannel() {
}
function loadWhatsAppActions() {
whatsappActionsPromise ??= import("../../../extensions/whatsapp/action-runtime-api.js");
whatsappActionsPromise ??= import("openclaw/plugin-sdk/whatsapp-action-runtime");
return whatsappActionsPromise;
}

View File

@ -205,19 +205,19 @@ export type PluginRuntimeChannel = {
sendMessageIMessage: typeof import("../../../extensions/imessage/runtime-api.js").sendMessageIMessage;
};
whatsapp: {
getActiveWebListener: typeof import("../../../extensions/whatsapp/runtime-api.js").getActiveWebListener;
getWebAuthAgeMs: typeof import("../../../extensions/whatsapp/runtime-api.js").getWebAuthAgeMs;
logoutWeb: typeof import("../../../extensions/whatsapp/runtime-api.js").logoutWeb;
logWebSelfId: typeof import("../../../extensions/whatsapp/runtime-api.js").logWebSelfId;
readWebSelfId: typeof import("../../../extensions/whatsapp/runtime-api.js").readWebSelfId;
webAuthExists: typeof import("../../../extensions/whatsapp/runtime-api.js").webAuthExists;
sendMessageWhatsApp: typeof import("../../../extensions/whatsapp/runtime-api.js").sendMessageWhatsApp;
sendPollWhatsApp: typeof import("../../../extensions/whatsapp/runtime-api.js").sendPollWhatsApp;
loginWeb: typeof import("../../../extensions/whatsapp/runtime-api.js").loginWeb;
startWebLoginWithQr: typeof import("../../../extensions/whatsapp/login-qr-api.js").startWebLoginWithQr;
waitForWebLogin: typeof import("../../../extensions/whatsapp/login-qr-api.js").waitForWebLogin;
getActiveWebListener: typeof import("openclaw/plugin-sdk/whatsapp").getActiveWebListener;
getWebAuthAgeMs: typeof import("openclaw/plugin-sdk/whatsapp").getWebAuthAgeMs;
logoutWeb: typeof import("openclaw/plugin-sdk/whatsapp").logoutWeb;
logWebSelfId: typeof import("openclaw/plugin-sdk/whatsapp").logWebSelfId;
readWebSelfId: typeof import("openclaw/plugin-sdk/whatsapp").readWebSelfId;
webAuthExists: typeof import("openclaw/plugin-sdk/whatsapp").webAuthExists;
sendMessageWhatsApp: typeof import("openclaw/plugin-sdk/whatsapp").sendMessageWhatsApp;
sendPollWhatsApp: typeof import("openclaw/plugin-sdk/whatsapp").sendPollWhatsApp;
loginWeb: typeof import("openclaw/plugin-sdk/whatsapp").loginWeb;
startWebLoginWithQr: typeof import("openclaw/plugin-sdk/whatsapp-login-qr").startWebLoginWithQr;
waitForWebLogin: typeof import("openclaw/plugin-sdk/whatsapp-login-qr").waitForWebLogin;
monitorWebChannel: typeof import("../../channels/web/index.js").monitorWebChannel;
handleWhatsAppAction: typeof import("../../../extensions/whatsapp/action-runtime-api.js").handleWhatsAppAction;
handleWhatsAppAction: typeof import("openclaw/plugin-sdk/whatsapp-action-runtime").handleWhatsAppAction;
createLoginTool: typeof import("./runtime-whatsapp-login-tool.js").createRuntimeWhatsAppLoginTool;
};
line: {

View File

@ -94,61 +94,5 @@
"specifier": "../../extensions/zai/model-definitions.js",
"resolvedPath": "extensions/zai/model-definitions.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp-login-tool.ts",
"line": 1,
"kind": "export",
"specifier": "../../../extensions/whatsapp/runtime-api.js",
"resolvedPath": "extensions/whatsapp/runtime-api.js",
"reason": "re-exports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp-login.runtime.ts",
"line": 1,
"kind": "import",
"specifier": "../../../extensions/whatsapp/runtime-api.js",
"resolvedPath": "extensions/whatsapp/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp-outbound.runtime.ts",
"line": 4,
"kind": "import",
"specifier": "../../../extensions/whatsapp/runtime-api.js",
"resolvedPath": "extensions/whatsapp/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp.ts",
"line": 1,
"kind": "import",
"specifier": "../../../extensions/whatsapp/runtime-api.js",
"resolvedPath": "extensions/whatsapp/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp.ts",
"line": 8,
"kind": "import",
"specifier": "../../../extensions/whatsapp/runtime-api.js",
"resolvedPath": "extensions/whatsapp/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp.ts",
"line": 75,
"kind": "dynamic-import",
"specifier": "../../../extensions/whatsapp/login-qr-api.js",
"resolvedPath": "extensions/whatsapp/login-qr-api.js",
"reason": "dynamically imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-whatsapp.ts",
"line": 85,
"kind": "dynamic-import",
"specifier": "../../../extensions/whatsapp/action-runtime-api.js",
"resolvedPath": "extensions/whatsapp/action-runtime-api.js",
"reason": "dynamically imports extension-owned file from src/plugins"
}
]