@openclaw/sms 2026.7.2-beta.5 → 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,128 +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
- const SMS_COMPLETED_TTL_MS = 1440 * 60 * 1e3;
758
- const SMS_COMPLETED_MAX_ENTRIES = 2e4;
759
- const SMS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
760
- const SMS_FAILED_MAX_ENTRIES = 1e3;
761
- var SmsIngressPermanentError = class extends Error {};
762
- function parseSmsIngressForm(form, account) {
763
- const message = buildTwilioInboundMessage(form);
764
- if (!message) throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
765
- if (message.accountSid && message.accountSid !== account.accountSid) throw new SmsIngressPermanentError("SMS ingress payload has an invalid Twilio account.");
766
- return message;
767
- }
768
- function createSmsIngressSpool(params) {
769
- const queue = params.queue ?? getSmsRuntime().state.openChannelIngressQueue({ accountId: params.account.accountId });
770
- const deliver = params.deliver ?? (async (message, lifecycle, receivedAt) => {
771
- await dispatchSmsInboundEvent({
772
- cfg: params.cfg,
773
- account: params.account,
774
- channelRuntime: params.channelRuntime,
775
- msg: message,
776
- receivedAt,
777
- turnAdoptionLifecycle: lifecycle,
778
- log: params.log
779
- });
780
- });
781
- const monitor = createChannelIngressMonitor({
782
- queue,
783
- inspect: (form, context) => {
784
- const eventId = resolveTwilioMessageSid(form);
785
- if (!eventId) {
786
- if (context.phase === "claim") throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
787
- throw new Error("SMS webhook is missing MessageSid.");
788
- }
789
- const sender = resolveTwilioInboundSender(form);
790
- return {
791
- eventId,
792
- laneKey: sender ? `sender:${sender}` : `event:${eventId}`
793
- };
794
- },
795
- payload: {
796
- version: SMS_INGRESS_PAYLOAD_VERSION,
797
- serialize: (form) => form,
798
- deserialize: (form) => form,
799
- encode: ({ body }) => ({
800
- version: SMS_INGRESS_PAYLOAD_VERSION,
801
- form: body
802
- }),
803
- decode: (payload) => ({
804
- version: payload.version,
805
- body: payload.form
806
- }),
807
- createClaimError: (kind) => new SmsIngressPermanentError(kind === "invalid-version" ? "SMS ingress payload version is invalid." : "SMS ingress identity changed after durable admission.")
808
- },
809
- deliver: (_form, lifecycle, event) => deliver(parseSmsIngressForm(event.payload.form, params.account), bindIngressLifecycleToReplyOptions(lifecycle).turnAdoptionLifecycle, event.receivedAt),
810
- pollIntervalMs: SMS_INGRESS_DRAIN_INTERVAL_MS,
811
- retention: {
812
- pruneIntervalMs: 0,
813
- completedTtlMs: SMS_COMPLETED_TTL_MS,
814
- completedMaxEntries: SMS_COMPLETED_MAX_ENTRIES,
815
- failedTtlMs: SMS_FAILED_TTL_MS,
816
- failedMaxEntries: SMS_FAILED_MAX_ENTRIES
817
- },
818
- appendRetryDelaysMs: [0],
819
- waitForDeliveryIdleBeforeRepump: false,
820
- waitForDeliveryIdleOnStop: false,
821
- runPumpTask: runDetachedWebhookWork,
822
- admissionMode: "durable-after-stop",
823
- drain: {
824
- onLog: (message) => params.log?.warn?.(message),
825
- resolveNonRetryableFailure: (error) => error instanceof SmsIngressPermanentError ? {
826
- reason: "invalid-payload",
827
- message: error.message
828
- } : null
829
- },
830
- ...params.abortSignal ? { abortSignal: params.abortSignal } : {},
831
- createStoppedError: () => /* @__PURE__ */ new Error("SMS ingress stopped."),
832
- onError: (error) => params.log?.error?.(`SMS ingress drain failed: ${error instanceof Error ? error.message : String(error)}`)
833
- });
834
- return {
835
- enqueue: async (form) => {
836
- const admitted = await monitor.admit(form);
837
- if (admitted.kind === "ignored") throw new Error("SMS webhook admission was unexpectedly ignored.");
838
- return {
839
- kind: admitted.queueResult.kind,
840
- duplicate: admitted.queueResult.duplicate
841
- };
842
- },
843
- start: monitor.start,
844
- pause: monitor.pause,
845
- waitForIdle: monitor.waitForIdle,
846
- stop: monitor.stop
847
- };
848
- }
849
- //#endregion
850
736
  //#region extensions/sms/src/webhook.ts
