refactor(channels): drop unused approval aliases

This commit is contained in:
Vincent Koc
2026-06-19 16:41:05 +08:00
parent dba291ed35
commit 7211d77553
12 changed files with 78 additions and 113 deletions

View File

@@ -7,7 +7,6 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import {
imessageApprovalCapability,
imessageNativeApprovalAdapter,
shouldSuppressLocalIMessageExecApprovalPrompt,
} from "./approval-native.js";
@@ -112,7 +111,7 @@ describe("imessage approval capability", () => {
const pluginRequest = buildPluginRequest("+15551230000");
expect(
imessageNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
imessageApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -255,7 +254,7 @@ describe("imessage approval capability", () => {
const request = buildExecRequest("+15551230000");
expect(
imessageNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
imessageApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -398,7 +397,7 @@ describe("imessage approval capability", () => {
});
expect(
imessageNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
imessageApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -440,7 +439,7 @@ describe("imessage approval capability", () => {
});
expect(
imessageNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
imessageApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -448,7 +447,7 @@ describe("imessage approval capability", () => {
}),
).toEqual({ kind: "disabled" });
expect(
imessageNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
imessageApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "work",
action: "approve",

View File

@@ -1,8 +1,5 @@
// Imessage plugin module implements approval native behavior.
import {
createChannelApprovalCapability,
splitChannelApprovalCapability,
} from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createChannelApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
import type { ChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
import {
@@ -444,7 +441,3 @@ export const imessageApprovalCapability: ChannelApprovalCapability =
.imessageApprovalNativeRuntime as unknown as ChannelApprovalNativeRuntimeAdapter,
}),
});
export const imessageNativeApprovalAdapter = splitChannelApprovalCapability(
imessageApprovalCapability,
);

View File

@@ -8,7 +8,6 @@ import { describe, expect, it } from "vitest";
import {
shouldSuppressLocalSignalExecApprovalPrompt,
signalApprovalCapability,
signalNativeApprovalAdapter,
} from "./approval-native.js";
type SignalConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["signal"]>;
@@ -112,7 +111,7 @@ describe("signal approval capability", () => {
const pluginRequest = buildPluginRequest("+15551230000");
expect(
signalNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -120,7 +119,7 @@ describe("signal approval capability", () => {
}),
).toEqual({ kind: "disabled" });
expect(
signalNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -235,7 +234,7 @@ describe("signal approval capability", () => {
const request = buildExecRequest("+15551230000");
expect(
signalNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
signalApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",

View File

@@ -1,8 +1,5 @@
// Signal plugin module implements approval native behavior.
import {
createChannelApprovalCapability,
splitChannelApprovalCapability,
} from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createChannelApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
import type { ChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
import {
@@ -324,5 +321,3 @@ export const signalApprovalCapability: ChannelApprovalCapability = createChannel
.signalApprovalNativeRuntime as unknown as ChannelApprovalNativeRuntimeAdapter,
}),
});
export const signalNativeApprovalAdapter = splitChannelApprovalCapability(signalApprovalCapability);

View File

@@ -4,7 +4,7 @@ import path from "node:path";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { saveSessionStore } from "openclaw/plugin-sdk/session-store-runtime";
import { describe, expect, it } from "vitest";
import { slackApprovalCapability, slackNativeApprovalAdapter, testing } from "./approval-native.js";
import { slackApprovalCapability, testing } from "./approval-native.js";
function buildConfig(
overrides?: Partial<NonNullable<NonNullable<OpenClawConfig["channels"]>["slack"]>>,
@@ -55,7 +55,7 @@ function createExecApprovalRequest(
async function resolveExecOriginTarget(
requestOverrides: Parameters<typeof createExecApprovalRequest>[0] = {},
) {
return await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
return await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -78,14 +78,14 @@ describe("slack native approval adapter", () => {
});
expect(
slackNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
slackApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
}),
).toEqual({ kind: "enabled" });
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
@@ -112,7 +112,7 @@ describe("slack native approval adapter", () => {
});
it("describes native slack approval delivery capabilities", () => {
const capabilities = slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
const capabilities = slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -181,7 +181,7 @@ describe("slack native approval adapter", () => {
});
it("resolves approver dm targets", async () => {
const targets = await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
const targets = await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -208,7 +208,7 @@ describe("slack native approval adapter", () => {
},
});
const targets = await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
const targets = await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -249,7 +249,7 @@ describe("slack native approval adapter", () => {
};
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -257,7 +257,7 @@ describe("slack native approval adapter", () => {
}).enabled,
).toBe(true);
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
@@ -274,7 +274,7 @@ describe("slack native approval adapter", () => {
}).enabled,
).toBe(false);
expect(
await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -295,7 +295,7 @@ describe("slack native approval adapter", () => {
}),
).toBe(true);
expect(
slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback?.({
slackApprovalCapability.delivery?.shouldSuppressForwardingFallback?.({
cfg,
approvalKind: "plugin",
target: { channel: "slack", to: "user:U123OWNER", accountId: "default" },
@@ -335,7 +335,7 @@ describe("slack native approval adapter", () => {
};
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "exec",
@@ -352,7 +352,7 @@ describe("slack native approval adapter", () => {
}).enabled,
).toBe(false);
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -420,7 +420,7 @@ describe("slack native approval adapter", () => {
}),
).toBe(true);
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -434,7 +434,7 @@ describe("slack native approval adapter", () => {
notifyOriginWhenDmOnly: true,
});
expect(
await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -495,7 +495,7 @@ describe("slack native approval adapter", () => {
}),
).toBe(false);
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "work",
approvalKind: "plugin",
@@ -555,7 +555,7 @@ describe("slack native approval adapter", () => {
}),
).toBe(true);
expect(
slackNativeApprovalAdapter.native?.describeDeliveryCapabilities({
slackApprovalCapability.native?.describeDeliveryCapabilities({
cfg,
accountId: "work",
approvalKind: "plugin",
@@ -658,7 +658,7 @@ describe("slack native approval adapter", () => {
}),
).toBe(false);
expect(
await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg,
accountId: "default",
approvalKind: "plugin",
@@ -687,7 +687,7 @@ describe("slack native approval adapter", () => {
});
it("resolves Slack app conversation plugin approvals to the live D-channel thread", async () => {
const target = await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg: buildConfig({ allowFrom: ["U123OWNER"] }),
accountId: "default",
approvalKind: "plugin",
@@ -763,7 +763,7 @@ describe("slack native approval adapter", () => {
});
it("falls back to the session-key origin target for plugin approvals when the store is missing", async () => {
const target = await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg: {
...buildConfig({ allowFrom: ["U123OWNER"] }),
session: { store: STORE_PATH },
@@ -798,7 +798,7 @@ describe("slack native approval adapter", () => {
},
});
const originTarget = await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
const originTarget = await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg,
accountId: "default",
approvalKind: "exec",
@@ -816,7 +816,7 @@ describe("slack native approval adapter", () => {
expiresAtMs: 1000,
},
});
const dmTargets = await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
const dmTargets = await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg,
accountId: "default",
approvalKind: "exec",
@@ -837,7 +837,7 @@ describe("slack native approval adapter", () => {
});
it("skips native delivery when the request is bound to another Slack account", async () => {
const originTarget = await slackNativeApprovalAdapter.native?.resolveOriginTarget?.({
const originTarget = await slackApprovalCapability.native?.resolveOriginTarget?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -854,7 +854,7 @@ describe("slack native approval adapter", () => {
expiresAtMs: 1000,
},
});
const dmTargets = await slackNativeApprovalAdapter.native?.resolveApproverDmTargets?.({
const dmTargets = await slackApprovalCapability.native?.resolveApproverDmTargets?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -876,7 +876,7 @@ describe("slack native approval adapter", () => {
});
it("suppresses generic slack fallback only for slack-originated approvals", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -919,7 +919,7 @@ describe("slack native approval adapter", () => {
});
it("keeps plugin forwarding fallback when Slack has no plugin approvers", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -951,7 +951,7 @@ describe("slack native approval adapter", () => {
});
it("keeps plugin forwarding fallback for Slack targets not handled by native delivery", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -984,7 +984,7 @@ describe("slack native approval adapter", () => {
});
it("suppresses plugin forwarding fallback for the native origin target", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -1036,7 +1036,7 @@ describe("slack native approval adapter", () => {
});
it("suppresses explicit plugin forwarding targets when native Slack plugin delivery is active", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -1078,7 +1078,7 @@ describe("slack native approval adapter", () => {
});
it("suppresses bare Slack user plugin forwarding targets handled by native DM delivery", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -1124,7 +1124,7 @@ describe("slack native approval adapter", () => {
});
it("keeps explicit plugin forwarding channel targets outside native Slack delivery", () => {
const shouldSuppress = slackNativeApprovalAdapter.delivery?.shouldSuppressForwardingFallback;
const shouldSuppress = slackApprovalCapability.delivery?.shouldSuppressForwardingFallback;
if (!shouldSuppress) {
throw new Error("slack native delivery suppression unavailable");
}
@@ -1176,7 +1176,7 @@ describe("slack native approval adapter", () => {
});
expect(
slackNativeApprovalAdapter.auth.authorizeActorAction?.({
slackApprovalCapability.authorizeActorAction?.({
cfg,
accountId: "default",
senderId: "U123OWNER",
@@ -1186,7 +1186,7 @@ describe("slack native approval adapter", () => {
).toEqual({ authorized: true });
expect(
slackNativeApprovalAdapter.auth.authorizeActorAction?.({
slackApprovalCapability.authorizeActorAction?.({
cfg,
accountId: "default",
senderId: "U999EXEC",
@@ -1199,7 +1199,7 @@ describe("slack native approval adapter", () => {
});
expect(
slackNativeApprovalAdapter.auth.authorizeActorAction?.({
slackApprovalCapability.authorizeActorAction?.({
cfg,
accountId: "default",
senderId: "U999EXEC",

View File

@@ -1,8 +1,5 @@
// Slack plugin module implements approval native behavior.
import {
createApproverRestrictedNativeApprovalCapability,
splitChannelApprovalCapability,
} from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createApproverRestrictedNativeApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
import type { ChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
import {
@@ -229,8 +226,6 @@ export const slackApprovalCapability: ChannelApprovalCapability = {
: undefined,
};
export const slackNativeApprovalAdapter = splitChannelApprovalCapability(slackApprovalCapability);
export const testing = {
resolveSessionSlackOriginTarget,
resolveTurnSourceSlackOriginTarget,

View File

@@ -3,7 +3,7 @@ import path from "node:path";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { saveSessionStore, type SessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
import { describe, expect, it } from "vitest";
import { telegramApprovalCapability, telegramNativeApprovalAdapter } from "./approval-native.js";
import { telegramApprovalCapability } from "./approval-native.js";
function buildConfig(
overrides?: Partial<NonNullable<NonNullable<OpenClawConfig["channels"]>["telegram"]>>,
@@ -60,7 +60,7 @@ describe("telegram native approval adapter", () => {
});
it("normalizes direct-chat origin targets so DM dedupe can converge", async () => {
const target = await telegramNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await telegramApprovalCapability.native?.resolveOriginTarget?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -85,7 +85,7 @@ describe("telegram native approval adapter", () => {
});
it("parses topic-scoped turn-source targets in the extension", async () => {
const target = await telegramNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await telegramApprovalCapability.native?.resolveOriginTarget?.({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",
@@ -123,7 +123,7 @@ describe("telegram native approval adapter", () => {
},
});
const target = await telegramNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await telegramApprovalCapability.native?.resolveOriginTarget?.({
cfg: {
...buildConfig(),
session: { store: STORE_PATH },
@@ -162,7 +162,7 @@ describe("telegram native approval adapter", () => {
},
});
const target = await telegramNativeApprovalAdapter.native?.resolveOriginTarget?.({
const target = await telegramApprovalCapability.native?.resolveOriginTarget?.({
cfg: {
...buildConfig(),
session: { store: STORE_PATH },
@@ -188,7 +188,7 @@ describe("telegram native approval adapter", () => {
});
it("marks DM-only telegram approvals to notify the origin chat after delivery", () => {
const capabilities = telegramNativeApprovalAdapter.native?.describeDeliveryCapabilities({
const capabilities = telegramApprovalCapability.native?.describeDeliveryCapabilities({
cfg: buildConfig(),
accountId: "default",
approvalKind: "exec",

View File

@@ -1,8 +1,5 @@
// Telegram plugin module implements approval native behavior.
import {
createApproverRestrictedNativeApprovalCapability,
splitChannelApprovalCapability,
} from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createApproverRestrictedNativeApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
import type { ChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
import {
@@ -163,7 +160,3 @@ export const telegramApprovalCapability: ChannelApprovalCapability = {
...telegramNativeApprovalCapability,
resolveApproveCommandBehavior: resolveTelegramApproveCommandBehavior,
};
export const telegramNativeApprovalAdapter = splitChannelApprovalCapability(
telegramApprovalCapability,
);

View File

@@ -5,7 +5,7 @@ import type {
} from "openclaw/plugin-sdk/approval-runtime";
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import { whatsappApprovalCapability, whatsappNativeApprovalAdapter } from "./approval-native.js";
import { whatsappApprovalCapability } from "./approval-native.js";
type WhatsAppConfig = NonNullable<NonNullable<OpenClawConfig["channels"]>["whatsapp"]>;
@@ -87,7 +87,7 @@ describe("whatsapp approval capability", () => {
const pluginRequest = buildPluginRequest("+15551230000");
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -95,7 +95,7 @@ describe("whatsapp approval capability", () => {
}),
).toEqual({ kind: "disabled" });
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -182,7 +182,7 @@ describe("whatsapp approval capability", () => {
const request = buildExecRequest("+15551230000");
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -288,7 +288,7 @@ describe("whatsapp approval capability", () => {
});
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -330,7 +330,7 @@ describe("whatsapp approval capability", () => {
});
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "default",
action: "approve",
@@ -338,7 +338,7 @@ describe("whatsapp approval capability", () => {
}),
).toEqual({ kind: "disabled" });
expect(
whatsappNativeApprovalAdapter.auth?.getActionAvailabilityState?.({
whatsappApprovalCapability?.getActionAvailabilityState?.({
cfg,
accountId: "work",
action: "approve",

View File

@@ -1,8 +1,5 @@
// Whatsapp plugin module implements approval native behavior.
import {
createChannelApprovalCapability,
splitChannelApprovalCapability,
} from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createChannelApprovalCapability } from "openclaw/plugin-sdk/approval-delivery-runtime";
import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
import type { ChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-sdk/approval-handler-runtime";
import {
@@ -275,7 +272,3 @@ export const whatsappApprovalCapability: ChannelApprovalCapability =
.whatsappApprovalNativeRuntime as unknown as ChannelApprovalNativeRuntimeAdapter,
}),
});
export const whatsappNativeApprovalAdapter = splitChannelApprovalCapability(
whatsappApprovalCapability,
);

View File

@@ -1,6 +1,6 @@
// Whatsapp tests cover channel react action plugin behavior.
import { beforeEach, describe, expect, it, vi } from "vitest";
import { handleWhatsAppReactAction } from "./channel-react-action.js";
import { handleWhatsAppMessageAction } from "./channel-react-action.js";
import type { OpenClawConfig } from "./runtime-api.js";
const hoisted = vi.hoisted(() => ({
@@ -107,7 +107,7 @@ describe("whatsapp react action messageId resolution", () => {
it("sends upload-file through the WhatsApp media send path", async () => {
const mediaReadFile = vi.fn(async () => Buffer.from("media"));
const result = await handleWhatsAppReactAction({
const result = await handleWhatsAppMessageAction({
action: "upload-file",
params: {
to: "+1555",
@@ -156,7 +156,7 @@ describe("whatsapp react action messageId resolution", () => {
});
await expect(
handleWhatsAppReactAction({
handleWhatsAppMessageAction({
action: "upload-file",
params: {
to: "+1555",
@@ -170,7 +170,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("sends upload-file from the hydrated buffer payload", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "upload-file",
params: {
to: "+1555",
@@ -207,7 +207,7 @@ describe("whatsapp react action messageId resolution", () => {
hoisted.resolveWhatsAppMediaMaxBytes.mockReturnValueOnce(4);
await expect(
handleWhatsAppReactAction({
handleWhatsAppMessageAction({
action: "upload-file",
params: {
to: "+1555",
@@ -224,7 +224,7 @@ describe("whatsapp react action messageId resolution", () => {
it("requires upload-file media path input", async () => {
await expect(
handleWhatsAppReactAction({
handleWhatsAppMessageAction({
action: "upload-file",
params: {
to: "+1555",
@@ -238,7 +238,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("uses explicit messageId when provided", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { messageId: "explicit-id", emoji: "👍", to: "+1555" },
cfg: baseCfg,
@@ -260,7 +260,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("falls back to toolContext.currentMessageId when messageId omitted", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "❤️", to: "+1555" },
cfg: baseCfg,
@@ -287,7 +287,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("converts numeric toolContext messageId to string", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "🎉", to: "+1555" },
cfg: baseCfg,
@@ -314,7 +314,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("throws ToolInputError when messageId missing and no toolContext", async () => {
const err = await handleWhatsAppReactAction({
const err = await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "+1555" },
cfg: baseCfg,
@@ -325,7 +325,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("skips context fallback when targeting a different chat", async () => {
const err = await handleWhatsAppReactAction({
const err = await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "+9999" },
cfg: baseCfg,
@@ -341,7 +341,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("uses context fallback when target matches current chat", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "12345@g.us" },
cfg: baseCfg,
@@ -369,7 +369,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("keeps direct-chat reactions without an inferred participant", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "+1555" },
cfg: baseCfg,
@@ -397,7 +397,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("prefers explicit participant over inferred current-message participant", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: {
emoji: "👍",
@@ -429,7 +429,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("does not reuse the current-chat participant for cross-chat reactions", async () => {
const err = await handleWhatsAppReactAction({
const err = await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "99999@g.us" },
cfg: baseCfg,
@@ -447,7 +447,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("does not infer participant when messageId is explicitly provided", async () => {
await handleWhatsAppReactAction({
await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "12345@g.us", messageId: "older-msg-7" },
cfg: baseCfg,
@@ -475,7 +475,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("skips context fallback when source is another provider", async () => {
const err = await handleWhatsAppReactAction({
const err = await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "+1555" },
cfg: baseCfg,
@@ -491,7 +491,7 @@ describe("whatsapp react action messageId resolution", () => {
});
it("skips context fallback when currentChannelId is missing with explicit target", async () => {
const err = await handleWhatsAppReactAction({
const err = await handleWhatsAppMessageAction({
action: "react",
params: { emoji: "👍", to: "+1555" },
cfg: baseCfg,

View File

@@ -244,5 +244,3 @@ export async function handleWhatsAppMessageAction(params: WhatsAppMessageActionP
params.cfg,
);
}
export const handleWhatsAppReactAction = handleWhatsAppMessageAction;