@openclaw/sms 2026.7.2-beta.4 → 2026.7.2-beta.7
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/channel-plugin-api.js +42 -38
- package/package.json +4 -5
- package/npm-shrinkwrap.json +0 -24
|
@@ -9,7 +9,8 @@ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
|
9
9
|
import { createEmptyChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
|
|
10
10
|
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
11
11
|
import { chunkTextForOutbound, renderMarkdownIRChunksWithinLimit, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
|
|
12
|
-
import {
|
|
12
|
+
import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
|
13
|
+
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, hasConfiguredAccountValue, resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
|
|
13
14
|
import { parseStrictInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
14
15
|
import { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
15
16
|
import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
|
|
@@ -70,30 +71,16 @@ function hasBaseAccount(channelCfg) {
|
|
|
70
71
|
process.env.TWILIO_MESSAGING_SERVICE_SID
|
|
71
72
|
].some((value) => hasConfiguredAccountValue(value)) || hasConfiguredSecretInput(channelCfg?.authToken);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function resolveDefaultSmsAccountId(cfg) {
|
|
81
|
-
const channelCfg = getChannelConfig(cfg);
|
|
82
|
-
return resolveListedDefaultAccountId({
|
|
83
|
-
accountIds: listSmsAccountIds(cfg),
|
|
84
|
-
configuredDefaultAccountId: normalizeOptionalAccountId(channelCfg?.defaultAccount)
|
|
85
|
-
});
|
|
86
|
-
}
|
|
74
|
+
const { listAccountIds: listSmsAccountIds, resolveDefaultAccountId: resolveDefaultSmsAccountId, resolveAccountConfig: resolveMergedSmsAccountConfig } = createAccountListHelpers(CHANNEL_ID$3, {
|
|
75
|
+
fallbackAccountIdWhenEmpty: false,
|
|
76
|
+
hasImplicitDefaultAccount: (cfg) => hasBaseAccount(getChannelConfig(cfg)),
|
|
77
|
+
omitKeys: ["defaultAccount"]
|
|
78
|
+
});
|
|
87
79
|
function resolveSmsAccount(cfg, accountId) {
|
|
88
80
|
const channelCfg = getChannelConfig(cfg) ?? {};
|
|
89
81
|
const id = normalizeOptionalAccountId(accountId) ?? resolveDefaultSmsAccountId(cfg);
|
|
90
82
|
const accountConfig = resolveAccountEntry(channelCfg.accounts, id);
|
|
91
|
-
const merged =
|
|
92
|
-
channelConfig: { ...channelCfg },
|
|
93
|
-
accounts: channelCfg.accounts ? Object.fromEntries(Object.entries(channelCfg.accounts).map(([accountKey, account]) => [accountKey, { ...account }])) : void 0,
|
|
94
|
-
accountId: id,
|
|
95
|
-
omitKeys: ["defaultAccount"]
|
|
96
|
-
});
|
|
83
|
+
const merged = resolveMergedSmsAccountConfig(cfg, id);
|
|
97
84
|
const useEnvFallbacks = id === DEFAULT_ACCOUNT_ID$1;
|
|
98
85
|
const envAccountSid = useEnvFallbacks ? process.env.TWILIO_ACCOUNT_SID : void 0;
|
|
99
86
|
const envAuthToken = useEnvFallbacks ? process.env.TWILIO_AUTH_TOKEN : void 0;
|
|
@@ -767,10 +754,6 @@ async function dispatchSmsInboundEvent(params) {
|
|
|
767
754
|
//#region extensions/sms/src/ingress-spool.ts
|
|
768
755
|
const SMS_INGRESS_PAYLOAD_VERSION = 1;
|
|
769
756
|
const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
|
|
770
|
-
const SMS_COMPLETED_TTL_MS = 1440 * 60 * 1e3;
|
|
771
|
-
const SMS_COMPLETED_MAX_ENTRIES = 2e4;
|
|
772
|
-
const SMS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
|
|
773
|
-
const SMS_FAILED_MAX_ENTRIES = 1e3;
|
|
774
757
|
var SmsIngressPermanentError = class extends Error {};
|
|
775
758
|
function parseSmsIngressForm(form, account) {
|
|
776
759
|
const message = buildTwilioInboundMessage(form);
|
|
@@ -823,10 +806,8 @@ function createSmsIngressSpool(params) {
|
|
|
823
806
|
pollIntervalMs: SMS_INGRESS_DRAIN_INTERVAL_MS,
|
|
824
807
|
retention: {
|
|
825
808
|
pruneIntervalMs: 0,
|
|
826
|
-
completedTtlMs:
|
|
827
|
-
|
|
828
|
-
failedTtlMs: SMS_FAILED_TTL_MS,
|
|
829
|
-
failedMaxEntries: SMS_FAILED_MAX_ENTRIES
|
|
809
|
+
completedTtlMs: 1440 * 60 * 1e3,
|
|
810
|
+
failedMaxEntries: 1e3
|
|
830
811
|
},
|
|
831
812
|
appendRetryDelaysMs: [0],
|
|
832
813
|
waitForDeliveryIdleBeforeRepump: false,
|
|
@@ -863,6 +844,8 @@ function createSmsIngressSpool(params) {
|
|
|
863
844
|
//#region extensions/sms/src/webhook.ts
|
|
864
845
|
const INVALID_REQUEST_MAX_REQUESTS = 300;
|
|
865
846
|
const CALLBACK_DISPATCH_MAX_REQUESTS = 30;
|
|
847
|
+
const SMS_WEBHOOK_ACCEPTED_HEADER = "x-openclaw-delivery-accepted";
|
|
848
|
+
const SMS_WEBHOOK_ACCEPTED_VALUE = "durable";
|
|
866
849
|
const invalidRequestRateLimiter = createFixedWindowRateLimiter({
|
|
867
850
|
maxRequests: INVALID_REQUEST_MAX_REQUESTS,
|
|
868
851
|
windowMs: 6e4,
|
|
@@ -873,6 +856,11 @@ const callbackDispatchRateLimiter = createFixedWindowRateLimiter({
|
|
|
873
856
|
windowMs: 6e4,
|
|
874
857
|
maxTrackedKeys: 5e3
|
|
875
858
|
});
|
|
859
|
+
const validatedAggregateRateLimiter = createFixedWindowRateLimiter({
|
|
860
|
+
maxRequests: 300,
|
|
861
|
+
windowMs: 6e4,
|
|
862
|
+
maxTrackedKeys: 1e3
|
|
863
|
+
});
|
|
876
864
|
function headerValue(value) {
|
|
877
865
|
if (Array.isArray(value)) return value[0];
|
|
878
866
|
return value;
|
|
@@ -881,7 +869,10 @@ function resolvedClientAddress(params) {
|
|
|
881
869
|
return resolveRequestClientIp(params.req, params.cfg.gateway?.trustedProxies, params.cfg.gateway?.allowRealIpFallback === true) ?? params.req.socket?.remoteAddress ?? "unknown";
|
|
882
870
|
}
|
|
883
871
|
function rateLimitKey(params) {
|
|
884
|
-
return `${params.account.accountId}:${params.account.webhookPath}:${params.
|
|
872
|
+
return `${params.account.accountId}:${params.account.webhookPath}:${params.subject}`;
|
|
873
|
+
}
|
|
874
|
+
function accountRouteRateLimitKey(account) {
|
|
875
|
+
return `${account.accountId}:${account.webhookPath}`;
|
|
885
876
|
}
|
|
886
877
|
function rejectInvalidRequestRateLimit(params) {
|
|
887
878
|
params.log?.warn?.(`SMS webhook invalid-request rate limit exceeded for ${params.key}`);
|
|
@@ -898,17 +889,17 @@ function createSmsWebhookHandler(params) {
|
|
|
898
889
|
cfg: params.cfg,
|
|
899
890
|
req
|
|
900
891
|
});
|
|
901
|
-
const
|
|
892
|
+
const clientAddressKey = rateLimitKey({
|
|
902
893
|
account: params.account,
|
|
903
|
-
clientAddress
|
|
894
|
+
subject: clientAddress
|
|
904
895
|
});
|
|
905
|
-
const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(
|
|
896
|
+
const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(clientAddressKey);
|
|
906
897
|
let form;
|
|
907
898
|
try {
|
|
908
899
|
form = await readTwilioWebhookForm(req);
|
|
909
900
|
} catch {
|
|
910
901
|
if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
|
|
911
|
-
key,
|
|
902
|
+
key: clientAddressKey,
|
|
912
903
|
log: params.log,
|
|
913
904
|
res
|
|
914
905
|
});
|
|
@@ -926,7 +917,7 @@ function createSmsWebhookHandler(params) {
|
|
|
926
917
|
form
|
|
927
918
|
})) {
|
|
928
919
|
if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
|
|
929
|
-
key,
|
|
920
|
+
key: clientAddressKey,
|
|
930
921
|
log: params.log,
|
|
931
922
|
res
|
|
932
923
|
});
|
|
@@ -936,21 +927,34 @@ function createSmsWebhookHandler(params) {
|
|
|
936
927
|
}
|
|
937
928
|
}
|
|
938
929
|
if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
|
|
939
|
-
key,
|
|
930
|
+
key: clientAddressKey,
|
|
940
931
|
log: params.log,
|
|
941
932
|
res
|
|
942
933
|
});
|
|
943
|
-
|
|
944
|
-
params.
|
|
934
|
+
const dispatchKey = params.account.dangerouslyDisableSignatureValidation ? clientAddressKey : rateLimitKey({
|
|
935
|
+
account: params.account,
|
|
936
|
+
subject: resolveTwilioInboundSender(form)
|
|
937
|
+
});
|
|
938
|
+
if (callbackDispatchRateLimiter.isRateLimited(dispatchKey)) {
|
|
939
|
+
params.log?.warn?.("SMS webhook callback rate limit exceeded");
|
|
945
940
|
respondTwiml(res, 429, "Rate limit exceeded");
|
|
946
941
|
return true;
|
|
947
942
|
}
|
|
943
|
+
if (!params.account.dangerouslyDisableSignatureValidation) {
|
|
944
|
+
const aggregateKey = accountRouteRateLimitKey(params.account);
|
|
945
|
+
if (validatedAggregateRateLimiter.isRateLimited(aggregateKey)) {
|
|
946
|
+
params.log?.warn?.(`SMS webhook aggregate rate limit exceeded for ${aggregateKey}`);
|
|
947
|
+
respondTwiml(res, 429, "Rate limit exceeded");
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
948
951
|
const messageSid = resolveTwilioMessageSid(form);
|
|
949
952
|
if (!messageSid) {
|
|
950
953
|
respondTwiml(res, 400, "Missing MessageSid");
|
|
951
954
|
return true;
|
|
952
955
|
}
|
|
953
956
|
if ((await params.ingress.enqueue(form)).duplicate) params.log?.warn?.(`SMS webhook ignored replayed message ${messageSid}`);
|
|
957
|
+
res.setHeader(SMS_WEBHOOK_ACCEPTED_HEADER, SMS_WEBHOOK_ACCEPTED_VALUE);
|
|
954
958
|
respondTwiml(res, 200);
|
|
955
959
|
return true;
|
|
956
960
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/sms",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.7",
|
|
4
4
|
"description": "OpenClaw SMS channel plugin for Twilio text messages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -124,10 +124,10 @@
|
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
126
|
"compat": {
|
|
127
|
-
"pluginApi": ">=2026.7.2-beta.
|
|
127
|
+
"pluginApi": ">=2026.7.2-beta.7"
|
|
128
128
|
},
|
|
129
129
|
"build": {
|
|
130
|
-
"openclawVersion": "2026.7.2-beta.
|
|
130
|
+
"openclawVersion": "2026.7.2-beta.7",
|
|
131
131
|
"bundledDist": false
|
|
132
132
|
},
|
|
133
133
|
"install": {
|
|
@@ -148,11 +148,10 @@
|
|
|
148
148
|
"files": [
|
|
149
149
|
"dist/**",
|
|
150
150
|
"openclaw.plugin.json",
|
|
151
|
-
"npm-shrinkwrap.json",
|
|
152
151
|
"README.md"
|
|
153
152
|
],
|
|
154
153
|
"peerDependencies": {
|
|
155
|
-
"openclaw": ">=2026.7.2-beta.
|
|
154
|
+
"openclaw": ">=2026.7.2-beta.7"
|
|
156
155
|
},
|
|
157
156
|
"peerDependenciesMeta": {
|
|
158
157
|
"openclaw": {
|
package/npm-shrinkwrap.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@openclaw/sms",
|
|
3
|
-
"version": "2026.7.2-beta.4",
|
|
4
|
-
"lockfileVersion": 3,
|
|
5
|
-
"requires": true,
|
|
6
|
-
"packages": {
|
|
7
|
-
"": {
|
|
8
|
-
"name": "@openclaw/sms",
|
|
9
|
-
"version": "2026.7.2-beta.4",
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"zod": "4.4.3"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"node_modules/zod": {
|
|
15
|
-
"version": "4.4.3",
|
|
16
|
-
"resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
|
|
17
|
-
"integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"funding": {
|
|
20
|
-
"url": "https://github.com/sponsors/colinhacks"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|