851
- const INVALID_REQUEST_MAX_REQUESTS = 300;
852
- const CALLBACK_DISPATCH_MAX_REQUESTS = 30;
853
- const invalidRequestRateLimiter = createFixedWindowRateLimiter({
854
- maxRequests: INVALID_REQUEST_MAX_REQUESTS,
855
- windowMs: 6e4,
856
- maxTrackedKeys: 5e3
857
- });
858
- const callbackDispatchRateLimiter = createFixedWindowRateLimiter({
859
- maxRequests: CALLBACK_DISPATCH_MAX_REQUESTS,
737
+ const rateLimiter = createFixedWindowRateLimiter({
738
+ maxRequests: 30,
860
739
  windowMs: 6e4,
861
740
  maxTrackedKeys: 5e3
862
741
  });
742
+ const REPLAY_CACHE_TTL_MS = 6e5;
743
+ const REPLAY_CACHE_MAX_KEYS = 1e4;
744
+ const replayCache = /* @__PURE__ */ new Map();
863
745
  function headerValue(value) {
864
746
  if (Array.isArray(value)) return value[0];
865
747
  return value;
866
748
  }
867
- function resolvedClientAddress(params) {
868
- return resolveRequestClientIp(params.req, params.cfg.gateway?.trustedProxies, params.cfg.gateway?.allowRealIpFallback === true) ?? params.req.socket?.remoteAddress ?? "unknown";
869
- }
870
- function rateLimitKey(params) {
871
- return `${params.account.accountId}:${params.account.webhookPath}:${params.clientAddress}`;
749
+ function rateLimitKey(req) {
750
+ return req.socket?.remoteAddress ?? "unknown";
872
751
  }
873
- function rejectInvalidRequestRateLimit(params) {
874
- params.log?.warn?.(`SMS webhook invalid-request rate limit exceeded for ${params.key}`);
875
- 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);
876
761
  return true;
877
762
  }
878
763
  function createSmsWebhookHandler(params) {
@@ -881,24 +766,16 @@ function createSmsWebhookHandler(params) {
881
766
  respondTwiml(res, 405, "Method not allowed");
882
767
  return true;
883
768
  }
884
- const clientAddress = resolvedClientAddress({
885
- cfg: params.cfg,
886
- req
887
- });
888
- const key = rateLimitKey({
889
- account: params.account,
890
- clientAddress
891
- });
892
- const invalidRequestRateLimited = invalidRequestRateLimiter.isRateLimited(key);
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
+ }
893
775
  let form;
894
776
  try {
895
777
  form = await readTwilioWebhookForm(req);
896
778
  } catch {
897
- if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
898
- key,
899
- log: params.log,
900
- res
901
- });
902
779
  respondTwiml(res, 400, "Invalid request body");
903
780
  return true;
904
781
  }
@@ -912,32 +789,38 @@ function createSmsWebhookHandler(params) {
912
789
  authToken: params.account.authToken,
913
790
  form
914
791
  })) {
915
- if (invalidRequestRateLimited) return rejectInvalidRequestRateLimit({
916
- key,
917
- log: params.log,
918
- res
919
- });
920
792
  params.log?.warn?.("SMS webhook rejected invalid Twilio signature");
921
793
  respondTwiml(res, 403, "Invalid signature");
922
794
  return true;
923
795
  }
924
796
  }
