@openclaw/whatsapp 2026.7.2-beta.2 → 2026.7.2-beta.3
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/dist/{access-control-DazDX3RB.js → access-control-tjy_em01.js} +1 -1
- package/dist/{accounts-CKOFMPf-.js → accounts-ejK8sXPU.js} +43 -3
- package/dist/action-runtime-api.js +1 -1
- package/dist/{action-runtime-Bf-12TIH.js → action-runtime-p0V390gA.js} +2 -2
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{active-listener-5kHap439.js → active-listener-BbdlXooT.js} +1 -1
- package/dist/api.js +10 -10
- package/dist/{approval-handler.runtime-CBiGQuZ5.js → approval-handler.runtime-BO1oJ-b8.js} +3 -3
- package/dist/{approval-reactions-BGQoz25s.js → approval-reactions-CrZFAyf-.js} +2 -2
- package/dist/call-tool-api.js +2 -2
- package/dist/{channel-DbadDUDD.js → channel-B2I4Opzb.js} +18 -9
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-PoRWfP9x.js → channel-react-action-CPRQE-s3.js} +3 -3
- package/dist/{channel.runtime-BDDy4Lhz.js → channel.runtime-CjkhQzk8.js} +4 -4
- package/dist/{channel.setup-BZ-po8fg.js → channel.setup-BMWE9LmN.js} +1 -1
- package/dist/{connection-controller-C1rwfWb4.js → connection-controller-HGaffeFb.js} +183 -22
- package/dist/{connection-controller-runtime-context-CbTsqmPT.js → connection-controller-runtime-context-9mEeAvu1.js} +10 -1
- package/dist/contract-api.js +1 -1
- package/dist/directory-config-BZ775eGX.js +196 -0
- package/dist/directory-contract-api.js +1 -1
- package/dist/{group-session-key-CLTZeH_F.js → group-session-key-Dh8WZun_.js} +1 -1
- package/dist/light-runtime-api.js +1 -1
- package/dist/{login-DGIoToX8.js → login-ifOXCBjo.js} +3 -3
- package/dist/{login-qr-X-CZHOk9.js → login-qr-DUHzVH_Y.js} +4 -4
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BZ8QvCeV.js → monitor-_jqDKBXj.js} +544 -295
- package/dist/question-reactions-C0qJ6wGA.js +142 -0
- package/dist/runtime-api.js +7 -7
- package/dist/{send-D9Ydnn4o.js → send-SB-4JrVZ.js} +2 -3
- package/dist/{send-api-W33lI2nR.js → send-api-BG0MgoFI.js} +3 -3
- package/dist/{setup-core-3aSOoK2T.js → setup-core-BbIgEl2M.js} +3 -3
- package/dist/{setup-finalize-DBf1jjBj.js → setup-finalize-Cc-4iWGj.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CiKGdNJv.js → setup-surface-DhnXEZir.js} +2 -2
- package/dist/{session-mxWFn0eS.js → socket-close-jNGyZY4T.js} +221 -1
- package/npm-shrinkwrap.json +3 -3
- package/package.json +4 -4
- package/dist/account-config-LiT9wWH9.js +0 -43
- package/dist/directory-config-CLBQrjtC.js +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-ejK8sXPU.js";
|
|
2
2
|
import { n as isSelfChatMode } from "./targets-runtime-Bsh0HR9y.js";
|
|
3
3
|
import { n as normalizeE164 } from "./text-runtime-BTGkMN0o.js";
|
|
4
4
|
import { a as getSelfIdentity, o as getSenderIdentity } from "./identity-D7L8LCuH.js";
|
|
@@ -1,11 +1,51 @@
|
|
|
1
|
-
import { t as resolveMergedWhatsAppAccountConfig } from "./account-config-LiT9wWH9.js";
|
|
2
1
|
import { n as listConfiguredAccountIds, r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-CB5SOWjc.js";
|
|
3
2
|
import { n as hasWebCredsRegularFileSync, r as hasWebCredsSync } from "./creds-files-B1kSWtBg.js";
|
|
4
3
|
import fs from "node:fs";
|
|
5
4
|
import path from "node:path";
|
|
6
|
-
import { DEFAULT_ACCOUNT_ID, normalizeAccountId, resolveUserPath } from "openclaw/plugin-sdk/account-core";
|
|
5
|
+
import { DEFAULT_ACCOUNT_ID, mergeAccountConfig, normalizeAccountId, resolveAccountEntry, resolveMergedAccountConfig, resolveUserPath } from "openclaw/plugin-sdk/account-core";
|
|
7
6
|
import { resolveOAuthDir } from "openclaw/plugin-sdk/state-paths";
|
|
8
7
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
|
+
//#region extensions/whatsapp/src/account-config.ts
|
|
9
|
+
function resolveWhatsAppDefaultAccountSharedConfig(cfg) {
|
|
10
|
+
const defaultAccount = resolveAccountEntry(cfg.channels?.whatsapp?.accounts, DEFAULT_ACCOUNT_ID);
|
|
11
|
+
if (!defaultAccount) return;
|
|
12
|
+
const { enabled: _ignoredEnabled, name: _ignoredName, authDir: _ignoredAuthDir, selfChatMode: _ignoredSelfChatMode, ...sharedDefaults } = defaultAccount;
|
|
13
|
+
return sharedDefaults;
|
|
14
|
+
}
|
|
15
|
+
function resolveWhatsAppAccountConfigForTest(cfg, accountId) {
|
|
16
|
+
return resolveAccountEntry(cfg.channels?.whatsapp?.accounts, accountId);
|
|
17
|
+
}
|
|
18
|
+
function resolveMergedNamedWhatsAppAccountConfig(params) {
|
|
19
|
+
const rootCfg = params.cfg.channels?.whatsapp;
|
|
20
|
+
const accountConfig = resolveWhatsAppAccountConfigForTest(params.cfg, params.accountId);
|
|
21
|
+
return {
|
|
22
|
+
...mergeAccountConfig({
|
|
23
|
+
channelConfig: rootCfg,
|
|
24
|
+
accountConfig: void 0,
|
|
25
|
+
omitKeys: ["defaultAccount"]
|
|
26
|
+
}),
|
|
27
|
+
...resolveWhatsAppDefaultAccountSharedConfig(params.cfg),
|
|
28
|
+
...accountConfig
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function resolveMergedWhatsAppAccountConfig(params) {
|
|
32
|
+
const rootCfg = params.cfg.channels?.whatsapp;
|
|
33
|
+
const accountId = params.accountId?.trim() || rootCfg?.defaultAccount || DEFAULT_ACCOUNT_ID;
|
|
34
|
+
const base = resolveMergedAccountConfig({
|
|
35
|
+
channelConfig: rootCfg,
|
|
36
|
+
accounts: rootCfg?.accounts,
|
|
37
|
+
accountId,
|
|
38
|
+
omitKeys: ["defaultAccount"]
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
accountId,
|
|
42
|
+
...accountId === DEFAULT_ACCOUNT_ID ? base : resolveMergedNamedWhatsAppAccountConfig({
|
|
43
|
+
cfg: params.cfg,
|
|
44
|
+
accountId
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
9
49
|
//#region extensions/whatsapp/src/accounts.ts
|
|
10
50
|
const DEFAULT_WHATSAPP_MEDIA_MAX_MB = 50;
|
|
11
51
|
function listWhatsAppAuthDirs(cfg) {
|
|
@@ -110,4 +150,4 @@ function listEnabledWhatsAppAccounts(cfg) {
|
|
|
110
150
|
})).filter((account) => account.enabled);
|
|
111
151
|
}
|
|
112
152
|
//#endregion
|
|
113
|
-
export { resolveWhatsAppAccount as a, listWhatsAppAuthDirs as i, hasAnyWhatsAppAuth as n, resolveWhatsAppAuthDir as o, listEnabledWhatsAppAccounts as r, resolveWhatsAppMediaMaxBytes as s, DEFAULT_WHATSAPP_MEDIA_MAX_MB as t };
|
|
153
|
+
export { resolveWhatsAppAccount as a, resolveMergedWhatsAppAccountConfig as c, listWhatsAppAuthDirs as i, hasAnyWhatsAppAuth as n, resolveWhatsAppAuthDir as o, listEnabledWhatsAppAccounts as r, resolveWhatsAppMediaMaxBytes as s, DEFAULT_WHATSAPP_MEDIA_MAX_MB as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as handleWhatsAppAction } from "./action-runtime-
|
|
1
|
+
import { t as handleWhatsAppAction } from "./action-runtime-p0V390gA.js";
|
|
2
2
|
export { handleWhatsAppAction };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-ejK8sXPU.js";
|
|
2
2
|
import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-BR97fAbB.js";
|
|
3
|
-
import { r as sendReactionWhatsApp, u as resolveWhatsAppReactionLevel } from "./send-
|
|
3
|
+
import { r as sendReactionWhatsApp, u as resolveWhatsAppReactionLevel } from "./send-SB-4JrVZ.js";
|
|
4
4
|
import { ToolAuthorizationError, createActionGate, jsonResult, readReactionParams, readStringParam } from "openclaw/plugin-sdk/channel-actions";
|
|
5
5
|
//#region extensions/whatsapp/src/action-runtime-target-auth.ts
|
|
6
6
|
function resolveAuthorizedWhatsAppOutboundTarget(params) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as handleWhatsAppAction } from "./action-runtime-
|
|
1
|
+
import { t as handleWhatsAppAction } from "./action-runtime-p0V390gA.js";
|
|
2
2
|
export { handleWhatsAppAction };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-9mEeAvu1.js";
|
|
3
3
|
//#region extensions/whatsapp/src/active-listener.ts
|
|
4
4
|
function resolveWebAccountId(params) {
|
|
5
5
|
return (params.accountId ?? "").trim() || resolveDefaultWhatsAppAccountId(params.cfg);
|
package/dist/api.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
+
import { a as resolveWhatsAppAccount, i as listWhatsAppAuthDirs, n as hasAnyWhatsAppAuth, o as resolveWhatsAppAuthDir, r as listEnabledWhatsAppAccounts, s as resolveWhatsAppMediaMaxBytes, t as DEFAULT_WHATSAPP_MEDIA_MAX_MB } from "./accounts-ejK8sXPU.js";
|
|
1
2
|
import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-CB5SOWjc.js";
|
|
2
|
-
import { a as resolveWhatsAppAccount, i as listWhatsAppAuthDirs, n as hasAnyWhatsAppAuth, o as resolveWhatsAppAuthDir, r as listEnabledWhatsAppAccounts, s as resolveWhatsAppMediaMaxBytes, t as DEFAULT_WHATSAPP_MEDIA_MAX_MB } from "./accounts-CKOFMPf-.js";
|
|
3
3
|
import { a as normalizeWhatsAppAllowFromEntries, c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, r as isWhatsAppUserTarget, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./normalize-target-DSZnHkKF.js";
|
|
4
4
|
import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-BR97fAbB.js";
|
|
5
|
-
import "./send-
|
|
5
|
+
import "./send-SB-4JrVZ.js";
|
|
6
6
|
import { c as toWhatsappJidWithLid, i as markdownToWhatsApp, n as isSelfChatMode, o as resolveJidToE164, r as jidToE164, s as toWhatsappJid, t as assertWebChannel } from "./targets-runtime-Bsh0HR9y.js";
|
|
7
7
|
import { n as normalizeE164, r as resolveUserPath } from "./text-runtime-BTGkMN0o.js";
|
|
8
|
-
import { n as resolveWhatsAppGroupIntroHint, r as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./channel-
|
|
8
|
+
import { n as resolveWhatsAppGroupIntroHint, r as WHATSAPP_LEGACY_OUTBOUND_SEND_DEP_KEYS, t as whatsappPlugin } from "./channel-B2I4Opzb.js";
|
|
9
9
|
import { t as whatsappCommandPolicy } from "./command-policy-BIOSHySD.js";
|
|
10
|
-
import { a as resolveWhatsAppGroupRequireMention, o as resolveWhatsAppGroupToolPolicy } from "./setup-core-
|
|
10
|
+
import { a as resolveWhatsAppGroupRequireMention, o as resolveWhatsAppGroupToolPolicy } from "./setup-core-BbIgEl2M.js";
|
|
11
11
|
import "./config-schema-BZ8h1hWA.js";
|
|
12
|
-
import { t as whatsappSetupPlugin } from "./channel.setup-
|
|
12
|
+
import { t as whatsappSetupPlugin } from "./channel.setup-BMWE9LmN.js";
|
|
13
13
|
import { t as DEFAULT_WEB_MEDIA_BYTES } from "./constants-HU41RHGI.js";
|
|
14
|
-
import {
|
|
15
|
-
import { n as testing } from "./access-control-DazDX3RB.js";
|
|
16
|
-
import { _ as extractLocationData, b as extractText, d as normalizeMessageContent, f as resolveInboundMediaMimetype, h as extractContextInfo, p as describeReplyContext, t as createWebSendApi } from "./send-api-W33lI2nR.js";
|
|
17
|
-
import { a as createWhatsAppSocketOperationTimeoutAdapter, i as DEFAULT_WHATSAPP_SOCKET_TIMING, r as waitForWaConnection, t as createWaSocket } from "./session-mxWFn0eS.js";
|
|
14
|
+
import { a as waitForWaConnection, o as DEFAULT_WHATSAPP_SOCKET_TIMING, r as createWaSocket, s as createWhatsAppSocketOperationTimeoutAdapter } from "./socket-close-jNGyZY4T.js";
|
|
18
15
|
import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
|
|
16
|
+
import { n as listWhatsAppDirectoryGroupsFromConfig, r as listWhatsAppDirectoryPeersFromConfig } from "./directory-config-BZ775eGX.js";
|
|
17
|
+
import { n as testing } from "./access-control-tjy_em01.js";
|
|
18
|
+
import { _ as extractLocationData, b as extractText, d as normalizeMessageContent, f as resolveInboundMediaMimetype, h as extractContextInfo, p as describeReplyContext, t as createWebSendApi } from "./send-api-BG0MgoFI.js";
|
|
19
19
|
import "openclaw/plugin-sdk/channel-actions";
|
|
20
20
|
import "openclaw/plugin-sdk/account-resolution";
|
|
21
21
|
import "openclaw/plugin-sdk/core";
|
|
22
22
|
import "openclaw/plugin-sdk/account-id";
|
|
23
23
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
24
24
|
import { formatLocationText } from "openclaw/plugin-sdk/channel-inbound";
|
|
25
|
-
createLazyRuntimeModule(() => import("./channel.runtime-
|
|
25
|
+
createLazyRuntimeModule(() => import("./channel.runtime-CjkhQzk8.js"));
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region extensions/whatsapp/src/qa-driver.runtime.ts
|
|
28
28
|
function isRecord(value) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import "./accounts-ejK8sXPU.js";
|
|
1
2
|
import { r as resolveDefaultWhatsAppAccountId } from "./account-ids-CB5SOWjc.js";
|
|
2
|
-
import "./accounts-CKOFMPf-.js";
|
|
3
3
|
import { s as normalizeWhatsAppMessagingTarget } from "./normalize-target-DSZnHkKF.js";
|
|
4
|
-
import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-
|
|
4
|
+
import { i as sendTypingWhatsApp, t as sendMessageWhatsApp } from "./send-SB-4JrVZ.js";
|
|
5
5
|
import { n as getWhatsAppRuntime } from "./runtime-BfAdAEYT.js";
|
|
6
6
|
import "./normalize-C-Z16y7Q.js";
|
|
7
|
-
import { i as unregisterWhatsAppApprovalReactionTarget, r as registerWhatsAppApprovalReactionTarget } from "./approval-reactions-
|
|
7
|
+
import { i as unregisterWhatsAppApprovalReactionTarget, r as registerWhatsAppApprovalReactionTarget } from "./approval-reactions-CrZFAyf-.js";
|
|
8
8
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
9
9
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
10
10
|
import { buildChannelApprovalNativeTargetKey } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
2
|
+
import { a as resolveWhatsAppAccount } from "./accounts-ejK8sXPU.js";
|
|
3
3
|
import { t as getOptionalWhatsAppRuntime } from "./runtime-BfAdAEYT.js";
|
|
4
|
-
import { c as getWhatsAppApprovalApprovers, l as whatsappApprovalAuth } from "./group-session-key-
|
|
4
|
+
import { c as getWhatsAppApprovalApprovers, l as whatsappApprovalAuth } from "./group-session-key-Dh8WZun_.js";
|
|
5
5
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
6
|
import { createApprovalReactionTargetStore, listApprovalReactionBindings, resolveTypedApprovalReactionTarget } from "openclaw/plugin-sdk/approval-reaction-runtime";
|
|
7
7
|
//#region extensions/whatsapp/src/approval-reactions.ts
|
package/dist/call-tool-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount } from "./accounts-
|
|
2
|
-
import {
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-ejK8sXPU.js";
|
|
2
|
+
import { r as getWhatsAppConnectionController } from "./connection-controller-runtime-context-9mEeAvu1.js";
|
|
3
3
|
import { o as resolveJidToE164 } from "./targets-runtime-Bsh0HR9y.js";
|
|
4
4
|
import { createActionGate, stringEnum } from "openclaw/plugin-sdk/channel-actions";
|
|
5
5
|
import path from "node:path";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { a as resolveWhatsAppAccount } from "./accounts-ejK8sXPU.js";
|
|
1
2
|
import { r as resolveDefaultWhatsAppAccountId, t as listAccountIds } from "./account-ids-CB5SOWjc.js";
|
|
2
|
-
import { a as resolveWhatsAppAccount } from "./accounts-CKOFMPf-.js";
|
|
3
3
|
import { c as normalizeWhatsAppTarget, i as looksLikeWhatsAppTargetId, n as isWhatsAppNewsletterJid, o as normalizeWhatsAppAllowFromEntry, s as normalizeWhatsAppMessagingTarget, t as isWhatsAppGroupJid } from "./normalize-target-DSZnHkKF.js";
|
|
4
4
|
import { t as resolveWhatsAppOutboundTarget } from "./resolve-outbound-target-BR97fAbB.js";
|
|
5
|
-
import { a as normalizeWhatsAppOutboundPayload, i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppPayloadText, s as normalizeWhatsAppPayloadTextPreservingIndentation, t as sendMessageWhatsApp, u as resolveWhatsAppReactionLevel } from "./send-
|
|
5
|
+
import { a as normalizeWhatsAppOutboundPayload, i as sendTypingWhatsApp, n as sendPollWhatsApp, o as normalizeWhatsAppPayloadText, s as normalizeWhatsAppPayloadTextPreservingIndentation, t as sendMessageWhatsApp, u as resolveWhatsAppReactionLevel } from "./send-SB-4JrVZ.js";
|
|
6
6
|
import { n as getWhatsAppRuntime } from "./runtime-BfAdAEYT.js";
|
|
7
7
|
import "./normalize-C-Z16y7Q.js";
|
|
8
8
|
import { s as toWhatsappJid } from "./targets-runtime-Bsh0HR9y.js";
|
|
9
9
|
import "./text-runtime-BTGkMN0o.js";
|
|
10
10
|
import { t as createWhatsAppLoginTool } from "./agent-tools-login-DfyToBpG.js";
|
|
11
|
-
import { c as getWhatsAppApprovalApprovers, l as whatsappApprovalAuth, s as lookupInboundMessageMetaForTarget, t as resolveWhatsAppGroupSessionKey } from "./group-session-key-
|
|
11
|
+
import { c as getWhatsAppApprovalApprovers, l as whatsappApprovalAuth, s as lookupInboundMessageMetaForTarget, t as resolveWhatsAppGroupSessionKey } from "./group-session-key-Dh8WZun_.js";
|
|
12
12
|
import { t as whatsappCommandPolicy } from "./command-policy-BIOSHySD.js";
|
|
13
|
-
import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupWizardProxy, n as createWhatsAppPluginBase, o as resolveWhatsAppGroupToolPolicy, r as loadWhatsAppChannelRuntime, s as formatWhatsAppConfigAllowFromEntries, t as whatsappSetupAdapter } from "./setup-core-
|
|
13
|
+
import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupWizardProxy, n as createWhatsAppPluginBase, o as resolveWhatsAppGroupToolPolicy, r as loadWhatsAppChannelRuntime, s as formatWhatsAppConfigAllowFromEntries, t as whatsappSetupAdapter } from "./setup-core-BbIgEl2M.js";
|
|
14
14
|
import { f as readWebAuthExistsForDecision, n as WHATSAPP_AUTH_UNSTABLE_CODE } from "./auth-store-BQi9pZqQ.js";
|
|
15
15
|
import { t as detectWhatsAppLegacyStateMigrations } from "./state-migrations-CAMTrs2U.js";
|
|
16
16
|
import { createActionGate as createActionGate$1 } from "openclaw/plugin-sdk/channel-actions";
|
|
@@ -30,6 +30,7 @@ import { createLazyChannelApprovalNativeRuntimeAdapter } from "openclaw/plugin-s
|
|
|
30
30
|
import { createChannelApproverDmTargetResolver, createChannelNativeOriginTargetResolver, createNativeApprovalChannelRouteGates, createNativeApprovalForwardingFallbackSuppressor } from "openclaw/plugin-sdk/approval-native-runtime";
|
|
31
31
|
import { buildApprovalReactionPromptPayloadForRequest } from "openclaw/plugin-sdk/approval-reaction-runtime";
|
|
32
32
|
import { buildTypedApprovalPresentation } from "openclaw/plugin-sdk/approval-reply-runtime";
|
|
33
|
+
import { questionGatewayRuntime } from "openclaw/plugin-sdk/question-gateway-runtime";
|
|
33
34
|
import { chunkText } from "openclaw/plugin-sdk/reply-chunking";
|
|
34
35
|
import { attachChannelToResult, createAttachedChannelResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
35
36
|
//#region extensions/whatsapp/src/approval-native.ts
|
|
@@ -224,7 +225,7 @@ const whatsappApprovalCapability = createChannelApprovalCapability({
|
|
|
224
225
|
approvalKind,
|
|
225
226
|
request
|
|
226
227
|
}),
|
|
227
|
-
load: async () => (await import("./approval-handler.runtime-
|
|
228
|
+
load: async () => (await import("./approval-handler.runtime-BO1oJ-b8.js")).whatsappApprovalNativeRuntime
|
|
228
229
|
})
|
|
229
230
|
});
|
|
230
231
|
//#endregion
|
|
@@ -390,7 +391,8 @@ function createWhatsAppOutboundBase({ chunker, sendMessageWhatsApp, sendPollWhat
|
|
|
390
391
|
}
|
|
391
392
|
//#endregion
|
|
392
393
|
//#region extensions/whatsapp/src/channel-outbound.ts
|
|
393
|
-
const loadWhatsAppApprovalReactionsModule = createLazyRuntimeModule(() => import("./approval-reactions-
|
|
394
|
+
const loadWhatsAppApprovalReactionsModule = createLazyRuntimeModule(() => import("./approval-reactions-CrZFAyf-.js").then((n) => n.t));
|
|
395
|
+
const loadWhatsAppQuestionReactionsModule = createLazyRuntimeModule(() => import("./question-reactions-C0qJ6wGA.js").then((n) => n.n));
|
|
394
396
|
function normalizeWhatsAppChannelPayloadText(text) {
|
|
395
397
|
return normalizeWhatsAppPayloadTextPreservingIndentation(text);
|
|
396
398
|
}
|
|
@@ -399,12 +401,18 @@ function normalizeWhatsAppChannelSendText(text) {
|
|
|
399
401
|
return normalized.trim() ? normalized : "";
|
|
400
402
|
}
|
|
401
403
|
async function prepareWhatsAppApprovalPayloadForDelivery(params) {
|
|
404
|
+
const questionPayload = questionGatewayRuntime.prepareReactionPayloadForDelivery({
|
|
405
|
+
payload: params.payload,
|
|
406
|
+
presentation: params.presentation
|
|
407
|
+
});
|
|
408
|
+
if (questionPayload) return questionPayload;
|
|
402
409
|
return (await loadWhatsAppApprovalReactionsModule()).prepareWhatsAppApprovalPayloadForDelivery({
|
|
403
410
|
payload: params.payload,
|
|
404
411
|
presentation: params.presentation
|
|
405
412
|
});
|
|
406
413
|
}
|
|
407
414
|
async function registerDeliveredWhatsAppApprovalPayload(params) {
|
|
415
|
+
(await loadWhatsAppQuestionReactionsModule()).registerWhatsAppQuestionReactionTargetForDeliveredPayload(params);
|
|
408
416
|
(await loadWhatsAppApprovalReactionsModule()).registerWhatsAppApprovalReactionTargetForDeliveredPayload(params);
|
|
409
417
|
}
|
|
410
418
|
const whatsappChannelOutbound = {
|
|
@@ -657,8 +665,8 @@ function collectWhatsAppStatusIssues(accounts) {
|
|
|
657
665
|
}
|
|
658
666
|
//#endregion
|
|
659
667
|
//#region extensions/whatsapp/src/channel.ts
|
|
660
|
-
const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config-
|
|
661
|
-
const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-
|
|
668
|
+
const loadWhatsAppDirectoryConfig = createLazyRuntimeModule(() => import("./directory-config-BZ775eGX.js").then((n) => n.t));
|
|
669
|
+
const loadWhatsAppChannelReactAction = createLazyRuntimeModule(() => import("./channel-react-action-CPRQE-s3.js"));
|
|
662
670
|
function resolveWhatsAppTargetInfo(raw) {
|
|
663
671
|
const normalized = normalizeWhatsAppTarget(raw);
|
|
664
672
|
if (!normalized) return null;
|
|
@@ -758,7 +766,8 @@ const whatsappPlugin = createChatChannelPlugin({
|
|
|
758
766
|
};
|
|
759
767
|
},
|
|
760
768
|
listPeers: async (params) => (await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryPeersFromConfig(params),
|
|
761
|
-
listGroups: async (params) => (await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryGroupsFromConfig(params)
|
|
769
|
+
listGroups: async (params) => (await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryGroupsFromConfig(params),
|
|
770
|
+
listGroupsLive: async (params) => (await loadWhatsAppDirectoryConfig()).listWhatsAppDirectoryGroupsLive(params)
|
|
762
771
|
},
|
|
763
772
|
actions: {
|
|
764
773
|
describeMessageTool: ({ cfg, accountId }) => describeWhatsAppMessageActions({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as whatsappPlugin } from "./channel-
|
|
1
|
+
import { t as whatsappPlugin } from "./channel-B2I4Opzb.js";
|
|
2
2
|
export { whatsappPlugin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-
|
|
1
|
+
import { a as resolveWhatsAppAccount, s as resolveWhatsAppMediaMaxBytes } from "./accounts-ejK8sXPU.js";
|
|
2
2
|
import { c as normalizeWhatsAppTarget, t as isWhatsAppGroupJid } from "./normalize-target-DSZnHkKF.js";
|
|
3
|
-
import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-
|
|
4
|
-
import { t as sendMessageWhatsApp } from "./send-
|
|
3
|
+
import { r as resolveAuthorizedWhatsAppOutboundTarget, t as handleWhatsAppAction } from "./action-runtime-p0V390gA.js";
|
|
4
|
+
import { t as sendMessageWhatsApp } from "./send-SB-4JrVZ.js";
|
|
5
5
|
import "./normalize-C-Z16y7Q.js";
|
|
6
6
|
import { jsonResult, readStringOrNumberParam, readStringParam as readStringParam$1, resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
|
|
7
7
|
import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { startWebLoginWithQr as startWebLoginWithQr$1, waitForWebLogin as waitForWebLogin$1 } from "./login-qr-runtime.js";
|
|
2
2
|
import { c as logoutWeb$1, d as readWebAuthExistsBestEffort$1, f as readWebAuthExistsForDecision$1, g as readWebSelfId$1, h as readWebAuthState$1, m as readWebAuthSnapshotBestEffort$1, o as getWebAuthAgeMs$1, p as readWebAuthSnapshot$1, s as logWebSelfId$1, x as webAuthExists$1 } from "./auth-store-BQi9pZqQ.js";
|
|
3
|
-
import { t as getActiveWebListener$1 } from "./active-listener-
|
|
4
|
-
import { t as monitorWebChannel$1 } from "./monitor-
|
|
5
|
-
import { t as loginWeb$1 } from "./login-
|
|
6
|
-
import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-
|
|
3
|
+
import { t as getActiveWebListener$1 } from "./active-listener-BbdlXooT.js";
|
|
4
|
+
import { t as monitorWebChannel$1 } from "./monitor-_jqDKBXj.js";
|
|
5
|
+
import { t as loginWeb$1 } from "./login-ifOXCBjo.js";
|
|
6
|
+
import { whatsappSetupWizard as whatsappSetupWizard$1 } from "./setup-surface-DhnXEZir.js";
|
|
7
7
|
//#region extensions/whatsapp/src/channel.runtime.ts
|
|
8
8
|
function getActiveWebListener(...args) {
|
|
9
9
|
return getActiveWebListener$1(...args);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupWizardProxy, n as createWhatsAppPluginBase, o as resolveWhatsAppGroupToolPolicy, t as whatsappSetupAdapter } from "./setup-core-
|
|
1
|
+
import { a as resolveWhatsAppGroupRequireMention, i as whatsappSetupWizardProxy, n as createWhatsAppPluginBase, o as resolveWhatsAppGroupToolPolicy, t as whatsappSetupAdapter } from "./setup-core-BbIgEl2M.js";
|
|
2
2
|
import { t as detectWhatsAppLegacyStateMigrations } from "./state-migrations-CAMTrs2U.js";
|
|
3
3
|
//#region extensions/whatsapp/src/channel.setup.ts
|
|
4
4
|
async function isWhatsAppAuthConfigured(account) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as getWhatsAppRuntime } from "./runtime-BfAdAEYT.js";
|
|
2
|
-
import { t as WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY } from "./connection-controller-runtime-context-
|
|
3
|
-
import { c as logoutWeb, f as readWebAuthExistsForDecision, r as WhatsAppAuthUnstableError } from "./auth-store-BQi9pZqQ.js";
|
|
2
|
+
import { n as WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY, t as WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY } from "./connection-controller-runtime-context-9mEeAvu1.js";
|
|
3
|
+
import { c as logoutWeb, f as readWebAuthExistsForDecision, r as WhatsAppAuthUnstableError, w as waitForCredsSaveQueueWithTimeout } from "./auth-store-BQi9pZqQ.js";
|
|
4
4
|
import { c as resolveComparableIdentity } from "./identity-D7L8LCuH.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as waitForWaConnection, m as acquireWhatsAppGatewayConnectionOwner, o as DEFAULT_WHATSAPP_SOCKET_TIMING, r as createWaSocket, t as closeWhatsAppSocketAndWait } from "./socket-close-jNGyZY4T.js";
|
|
6
6
|
import { n as getStatusCode, t as formatError } from "./session-errors-JuazczrA.js";
|
|
7
7
|
import { computeBackoff, info, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
8
8
|
import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
|
@@ -89,17 +89,28 @@ function createLiveConnection(params) {
|
|
|
89
89
|
openedAfterRecentInbound: params.openedAfterRecentInbound,
|
|
90
90
|
backgroundTasks: /* @__PURE__ */ new Set(),
|
|
91
91
|
closePromise,
|
|
92
|
-
resolveClose: resolveClosePromise
|
|
92
|
+
resolveClose: resolveClosePromise,
|
|
93
|
+
socketClosed: false
|
|
93
94
|
};
|
|
94
95
|
}
|
|
96
|
+
async function closeWebSocketBestEffort(sock) {
|
|
97
|
+
try {
|
|
98
|
+
await sock.ws?.close?.();
|
|
99
|
+
} catch {}
|
|
100
|
+
}
|
|
95
101
|
function closeWaSocket(sock) {
|
|
96
102
|
try {
|
|
97
103
|
if (typeof sock?.end === "function") {
|
|
98
|
-
sock.end(/* @__PURE__ */ new Error("OpenClaw WhatsApp socket close"));
|
|
104
|
+
Promise.resolve(sock.end(/* @__PURE__ */ new Error("OpenClaw WhatsApp socket close"))).catch(async () => await closeWebSocketBestEffort(sock));
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
sock
|
|
102
|
-
} catch {
|
|
107
|
+
if (sock) closeWebSocketBestEffort(sock);
|
|
108
|
+
} catch {
|
|
109
|
+
if (sock) closeWebSocketBestEffort(sock);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function stoppedControllerError() {
|
|
113
|
+
return /* @__PURE__ */ new Error("WhatsApp connection controller is shutting down");
|
|
103
114
|
}
|
|
104
115
|
function closeWaSocketSoon(sock, delayMs = 500) {
|
|
105
116
|
setTimeout(() => {
|
|
@@ -229,6 +240,15 @@ var WhatsAppConnectionController = class {
|
|
|
229
240
|
this.disconnectRetryController = new AbortController();
|
|
230
241
|
this.current = null;
|
|
231
242
|
this.runtimeContextLease = null;
|
|
243
|
+
this.pendingOwnerContextLease = null;
|
|
244
|
+
this.connectionOwnerLease = null;
|
|
245
|
+
this.retainedOwnerReleaseLease = null;
|
|
246
|
+
this.connectionOwnerLeasePromise = null;
|
|
247
|
+
this.connectionSetupPromise = null;
|
|
248
|
+
this.pendingSocketCleanup = null;
|
|
249
|
+
this.shuttingDown = false;
|
|
250
|
+
this.ownerAcquireAbortController = new AbortController();
|
|
251
|
+
this.setupAbortController = new AbortController();
|
|
232
252
|
this.reconnectAttempts = 0;
|
|
233
253
|
this.lastHandledInboundAt = null;
|
|
234
254
|
this.accountId = params.accountId;
|
|
@@ -249,11 +269,17 @@ var WhatsAppConnectionController = class {
|
|
|
249
269
|
...params.socketTiming
|
|
250
270
|
};
|
|
251
271
|
this.socketRef = { current: null };
|
|
252
|
-
|
|
253
|
-
|
|
272
|
+
const abortSignal = params.abortSignal;
|
|
273
|
+
if (abortSignal) this.abortPromise = new Promise((resolve) => {
|
|
274
|
+
const stop = () => {
|
|
275
|
+
resolve("aborted");
|
|
276
|
+
this.stopDisconnectRetries();
|
|
277
|
+
this.ownerAcquireAbortController.abort(abortSignal.reason);
|
|
278
|
+
this.setupAbortController.abort(abortSignal.reason);
|
|
279
|
+
};
|
|
280
|
+
if (abortSignal.aborted) stop();
|
|
281
|
+
else abortSignal.addEventListener("abort", stop, { once: true });
|
|
254
282
|
});
|
|
255
|
-
if (params.abortSignal?.aborted) this.stopDisconnectRetries();
|
|
256
|
-
else params.abortSignal?.addEventListener("abort", () => this.stopDisconnectRetries(), { once: true });
|
|
257
283
|
}
|
|
258
284
|
getActiveListener() {
|
|
259
285
|
return this.current?.listener ?? null;
|
|
@@ -322,7 +348,23 @@ var WhatsAppConnectionController = class {
|
|
|
322
348
|
this.current.unregisterUnhandled = unregister;
|
|
323
349
|
}
|
|
324
350
|
async openConnection(params) {
|
|
351
|
+
if (this.shuttingDown) throw stoppedControllerError();
|
|
352
|
+
if (this.connectionSetupPromise) throw new Error("WhatsApp connection setup is already in progress");
|
|
353
|
+
const setupPromise = this.openConnectionOwned(params);
|
|
354
|
+
this.connectionSetupPromise = setupPromise;
|
|
355
|
+
try {
|
|
356
|
+
return await setupPromise;
|
|
357
|
+
} finally {
|
|
358
|
+
if (this.connectionSetupPromise === setupPromise) this.connectionSetupPromise = null;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
async openConnectionOwned(params) {
|
|
362
|
+
await this.ensureConnectionOwnership();
|
|
363
|
+
this.throwIfSetupStopped();
|
|
364
|
+
await this.finishPendingSocketCleanup();
|
|
365
|
+
this.throwIfSetupStopped();
|
|
325
366
|
if (this.current) await this.closeCurrentConnection();
|
|
367
|
+
this.throwIfSetupStopped();
|
|
326
368
|
let sock = null;
|
|
327
369
|
let connection = null;
|
|
328
370
|
try {
|
|
@@ -332,8 +374,9 @@ var WhatsAppConnectionController = class {
|
|
|
332
374
|
...params.getMessage ? { getMessage: params.getMessage } : {},
|
|
333
375
|
...params.cachedGroupMetadata ? { cachedGroupMetadata: params.cachedGroupMetadata } : {}
|
|
334
376
|
});
|
|
335
|
-
|
|
336
|
-
|
|
377
|
+
this.throwIfSetupStopped();
|
|
378
|
+
await this.waitForSetupStep(waitForWaConnection(sock, { timeoutMs: this.socketTiming.connectTimeoutMs }));
|
|
379
|
+
this.throwIfSetupStopped();
|
|
337
380
|
this.socketRef.current = sock;
|
|
338
381
|
connection = createLiveConnection({
|
|
339
382
|
connectionId: params.connectionId,
|
|
@@ -341,16 +384,24 @@ var WhatsAppConnectionController = class {
|
|
|
341
384
|
listener: {},
|
|
342
385
|
openedAfterRecentInbound: this.isOpeningAfterRecentInbound()
|
|
343
386
|
});
|
|
344
|
-
const
|
|
387
|
+
const listenerTask = params.createListener({
|
|
345
388
|
sock,
|
|
346
389
|
connection
|
|
347
390
|
});
|
|
391
|
+
let listener;
|
|
392
|
+
try {
|
|
393
|
+
listener = await this.waitForSetupStep(listenerTask);
|
|
394
|
+
} catch (error) {
|
|
395
|
+
if (this.setupAbortController.signal.aborted) listenerTask.then((lateListener) => lateListener.close?.()).catch(() => {});
|
|
396
|
+
throw error;
|
|
397
|
+
}
|
|
348
398
|
connection.listener = listener;
|
|
399
|
+
this.throwIfSetupStopped();
|
|
349
400
|
this.current = connection;
|
|
350
401
|
connection.unregisterTransportActivity = this.attachTransportActivityListener(sock);
|
|
351
402
|
const previousRuntimeContextLease = this.runtimeContextLease;
|
|
352
403
|
this.runtimeContextLease = registerChannelRuntimeContext({
|
|
353
|
-
channelRuntime,
|
|
404
|
+
channelRuntime: getWhatsAppRuntime().channel,
|
|
354
405
|
channelId: "whatsapp",
|
|
355
406
|
accountId: this.accountId,
|
|
356
407
|
capability: WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY,
|
|
@@ -358,16 +409,38 @@ var WhatsAppConnectionController = class {
|
|
|
358
409
|
abortSignal: this.abortSignal
|
|
359
410
|
});
|
|
360
411
|
previousRuntimeContextLease?.dispose();
|
|
412
|
+
this.pendingOwnerContextLease?.dispose();
|
|
413
|
+
this.pendingOwnerContextLease = null;
|
|
361
414
|
this.startTimers(connection, {
|
|
362
415
|
onHeartbeat: params.onHeartbeat,
|
|
363
416
|
onWatchdogTimeout: params.onWatchdogTimeout
|
|
364
417
|
});
|
|
365
418
|
return connection;
|
|
366
419
|
} catch (err) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
420
|
+
try {
|
|
421
|
+
if (connection && this.current === connection) await this.closeCurrentConnection();
|
|
422
|
+
else {
|
|
423
|
+
try {
|
|
424
|
+
await connection?.listener.close?.();
|
|
425
|
+
} catch {}
|
|
426
|
+
if (this.socketRef.current === sock) this.socketRef.current = null;
|
|
427
|
+
if (sock) {
|
|
428
|
+
const cleanup = connection ?? {
|
|
429
|
+
sock,
|
|
430
|
+
socketClosed: false
|
|
431
|
+
};
|
|
432
|
+
await this.finishSocketCleanup(cleanup);
|
|
433
|
+
}
|
|
434
|
+
if (connection?.unregisterUnhandled) connection.unregisterUnhandled();
|
|
435
|
+
connection?.unregisterTransportActivity?.();
|
|
436
|
+
}
|
|
437
|
+
} catch (closeError) {
|
|
438
|
+
if (sock && (!connection || this.current !== connection)) this.pendingSocketCleanup = connection ?? {
|
|
439
|
+
sock,
|
|
440
|
+
socketClosed: false
|
|
441
|
+
};
|
|
442
|
+
throw new AggregateError([err, closeError], "WhatsApp connection setup and close failed", { cause: err });
|
|
443
|
+
}
|
|
371
444
|
throw err;
|
|
372
445
|
}
|
|
373
446
|
}
|
|
@@ -460,6 +533,7 @@ var WhatsAppConnectionController = class {
|
|
|
460
533
|
const connection = this.current;
|
|
461
534
|
if (!connection) return;
|
|
462
535
|
this.current = null;
|
|
536
|
+
this.pendingSocketCleanup = connection;
|
|
463
537
|
if (this.socketRef.current === connection.sock) this.socketRef.current = null;
|
|
464
538
|
connection.unregisterUnhandled?.();
|
|
465
539
|
connection.unregisterTransportActivity?.();
|
|
@@ -472,16 +546,103 @@ var WhatsAppConnectionController = class {
|
|
|
472
546
|
try {
|
|
473
547
|
await connection.listener.close?.();
|
|
474
548
|
} catch {}
|
|
475
|
-
|
|
549
|
+
await this.finishSocketCleanup(connection);
|
|
550
|
+
if (this.pendingSocketCleanup === connection) this.pendingSocketCleanup = null;
|
|
476
551
|
}
|
|
477
552
|
async waitBeforeRetry(delayMs) {
|
|
478
553
|
await this.sleep(delayMs, this.abortSignal);
|
|
479
554
|
}
|
|
480
555
|
async shutdown() {
|
|
556
|
+
this.shuttingDown = true;
|
|
557
|
+
const stoppedError = stoppedControllerError();
|
|
558
|
+
this.ownerAcquireAbortController.abort(stoppedError);
|
|
559
|
+
this.setupAbortController.abort(stoppedError);
|
|
481
560
|
this.stopDisconnectRetries();
|
|
561
|
+
await this.connectionSetupPromise?.catch(() => {});
|
|
562
|
+
await this.connectionOwnerLeasePromise?.catch(() => {});
|
|
482
563
|
await this.closeCurrentConnection();
|
|
483
|
-
this.
|
|
484
|
-
|
|
564
|
+
await this.finishPendingSocketCleanup();
|
|
565
|
+
try {
|
|
566
|
+
this.runtimeContextLease?.dispose();
|
|
567
|
+
} finally {
|
|
568
|
+
this.runtimeContextLease = null;
|
|
569
|
+
try {
|
|
570
|
+
this.pendingOwnerContextLease?.dispose();
|
|
571
|
+
} finally {
|
|
572
|
+
this.pendingOwnerContextLease = null;
|
|
573
|
+
if (this.connectionOwnerLease) {
|
|
574
|
+
await this.connectionOwnerLease.release();
|
|
575
|
+
this.connectionOwnerLease = null;
|
|
576
|
+
}
|
|
577
|
+
if (this.retainedOwnerReleaseLease) {
|
|
578
|
+
await this.retainedOwnerReleaseLease.release();
|
|
579
|
+
this.retainedOwnerReleaseLease = null;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
async finishSocketCleanup(cleanup) {
|
|
585
|
+
if (!cleanup.socketClosed) {
|
|
586
|
+
await closeWhatsAppSocketAndWait(cleanup.sock, "OpenClaw WhatsApp socket close");
|
|
587
|
+
cleanup.socketClosed = true;
|
|
588
|
+
}
|
|
589
|
+
if (await waitForCredsSaveQueueWithTimeout(this.authDir) === "timed_out") throw new Error("WhatsApp credential persistence did not drain before owner release");
|
|
590
|
+
}
|
|
591
|
+
async finishPendingSocketCleanup() {
|
|
592
|
+
const cleanup = this.pendingSocketCleanup;
|
|
593
|
+
if (!cleanup) return;
|
|
594
|
+
await this.finishSocketCleanup(cleanup);
|
|
595
|
+
if (this.pendingSocketCleanup === cleanup) this.pendingSocketCleanup = null;
|
|
596
|
+
}
|
|
597
|
+
throwIfSetupStopped() {
|
|
598
|
+
if (this.shuttingDown || this.setupAbortController.signal.aborted) throw stoppedControllerError();
|
|
599
|
+
}
|
|
600
|
+
async waitForSetupStep(task) {
|
|
601
|
+
this.throwIfSetupStopped();
|
|
602
|
+
const signal = this.setupAbortController.signal;
|
|
603
|
+
let onAbort;
|
|
604
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
605
|
+
onAbort = () => reject(stoppedControllerError());
|
|
606
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
607
|
+
});
|
|
608
|
+
try {
|
|
609
|
+
return await Promise.race([task, aborted]);
|
|
610
|
+
} finally {
|
|
611
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
async ensureConnectionOwnership() {
|
|
615
|
+
if (this.retainedOwnerReleaseLease) {
|
|
616
|
+
await this.retainedOwnerReleaseLease.release();
|
|
617
|
+
this.retainedOwnerReleaseLease = null;
|
|
618
|
+
}
|
|
619
|
+
if (this.connectionOwnerLease) return;
|
|
620
|
+
if (!this.connectionOwnerLeasePromise) this.connectionOwnerLeasePromise = (async () => {
|
|
621
|
+
const ownerLease = await acquireWhatsAppGatewayConnectionOwner(this.authDir, this.ownerAcquireAbortController.signal);
|
|
622
|
+
try {
|
|
623
|
+
if (this.shuttingDown) throw stoppedControllerError();
|
|
624
|
+
this.pendingOwnerContextLease = registerChannelRuntimeContext({
|
|
625
|
+
channelRuntime: getWhatsAppRuntime().channel,
|
|
626
|
+
channelId: "whatsapp",
|
|
627
|
+
accountId: this.accountId,
|
|
628
|
+
capability: WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY,
|
|
629
|
+
context: true,
|
|
630
|
+
abortSignal: this.abortSignal
|
|
631
|
+
});
|
|
632
|
+
this.connectionOwnerLease = ownerLease;
|
|
633
|
+
} catch (error) {
|
|
634
|
+
try {
|
|
635
|
+
await ownerLease.release();
|
|
636
|
+
} catch (releaseError) {
|
|
637
|
+
this.retainedOwnerReleaseLease = ownerLease;
|
|
638
|
+
throw new AggregateError([error, releaseError], "WhatsApp connection ownership setup and release failed", { cause: error });
|
|
639
|
+
}
|
|
640
|
+
throw error;
|
|
641
|
+
}
|
|
642
|
+
})().finally(() => {
|
|
643
|
+
this.connectionOwnerLeasePromise = null;
|
|
644
|
+
});
|
|
645
|
+
await this.connectionOwnerLeasePromise;
|
|
485
646
|
}
|
|
486
647
|
startTimers(connection, hooks) {
|
|
487
648
|
if (!this.keepAlive) return;
|
|
@@ -2,6 +2,7 @@ import { t as getOptionalWhatsAppRuntime } from "./runtime-BfAdAEYT.js";
|
|
|
2
2
|
import { getChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
|
3
3
|
//#region extensions/whatsapp/src/connection-controller-runtime-context.ts
|
|
4
4
|
const WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY = "connection-controller";
|
|
5
|
+
const WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY = "connection-owner-pending";
|
|
5
6
|
function getWhatsAppConnectionController(accountId) {
|
|
6
7
|
return getChannelRuntimeContext({
|
|
7
8
|
channelRuntime: getOptionalWhatsAppRuntime()?.channel,
|
|
@@ -10,5 +11,13 @@ function getWhatsAppConnectionController(accountId) {
|
|
|
10
11
|
capability: "connection-controller"
|
|
11
12
|
}) ?? null;
|
|
12
13
|
}
|
|
14
|
+
function hasPendingWhatsAppConnectionOwner(accountId) {
|
|
15
|
+
return Boolean(getChannelRuntimeContext({
|
|
16
|
+
channelRuntime: getOptionalWhatsAppRuntime()?.channel,
|
|
17
|
+
channelId: "whatsapp",
|
|
18
|
+
accountId,
|
|
19
|
+
capability: WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
13
22
|
//#endregion
|
|
14
|
-
export {
|
|
23
|
+
export { hasPendingWhatsAppConnectionOwner as i, WHATSAPP_CONNECTION_OWNER_PENDING_CAPABILITY as n, getWhatsAppConnectionController as r, WHATSAPP_CONNECTION_CONTROLLER_CAPABILITY as t };
|
package/dist/contract-api.js
CHANGED
|
@@ -2,7 +2,7 @@ import { c as normalizeWhatsAppTarget$1, t as isWhatsAppGroupJid$1 } from "./nor
|
|
|
2
2
|
import { t as whatsappCommandPolicy$1 } from "./command-policy-BIOSHySD.js";
|
|
3
3
|
import { t as resolveLegacyGroupSessionKey$1 } from "./group-session-contract-DDnZSsJ1.js";
|
|
4
4
|
import { r as isLegacyGroupSessionKey$1, t as canonicalizeLegacySessionKey$1 } from "./session-contract-DMTm6Q_L.js";
|
|
5
|
-
import { a as resolveWhatsAppRuntimeGroupPolicy$1, n as testing } from "./access-control-
|
|
5
|
+
import { a as resolveWhatsAppRuntimeGroupPolicy$1, n as testing } from "./access-control-tjy_em01.js";
|
|
6
6
|
//#region extensions/whatsapp/contract-api.ts
|
|
7
7
|
const canonicalizeLegacySessionKey = canonicalizeLegacySessionKey$1;
|
|
8
8
|
const isLegacyGroupSessionKey = isLegacyGroupSessionKey$1;
|