@laburen/openclaw-plugin-whatsapp-api 0.2.0 → 0.2.2
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/index.d.ts +0 -2
- package/index.js +4 -13
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as openclaw_plugin_sdk0 from "openclaw/plugin-sdk";
|
|
2
1
|
import { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
3
2
|
|
|
4
3
|
//#region index.d.ts
|
|
@@ -9,7 +8,6 @@ declare const plugin: {
|
|
|
9
8
|
id: string;
|
|
10
9
|
name: string;
|
|
11
10
|
description: string;
|
|
12
|
-
configSchema: openclaw_plugin_sdk0.OpenClawPluginConfigSchema;
|
|
13
11
|
/**
|
|
14
12
|
* Wires the channel into OpenClaw: saves plugin API, registers `whatsapp-api`.
|
|
15
13
|
*
|
package/index.js
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
2
|
-
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
3
1
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
2
|
import path from "node:path";
|
|
5
3
|
import { tmpdir } from "node:os";
|
|
6
4
|
//#region src/core/accounts.ts
|
|
7
|
-
/**
|
|
8
|
-
* SPDX-License-Identifier: MIT
|
|
9
|
-
*
|
|
10
|
-
* Account resolution for the WhatsApp API channel.
|
|
11
|
-
*
|
|
12
|
-
* Reads `channels.whatsapp-api` (and per-account entries) from Clawdbot config
|
|
13
|
-
* and returns fully resolved defaults for webhooks, Graph API, and media.
|
|
14
|
-
*/
|
|
15
5
|
const CHANNEL_ID$1 = "whatsapp-api";
|
|
16
6
|
const DEFAULT_WEBHOOK_PATH = "/webhook/whatsapp-api";
|
|
17
7
|
const DEFAULT_API_VERSION = "v22.0";
|
|
@@ -22,6 +12,7 @@ const DEFAULT_DEDUPE_TTL_MS = 5 * 6e4;
|
|
|
22
12
|
const DEFAULT_MAX_BODY_BYTES = 512 * 1024;
|
|
23
13
|
const DEFAULT_MEDIA_MAX_BYTES = 20 * 1024 * 1024;
|
|
24
14
|
const DEFAULT_MEDIA_REQUEST_TIMEOUT_MS = 15e3;
|
|
15
|
+
const DEFAULT_ACCOUNT_ID$1 = "default";
|
|
25
16
|
function getChannelConfig(cfg) {
|
|
26
17
|
return (cfg.channels ?? {})[CHANNEL_ID$1] ?? {};
|
|
27
18
|
}
|
|
@@ -45,7 +36,7 @@ function listAccountIds(cfg) {
|
|
|
45
36
|
const ids = /* @__PURE__ */ new Set();
|
|
46
37
|
const accounts = channelCfg.accounts ?? {};
|
|
47
38
|
if (Object.keys(accounts).length > 0) for (const id of Object.keys(accounts)) ids.add(id);
|
|
48
|
-
else ids.add(DEFAULT_ACCOUNT_ID);
|
|
39
|
+
else ids.add(DEFAULT_ACCOUNT_ID$1);
|
|
49
40
|
return [...ids];
|
|
50
41
|
}
|
|
51
42
|
/**
|
|
@@ -60,7 +51,7 @@ function listAccountIds(cfg) {
|
|
|
60
51
|
*/
|
|
61
52
|
function resolveAccount(cfg, accountId) {
|
|
62
53
|
const channelCfg = getChannelConfig(cfg);
|
|
63
|
-
const id = accountId ?? DEFAULT_ACCOUNT_ID;
|
|
54
|
+
const id = accountId ?? DEFAULT_ACCOUNT_ID$1;
|
|
64
55
|
const accountCfg = (channelCfg.accounts ?? {})[id] ?? {};
|
|
65
56
|
return {
|
|
66
57
|
accountId: id,
|
|
@@ -1089,6 +1080,7 @@ async function handleWhatsAppApiWebhook(params) {
|
|
|
1089
1080
|
//#region src/channel/plugin.ts
|
|
1090
1081
|
const CHANNEL_ID = "whatsapp-api";
|
|
1091
1082
|
const log$1 = waLogger("channel");
|
|
1083
|
+
const DEFAULT_ACCOUNT_ID = "default";
|
|
1092
1084
|
/**
|
|
1093
1085
|
* Resolves when `signal` aborts, or never if `signal` is undefined.
|
|
1094
1086
|
*
|
|
@@ -1352,7 +1344,6 @@ const plugin = {
|
|
|
1352
1344
|
id: "whatsapp-api",
|
|
1353
1345
|
name: "WhatsApp API",
|
|
1354
1346
|
description: "WhatsApp API channel plugin with inbound webhook and direct Meta outbound",
|
|
1355
|
-
configSchema: emptyPluginConfigSchema(),
|
|
1356
1347
|
register(api) {
|
|
1357
1348
|
setPluginApi(api);
|
|
1358
1349
|
api.registerChannel({ plugin: createWhatsAppApiChannel(api) });
|