925
- if (invalidRequestRateLimited && params.account.dangerouslyDisableSignatureValidation) return rejectInvalidRequestRateLimit({
926
- key,
927
- log: params.log,
928
- res
929
- });
930
- if (callbackDispatchRateLimiter.isRateLimited(key)) {
931
- params.log?.warn?.(`SMS webhook rate limit exceeded for ${key}`);
932
- respondTwiml(res, 429, "Rate limit exceeded");
797
+ const msg = buildTwilioInboundMessage(form);
798
+ if (!msg) {
799
+ respondTwiml(res, 400, "Missing SMS payload");
933
800
  return true;
934
801
  }
935
- const messageSid = resolveTwilioMessageSid(form);
936
- if (!messageSid) {
937
- respondTwiml(res, 400, "Missing MessageSid");
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");
938
805
  return true;
939
806
  }
940
- if ((await params.ingress.enqueue(form)).duplicate) params.log?.warn?.(`SMS webhook ignored replayed message ${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);
813
+ return true;
814
+ }
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
+ });
941
824
  respondTwiml(res, 200);
942
825
  return true;
943
826
  };
@@ -945,34 +828,15 @@ function createSmsWebhookHandler(params) {
945
828
  //#endregion
946
829
  //#region extensions/sms/src/gateway.ts
947
830
  const CHANNEL_ID$1 = "sms";
831
+ const activeRoutes = /* @__PURE__ */ new Map();
948
832
  const activeRoutePaths = /* @__PURE__ */ new Map();
949
- const pendingRouteStops = /* @__PURE__ */ new Map();
833
+ function routeKey(account) {
834
+ return `${account.accountId}:${normalizeWebhookPath(account.webhookPath)}`;
835
+ }
950
836
  function normalizeWebhookPath(path) {
951
837
  const trimmed = path.trim();
952
838
  return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
953
839
  }
954
- function stopSmsWebhookRoute(webhookPath, route) {
955
- if (route.stopTask) return route.stopTask;
956
- const pauseTask = route.ingress.pause();
957
- route.unregisterRoute();
958
- if (activeRoutePaths.get(webhookPath) === route) activeRoutePaths.delete(webhookPath);
959
- const previousStop = pendingRouteStops.get(webhookPath) ?? Promise.resolve();
960
- const stopTask = Promise.all([
961
- previousStop,
962
- route.ready,
963
- pauseTask
964
- ]).then(() => route.ingress.stop(), async (error) => {
965
- await Promise.allSettled([route.ingress.stop()]);
966
- throw error;
967
- });
968
- route.stopTask = stopTask;
969
- pendingRouteStops.set(webhookPath, stopTask);
970
- const clear = () => {
971
- if (pendingRouteStops.get(webhookPath) === stopTask) pendingRouteStops.delete(webhookPath);
972
- };
973
- stopTask.then(clear, clear);
974
- return stopTask;
975
- }
976
840
  function collectSmsStartupWarnings(account) {
977
841
  const warnings = [];
978
842
  if (!account.accountSid || !account.authToken || !account.fromNumber && !account.messagingServiceSid) warnings.push("- SMS: accountSid, authToken, and fromNumber or messagingServiceSid are required.");
@@ -981,57 +845,27 @@ function collectSmsStartupWarnings(account) {
981
845
  if (account.dmPolicy === "open" && !account.allowFrom.includes("*")) warnings.push("- SMS: dmPolicy=open should set allowFrom=[\"*\"] or explicit sender numbers.");
982
846
  return warnings;
983
847
  }
984
- async function registerSmsWebhookRoute(params) {
848
+ function registerSmsWebhookRoute(params) {
849
+ const key = routeKey(params.account);
985
850
  const webhookPath = normalizeWebhookPath(params.account.webhookPath);
986
- const currentRoute = activeRoutePaths.get(webhookPath);
987
- 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}.`);
988
- const predecessorStop = currentRoute ? stopSmsWebhookRoute(webhookPath, currentRoute) : pendingRouteStops.get(webhookPath) ?? Promise.resolve();
989
- const ingress = createSmsIngressSpool({
990
- cfg: params.cfg,
991
- account: params.account,
992
- channelRuntime: params.channelRuntime,
993
- ...params.log ? { log: params.log } : {}
994
- });
995
- let unregisterRoute;
996
- try {
997
- unregisterRoute = registerPluginHttpRoute({
998
- path: webhookPath,
999
- auth: "plugin",
1000
- pluginId: CHANNEL_ID$1,
1001
- accountId: params.account.accountId,
1002
- log: (msg) => params.log?.info?.(msg),
1003
- handler: createSmsWebhookHandler({
1004
- ...params,
1005
- ingress
1006
- })
1007
- });
1008
- } catch (error) {
1009
- await Promise.allSettled([predecessorStop, ingress.stop()]);
1010
- throw error;
1011
- }
1012
- 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,
1013
859
  accountId: params.account.accountId,
1014
- ingress,
1015
- unregisterRoute,
1016
- ready: Promise.resolve()
1017
- };
1018
- activeRoutePaths.set(webhookPath, route);
1019
- route.ready = predecessorStop.then(() => {
1020
- if (activeRoutePaths.get(webhookPath) === route && !route.stopTask) ingress.start();
860
+ log: (msg) => params.log?.info?.(msg),
861
+ handler: createSmsWebhookHandler(params)
1021
862
  });
