@openclaw/sms 2026.7.2-beta.7 → 2026.7.33

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.
@@ -1,11 +1,27 @@
1
- import { collectConditionalChannelFieldAssignments, createChannelSecretTargetRegistryEntries, getChannelSurface, hasOwnProperty } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
1
+ import { collectConditionalChannelFieldAssignments, getChannelSurface, hasOwnProperty } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
2
2
  //#region extensions/sms/src/secret-contract.ts
3
3
  const DEFAULT_ACCOUNT_ID = "default";
4
- const secretTargetRegistryEntries = createChannelSecretTargetRegistryEntries({
5
- channelKey: "sms",
6
- account: ["authToken"],
7
- channel: ["authToken"]
8
- });
4
+ const secretTargetRegistryEntries = [{
5
+ id: "channels.sms.accounts.*.authToken",
6
+ targetType: "channels.sms.accounts.*.authToken",
7
+ configFile: "openclaw.json",
8
+ pathPattern: "channels.sms.accounts.*.authToken",
9
+ secretShape: "secret_input",
10
+ expectedResolvedValue: "string",
11
+ includeInPlan: true,
12
+ includeInConfigure: true,
13
+ includeInAudit: true
14
+ }, {
15
+ id: "channels.sms.authToken",
16
+ targetType: "channels.sms.authToken",
17
+ configFile: "openclaw.json",
18
+ pathPattern: "channels.sms.authToken",
19
+ secretShape: "secret_input",
20
+ expectedResolvedValue: "string",
21
+ includeInPlan: true,
22
+ includeInConfigure: true,
23
+ includeInAudit: true
24
+ }];
9
25
  function hasTopLevelSmsAccount(channel) {
10
26
  for (const field of [
11
27
  "accountSid",
package/dist/api.js CHANGED
@@ -1,2 +1,8 @@
1
- import { n as setSmsRuntime, t as getSmsRuntime } from "./runtime-BBlPgBIF.js";
1
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
2
+ //#region extensions/sms/src/runtime.ts
3
+ const { setRuntime: setSmsRuntime, getRuntime: getSmsRuntime } = createPluginRuntimeStore({
4
+ pluginId: "sms",
5
+ errorMessage: "SMS runtime not initialized - plugin not registered"
6
+ });
7
+ //#endregion
2
8
  export { getSmsRuntime, setSmsRuntime };
@@ -1,33 +1,27 @@
1
- import { t as getSmsRuntime } from "./runtime-BBlPgBIF.js";
2
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-Cp0f-YPc.js";
1
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-CS-JLPcU.mjs";
3
2
  import { DEFAULT_ACCOUNT_ID, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
4
3
  import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
5
4
  import { buildChannelOutboundSessionRoute, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
6
- import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
5
+ import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
7
6
  import { createConditionalWarningCollector } from "openclaw/plugin-sdk/channel-policy";
8
- import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
9
7
  import { createEmptyChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
10
8
  import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
11
- import { chunkTextForOutbound, renderMarkdownIRChunksWithinLimit, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
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";
9
+ import { chunkTextForOutbound, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
10
+ import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, listCombinedAccountIds, resolveAccountEntry, resolveListedDefaultAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
14
11
  import { parseStrictInteger } from "openclaw/plugin-sdk/number-runtime";
15
12
  import { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
16
- import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
13
+ import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-primitives";
17
14
  import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
18
15
  import { z } from "zod";
19
- import { createFixedWindowRateLimiter, readRequestBodyWithLimit, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
20
- import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
16
+ import { createFixedWindowRateLimiter, readRequestBodyWithLimit, registerPluginHttpRoute } from "openclaw/plugin-sdk/webhook-ingress";
21
17
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
22
18
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
23
- import { createHmac } from "node:crypto";
19
+ import { createHmac, timingSafeEqual } from "node:crypto";
24
20
  import * as querystring from "node:querystring";
25
- import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
26
- import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
27
21
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
28
22
  //#region extensions/sms/src/phone.ts
29
23
  function normalizeSmsPhoneNumber(raw) {
30
- const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "").trim();
24
+ const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "");
31
25
  if (!trimmed) return "";
32
26
  return (trimmed.startsWith("+") ? trimmed : `+${trimmed}`).replace(/[^\d+]/g, "");
33
27
  }
@@ -60,27 +54,34 @@ function firstNonBlankEnv(...values) {
60
54
  return values.find((value) => value?.trim());
61
55
  }
62
56
  function hasBaseAccount(channelCfg) {
63
- return [
64
- channelCfg?.accountSid,
65
- channelCfg?.fromNumber,
66
- channelCfg?.messagingServiceSid,
67
- process.env.TWILIO_ACCOUNT_SID,
68
- process.env.TWILIO_AUTH_TOKEN,
69
- process.env.TWILIO_PHONE_NUMBER,
70
- process.env.TWILIO_SMS_FROM,
71
- process.env.TWILIO_MESSAGING_SERVICE_SID
72
- ].some((value) => hasConfiguredAccountValue(value)) || hasConfiguredSecretInput(channelCfg?.authToken);
73
- }
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
- });
57
+ return Boolean(channelCfg?.accountSid || hasConfiguredSecretInput(channelCfg?.authToken) || channelCfg?.fromNumber || channelCfg?.messagingServiceSid || process.env.TWILIO_ACCOUNT_SID || process.env.TWILIO_AUTH_TOKEN || process.env.TWILIO_PHONE_NUMBER || process.env.TWILIO_SMS_FROM || process.env.TWILIO_MESSAGING_SERVICE_SID);
58
+ }
59
+ function listSmsAccountIds(cfg) {
60
+ const channelCfg = getChannelConfig(cfg);
61
+ return listCombinedAccountIds({
62
+ configuredAccountIds: Object.keys(channelCfg?.accounts ?? {}),
63
+ implicitAccountId: hasBaseAccount(channelCfg) ? DEFAULT_ACCOUNT_ID$1 : void 0
64
+ });
65
+ }
66
+ function resolveDefaultSmsAccountId(cfg) {
67
+ const channelCfg = getChannelConfig(cfg);
68
+ return resolveListedDefaultAccountId({
69
+ accountIds: listSmsAccountIds(cfg),
70
+ configuredDefaultAccountId: normalizeOptionalAccountId(channelCfg?.defaultAccount)
71
+ });
72
+ }
79
73
  function resolveSmsAccount(cfg, accountId) {
80
74
  const channelCfg = getChannelConfig(cfg) ?? {};
81
75
  const id = normalizeOptionalAccountId(accountId) ?? resolveDefaultSmsAccountId(cfg);
82
76
  const accountConfig = resolveAccountEntry(channelCfg.accounts, id);
83
- const merged = resolveMergedSmsAccountConfig(cfg, id);
77
+ const channelConfig = { ...channelCfg };
78
+ const accountEntries = channelCfg.accounts ? Object.fromEntries(Object.entries(channelCfg.accounts).map(([accountKey, account]) => [accountKey, { ...account }])) : void 0;
79
+ const merged = resolveMergedAccountConfig({
80
+ channelConfig,
81
+ accounts: accountEntries,
82
+ accountId: id,
83
+ omitKeys: ["defaultAccount"]
84
+ });
84
85
  const useEnvFallbacks = id === DEFAULT_ACCOUNT_ID$1;
85
86
  const envAccountSid = useEnvFallbacks ? process.env.TWILIO_ACCOUNT_SID : void 0;
86
87
  const envAuthToken = useEnvFallbacks ? process.env.TWILIO_AUTH_TOKEN : void 0;
@@ -130,7 +131,7 @@ function isSmsAccountConfigured(account) {
130
131
  //#endregion
131
132
  //#region extensions/sms/src/config-schema.ts
132
133
  const SecretInputSchema = buildSecretInputSchema();
133
- const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannelSchema(z.object({
134
+ const SmsAccountConfigSchema = z.object({
134
135
  name: z.string().optional(),
135
136
  enabled: z.boolean().optional(),
136
137
  accountSid: z.string().optional(),
@@ -144,18 +145,20 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
144
145
  dmPolicy: DmPolicySchema.optional().default("pairing"),
145
146
  allowFrom: AllowFromListSchema,
146
147
  textChunkLimit: z.number().int().positive().optional()
147
- }).strict(), {
148
- optionalAccount: true,
149
- refine: (value, ctx) => {
150
- requireChannelOpenAllowFrom({
151
- channel: "sms",
152
- policy: value.dmPolicy,
153
- allowFrom: value.allowFrom,
154
- ctx,
155
- requireOpenAllowFrom
156
- });
157
- }
158
- }), { uiHints: {
148
+ }).strict().superRefine((value, ctx) => {
149
+ requireChannelOpenAllowFrom({
150
+ channel: "sms",
151
+ policy: value.dmPolicy,
152
+ allowFrom: value.allowFrom,
153
+ ctx,
154
+ requireOpenAllowFrom
155
+ });
156
+ });
157
+ const SmsConfigSchema = SmsAccountConfigSchema.extend({
158
+ accounts: z.record(z.string(), SmsAccountConfigSchema.optional()).optional(),
159
+ defaultAccount: z.string().optional()
160
+ });
161
+ const SmsChannelConfigSchema = buildChannelConfigSchema(SmsConfigSchema, { uiHints: {
159
162
  "": {
160
163
  label: "SMS",
161
164
  help: "Twilio SMS channel configuration for inbound webhooks and outbound text replies."
@@ -170,8 +173,7 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
170
173
  },
171
174
  fromNumber: {
172
175
  label: "SMS From Number",
173
- help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567.",
174
- presentation: "phone-number"
176
+ help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567."
175
177
  },
176
178
  messagingServiceSid: {
177
179
  label: "Twilio Messaging Service SID",
@@ -179,8 +181,7 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
179
181
  },
180
182
  defaultTo: {
181
183
  label: "SMS Default To Number",
182
- help: "Optional default outbound phone number used when a send flow omits an explicit SMS target.",
183
- presentation: "phone-number"
184
+ help: "Optional default outbound phone number used when a send flow omits an explicit SMS target."
184
185
  },
185
186
  publicWebhookUrl: {
186
187
  label: "SMS Public Webhook URL",
@@ -196,12 +197,8 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
196
197
  },
197
198
  allowFrom: {
198
199
  label: "SMS Allow From",
199
- help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open.",
200
- presentation: "phone-number"
200
+ help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open."
201
201
  },
202
- "accounts.*.fromNumber": { presentation: "phone-number" },
203
- "accounts.*.defaultTo": { presentation: "phone-number" },
204
- "accounts.*.allowFrom.*": { presentation: "phone-number" },
205
202
  textChunkLimit: {
206
203
  label: "SMS Text Chunk Limit",
207
204
  help: "Maximum characters per outbound SMS chunk before OpenClaw splits long replies."
@@ -214,12 +211,11 @@ const TWILIO_MESSAGING_URL = "https://messaging.twilio.com/v1";
214
211
  const TWILIO_API_HOSTNAME = "api.twilio.com";
215
212
  const TWILIO_MESSAGING_HOSTNAME = "messaging.twilio.com";
216
213
  const TWILIO_API_TIMEOUT_MS = 3e4;
217
- const TWILIO_API_SUCCESS_BODY_LIMIT_BYTES = 1 * 1024 * 1024;
218
- const TWILIO_API_ERROR_BODY_LIMIT_BYTES = 8 * 1024;
214
+ const TWILIO_API_SUCCESS_BODY_LIMIT_BYTES = 1048576;
215
+ const TWILIO_API_ERROR_BODY_LIMIT_BYTES = 8192;
219
216
  const TRUNCATED_RESPONSE_SUFFIX = "... [truncated]";
220
- const WEBHOOK_BODY_LIMIT_BYTES = 32 * 1024;
217
+ const WEBHOOK_BODY_LIMIT_BYTES = 32768;
221
218
  const WEBHOOK_BODY_TIMEOUT_MS = 5e3;
222
- const TWILIO_CHANNEL_ADDRESS_RE = /^([a-z][a-z0-9-]*):(.*)$/i;
223
219
  function firstString(value) {
224
220
  if (Array.isArray(value)) return firstString(value[0]);
225
221
  return typeof value === "string" ? value : "";
@@ -269,16 +265,17 @@ function requestSearch(req) {
269
265
  return "";
270
266
  }
271
267
  }
272
- function stripUrlFragment(url) {
268
+ function configuredUrlHasQuery(url) {
273
269
  const hashIndex = url.indexOf("#");
274
- return hashIndex === -1 ? url : url.slice(0, hashIndex);
270
+ return (hashIndex === -1 ? url : url.slice(0, hashIndex)).includes("?");
275
271
  }
276
272
  function resolveTwilioWebhookSignatureUrl(params) {
277
- const signatureBaseUrl = stripUrlFragment(params.publicWebhookUrl);
278
- if (signatureBaseUrl.includes("?")) return signatureBaseUrl;
273
+ if (configuredUrlHasQuery(params.publicWebhookUrl)) return params.publicWebhookUrl;
279
274
  const search = requestSearch(params.req);
280
- if (!search) return signatureBaseUrl;
281
- return `${signatureBaseUrl}${search}`;
275
+ if (!search) return params.publicWebhookUrl;
276
+ const hashIndex = params.publicWebhookUrl.indexOf("#");
277
+ if (hashIndex === -1) return `${params.publicWebhookUrl}${search}`;
278
+ return `${params.publicWebhookUrl.slice(0, hashIndex)}${search}${params.publicWebhookUrl.slice(hashIndex)}`;
282
279
  }
283
280
  var TwilioSmsApiError = class extends Error {
284
281
  constructor(httpStatus, responseText, operation = "send") {
@@ -301,33 +298,25 @@ function computeTwilioSignature(params) {
301
298
  const data = params.url + Object.keys(params.form).toSorted().map((key) => `${key}${params.form[key] ?? ""}`).join("");
302
299
  return createHmac("sha1", params.authToken).update(data).digest("base64");
303
300
  }
301
+ function safeEqual(a, b) {
302
+ const left = Buffer.from(a);
303
+ const right = Buffer.from(b);
304
+ return left.length === right.length && timingSafeEqual(left, right);
305
+ }
304
306
  function verifyTwilioSignature(params) {
305
307
  if (!params.signature || !params.url || !params.authToken) return false;
306
- return safeEqualSecret(params.signature, computeTwilioSignature({
308
+ return safeEqual(params.signature, computeTwilioSignature({
307
309
  url: params.url,
308
310
  authToken: params.authToken,
309
311
  form: params.form
310
312
  }));
311
313
  }
312
- function parseTwilioInboundFrom(raw) {
313
- const trimmed = raw.trim();
314
- if (!trimmed) return null;
315
- const channelAddress = trimmed.match(TWILIO_CHANNEL_ADDRESS_RE);
316
- const kind = channelAddress?.[1]?.toLowerCase();
317
- if (kind && kind !== "rcs") return null;
318
- const phoneNumber = normalizeSmsPhoneNumber(channelAddress?.[2] ?? trimmed);
319
- if (!looksLikeSmsPhoneNumber(phoneNumber)) return null;
320
- return phoneNumber;
321
- }
322
- function resolveTwilioInboundSender(form) {
323
- return parseTwilioInboundFrom(firstTrimmedString(form.From)) ?? "";
324
- }
325
314
  function buildTwilioInboundMessage(form) {
326
- const from = resolveTwilioInboundSender(form);
315
+ const from = firstTrimmedString(form.From);
327
316
  const to = firstTrimmedString(form.To);
328
317
  const body = firstString(form.Body);
329
318
  const accountSid = firstTrimmedString(form.AccountSid);
330
- const messageSid = resolveTwilioMessageSid(form);
319
+ const messageSid = firstTrimmedString(form.MessageSid) || firstTrimmedString(form.SmsSid) || firstTrimmedString(form.SmsMessageSid);
331
320
  if (!from || !to || !body || !messageSid) return null;
332
321
  return {
333
322
  accountSid,
@@ -337,9 +326,6 @@ function buildTwilioInboundMessage(form) {
337
326
  messageSid
338
327
  };
339
328
  }
340
- function resolveTwilioMessageSid(form) {
341
- return firstTrimmedString(form.MessageSid) || firstTrimmedString(form.SmsSid) || firstTrimmedString(form.SmsMessageSid);
342
- }
343
329
  async function readTwilioWebhookForm(req) {
344
330
  return parseTwilioFormBody(await readRequestBodyWithLimit(req, {
345
331
  maxBytes: WEBHOOK_BODY_LIMIT_BYTES,
@@ -370,13 +356,37 @@ function appendTruncatedResponseSuffix(text) {
370
356
  return `${text.trimEnd()}${TRUNCATED_RESPONSE_SUFFIX}`;
371
357
  }
372
358
  async function readTwilioApiResponseText(response) {
359
+ if (!response.body) return "";
373
360
  const maxBytes = response.ok ? TWILIO_API_SUCCESS_BODY_LIMIT_BYTES : TWILIO_API_ERROR_BODY_LIMIT_BYTES;
374
- if (!response.ok) {
375
- const prefix = await readResponseTextPrefix(response, maxBytes);
376
- return prefix.truncated ? appendTruncatedResponseSuffix(prefix.text) : prefix.text;
361
+ const truncateOnLimit = !response.ok;
362
+ const reader = response.body.getReader();
363
+ const decoder = new TextDecoder();
364
+ let totalBytes = 0;
365
+ let text = "";
366
+ try {
367
+ while (true) {
368
+ const { done, value } = await reader.read();
369
+ if (done) return text + decoder.decode();
370
+ if (!value?.byteLength) continue;
371
+ const remainingBytes = maxBytes - totalBytes;
372
+ if (value.byteLength > remainingBytes) {
373
+ const clipped = remainingBytes > 0 ? value.slice(0, remainingBytes) : void 0;
374
+ if (truncateOnLimit) {
375
+ if (clipped) text += decoder.decode(clipped, { stream: true });
376
+ await reader.cancel().catch(() => void 0);
377
+ return appendTruncatedResponseSuffix(text + decoder.decode());
378
+ }
379
+ await reader.cancel().catch(() => void 0);
380
+ throw new Error(`Twilio SMS API response body too large: ${totalBytes + value.byteLength} bytes (limit: ${maxBytes} bytes)`);
381
+ }
382
+ text += decoder.decode(value, { stream: true });
383
+ totalBytes += value.byteLength;
384
+ }
385
+ } finally {
386
+ try {
387
+ reader.releaseLock();
388
+ } catch {}
377
389
  }
378
- const body = await readResponseWithLimit(response, maxBytes, { onOverflow: ({ size, maxBytes: limit }) => /* @__PURE__ */ new Error(`Twilio SMS API response body too large: ${size} bytes (limit: ${limit} bytes)`) });
379
- return new TextDecoder().decode(body);
380
390
  }
381
391
  function normalizeRequestHeaders(headers) {
382
392
  if (!headers) return {};
@@ -540,31 +550,18 @@ async function sendSmsViaTwilio(params) {
540
550
  }
541
551
  //#endregion
542
552
  //#region extensions/sms/src/send.ts
543
- const SMS_ASSISTANT_TRANSCRIPT_ROLE_PREFIX = "[assistant-authored transcript] ";
544
553
  function toSmsPlainText(text) {
545
- return stripMarkdown(sanitizeAssistantVisibleText(text), {
546
- assistantTranscriptRoleHeaders: true,
547
- assistantTranscriptRolePrefix: SMS_ASSISTANT_TRANSCRIPT_ROLE_PREFIX,
548
- linkStyle: "label-and-url"
549
- }).replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
550
- }
551
- function chunkSmsPlainText(text, limit) {
552
- return renderMarkdownIRChunksWithinLimit({
553
- ir: {
554
- text,
555
- styles: [],
556
- links: []
557
- },
558
- limit,
559
- assistantTranscriptRoleMessageBoundaries: true,
560
- renderChunk: (chunk) => chunk.annotations?.some((annotation) => annotation.type === "assistant_transcript_role") ? `${SMS_ASSISTANT_TRANSCRIPT_ROLE_PREFIX}${chunk.text}` : chunk.text,
561
- measureRendered: (rendered) => rendered.length
562
- }).map(({ rendered }) => rendered).filter(Boolean);
554
+ const withReadableLinks = sanitizeAssistantVisibleText(text).replace(/```[^\n]*\n?([\s\S]*?)```/g, (_match, body) => body.trim()).replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, (_match, label, url) => {
555
+ const cleanLabel = label.trim();
556
+ const cleanUrl = url.trim();
557
+ return cleanLabel && cleanLabel !== cleanUrl ? `${cleanLabel} (${cleanUrl})` : cleanUrl;
558
+ });
559
+ return stripMarkdown(withReadableLinks).replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
563
560
  }
564
561
  async function sendSmsTextChunks(params) {
565
562
  const text = toSmsPlainText(params.text);
566
563
  if (!text) throw new Error("SMS send requires non-empty text.");
567
- const chunks = chunkSmsPlainText(text, params.account.textChunkLimit);
564
+ const chunks = chunkTextForOutbound(text, params.account.textChunkLimit).filter(Boolean);
568
565
  const sendChunks = chunks.length ? chunks : [text];
569
566
  const results = [];
570
567
  for (const textLocal of sendChunks) results.push(await sendSmsViaTwilio({
@@ -578,7 +575,6 @@ async function sendSmsTextChunks(params) {
578
575
  //#region extensions/sms/src/inbound.ts
579
576
  const CHANNEL_ID$2 = "sms";
580
577
  async function authorizeSmsSender(params) {
581
- const commandRequested = params.channelRuntime.commands.shouldComputeCommandAuthorized(params.rawBody, params.cfg);
582
578
  return await resolveStableChannelMessageIngress({
583
579
  channelId: CHANNEL_ID$2,
584
580
  accountId: params.account.accountId,
@@ -598,11 +594,7 @@ async function authorizeSmsSender(params) {
598
594
  },
599
595
  event: { mayPair: true },
600
596
  dmPolicy: params.account.dmPolicy,
601
- allowFrom: params.account.allowFrom,
602
- command: commandRequested ? {
603
- cfg: params.cfg,
604
- modeWhenAccessGroupsOff: "configured"
605
- } : void 0
597
+ allowFrom: params.account.allowFrom
606
598
  });
607
599
  }
608
600
  async function issueSmsPairingChallenge(params) {
@@ -638,8 +630,7 @@ async function dispatchSmsInboundEvent(params) {
638
630
  cfg: params.cfg,
639
631
  account: params.account,
640
632
  channelRuntime: params.channelRuntime,
641
- from,
642
- rawBody: params.msg.body
633
+ from
643
634
  });
644
635
  if (!auth.senderAccess.allowed) {
645
636
  if (auth.senderAccess.decision === "pairing") {
@@ -664,18 +655,14 @@ async function dispatchSmsInboundEvent(params) {
664
655
  }
665
656
  });
666
657
  const sessionKey = route.sessionKey;
667
- const commandRequested = auth.commandAccess.requested;
668
- const commandAuthorized = auth.commandAccess.authorized;
669
- const isTextCommand = params.channelRuntime.commands.isControlCommandMessage(params.msg.body, params.cfg);
670
658
  await params.channelRuntime.inbound.run({
671
659
  channel: CHANNEL_ID$2,
672
660
  accountId: params.account.accountId,
673
661
  raw: params.msg,
674
- ...params.turnAdoptionLifecycle ? { turnAdoptionLifecycle: params.turnAdoptionLifecycle } : {},
675
662
  adapter: {
676
663
  ingest: (msg) => ({
677
664
  id: msg.messageSid,
678
- timestamp: params.receivedAt,
665
+ timestamp: Date.now(),
679
666
  rawText: msg.body,
680
667
  textForAgent: msg.body,
681
668
  textForCommands: msg.body,
@@ -708,27 +695,22 @@ async function dispatchSmsInboundEvent(params) {
708
695
  commandBody: input.textForCommands,
709
696
  bodyForAgent: input.textForAgent
710
697
  },
711
- access: commandRequested ? { commands: { authorized: commandAuthorized } } : void 0,
712
- command: isTextCommand ? {
713
- kind: "text-slash",
714
- body: input.textForCommands,
715
- authorized: commandAuthorized
716
- } : void 0,
717
698
  extra: {
718
699
  MessageSid: params.msg.messageSid,
719
- SenderE164: from,
720
700
  To: params.msg.to
721
701
  }
722
702
  });
703
+ const storePath = params.channelRuntime.session.resolveStorePath(params.cfg.session?.store, { agentId: route.agentId });
723
704
  return {
724
705
  cfg: params.cfg,
725
706
  channel: CHANNEL_ID$2,
726
707
  accountId: params.account.accountId,
727
- route: {
728
- agentId: route.agentId,
729
- sessionKey
730
- },
708
+ agentId: route.agentId,
709
+ routeSessionKey: sessionKey,
710
+ storePath,
731
711
  ctxPayload,
712
+ recordInboundSession: params.channelRuntime.session.recordInboundSession,
713
+ dispatchReplyWithBufferedBlockDispatcher: params.channelRuntime.reply.dispatchReplyWithBufferedBlockDispatcher,
732
714
  delivery: {
733
715
  durable: () => ({ to: from }),
734
716
  deliver: async (payload) => {
@@ -751,132 +733,31 @@ async function dispatchSmsInboundEvent(params) {
751
733
  });
752
734
  }
753
735
  //#endregion
754
- //#region extensions/sms/src/ingress-spool.ts
755
- const SMS_INGRESS_PAYLOAD_VERSION = 1;
756
- const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
757
- var SmsIngressPermanentError = class extends Error {};
758
- function parseSmsIngressForm(form, account) {
759
- const message = buildTwilioInboundMessage(form);
760
- if (!message) throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
761
- if (message.accountSid && message.accountSid !== account.accountSid) throw new SmsIngressPermanentError("SMS ingress payload has an invalid Twilio account.");
762
- return message;
763
- }
764
- function createSmsIngressSpool(params) {
765
- const queue = params.queue ?? getSmsRuntime().state.openChannelIngressQueue({ accountId: params.account.accountId });
766
- const deliver = params.deliver ?? (async (message, lifecycle, receivedAt) => {
767
- await dispatchSmsInboundEvent({
768
- cfg: params.cfg,
769
- account: params.account,
770
- channelRuntime: params.channelRuntime,
771
- msg: message,
772
- receivedAt,
773
- turnAdoptionLifecycle: lifecycle,
774
- log: params.log
775
- });
776
- });
777
- const monitor = createChannelIngressMonitor({
778
- queue,
779
- inspect: (form, context) => {
780
- const eventId = resolveTwilioMessageSid(form);
781
- if (!eventId) {
782
- if (context.phase === "claim") throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
783
- throw new Error("SMS webhook is missing MessageSid.");
784
- }
785
- const sender = resolveTwilioInboundSender(form);
786
- return {
787
- eventId,
788
- laneKey: sender ? `sender:${sender}` : `event:${eventId}`
789
- };
790
- },
791
- payload: {
792
- version: SMS_INGRESS_PAYLOAD_VERSION,
793
- serialize: (form) => form,
794
- deserialize: (form) => form,
795
- encode: ({ body }) => ({
796
- version: SMS_INGRESS_PAYLOAD_VERSION,
797
- form: body
798
- }),
799
- decode: (payload) => ({
800
- version: payload.version,
801
- body: payload.form
802
- }),
803
- createClaimError: (kind) => new SmsIngressPermanentError(kind === "invalid-version" ? "SMS ingress payload version is invalid." : "SMS ingress identity changed after durable admission.")
804
- },
805
- deliver: (_form, lifecycle, event) => deliver(parseSmsIngressForm(event.payload.form, params.account), bindIngressLifecycleToReplyOptions(lifecycle).turnAdoptionLifecycle, event.receivedAt),
806
- pollIntervalMs: SMS_INGRESS_DRAIN_INTERVAL_MS,
807
- retention: {
808
- pruneIntervalMs: 0,
809
- completedTtlMs: 1440 * 60 * 1e3,
810
- failedMaxEntries: 1e3
811
- },
812
- appendRetryDelaysMs: [0],
813
- waitForDeliveryIdleBeforeRepump: false,
814
- waitForDeliveryIdleOnStop: false,
815
- runPumpTask: runDetachedWebhookWork,
816
- admissionMode: "durable-after-stop",
817
- drain: {
818
- onLog: (message) => params.log?.warn?.(message),
819
- resolveNonRetryableFailure: (error) => error instanceof SmsIngressPermanentError ? {
820
- reason: "invalid-payload",
821
- message: error.message
822
- } : null
823
- },
824
- ...params.abortSignal ? { abortSignal: params.abortSignal } : {},
825
- createStoppedError: () => /* @__PURE__ */ new Error("SMS ingress stopped."),
826
- onError: (error) => params.log?.error?.(`SMS ingress drain failed: ${error instanceof Error ? error.message : String(error)}`)
827
- });
828
- return {
829
- enqueue: async (form) => {
830
- const admitted = await monitor.admit(form);
831
- if (admitted.kind === "ignored") throw new Error("SMS webhook admission was unexpectedly ignored.");
832
- return {
833
- kind: admitted.queueResult.kind,
834
- duplicate: admitted.queueResult.duplicate
835
- };
836
- },
837
- start: monitor.start,
838
- pause: monitor.pause,
839
- waitForIdle: monitor.waitForIdle,
840
- stop: monitor.stop
841
- };
842
- }
843
- //#endregion
844
736
  //#region extensions/sms/src/webhook.ts
845
- const INVALID_REQUEST_MAX_REQUESTS = 300;
846
- const CALLBACK_DISPATCH_MAX_REQUESTS = 30;
847
- const SMS_WEBHOOK_ACCEPTED_HEADER = "x-openclaw-delivery-accepted";
848
- const SMS_WEBHOOK_ACCEPTED_VALUE = "durable";
849
- const invalidRequestRateLimiter = createFixedWindowRateLimiter({
850
- maxRequests: INVALID_REQUEST_MAX_REQUESTS,
737
+ const rateLimiter = createFixedWindowRateLimiter({
738
+ maxRequests: 30,
851
739
  windowMs: 6e4,
852
740
  maxTrackedKeys: 5e3
853
741
  });
854
- const callbackDispatchRateLimiter = createFixedWindowRateLimiter({
855
- maxRequests: CALLBACK_DISPATCH_MAX_REQUESTS,
856
- windowMs: 6e4,
857
- maxTrackedKeys: 5e3
858
- });
859
- const validatedAggregateRateLimiter = createFixedWindowRateLimiter({
860
- maxRequests: 300,
861
- windowMs: 6e4,
862
- maxTrackedKeys: 1e3
863
- });
742
+ const REPLAY_CACHE_TTL_MS = 6e5;
743
+ const REPLAY_CACHE_MAX_KEYS = 1e4;
744
+ const replayCache = /* @__PURE__ */ new Map();
864
745
  function headerValue(value) {
865
746
  if (Array.isArray(value)) return value[0];
866
747
  return value;
867
748
  }
868
- function resolvedClientAddress(params) {
869
- return resolveRequestClientIp(params.req, params.cfg.gateway?.trustedProxies, params.cfg.gateway?.allowRealIpFallback === true) ?? params.req.socket?.remoteAddress ?? "unknown";
749
+ function rateLimitKey(req) {
750
+ return req.socket?.remoteAddress ?? "unknown";
870
751
  }
871
- function rateLimitKey(params) {
872
- return `${params.account.accountId}:${params.account.webhookPath}:${params.subject}`;
873
- }
874
- function accountRouteRateLimitKey(account) {
875
- return `${account.accountId}:${account.webhookPath}`;
876
- }
877
- function rejectInvalidRequestRateLimit(params) {
878
- params.log?.warn?.(`SMS webhook invalid-request rate limit exceeded for ${params.key}`);
879
- respondTwiml(params.res, 429, "Rate limit exceeded");
752
+ function rememberWebhookMessage(params) {
753
+ const now = params.now ?? Date.now();
754
+ for (const [key, expiresAt] of replayCache) {
755
+ if (expiresAt > now && replayCache.size <= REPLAY_CACHE_MAX_KEYS) break;
756
+ replayCache.delete(key);
757
+ }
758
+ const key = `${params.accountId}:${params.messageSid}`;
759
+ if ((replayCache.get(key) ?? 0) > now) return false;
760
+ replayCache.set(key, now + REPLAY_CACHE_TTL_MS);
880
761
  return true;
881
762
  }
882
763
  function createSmsWebhookHandler(params) {
@@ -885,24 +766,16 @@ function createSmsWebhookHandler(params) {
885
766
  respondTwiml(res, 405, "Method not allowed");
886
767
  return true;
887
768
  }
888
- const clientAddress = resolvedClientAddress({
889
- cfg: params.cfg,
890
- req
891
- });
892
- const clientAddressKey = rateLimitKey({
893
- account: params.account,
894
- subject: clientAddress
895
- });
896
- const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(clientAddressKey);
769
+ const key = rateLimitKey(req);
770
+ if (rateLimiter.isRateLimited(key)) {
771
+ params.log?.warn?.(`SMS webhook rate limit exceeded for ${key}`);
772
+ respondTwiml(res, 429, "Rate limit exceeded");
773
+ return true;
774
+ }
897
775
  let form;
898
776
  try {
899
777
  form = await readTwilioWebhookForm(req);
900
778
  } catch {
901
- if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
902
- key: clientAddressKey,
903
- log: params.log,
904
- res
905
- });
906
779
  respondTwiml(res, 400, "Invalid request body");
907
780
  return true;
908
781
  }
@@ -916,45 +789,38 @@ function createSmsWebhookHandler(params) {
916
789
  authToken: params.account.authToken,
917
790
  form
918
791
  })) {
919
- if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
920
- key: clientAddressKey,
921
- log: params.log,
922
- res
923
- });
924
792
  params.log?.warn?.("SMS webhook rejected invalid Twilio signature");
925
793
  respondTwiml(res, 403, "Invalid signature");
926
794
  return true;
927
795
  }
928
796
  }
929
- if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
930
- key: clientAddressKey,
931
- log: params.log,
932
- res
933
- });
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");
940
- respondTwiml(res, 429, "Rate limit exceeded");
797
+ const msg = buildTwilioInboundMessage(form);
798
+ if (!msg) {
799
+ respondTwiml(res, 400, "Missing SMS payload");
941
800
  return true;
942
801
  }
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
- }
802
+ if (msg.accountSid && msg.accountSid !== params.account.accountSid) {
803
+ params.log?.warn?.("SMS webhook rejected mismatched Twilio AccountSid");
804
+ respondTwiml(res, 403, "Invalid account");
805
+ return true;
950
806
  }
951
- const messageSid = resolveTwilioMessageSid(form);
952
- if (!messageSid) {
953
- respondTwiml(res, 400, "Missing MessageSid");
807
+ if (!rememberWebhookMessage({
808
+ accountId: params.account.accountId,
809
+ messageSid: msg.messageSid
810
+ })) {
811
+ params.log?.warn?.(`SMS webhook ignored replayed message ${msg.messageSid}`);
812
+ respondTwiml(res, 200);
954
813
  return true;
955
814
  }
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);
815
+ dispatchSmsInboundEvent({
816
+ cfg: params.cfg,
817
+ account: params.account,
818
+ msg,
819
+ channelRuntime: params.channelRuntime,
820
+ log: params.log
821
+ }).catch((err) => {
822
+ params.log?.error?.(`SMS webhook dispatch failed: ${err instanceof Error ? err.message : String(err)}`);
823
+ });
958
824
  respondTwiml(res, 200);
959
825
  return true;
960
826
  };
@@ -962,34 +828,15 @@ function createSmsWebhookHandler(params) {
962
828
  //#endregion
963
829
  //#region extensions/sms/src/gateway.ts
964
830
  const CHANNEL_ID$1 = "sms";
831
+ const activeRoutes = /* @__PURE__ */ new Map();
965
832
  const activeRoutePaths = /* @__PURE__ */ new Map();
966
- const pendingRouteStops = /* @__PURE__ */ new Map();
833
+ function routeKey(account) {
834
+ return `${account.accountId}:${normalizeWebhookPath(account.webhookPath)}`;
835
+ }
967
836
  function normalizeWebhookPath(path) {
968
837
  const trimmed = path.trim();
969
838
  return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
970
839
  }
971
- function stopSmsWebhookRoute(webhookPath, route) {
972
- if (route.stopTask) return route.stopTask;
973
- const pauseTask = route.ingress.pause();
974
- route.unregisterRoute();
975
- if (activeRoutePaths.get(webhookPath) === route) activeRoutePaths.delete(webhookPath);
976
- const previousStop = pendingRouteStops.get(webhookPath) ?? Promise.resolve();
977
- const stopTask = Promise.all([
978
- previousStop,
979
- route.ready,
980
- pauseTask
981
- ]).then(() => route.ingress.stop(), async (error) => {
982
- await Promise.allSettled([route.ingress.stop()]);
983
- throw error;
984
- });
985
- route.stopTask = stopTask;
986
- pendingRouteStops.set(webhookPath, stopTask);
987
- const clear = () => {
988
- if (pendingRouteStops.get(webhookPath) === stopTask) pendingRouteStops.delete(webhookPath);
989
- };
990
- stopTask.then(clear, clear);
991
- return stopTask;
992
- }
993
840
  function collectSmsStartupWarnings(account) {
994
841
  const warnings = [];
995
842
  if (!account.accountSid || !account.authToken || !account.fromNumber && !account.messagingServiceSid) warnings.push("- SMS: accountSid, authToken, and fromNumber or messagingServiceSid are required.");
@@ -998,57 +845,27 @@ function collectSmsStartupWarnings(account) {
998
845
  if (account.dmPolicy === "open" && !account.allowFrom.includes("*")) warnings.push("- SMS: dmPolicy=open should set allowFrom=[\"*\"] or explicit sender numbers.");
999
846
  return warnings;
1000
847
  }
1001
- async function registerSmsWebhookRoute(params) {
848
+ function registerSmsWebhookRoute(params) {
849
+ const key = routeKey(params.account);
1002
850
  const webhookPath = normalizeWebhookPath(params.account.webhookPath);
1003
- const currentRoute = activeRoutePaths.get(webhookPath);
1004
- if (currentRoute && currentRoute.accountId !== params.account.accountId) throw new Error(`SMS webhook path ${webhookPath} is already registered by account ${currentRoute.accountId}; configure a distinct webhookPath for account ${params.account.accountId}.`);
1005
- const predecessorStop = currentRoute ? stopSmsWebhookRoute(webhookPath, currentRoute) : pendingRouteStops.get(webhookPath) ?? Promise.resolve();
1006
- const ingress = createSmsIngressSpool({
1007
- cfg: params.cfg,
1008
- account: params.account,
1009
- channelRuntime: params.channelRuntime,
1010
- ...params.log ? { log: params.log } : {}
1011
- });
1012
- let unregisterRoute;
1013
- try {
1014
- unregisterRoute = registerPluginHttpRoute({
1015
- path: webhookPath,
1016
- auth: "plugin",
1017
- pluginId: CHANNEL_ID$1,
1018
- accountId: params.account.accountId,
1019
- log: (msg) => params.log?.info?.(msg),
1020
- handler: createSmsWebhookHandler({
1021
- ...params,
1022
- ingress
1023
- })
1024
- });
1025
- } catch (error) {
1026
- await Promise.allSettled([predecessorStop, ingress.stop()]);
1027
- throw error;
1028
- }
1029
- const route = {
851
+ const currentPathOwner = activeRoutePaths.get(webhookPath);
852
+ if (currentPathOwner && currentPathOwner !== params.account.accountId) throw new Error(`SMS webhook path ${webhookPath} is already registered by account ${currentPathOwner}; configure a distinct webhookPath for account ${params.account.accountId}.`);
853
+ activeRoutes.get(key)?.();
854
+ activeRoutePaths.delete(webhookPath);
855
+ const unregister = registerPluginHttpRoute({
856
+ path: webhookPath,
857
+ auth: "plugin",
858
+ pluginId: CHANNEL_ID$1,
1030
859
  accountId: params.account.accountId,
1031
- ingress,
1032
- unregisterRoute,
1033
- ready: Promise.resolve()
1034
- };
1035
- activeRoutePaths.set(webhookPath, route);
1036
- route.ready = predecessorStop.then(() => {
1037
- if (activeRoutePaths.get(webhookPath) === route && !route.stopTask) ingress.start();
860
+ log: (msg) => params.log?.info?.(msg),
861
+ handler: createSmsWebhookHandler(params)
1038
862
  });
1039
- const unregister = () => stopSmsWebhookRoute(webhookPath, route);
1040
- const readinessAbort = new AbortController();
1041
- const lifecycle = waitUntilAbort(AbortSignal.any([params.abortSignal, readinessAbort.signal]), unregister);
1042
- try {
1043
- await route.ready;
1044
- } catch (error) {
1045
- readinessAbort.abort();
1046
- await Promise.allSettled([lifecycle]);
1047
- throw error;
1048
- }
1049
- return {
1050
- lifecycle,
1051
- isActive: () => activeRoutePaths.get(webhookPath) === route
863
+ activeRoutes.set(key, unregister);
864
+ activeRoutePaths.set(webhookPath, params.account.accountId);
865
+ return () => {
866
+ unregister();
867
+ activeRoutes.delete(key);
868
+ if (activeRoutePaths.get(webhookPath) === params.account.accountId) activeRoutePaths.delete(webhookPath);
1052
869
  };
1053
870
  }
1054
871
  async function startSmsGatewayAccount(params) {
@@ -1062,9 +879,9 @@ async function startSmsGatewayAccount(params) {
1062
879
  return waitUntilAbort(params.abortSignal);
1063
880
  }
1064
881
  for (const warning of warnings) params.log?.warn?.(warning);
1065
- const registration = await registerSmsWebhookRoute(params);
1066
- if (registration.isActive()) params.log?.info?.(`Registered SMS webhook route ${params.account.webhookPath} for account ${params.account.accountId}`);
1067
- return registration.lifecycle;
882
+ const unregister = registerSmsWebhookRoute(params);
883
+ params.log?.info?.(`Registered SMS webhook route ${params.account.webhookPath} for account ${params.account.accountId}`);
884
+ return waitUntilAbort(params.abortSignal, unregister);
1068
885
  }
1069
886
  //#endregion
1070
887
  //#region extensions/sms/src/status.ts
@@ -1321,82 +1138,6 @@ function applySmsAccountConfig(params) {
1321
1138
  channels
1322
1139
  };
1323
1140
  }
1324
- const smsSetupContract = defineChannelSetupContract({
1325
- fields: {
1326
- accountSid: {
1327
- kind: "string",
1328
- sensitive: true,
1329
- cli: {
1330
- flags: "--account-sid <sid>",
1331
- description: "Twilio account SID"
1332
- }
1333
- },
1334
- authToken: {
1335
- kind: "string",
1336
- sensitive: true,
1337
- cli: {
1338
- flags: "--auth-token <token>",
1339
- description: "Twilio auth token"
1340
- }
1341
- },
1342
- fromNumber: {
1343
- kind: "string",
1344
- cli: {
1345
- flags: "--from-number <e164>",
1346
- description: "Twilio sender phone number"
1347
- }
1348
- },
1349
- messagingServiceSid: {
1350
- kind: "string",
1351
- cli: {
1352
- flags: "--messaging-service-sid <sid>",
1353
- description: "Twilio Messaging Service SID"
1354
- }
1355
- },
1356
- defaultTo: {
1357
- kind: "string",
1358
- cli: {
1359
- flags: "--default-to <e164>",
1360
- description: "Default SMS recipient"
1361
- }
1362
- },
1363
- webhookPath: {
1364
- kind: "string",
1365
- cli: {
1366
- flags: "--webhook-path <path>",
1367
- description: "SMS webhook path"
1368
- }
1369
- },
1370
- publicWebhookUrl: {
1371
- kind: "string",
1372
- cli: {
1373
- flags: "--public-webhook-url <url>",
1374
- description: "Public SMS webhook URL"
1375
- }
1376
- },
1377
- dmPolicy: {
1378
- kind: "choice",
1379
- choices: [
1380
- "pairing",
1381
- "allowlist",
1382
- "open",
1383
- "disabled"
1384
- ],
1385
- cli: {
1386
- flags: "--dm-policy <policy>",
1387
- description: "SMS DM policy"
1388
- }
1389
- },
1390
- allowFrom: {
1391
- kind: "string-list",
1392
- cli: {
1393
- flags: "--allow-from <numbers>",
1394
- description: "Allowed SMS senders"
1395
- }
1396
- }
1397
- },
1398
- adapter: { applyAccountConfig: applySmsAccountConfig }
1399
- });
1400
1141
  function createSmsReceipt(params) {
1401
1142
  const first = params.results[0];
1402
1143
  if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
@@ -1490,12 +1231,7 @@ const smsPlugin = createChatChannelPlugin({
1490
1231
  },
1491
1232
  reload: { configPrefixes: [`channels.${CHANNEL_ID}`] },
1492
1233
  configSchema: SmsChannelConfigSchema,
1493
- setup: { applyAccountConfig: ({ cfg, accountId, input }) => applySmsAccountConfig({
1494
- cfg,
1495
- accountId,
1496
- input
1497
- }) },
1498
- setupContract: smsSetupContract,
1234
+ setup: { applyAccountConfig: applySmsAccountConfig },
1499
1235
  config: {
1500
1236
  ...smsConfigAdapter,
1501
1237
  inspectAccount: inspectSmsAccount,
@@ -1,2 +1,2 @@
1
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries, t as channelSecrets } from "./secret-contract-Cp0f-YPc.js";
1
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries, t as channelSecrets } from "./.setup/secret-contract-CS-JLPcU.mjs";
2
2
  export { channelSecrets, collectRuntimeConfigAssignments, secretTargetRegistryEntries };
@@ -8,6 +8,18 @@
8
8
  "channels": [
9
9
  "sms"
10
10
  ],
11
+ "channelEnvVars": {
12
+ "sms": [
13
+ "TWILIO_ACCOUNT_SID",
14
+ "TWILIO_AUTH_TOKEN",
15
+ "TWILIO_PHONE_NUMBER",
16
+ "TWILIO_SMS_FROM",
17
+ "TWILIO_MESSAGING_SERVICE_SID",
18
+ "SMS_PUBLIC_WEBHOOK_URL",
19
+ "SMS_WEBHOOK_PATH",
20
+ "SMS_ALLOWED_USERS"
21
+ ]
22
+ },
11
23
  "configSchema": {
12
24
  "type": "object",
13
25
  "additionalProperties": false,
@@ -326,8 +338,7 @@
326
338
  },
327
339
  "fromNumber": {
328
340
  "label": "SMS From Number",
329
- "help": "Twilio SMS-capable phone number in E.164 format, for example +15551234567.",
330
- "presentation": "phone-number"
341
+ "help": "Twilio SMS-capable phone number in E.164 format, for example +15551234567."
331
342
  },
332
343
  "messagingServiceSid": {
333
344
  "label": "Twilio Messaging Service SID",
@@ -335,8 +346,7 @@
335
346
  },
336
347
  "defaultTo": {
337
348
  "label": "SMS Default To Number",
338
- "help": "Optional default outbound phone number used when a send flow omits an explicit SMS target.",
339
- "presentation": "phone-number"
349
+ "help": "Optional default outbound phone number used when a send flow omits an explicit SMS target."
340
350
  },
341
351
  "publicWebhookUrl": {
342
352
  "label": "SMS Public Webhook URL",
@@ -352,17 +362,7 @@
352
362
  },
353
363
  "allowFrom": {
354
364
  "label": "SMS Allow From",
355
- "help": "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open.",
356
- "presentation": "phone-number"
357
- },
358
- "accounts.*.fromNumber": {
359
- "presentation": "phone-number"
360
- },
361
- "accounts.*.defaultTo": {
362
- "presentation": "phone-number"
363
- },
364
- "accounts.*.allowFrom.*": {
365
- "presentation": "phone-number"
365
+ "help": "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open."
366
366
  },
367
367
  "textChunkLimit": {
368
368
  "label": "SMS Text Chunk Limit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/sms",
3
- "version": "2026.7.2-beta.7",
3
+ "version": "2026.7.33",
4
4
  "description": "OpenClaw SMS channel plugin for Twilio text messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,20 +16,6 @@
16
16
  ],
17
17
  "channel": {
18
18
  "id": "sms",
19
- "configuredState": {
20
- "env": {
21
- "anyOf": [
22
- "TWILIO_ACCOUNT_SID",
23
- "TWILIO_AUTH_TOKEN",
24
- "TWILIO_PHONE_NUMBER",
25
- "TWILIO_SMS_FROM",
26
- "TWILIO_MESSAGING_SERVICE_SID",
27
- "SMS_PUBLIC_WEBHOOK_URL",
28
- "SMS_WEBHOOK_PATH",
29
- "SMS_ALLOWED_USERS"
30
- ]
31
- }
32
- },
33
19
  "label": "SMS",
34
20
  "selectionLabel": "SMS (Twilio)",
35
21
  "detailLabel": "Twilio SMS",
@@ -37,97 +23,13 @@
37
23
  "docsLabel": "sms",
38
24
  "blurb": "Twilio-backed SMS with inbound webhooks and outbound replies.",
39
25
  "order": 88,
40
- "quickstartAllowFrom": true,
41
- "setup": {
42
- "fields": [
43
- {
44
- "key": "accountSid",
45
- "kind": "string",
46
- "sensitive": true,
47
- "cli": {
48
- "flags": "--account-sid <sid>",
49
- "description": "Twilio account SID"
50
- }
51
- },
52
- {
53
- "key": "authToken",
54
- "kind": "string",
55
- "sensitive": true,
56
- "cli": {
57
- "flags": "--auth-token <token>",
58
- "description": "Twilio auth token"
59
- }
60
- },
61
- {
62
- "key": "fromNumber",
63
- "kind": "string",
64
- "cli": {
65
- "flags": "--from-number <e164>",
66
- "description": "Twilio sender phone number"
67
- }
68
- },
69
- {
70
- "key": "messagingServiceSid",
71
- "kind": "string",
72
- "cli": {
73
- "flags": "--messaging-service-sid <sid>",
74
- "description": "Twilio Messaging Service SID"
75
- }
76
- },
77
- {
78
- "key": "defaultTo",
79
- "kind": "string",
80
- "cli": {
81
- "flags": "--default-to <e164>",
82
- "description": "Default SMS recipient"
83
- }
84
- },
85
- {
86
- "key": "webhookPath",
87
- "kind": "string",
88
- "cli": {
89
- "flags": "--webhook-path <path>",
90
- "description": "SMS webhook path"
91
- }
92
- },
93
- {
94
- "key": "publicWebhookUrl",
95
- "kind": "string",
96
- "cli": {
97
- "flags": "--public-webhook-url <url>",
98
- "description": "Public SMS webhook URL"
99
- }
100
- },
101
- {
102
- "key": "dmPolicy",
103
- "kind": "choice",
104
- "choices": [
105
- "pairing",
106
- "allowlist",
107
- "open",
108
- "disabled"
109
- ],
110
- "cli": {
111
- "flags": "--dm-policy <policy>",
112
- "description": "SMS DM policy"
113
- }
114
- },
115
- {
116
- "key": "allowFrom",
117
- "kind": "string-list",
118
- "cli": {
119
- "flags": "--allow-from <numbers>",
120
- "description": "Allowed SMS senders"
121
- }
122
- }
123
- ]
124
- }
26
+ "quickstartAllowFrom": true
125
27
  },
126
28
  "compat": {
127
- "pluginApi": ">=2026.7.2-beta.7"
29
+ "pluginApi": ">=2026.7.33"
128
30
  },
129
31
  "build": {
130
- "openclawVersion": "2026.7.2-beta.7",
32
+ "openclawVersion": "2026.7.33",
131
33
  "bundledDist": false
132
34
  },
133
35
  "install": {
@@ -151,7 +53,7 @@
151
53
  "README.md"
152
54
  ],
153
55
  "peerDependencies": {
154
- "openclaw": ">=2026.7.2-beta.7"
56
+ "openclaw": ">=2026.7.33"
155
57
  },
156
58
  "peerDependenciesMeta": {
157
59
  "openclaw": {
@@ -1,8 +0,0 @@
1
- import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
2
- //#region extensions/sms/src/runtime.ts
3
- const { setRuntime: setSmsRuntime, getRuntime: getSmsRuntime } = createPluginRuntimeStore({
4
- pluginId: "sms",
5
- errorMessage: "SMS runtime not initialized - plugin not registered"
6
- });
7
- //#endregion
8
- export { setSmsRuntime as n, getSmsRuntime as t };