@openclaw/whatsapp 2026.5.1-beta.1 → 2026.5.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/whatsapp",
3
- "version": "2026.5.1-beta.1",
3
+ "version": "2026.5.2-beta.1",
4
4
  "description": "OpenClaw WhatsApp channel plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "openclaw": "workspace:*"
20
20
  },
21
21
  "peerDependencies": {
22
- "openclaw": ">=2026.4.25"
22
+ "openclaw": ">=2026.5.2-beta.1"
23
23
  },
24
24
  "peerDependenciesMeta": {
25
25
  "openclaw": {
@@ -61,10 +61,10 @@
61
61
  "minHostVersion": ">=2026.4.25"
62
62
  },
63
63
  "compat": {
64
- "pluginApi": ">=2026.4.25"
64
+ "pluginApi": ">=2026.5.2-beta.1"
65
65
  },
66
66
  "build": {
67
- "openclawVersion": "2026.5.1-beta.1"
67
+ "openclawVersion": "2026.5.2-beta.1"
68
68
  },
69
69
  "release": {
70
70
  "publishToClawHub": true,
package/runtime-api.ts CHANGED
@@ -37,8 +37,6 @@ export {
37
37
  HEARTBEAT_PROMPT,
38
38
  HEARTBEAT_TOKEN,
39
39
  monitorWebChannel,
40
- resolveHeartbeatRecipients,
41
- runWebHeartbeatOnce,
42
40
  SILENT_REPLY_TOKEN,
43
41
  stripHeartbeatToken,
44
42
  type WebChannelStatus,
@@ -1,16 +1,27 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
4
+ import { normalizeMainKey } from "openclaw/plugin-sdk/routing";
3
5
  import { saveSessionStore } from "openclaw/plugin-sdk/session-store-runtime";
4
6
  import { withTempDir } from "openclaw/plugin-sdk/test-env";
5
7
  import { describe, expect, it, vi } from "vitest";
6
8
  import type { WhatsAppSendResult } from "../inbound/send-result.js";
9
+ import {
10
+ evaluateSessionFreshness,
11
+ loadSessionStore,
12
+ resolveChannelResetConfig,
13
+ resolveSessionKey,
14
+ resolveSessionResetPolicy,
15
+ resolveSessionResetType,
16
+ resolveStorePath,
17
+ resolveThreadFlag,
18
+ } from "./config.runtime.js";
7
19
  import {
8
20
  debugMention,
9
21
  isBotMentionedFromTargets,
10
22
  resolveMentionTargets,
11
23
  resolveOwnerList,
12
24
  } from "./mentions.js";
13
- import { getSessionSnapshot } from "./session-snapshot.js";
14
25
  import type { WebInboundMsg } from "./types.js";
15
26
  import { elide, isLikelyWhatsAppCryptoError } from "./util.js";
16
27
 
@@ -40,6 +51,60 @@ const makeMsg = (overrides: Partial<WebInboundMsg>): WebInboundMsg =>
40
51
  ...overrides,
41
52
  }) as WebInboundMsg;
42
53
 
54
+ function getSessionSnapshotForTest(
55
+ cfg: OpenClawConfig,
56
+ from: string,
57
+ ctx?: {
58
+ sessionKey?: string | null;
59
+ isGroup?: boolean;
60
+ messageThreadId?: string | number | null;
61
+ threadLabel?: string | null;
62
+ threadStarterBody?: string | null;
63
+ parentSessionKey?: string | null;
64
+ },
65
+ ) {
66
+ const sessionCfg = cfg.session;
67
+ const scope = sessionCfg?.scope ?? "per-sender";
68
+ const key =
69
+ ctx?.sessionKey?.trim() ??
70
+ resolveSessionKey(
71
+ scope,
72
+ { From: from, To: "", Body: "" },
73
+ normalizeMainKey(sessionCfg?.mainKey),
74
+ );
75
+ const store = loadSessionStore(resolveStorePath(sessionCfg?.store));
76
+ const entry = store[key];
77
+ const isThread = resolveThreadFlag({
78
+ sessionKey: key,
79
+ messageThreadId: ctx?.messageThreadId ?? null,
80
+ threadLabel: ctx?.threadLabel ?? null,
81
+ threadStarterBody: ctx?.threadStarterBody ?? null,
82
+ parentSessionKey: ctx?.parentSessionKey ?? null,
83
+ });
84
+ const resetType = resolveSessionResetType({ sessionKey: key, isGroup: ctx?.isGroup, isThread });
85
+ const resetPolicy = resolveSessionResetPolicy({
86
+ sessionCfg,
87
+ resetType,
88
+ resetOverride: resolveChannelResetConfig({
89
+ sessionCfg,
90
+ channel: entry?.lastChannel ?? entry?.channel,
91
+ }),
92
+ });
93
+ const freshness = entry
94
+ ? evaluateSessionFreshness({ updatedAt: entry.updatedAt, now: Date.now(), policy: resetPolicy })
95
+ : { fresh: false };
96
+
97
+ return {
98
+ key,
99
+ entry,
100
+ fresh: freshness.fresh,
101
+ resetPolicy,
102
+ resetType,
103
+ dailyResetAt: freshness.dailyResetAt,
104
+ idleExpiresAt: freshness.idleExpiresAt,
105
+ };
106
+ }
107
+
43
108
  describe("isBotMentionedFromTargets", () => {
44
109
  const mentionCfg = { mentionRegexes: [/\bopenclaw\b/i] };
45
110
 
@@ -215,9 +280,9 @@ describe("getSessionSnapshot", () => {
215
280
  whatsapp: { mode: "idle", idleMinutes: 360 },
216
281
  },
217
282
  },
218
- } as Parameters<typeof getSessionSnapshot>[0];
283
+ } as OpenClawConfig;
219
284
 
220
- const snapshot = getSessionSnapshot(cfg, "whatsapp:+15550001111", true, {
285
+ const snapshot = getSessionSnapshotForTest(cfg, "whatsapp:+15550001111", {
221
286
  sessionKey,
222
287
  });
223
288
 
@@ -2,6 +2,5 @@ export { HEARTBEAT_PROMPT, stripHeartbeatToken } from "openclaw/plugin-sdk/reply
2
2
  export { HEARTBEAT_TOKEN, SILENT_REPLY_TOKEN } from "openclaw/plugin-sdk/reply-runtime";
3
3
 
4
4
  export { DEFAULT_WEB_MEDIA_BYTES } from "./auto-reply/constants.js";
5
- export { resolveHeartbeatRecipients, runWebHeartbeatOnce } from "./auto-reply/heartbeat-runner.js";
6
5
  export { monitorWebChannel } from "./auto-reply/monitor.js";
7
6
  export type { WebChannelStatus, WebMonitorTuning } from "./auto-reply/types.js";
package/src/channel.ts CHANGED
@@ -25,7 +25,6 @@ import {
25
25
  resolveWhatsAppGroupRequireMention,
26
26
  resolveWhatsAppGroupToolPolicy,
27
27
  } from "./group-policy.js";
28
- import { resolveWhatsAppHeartbeatRecipients } from "./heartbeat-recipients.js";
29
28
  import { checkWhatsAppHeartbeatReady } from "./heartbeat.js";
30
29
  import {
31
30
  isWhatsAppGroupJid,
@@ -183,7 +182,6 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> =
183
182
  ...(accountId ? { accountId } : {}),
184
183
  });
185
184
  },
186
- resolveRecipients: ({ cfg, opts }) => resolveWhatsAppHeartbeatRecipients(cfg, opts),
187
185
  },
188
186
  status: createAsyncComputedAccountStatusAdapter<ResolvedWhatsAppAccount>({
189
187
  defaultRuntime: createDefaultChannelRuntimeState(DEFAULT_ACCOUNT_ID, {
@@ -27,7 +27,6 @@ export {
27
27
  resolveWhatsAppGroupIntroHint,
28
28
  resolveWhatsAppMentionStripRegexes,
29
29
  } from "./group-intro.js";
30
- export { resolveWhatsAppHeartbeatRecipients } from "./heartbeat-recipients.js";
31
30
  export { createWhatsAppOutboundBase } from "./outbound-base.js";
32
31
  export {
33
32
  isWhatsAppGroupJid,
@@ -1 +0,0 @@
1
- 2026-04-29T11:29:30.144Z