1022
- const unregister = () => stopSmsWebhookRoute(webhookPath, route);
1023
- const readinessAbort = new AbortController();
1024
- const lifecycle = waitUntilAbort(AbortSignal.any([params.abortSignal, readinessAbort.signal]), unregister);
1025
- try {
1026
- await route.ready;
1027
- } catch (error) {
1028
- readinessAbort.abort();
1029
- await Promise.allSettled([lifecycle]);
1030
- throw error;
1031
- }
1032
- return {
1033
- lifecycle,
1034
- 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);
1035
869
  };
1036
870
  }
1037
871
  async function startSmsGatewayAccount(params) {
@@ -1045,9 +879,9 @@ async function startSmsGatewayAccount(params) {
1045
879
  return waitUntilAbort(params.abortSignal);
1046
880
  }
1047
881
  for (const warning of warnings) params.log?.warn?.(warning);
1048
- const registration = await registerSmsWebhookRoute(params);
1049
- if (registration.isActive()) params.log?.info?.(`Registered SMS webhook route ${params.account.webhookPath} for account ${params.account.accountId}`);
1050
- 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);
1051
885
  }
1052
886
  //#endregion
1053
887
  //#region extensions/sms/src/status.ts
@@ -1304,82 +1138,6 @@ function applySmsAccountConfig(params) {
1304
1138
  channels
1305
1139
  };
1306
1140
  }
1307
- const smsSetupContract = defineChannelSetupContract({
1308
- fields: {
1309
- accountSid: {
1310
- kind: "string",
1311
- sensitive: true,
1312
- cli: {
1313
- flags: "--account-sid <sid>",
1314
- description: "Twilio account SID"
1315
- }
1316
- },
1317
- authToken: {
1318
- kind: "string",
1319
- sensitive: true,
1320
- cli: {
1321
- flags: "--auth-token <token>",
1322
- description: "Twilio auth token"
1323
- }
1324
- },
1325
- fromNumber: {
1326
- kind: "string",
1327
- cli: {
1328
- flags: "--from-number <e164>",
1329
- description: "Twilio sender phone number"
1330
- }
1331
- },
1332
- messagingServiceSid: {
1333
- kind: "string",
1334
- cli: {
1335
- flags: "--messaging-service-sid <sid>",
1336
- description: "Twilio Messaging Service SID"
1337
- }
1338
- },
1339
- defaultTo: {
1340
- kind: "string",
1341
- cli: {
1342
- flags: "--default-to <e164>",
1343
- description: "Default SMS recipient"
1344
- }
1345
- },
1346
- webhookPath: {
1347
- kind: "string",
1348
- cli: {
1349
- flags: "--webhook-path <path>",
1350
- description: "SMS webhook path"
1351
- }
1352
- },
1353
- publicWebhookUrl: {
1354
- kind: "string",
1355
- cli: {
1356
- flags: "--public-webhook-url <url>",
1357
- description: "Public SMS webhook URL"
1358
- }
1359
- },
1360
- dmPolicy: {
1361
- kind: "choice",
1362
- choices: [
1363
- "pairing",
1364
- "allowlist",
1365
- "open",
1366
- "disabled"
1367
- ],
1368
- cli: {
1369
- flags: "--dm-policy <policy>",
1370
- description: "SMS DM policy"
1371
- }
1372
- },
1373
- allowFrom: {
1374
- kind: "string-list",
1375
- cli: {
1376
- flags: "--allow-from <numbers>",
1377
- description: "Allowed SMS senders"
1378
- }
1379
- }
1380
- },
1381
- adapter: { applyAccountConfig: applySmsAccountConfig }
1382
- });
1383
1141
  function createSmsReceipt(params) {
1384
1142
  const first = params.results[0];
1385
1143
  if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
@@ -1473,12 +1231,7 @@ const smsPlugin = createChatChannelPlugin({
1473
1231
  },
1474
1232
  reload: { configPrefixes: [`channels.${CHANNEL_ID}`] },
1475
1233
  configSchema: SmsChannelConfigSchema,
1476
- setup: { applyAccountConfig: ({ cfg, accountId, input }) => applySmsAccountConfig({
1477
- cfg,
1478
- accountId,
1479
- input
1480
- }) },
1481
- setupContract: smsSetupContract,
1234
+ setup: { applyAccountConfig: applySmsAccountConfig },
1482
1235
  config: {
1483
1236
  ...smsConfigAdapter,
1484
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.5",
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.5"
29
+ "pluginApi": ">=2026.7.33"
128
30
  },
129
31
  "build": {
130
- "openclawVersion": "2026.7.2-beta.5",
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.5"
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 };