























11// Runtime web-channel plugin helpers expose web-channel tools through activated plugin runtimes.
2-import type { AgentToolResult } from "../../agents/runtime/index.js";
3-import type { ChannelAgentTool } from "../../channels/plugins/types.core.js";
42import type { OpenClawConfig } from "../../config/types.openclaw.js";
53import {
64getDefaultLocalRoots as getDefaultLocalRootsImpl,
75loadWebMedia as loadWebMediaImpl,
86loadWebMediaRaw as loadWebMediaRawImpl,
97optimizeImageToJpeg as optimizeImageToJpegImpl,
108} from "../../media/web-media.js";
11-import type { PollInput } from "../../polls.js";
129import {
1310createPluginModuleLoaderCache,
1411type PluginModuleLoaderCache,
@@ -49,7 +46,6 @@ type WebChannelLightRuntimeModule = {
4946lid: string | null;
5047};
5148webAuthExists: (authDir?: string) => Promise<boolean>;
52-createWhatsAppLoginTool: () => ChannelAgentTool;
5349formatError: (error: unknown) => string;
5450getStatusCode: (error: unknown) => number | undefined;
5551pickWebChannel: (pref: string, authDir?: string) => Promise<string>;
@@ -81,31 +77,6 @@ type WebChannelHeavyRuntimeModule = {
8177accountId?: string;
8278},
8379) => Promise<{ messageId: string; toJid: string }>;
84-sendPollWhatsApp: (
85-to: string,
86-poll: PollInput,
87-options: { verbose: boolean; accountId?: string; cfg?: OpenClawConfig },
88-) => Promise<{ messageId: string; toJid: string }>;
89-sendReactionWhatsApp: (
90-chatJid: string,
91-messageId: string,
92-emoji: string,
93-options: {
94-verbose: boolean;
95-fromMe?: boolean;
96-participant?: string;
97-accountId?: string;
98-},
99-) => Promise<void>;
100-createWaSocket: (
101-printQr: boolean,
102-verbose: boolean,
103-opts?: { authDir?: string; onQr?: (qr: string) => void },
104-) => Promise<unknown>;
105-handleWhatsAppAction: (
106-params: Record<string, unknown>,
107-cfg: OpenClawConfig,
108-) => Promise<AgentToolResult<unknown>>;
10980monitorWebChannel: (...args: unknown[]) => Promise<unknown>;
11081monitorWebInbox: (...args: unknown[]) => Promise<unknown>;
11182startWebLoginWithQr: (...args: unknown[]) => Promise<unknown>;
@@ -270,34 +241,6 @@ export function sendWebChannelMessage(
270241return loadWebChannelHeavyModule().then((loaded) => loaded.sendMessageWhatsApp(...args));
271242}
272243273-/** Sends a web-channel poll through the heavy runtime API. */
274-export function sendWebChannelPoll(
275- ...args: Parameters<WebChannelHeavyRuntimeModule["sendPollWhatsApp"]>
276-): ReturnType<WebChannelHeavyRuntimeModule["sendPollWhatsApp"]> {
277-return loadWebChannelHeavyModule().then((loaded) => loaded.sendPollWhatsApp(...args));
278-}
279-280-/** Sends a web-channel reaction through the heavy runtime API. */
281-export function sendWebChannelReaction(
282- ...args: Parameters<WebChannelHeavyRuntimeModule["sendReactionWhatsApp"]>
283-): ReturnType<WebChannelHeavyRuntimeModule["sendReactionWhatsApp"]> {
284-return loadWebChannelHeavyModule().then((loaded) => loaded.sendReactionWhatsApp(...args));
285-}
286-287-/** Creates the web-channel login tool from the light runtime API. */
288-export function createRuntimeWebChannelLoginTool(
289- ...args: Parameters<WebChannelLightRuntimeModule["createWhatsAppLoginTool"]>
290-): ReturnType<WebChannelLightRuntimeModule["createWhatsAppLoginTool"]> {
291-return getLightExport("createWhatsAppLoginTool")(...args);
292-}
293-294-/** Creates a web-channel socket through the heavy runtime API. */
295-export function createWebChannelSocket(
296- ...args: Parameters<WebChannelHeavyRuntimeModule["createWaSocket"]>
297-): ReturnType<WebChannelHeavyRuntimeModule["createWaSocket"]> {
298-return loadWebChannelHeavyModule().then((loaded) => loaded.createWaSocket(...args));
299-}
300-301244/** Formats a web-channel runtime error through the light runtime API. */
302245export function formatError(
303246 ...args: Parameters<WebChannelLightRuntimeModule["formatError"]>
@@ -336,13 +279,6 @@ export function resolveWebChannelAuthDir(): ReturnType<
336279throw new Error("web channel plugin runtime is missing export 'resolveDefaultWebAuthDir'");
337280}
338281339-/** Handles a web-channel action through the heavy runtime API. */
340-export async function handleWebChannelAction(
341- ...args: Parameters<WebChannelHeavyRuntimeModule["handleWhatsAppAction"]>
342-): ReturnType<WebChannelHeavyRuntimeModule["handleWhatsAppAction"]> {
343-return (await getHeavyExport("handleWhatsAppAction"))(...args);
344-}
345-346282/** Loads web media through the core media helper. */
347283export async function loadWebMedia(
348284 ...args: Parameters<typeof loadWebMediaImpl>
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。