@openclaw/sms 2026.9.6 → 2026.9.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/assets/icon.png
CHANGED
|
Binary file
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as getSmsRuntime } from "./runtime-BBlPgBIF.mjs";
|
|
2
|
-
import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-
|
|
2
|
+
import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-AlRQ6LtX.mjs";
|
|
3
3
|
import { collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
|
|
4
4
|
import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
|
-
import { formatInboundMediaUnavailableText, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
7
6
|
import { SsrFBlockedError, safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
7
|
+
import { formatInboundMediaUnavailableText, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
8
8
|
import { extensionForMime } from "openclaw/plugin-sdk/media-mime";
|
|
9
9
|
import { MediaFetchError, unlinkIfExists } from "openclaw/plugin-sdk/media-runtime";
|
|
10
10
|
import { createHostedOutboundMediaStore } from "openclaw/plugin-sdk/outbound-media";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as getSmsRuntime } from "./.setup/runtime-BBlPgBIF.mjs";
|
|
2
|
-
import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-
|
|
2
|
+
import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-AlRQ6LtX.mjs";
|
|
3
3
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-Cp0f-YPc.mjs";
|
|
4
4
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
5
5
|
import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
@@ -17,8 +17,8 @@ import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMul
|
|
|
17
17
|
import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
|
|
18
18
|
import { z } from "zod";
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
20
|
-
import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
21
20
|
import { createFixedWindowRateLimiter, isRequestBodyLimitError, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
|
|
21
|
+
import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
22
22
|
import { createWebhookInFlightLimiter, runDetachedWebhookWork, sendHttpRequestRejection } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
23
23
|
import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
|
24
24
|
import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
@@ -130,9 +130,6 @@ let deliveryStoreRuntime;
|
|
|
130
130
|
function firstTrimmed(form, key) {
|
|
131
131
|
return form[key]?.trim() ?? "";
|
|
132
132
|
}
|
|
133
|
-
function resolveMessageSid(form) {
|
|
134
|
-
return firstTrimmed(form, "MessageSid") || firstTrimmed(form, "SmsSid") || firstTrimmed(form, "SmsMessageSid");
|
|
135
|
-
}
|
|
136
133
|
function normalizeDeliveryStatus(rawStatus) {
|
|
137
134
|
const status = rawStatus.trim().toLowerCase();
|
|
138
135
|
return INBOUND_MESSAGE_STATUSES.has(status) ? "" : status;
|
|
@@ -172,7 +169,7 @@ function isTwilioDeliveryStatusForm(form) {
|
|
|
172
169
|
return Boolean(resolveDeliveryStatus(form));
|
|
173
170
|
}
|
|
174
171
|
function parseSmsDeliveryObservation(form, nowMs = Date.now()) {
|
|
175
|
-
const messageSid =
|
|
172
|
+
const messageSid = resolveTwilioMessageSid(form);
|
|
176
173
|
const status = resolveDeliveryStatus(form);
|
|
177
174
|
if (!messageSid || !status) return null;
|
|
178
175
|
const errorCode = firstTrimmed(form, "ErrorCode");
|
|
@@ -196,16 +193,12 @@ function parseSmsDeliveryObservation(form, nowMs = Date.now()) {
|
|
|
196
193
|
};
|
|
197
194
|
}
|
|
198
195
|
function reduceDeliveryStatus(current, observation) {
|
|
199
|
-
if (
|
|
200
|
-
status: observation.status,
|
|
201
|
-
...observation.errorCode ? { errorCode: observation.errorCode } : {}
|
|
202
|
-
};
|
|
203
|
-
if (current.status === "conflicted") return {
|
|
196
|
+
if (current?.status === "conflicted") return {
|
|
204
197
|
status: current.status,
|
|
205
198
|
...current.errorCode ? { errorCode: current.errorCode } : {},
|
|
206
199
|
conflict: true
|
|
207
200
|
};
|
|
208
|
-
if (current
|
|
201
|
+
if (current?.status === observation.status) {
|
|
209
202
|
const errorCode = current.errorCode ?? observation.errorCode;
|
|
210
203
|
return {
|
|
211
204
|
status: current.status,
|
|
@@ -213,9 +206,9 @@ function reduceDeliveryStatus(current, observation) {
|
|
|
213
206
|
...current.conflict ? { conflict: true } : {}
|
|
214
207
|
};
|
|
215
208
|
}
|
|
216
|
-
const currentTerminal = TERMINAL_DELIVERY_STATUSES.has(current.status);
|
|
209
|
+
const currentTerminal = current && TERMINAL_DELIVERY_STATUSES.has(current.status);
|
|
217
210
|
const nextTerminal = TERMINAL_DELIVERY_STATUSES.has(observation.status);
|
|
218
|
-
if (currentTerminal && nextTerminal
|
|
211
|
+
if (currentTerminal && nextTerminal) {
|
|
219
212
|
const errorCode = observation.errorCode ?? current.errorCode;
|
|
220
213
|
return {
|
|
221
214
|
status: "conflicted",
|
|
@@ -223,24 +216,11 @@ function reduceDeliveryStatus(current, observation) {
|
|
|
223
216
|
conflict: true
|
|
224
217
|
};
|
|
225
218
|
}
|
|
226
|
-
|
|
227
|
-
status: current.status,
|
|
228
|
-
...current.errorCode ? { errorCode: current.errorCode } : {},
|
|
229
|
-
...current.conflict ? { conflict: true } : {}
|
|
230
|
-
};
|
|
231
|
-
if (nextTerminal) return {
|
|
232
|
-
status: observation.status,
|
|
233
|
-
...observation.errorCode ? { errorCode: observation.errorCode } : {}
|
|
234
|
-
};
|
|
235
|
-
const currentRank = DELIVERY_STATUS_RANK[current.status] ?? -1;
|
|
236
|
-
if ((DELIVERY_STATUS_RANK[observation.status] ?? -1) > currentRank) return {
|
|
237
|
-
status: observation.status,
|
|
238
|
-
...observation.errorCode ? { errorCode: observation.errorCode } : {}
|
|
239
|
-
};
|
|
219
|
+
const selected = !current || !currentTerminal && (nextTerminal || (DELIVERY_STATUS_RANK[observation.status] ?? -1) > (DELIVERY_STATUS_RANK[current.status] ?? -1)) ? observation : current;
|
|
240
220
|
return {
|
|
241
|
-
status:
|
|
242
|
-
...
|
|
243
|
-
...current.conflict ? { conflict: true } : {}
|
|
221
|
+
status: selected.status,
|
|
222
|
+
...selected.errorCode ? { errorCode: selected.errorCode } : {},
|
|
223
|
+
...selected === current && current.conflict ? { conflict: true } : {}
|
|
244
224
|
};
|
|
245
225
|
}
|
|
246
226
|
function mergeSmsDeliveryObservation(params) {
|
|
@@ -358,15 +338,14 @@ function createSmsMessageReceipt(params) {
|
|
|
358
338
|
});
|
|
359
339
|
return receipt;
|
|
360
340
|
}
|
|
361
|
-
function
|
|
341
|
+
function createSmsSendResult(params) {
|
|
342
|
+
const first = params.results[0];
|
|
343
|
+
if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
|
|
362
344
|
return {
|
|
363
345
|
channel: "sms",
|
|
364
|
-
messageId:
|
|
365
|
-
chatId:
|
|
366
|
-
receipt: createSmsMessageReceipt(
|
|
367
|
-
results: [result],
|
|
368
|
-
kind
|
|
369
|
-
})
|
|
346
|
+
messageId: first.sid,
|
|
347
|
+
chatId: first.to,
|
|
348
|
+
receipt: createSmsMessageReceipt(params)
|
|
370
349
|
};
|
|
371
350
|
}
|
|
372
351
|
function throwSmsPartialDeliveryError(error, results, kind) {
|
|
@@ -427,17 +406,6 @@ async function sendSmsProviderMessage(params) {
|
|
|
427
406
|
await recordInitialDeliveryBestEffort(params.account, result);
|
|
428
407
|
return result;
|
|
429
408
|
}
|
|
430
|
-
function logInitialDeliveryPersistenceFailure(result, error) {
|
|
431
|
-
try {
|
|
432
|
-
getSmsRuntime().logging.getChildLogger({
|
|
433
|
-
plugin: "sms",
|
|
434
|
-
feature: "delivery-status"
|
|
435
|
-
}).warn("SMS delivery initial state could not be persisted.", {
|
|
436
|
-
messageSid: result.sid,
|
|
437
|
-
errorType: error instanceof Error ? error.name : typeof error
|
|
438
|
-
});
|
|
439
|
-
} catch {}
|
|
440
|
-
}
|
|
441
409
|
async function recordInitialDeliveryBestEffort(account, result) {
|
|
442
410
|
try {
|
|
443
411
|
await recordInitialSmsDeliveryResult({
|
|
@@ -445,7 +413,15 @@ async function recordInitialDeliveryBestEffort(account, result) {
|
|
|
445
413
|
result
|
|
446
414
|
});
|
|
447
415
|
} catch (error) {
|
|
448
|
-
|
|
416
|
+
try {
|
|
417
|
+
getSmsRuntime().logging.getChildLogger({
|
|
418
|
+
plugin: "sms",
|
|
419
|
+
feature: "delivery-status"
|
|
420
|
+
}).warn("SMS delivery initial state could not be persisted.", {
|
|
421
|
+
messageSid: result.sid,
|
|
422
|
+
errorType: error instanceof Error ? error.name : typeof error
|
|
423
|
+
});
|
|
424
|
+
} catch {}
|
|
449
425
|
}
|
|
450
426
|
}
|
|
451
427
|
async function sendSmsTextChunks(params) {
|
|
@@ -454,20 +430,26 @@ async function sendSmsTextChunks(params) {
|
|
|
454
430
|
configuredLimit: params.account.textChunkLimit
|
|
455
431
|
});
|
|
456
432
|
if (chunks.length === 0) throw new Error("SMS send requires non-empty text.");
|
|
433
|
+
return await sendSmsMessages(params, chunks.map((text) => ({ text })), "text");
|
|
434
|
+
}
|
|
435
|
+
async function sendSmsMessages(params, messages, kind) {
|
|
457
436
|
const results = [];
|
|
458
437
|
try {
|
|
459
|
-
for (const
|
|
438
|
+
for (const [index, message] of messages.entries()) {
|
|
460
439
|
const result = await sendSmsProviderMessage({
|
|
461
440
|
account: params.account,
|
|
462
441
|
to: params.to,
|
|
463
|
-
|
|
442
|
+
...message,
|
|
464
443
|
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
465
444
|
});
|
|
466
445
|
results.push(result);
|
|
467
|
-
await params.onDeliveryResult?.(
|
|
446
|
+
await params.onDeliveryResult?.(createSmsSendResult({
|
|
447
|
+
results: [result],
|
|
448
|
+
kind: index === 0 ? kind : "text"
|
|
449
|
+
}));
|
|
468
450
|
}
|
|
469
451
|
} catch (error) {
|
|
470
|
-
throwSmsPartialDeliveryError(error, results,
|
|
452
|
+
throwSmsPartialDeliveryError(error, results, kind);
|
|
471
453
|
}
|
|
472
454
|
return results;
|
|
473
455
|
}
|
|
@@ -479,7 +461,7 @@ async function prepareSmsMediaAttempt(params) {
|
|
|
479
461
|
});
|
|
480
462
|
let hostedMedia;
|
|
481
463
|
try {
|
|
482
|
-
const { prepareHostedSmsMedia } = await import("./.setup/media-
|
|
464
|
+
const { prepareHostedSmsMedia } = await import("./.setup/media-Cmf2YTCW.mjs");
|
|
483
465
|
assertSmsCredentialOwnerAvailable(params.account);
|
|
484
466
|
const prepared = await prepareHostedSmsMedia({
|
|
485
467
|
account: params.account,
|
|
@@ -504,31 +486,10 @@ async function prepareSmsMediaAttempt(params) {
|
|
|
504
486
|
};
|
|
505
487
|
}
|
|
506
488
|
async function sendPreparedSmsMediaAttempt(params) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
to: params.to,
|
|
512
|
-
...params.attempt.caption ? { text: params.attempt.caption } : {},
|
|
513
|
-
mediaUrls: [params.attempt.hostedMediaUrl],
|
|
514
|
-
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
515
|
-
});
|
|
516
|
-
results.push(mediaResult);
|
|
517
|
-
await params.onDeliveryResult?.(createSmsDeliveryProgressResult(mediaResult, "media"));
|
|
518
|
-
for (const text of params.attempt.remainingChunks) {
|
|
519
|
-
const result = await sendSmsProviderMessage({
|
|
520
|
-
account: params.account,
|
|
521
|
-
to: params.to,
|
|
522
|
-
text,
|
|
523
|
-
onPlatformSendDispatch: params.onPlatformSendDispatch
|
|
524
|
-
});
|
|
525
|
-
results.push(result);
|
|
526
|
-
await params.onDeliveryResult?.(createSmsDeliveryProgressResult(result, "text"));
|
|
527
|
-
}
|
|
528
|
-
} catch (error) {
|
|
529
|
-
throwSmsPartialDeliveryError(error, results, "media");
|
|
530
|
-
}
|
|
531
|
-
return results;
|
|
489
|
+
return await sendSmsMessages(params, [{
|
|
490
|
+
...params.attempt.caption ? { text: params.attempt.caption } : {},
|
|
491
|
+
mediaUrls: [params.attempt.hostedMediaUrl]
|
|
492
|
+
}, ...params.attempt.remainingChunks.map((text) => ({ text }))], "media");
|
|
532
493
|
}
|
|
533
494
|
//#endregion
|
|
534
495
|
//#region extensions/sms/src/inbound.ts
|
|
@@ -611,7 +572,7 @@ async function dispatchSmsInboundEvent(params) {
|
|
|
611
572
|
params.log?.warn?.(`SMS sender ${from} is not authorized`);
|
|
612
573
|
return;
|
|
613
574
|
}
|
|
614
|
-
const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-
|
|
575
|
+
const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-Cmf2YTCW.mjs")).materializeSmsInboundMedia({
|
|
615
576
|
account: params.account,
|
|
616
577
|
msg: params.msg,
|
|
617
578
|
mediaRuntime: params.channelRuntime,
|
|
@@ -762,10 +723,8 @@ async function dispatchSmsInboundEvent(params) {
|
|
|
762
723
|
}
|
|
763
724
|
}
|
|
764
725
|
});
|
|
726
|
+
} finally {
|
|
765
727
|
if (adoptionState === "pending" || adoptionState === "abandoned") await materialized.cleanup();
|
|
766
|
-
} catch (error) {
|
|
767
|
-
if (adoptionState === "pending" || adoptionState === "abandoned") await materialized.cleanup();
|
|
768
|
-
throw error;
|
|
769
728
|
}
|
|
770
729
|
}
|
|
771
730
|
//#endregion
|
|
@@ -1116,7 +1075,7 @@ async function registerSmsWebhookRoute(params) {
|
|
|
1116
1075
|
throwOnFailure: true,
|
|
1117
1076
|
log: (msg) => params.log?.info?.(msg),
|
|
1118
1077
|
handler: async (req, res) => {
|
|
1119
|
-
const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-
|
|
1078
|
+
const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-Cmf2YTCW.mjs");
|
|
1120
1079
|
if (await tryHandleHostedSmsMediaRequest(req, res, params.account.accountId)) return true;
|
|
1121
1080
|
return await webhookHandler(req, res);
|
|
1122
1081
|
}
|
|
@@ -1216,33 +1175,30 @@ function compareTwilioWebhook(account, phoneNumber) {
|
|
|
1216
1175
|
status: "number-not-found",
|
|
1217
1176
|
expectedNumber: account.fromNumber
|
|
1218
1177
|
};
|
|
1219
|
-
const
|
|
1220
|
-
if (!phoneNumber.smsUrl) return {
|
|
1221
|
-
status: "missing",
|
|
1178
|
+
const summary = {
|
|
1222
1179
|
phoneNumber: phoneNumber.phoneNumber || account.fromNumber,
|
|
1223
1180
|
expectedUrl: account.publicWebhookUrl,
|
|
1224
|
-
configuredMethod
|
|
1181
|
+
configuredMethod: phoneNumber.smsMethod.toUpperCase()
|
|
1225
1182
|
};
|
|
1226
|
-
if (
|
|
1183
|
+
if (!phoneNumber.smsUrl) return {
|
|
1184
|
+
status: "missing",
|
|
1185
|
+
...summary
|
|
1186
|
+
};
|
|
1187
|
+
const configured = {
|
|
1188
|
+
...summary,
|
|
1189
|
+
configuredUrl: phoneNumber.smsUrl
|
|
1190
|
+
};
|
|
1191
|
+
if (summary.configuredMethod && summary.configuredMethod !== "POST") return {
|
|
1227
1192
|
status: "method-mismatch",
|
|
1228
|
-
|
|
1229
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1230
|
-
configuredUrl: phoneNumber.smsUrl,
|
|
1231
|
-
configuredMethod
|
|
1193
|
+
...configured
|
|
1232
1194
|
};
|
|
1233
1195
|
if (phoneNumber.smsUrl !== account.publicWebhookUrl) return {
|
|
1234
1196
|
status: "url-mismatch",
|
|
1235
|
-
|
|
1236
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1237
|
-
configuredUrl: phoneNumber.smsUrl,
|
|
1238
|
-
configuredMethod
|
|
1197
|
+
...configured
|
|
1239
1198
|
};
|
|
1240
1199
|
return {
|
|
1241
1200
|
status: "matches",
|
|
1242
|
-
|
|
1243
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1244
|
-
configuredUrl: phoneNumber.smsUrl,
|
|
1245
|
-
configuredMethod,
|
|
1201
|
+
...configured,
|
|
1246
1202
|
voiceUrl: phoneNumber.voiceUrl
|
|
1247
1203
|
};
|
|
1248
1204
|
}
|
|
@@ -1251,33 +1207,30 @@ function compareTwilioMessagingService(account, service) {
|
|
|
1251
1207
|
status: "unavailable",
|
|
1252
1208
|
reason: "Twilio Messaging Service defers inbound webhooks to sender phone numbers; configure fromNumber or disable defer-to-sender before probing."
|
|
1253
1209
|
};
|
|
1254
|
-
const
|
|
1255
|
-
if (!service.inboundRequestUrl) return {
|
|
1256
|
-
status: "messaging-service-missing",
|
|
1210
|
+
const summary = {
|
|
1257
1211
|
serviceSid: service.sid || account.messagingServiceSid,
|
|
1258
1212
|
expectedUrl: account.publicWebhookUrl,
|
|
1259
|
-
configuredMethod
|
|
1213
|
+
configuredMethod: service.inboundMethod.toUpperCase()
|
|
1214
|
+
};
|
|
1215
|
+
if (!service.inboundRequestUrl) return {
|
|
1216
|
+
status: "messaging-service-missing",
|
|
1217
|
+
...summary
|
|
1218
|
+
};
|
|
1219
|
+
const configured = {
|
|
1220
|
+
...summary,
|
|
1221
|
+
configuredUrl: service.inboundRequestUrl
|
|
1260
1222
|
};
|
|
1261
|
-
if (configuredMethod && configuredMethod !== "POST") return {
|
|
1223
|
+
if (summary.configuredMethod && summary.configuredMethod !== "POST") return {
|
|
1262
1224
|
status: "messaging-service-method-mismatch",
|
|
1263
|
-
|
|
1264
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1265
|
-
configuredUrl: service.inboundRequestUrl,
|
|
1266
|
-
configuredMethod
|
|
1225
|
+
...configured
|
|
1267
1226
|
};
|
|
1268
1227
|
if (service.inboundRequestUrl !== account.publicWebhookUrl) return {
|
|
1269
1228
|
status: "messaging-service-url-mismatch",
|
|
1270
|
-
|
|
1271
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1272
|
-
configuredUrl: service.inboundRequestUrl,
|
|
1273
|
-
configuredMethod
|
|
1229
|
+
...configured
|
|
1274
1230
|
};
|
|
1275
1231
|
return {
|
|
1276
1232
|
status: "messaging-service-matches",
|
|
1277
|
-
|
|
1278
|
-
expectedUrl: account.publicWebhookUrl,
|
|
1279
|
-
configuredUrl: service.inboundRequestUrl,
|
|
1280
|
-
configuredMethod
|
|
1233
|
+
...configured
|
|
1281
1234
|
};
|
|
1282
1235
|
}
|
|
1283
1236
|
function recentInboundSummary(messages) {
|
|
@@ -1594,17 +1547,6 @@ const smsSetupContract = defineChannelSetupContract({
|
|
|
1594
1547
|
},
|
|
1595
1548
|
adapter: { applyAccountConfig: applySmsAccountConfig }
|
|
1596
1549
|
});
|
|
1597
|
-
function createSmsReceipt(params) {
|
|
1598
|
-
const first = params.results[0];
|
|
1599
|
-
if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
|
|
1600
|
-
const receipt = createSmsMessageReceipt(params);
|
|
1601
|
-
return {
|
|
1602
|
-
channel: CHANNEL_ID,
|
|
1603
|
-
messageId: first.sid,
|
|
1604
|
-
chatId: first.to,
|
|
1605
|
-
receipt
|
|
1606
|
-
};
|
|
1607
|
-
}
|
|
1608
1550
|
function resolveSmsTextChunkLimit(params) {
|
|
1609
1551
|
return resolveSmsAccount(params.cfg, params.accountId).textChunkLimit || params.fallbackLimit || 1500;
|
|
1610
1552
|
}
|
|
@@ -1612,7 +1554,7 @@ async function sendSmsText(ctx) {
|
|
|
1612
1554
|
const account = resolveSmsAccount(ctx.cfg, ctx.accountId);
|
|
1613
1555
|
const to = normalizeSmsPhoneNumber(ctx.to) || account.defaultTo;
|
|
1614
1556
|
if (!looksLikeSmsPhoneNumber(to)) throw new Error(`Invalid SMS target: ${ctx.to}`);
|
|
1615
|
-
return
|
|
1557
|
+
return createSmsSendResult({
|
|
1616
1558
|
results: await sendSmsTextChunks({
|
|
1617
1559
|
account,
|
|
1618
1560
|
to,
|
|
@@ -1658,7 +1600,7 @@ async function sendPreparedSmsAttachment(ctx) {
|
|
|
1658
1600
|
preparedSmsAttachmentAttempts.delete(ctx);
|
|
1659
1601
|
if (!preparation) throw new Error("SMS message lifecycle did not prepare the MMS attachment.");
|
|
1660
1602
|
const prepared = await preparation;
|
|
1661
|
-
return
|
|
1603
|
+
return createSmsSendResult({
|
|
1662
1604
|
results: await sendPreparedSmsMediaAttempt({
|
|
1663
1605
|
...prepared,
|
|
1664
1606
|
onPlatformSendDispatch: async () => {
|
|
@@ -1690,8 +1632,8 @@ const smsMessageAdapter = defineChannelMessageAdapter({
|
|
|
1690
1632
|
await attemptToken.attempt.cleanupHostedMedia();
|
|
1691
1633
|
}
|
|
1692
1634
|
},
|
|
1693
|
-
text:
|
|
1694
|
-
media:
|
|
1635
|
+
text: sendSmsText,
|
|
1636
|
+
media: sendPreparedSmsAttachment
|
|
1695
1637
|
}
|
|
1696
1638
|
});
|
|
1697
1639
|
function resolveSmsOutboundSessionRoute(params) {
|
|
@@ -1753,9 +1695,9 @@ const smsPlugin = createChatChannelPlugin({
|
|
|
1753
1695
|
},
|
|
1754
1696
|
messaging: {
|
|
1755
1697
|
targetPrefixes: ["twilio-sms"],
|
|
1756
|
-
normalizeTarget:
|
|
1757
|
-
inferTargetChatType: ({ to }) => looksLikeSmsPhoneNumber(
|
|
1758
|
-
resolveOutboundSessionRoute:
|
|
1698
|
+
normalizeTarget: normalizeSmsPhoneNumber,
|
|
1699
|
+
inferTargetChatType: ({ to }) => looksLikeSmsPhoneNumber(to) ? "direct" : void 0,
|
|
1700
|
+
resolveOutboundSessionRoute: resolveSmsOutboundSessionRoute,
|
|
1759
1701
|
targetResolver: {
|
|
1760
1702
|
looksLikeId: looksLikeSmsPhoneNumber,
|
|
1761
1703
|
hint: "<+15551234567>"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/sms",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.7",
|
|
4
4
|
"description": "OpenClaw SMS/MMS channel plugin for Twilio messages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -123,10 +123,10 @@
|
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"compat": {
|
|
126
|
-
"pluginApi": ">=2026.9.
|
|
126
|
+
"pluginApi": ">=2026.9.7"
|
|
127
127
|
},
|
|
128
128
|
"build": {
|
|
129
|
-
"openclawVersion": "2026.9.
|
|
129
|
+
"openclawVersion": "2026.9.7",
|
|
130
130
|
"bundledDist": false
|
|
131
131
|
},
|
|
132
132
|
"install": {
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"assets/activity.svg"
|
|
153
153
|
],
|
|
154
154
|
"peerDependencies": {
|
|
155
|
-
"openclaw": ">=2026.9.
|
|
155
|
+
"openclaw": ">=2026.9.7"
|
|
156
156
|
},
|
|
157
157
|
"peerDependenciesMeta": {
|
|
158
158
|
"openclaw": {
|
|
@@ -8,13 +8,13 @@ import { hasConfiguredSecretInput, resolveSecretInputString } from "openclaw/plu
|
|
|
8
8
|
import { isIP } from "node:net";
|
|
9
9
|
import { fetchWithSsrFGuard, isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
10
10
|
import { createHmac } from "node:crypto";
|
|
11
|
-
import { readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
|
|
12
|
-
import { assertSecretOwnerAvailable } from "openclaw/plugin-sdk/channel-secret-owner-runtime";
|
|
13
|
-
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
14
11
|
import * as querystring from "node:querystring";
|
|
15
12
|
import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
|
|
16
13
|
import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
|
|
17
14
|
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
15
|
+
import { readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
|
|
16
|
+
import { assertSecretOwnerAvailable } from "openclaw/plugin-sdk/channel-secret-owner-runtime";
|
|
17
|
+
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
18
18
|
//#region extensions/sms/src/phone.ts
|
|
19
19
|
function normalizeSmsPhoneNumber(raw) {
|
|
20
20
|
const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "").trim();
|