Skip to content

Commit 7d691a3

Browse files
committed
refactor(whatsapp): narrow channel runtime imports
1 parent 5c6dca7 commit 7d691a3

9 files changed

Lines changed: 35 additions & 36 deletions

‎extensions/whatsapp/src/action-runtime-target-auth.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import { ToolAuthorizationError } from "openclaw/plugin-sdk/channel-actions";
2+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
13
import { resolveWhatsAppAccount } from "./accounts.js";
2-
import {
3-
ToolAuthorizationError,
4-
resolveWhatsAppOutboundTarget,
5-
type OpenClawConfig,
6-
} from "./runtime-api.js";
4+
import { resolveWhatsAppOutboundTarget } from "./resolve-outbound-target.js";
75

86
export function resolveAuthorizedWhatsAppOutboundTarget(params: {
97
cfg: OpenClawConfig;

‎extensions/whatsapp/src/action-runtime.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
2-
import { resolveAuthorizedWhatsAppOutboundTarget } from "./action-runtime-target-auth.js";
3-
import { resolveWhatsAppReactionLevel } from "./reaction-level.js";
42
import {
53
createActionGate,
64
jsonResult,
75
readReactionParams,
86
readStringParam,
9-
type OpenClawConfig,
10-
} from "./runtime-api.js";
7+
} from "openclaw/plugin-sdk/channel-actions";
8+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
9+
import { resolveAuthorizedWhatsAppOutboundTarget } from "./action-runtime-target-auth.js";
10+
import { resolveWhatsAppReactionLevel } from "./reaction-level.js";
1111
import { sendReactionWhatsApp } from "./send.js";
1212

1313
export const whatsAppActionRuntime = {

‎extensions/whatsapp/src/approval-auth.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
resolveApprovalApprovers,
44
} from "openclaw/plugin-sdk/approval-auth-runtime";
55
import { resolveWhatsAppAccount } from "./accounts.js";
6-
import { normalizeWhatsAppTarget } from "./runtime-api.js";
6+
import { normalizeWhatsAppTarget } from "./normalize.js";
77

88
function normalizeWhatsAppApproverId(value: string | number): string | undefined {
99
const normalized = normalizeWhatsAppTarget(String(value));
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { createActionGate } from "openclaw/plugin-sdk/channel-actions";
2+
import type { ChannelMessageActionName } from "openclaw/plugin-sdk/channel-contract";
3+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
4+
15
export { listWhatsAppAccountIds, resolveWhatsAppAccount } from "./accounts.js";
2-
export {
3-
createActionGate,
4-
type ChannelMessageActionName,
5-
type OpenClawConfig,
6-
} from "./runtime-api.js";
76
export { resolveWhatsAppReactionLevel } from "./reaction-level.js";
7+
export { createActionGate, type ChannelMessageActionName, type OpenClawConfig };

‎extensions/whatsapp/src/channel-outbound.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { chunkText } from "openclaw/plugin-sdk/reply-runtime";
2-
import { createWhatsAppOutboundBase, resolveWhatsAppOutboundTarget } from "./runtime-api.js";
2+
import { createWhatsAppOutboundBase } from "./outbound-base.js";
3+
import { resolveWhatsAppOutboundTarget } from "./resolve-outbound-target.js";
34
import { getWhatsAppRuntime } from "./runtime.js";
45
import { sendMessageWhatsApp, sendPollWhatsApp } from "./send.js";
56

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { readStringParam } from "openclaw/plugin-sdk/channel-actions";
2+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
3+
14
export { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
25
export { handleWhatsAppAction } from "./action-runtime.js";
36
export { normalizeWhatsAppTarget } from "./normalize.js";
4-
export { readStringParam, type OpenClawConfig } from "./runtime-api.js";
7+
export { readStringParam, type OpenClawConfig };

‎extensions/whatsapp/src/channel.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
12
import { buildDmGroupAccountAllowlistAdapter } from "openclaw/plugin-sdk/allowlist-config-edit";
2-
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
3+
import { formatWhatsAppConfigAllowFromEntries } from "openclaw/plugin-sdk/channel-config-helpers";
4+
import { createChatChannelPlugin, type ChannelPlugin } from "openclaw/plugin-sdk/core";
35
import {
46
createAsyncComputedAccountStatusAdapter,
57
createDefaultChannelRuntimeState,
@@ -22,21 +24,17 @@ import {
2224
listWhatsAppDirectoryGroupsFromConfig,
2325
listWhatsAppDirectoryPeersFromConfig,
2426
} from "./directory-config.js";
27+
import {
28+
resolveWhatsAppGroupIntroHint,
29+
resolveWhatsAppMentionStripRegexes,
30+
} from "./group-intro.js";
2531
import {
2632
resolveWhatsAppGroupRequireMention,
2733
resolveWhatsAppGroupToolPolicy,
2834
} from "./group-policy.js";
35+
import { resolveWhatsAppHeartbeatRecipients } from "./heartbeat-recipients.js";
2936
import { looksLikeWhatsAppTargetId, normalizeWhatsAppMessagingTarget } from "./normalize.js";
30-
import {
31-
DEFAULT_ACCOUNT_ID,
32-
formatWhatsAppConfigAllowFromEntries,
33-
resolveWhatsAppGroupIntroHint,
34-
resolveWhatsAppHeartbeatRecipients,
35-
resolveWhatsAppMentionStripRegexes,
36-
type ChannelPlugin,
37-
isWhatsAppGroupJid,
38-
normalizeWhatsAppTarget,
39-
} from "./runtime-api.js";
37+
import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "./normalize.js";
4038
import { getWhatsAppRuntime } from "./runtime.js";
4139
import { resolveWhatsAppOutboundSessionRoute } from "./session-route.js";
4240
import { whatsappSetupAdapter } from "./setup-core.js";

‎extensions/whatsapp/src/session-route.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
buildChannelOutboundSessionRoute,
33
type ChannelOutboundSessionRouteParams,
44
} from "openclaw/plugin-sdk/core";
5-
import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "./runtime-api.js";
5+
import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "./normalize.js";
66

77
export function resolveWhatsAppOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
88
const normalized = normalizeWhatsAppTarget(params.target);

‎extensions/whatsapp/src/shared.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
2+
import { normalizeE164 } from "openclaw/plugin-sdk/account-resolution";
23
import {
34
adaptScopedAccountAccessor,
45
createScopedChannelConfigAdapter,
56
createScopedDmSecurityResolver,
7+
formatWhatsAppConfigAllowFromEntries,
68
} from "openclaw/plugin-sdk/channel-config-helpers";
79
import { createAllowlistProviderRouteAllowlistWarningCollector } from "openclaw/plugin-sdk/channel-policy";
8-
import { createChannelPluginBase } from "openclaw/plugin-sdk/core";
10+
import { createChannelPluginBase, getChatChannelMeta } from "openclaw/plugin-sdk/core";
11+
import type { ChannelPlugin } from "openclaw/plugin-sdk/core";
912
import {
1013
createDelegatedSetupWizardProxy,
1114
type ChannelSetupWizard,
@@ -19,15 +22,11 @@ import {
1922
} from "./accounts.js";
2023
import { WhatsAppChannelConfigSchema } from "./config-schema.js";
2124
import { whatsappDoctor } from "./doctor.js";
25+
import { resolveWhatsAppGroupIntroHint } from "./group-intro.js";
2226
import {
23-
formatWhatsAppConfigAllowFromEntries,
24-
getChatChannelMeta,
25-
normalizeE164,
26-
resolveWhatsAppGroupIntroHint,
2727
resolveWhatsAppGroupRequireMention,
2828
resolveWhatsAppGroupToolPolicy,
29-
type ChannelPlugin,
30-
} from "./runtime-api.js";
29+
} from "./group-policy.js";
3130

3231
export const WHATSAPP_CHANNEL = "whatsapp" as const;
3332

0 commit comments

Comments
 (0)