@openclaw/sms 2026.7.2-beta.3 → 2026.7.2-beta.4

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.
@@ -3,8 +3,9 @@ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries
3
3
  import { DEFAULT_ACCOUNT_ID, normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
4
4
  import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
5
5
  import { buildChannelOutboundSessionRoute, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
6
- import { bindIngressLifecycleToReplyOptions, createChannelIngressDrain, createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
6
+ import { bindIngressLifecycleToReplyOptions, createChannelIngressMonitor, createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
7
7
  import { createConditionalWarningCollector } from "openclaw/plugin-sdk/channel-policy";
8
+ import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
8
9
  import { createEmptyChannelDirectoryAdapter } from "openclaw/plugin-sdk/directory-runtime";
9
10
  import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
10
11
  import { chunkTextForOutbound, renderMarkdownIRChunksWithinLimit, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
@@ -15,6 +16,7 @@ import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMul
15
16
  import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
16
17
  import { z } from "zod";
17
18
  import { createFixedWindowRateLimiter, readRequestBodyWithLimit, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
19
+ import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
18
20
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
21
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
20
22
  import { createHmac } from "node:crypto";
@@ -22,10 +24,9 @@ import * as querystring from "node:querystring";
22
24
  import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
23
25
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
24
26
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
25
- import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
26
27
  //#region extensions/sms/src/phone.ts
27
28
  function normalizeSmsPhoneNumber(raw) {
28
- const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "");
29
+ const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "").trim();
29
30
  if (!trimmed) return "";
30
31
  return (trimmed.startsWith("+") ? trimmed : `+${trimmed}`).replace(/[^\d+]/g, "");
31
32
  }
@@ -182,7 +183,8 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
182
183
  },
183
184
  fromNumber: {
184
185
  label: "SMS From Number",
185
- help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567."
186
+ help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567.",
187
+ presentation: "phone-number"
186
188
  },
187
189
  messagingServiceSid: {
188
190
  label: "Twilio Messaging Service SID",
@@ -190,7 +192,8 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
190
192
  },
191
193
  defaultTo: {
192
194
  label: "SMS Default To Number",
193
- help: "Optional default outbound phone number used when a send flow omits an explicit SMS target."
195
+ help: "Optional default outbound phone number used when a send flow omits an explicit SMS target.",
196
+ presentation: "phone-number"
194
197
  },
195
198
  publicWebhookUrl: {
196
199
  label: "SMS Public Webhook URL",
@@ -206,8 +209,12 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
206
209
  },
207
210
  allowFrom: {
208
211
  label: "SMS Allow From",
209
- help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open."
212
+ help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open.",
213
+ presentation: "phone-number"
210
214
  },
215
+ "accounts.*.fromNumber": { presentation: "phone-number" },
216
+ "accounts.*.defaultTo": { presentation: "phone-number" },
217
+ "accounts.*.allowFrom.*": { presentation: "phone-number" },
211
218
  textChunkLimit: {
212
219
  label: "SMS Text Chunk Limit",
213
220
  help: "Maximum characters per outbound SMS chunk before OpenClaw splits long replies."
@@ -584,6 +591,7 @@ async function sendSmsTextChunks(params) {
584
591
  //#region extensions/sms/src/inbound.ts
585
592
  const CHANNEL_ID$2 = "sms";
586
593
  async function authorizeSmsSender(params) {
594
+ const commandRequested = params.channelRuntime.commands.shouldComputeCommandAuthorized(params.rawBody, params.cfg);
587
595
  return await resolveStableChannelMessageIngress({
588
596
  channelId: CHANNEL_ID$2,
589
597
  accountId: params.account.accountId,
@@ -603,7 +611,11 @@ async function authorizeSmsSender(params) {
603
611
  },
604
612
  event: { mayPair: true },
605
613
  dmPolicy: params.account.dmPolicy,
606
- allowFrom: params.account.allowFrom
614
+ allowFrom: params.account.allowFrom,
615
+ command: commandRequested ? {
616
+ cfg: params.cfg,
617
+ modeWhenAccessGroupsOff: "configured"
618
+ } : void 0
607
619
  });
608
620
  }
609
621
  async function issueSmsPairingChallenge(params) {
@@ -639,7 +651,8 @@ async function dispatchSmsInboundEvent(params) {
639
651
  cfg: params.cfg,
640
652
  account: params.account,
641
653
  channelRuntime: params.channelRuntime,
642
- from
654
+ from,
655
+ rawBody: params.msg.body
643
656
  });
644
657
  if (!auth.senderAccess.allowed) {
645
658
  if (auth.senderAccess.decision === "pairing") {
@@ -664,6 +677,9 @@ async function dispatchSmsInboundEvent(params) {
664
677
  }
665
678
  });
666
679
  const sessionKey = route.sessionKey;
680
+ const commandRequested = auth.commandAccess.requested;
681
+ const commandAuthorized = auth.commandAccess.authorized;
682
+ const isTextCommand = params.channelRuntime.commands.isControlCommandMessage(params.msg.body, params.cfg);
667
683
  await params.channelRuntime.inbound.run({
668
684
  channel: CHANNEL_ID$2,
669
685
  accountId: params.account.accountId,
@@ -705,8 +721,15 @@ async function dispatchSmsInboundEvent(params) {
705
721
  commandBody: input.textForCommands,
706
722
  bodyForAgent: input.textForAgent
707
723
  },
724
+ access: commandRequested ? { commands: { authorized: commandAuthorized } } : void 0,
725
+ command: isTextCommand ? {
726
+ kind: "text-slash",
727
+ body: input.textForCommands,
728
+ authorized: commandAuthorized
729
+ } : void 0,
708
730
  extra: {
709
731
  MessageSid: params.msg.messageSid,
732
+ SenderE164: from,
710
733
  To: params.msg.to
711
734
  }
712
735
  });
@@ -743,14 +766,14 @@ async function dispatchSmsInboundEvent(params) {
743
766
  //#endregion
744
767
  //#region extensions/sms/src/ingress-spool.ts
745
768
  const SMS_INGRESS_PAYLOAD_VERSION = 1;
769
+ const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
746
770
  const SMS_COMPLETED_TTL_MS = 1440 * 60 * 1e3;
747
771
  const SMS_COMPLETED_MAX_ENTRIES = 2e4;
748
772
  const SMS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
749
773
  const SMS_FAILED_MAX_ENTRIES = 1e3;
750
774
  var SmsIngressPermanentError = class extends Error {};
751
- function parseSmsIngressPayload(payload, account) {
752
- if (payload.version !== SMS_INGRESS_PAYLOAD_VERSION) throw new SmsIngressPermanentError("SMS ingress payload version is invalid.");
753
- const message = buildTwilioInboundMessage(payload.form);
775
+ function parseSmsIngressForm(form, account) {
776
+ const message = buildTwilioInboundMessage(form);
754
777
  if (!message) throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
755
778
  if (message.accountSid && message.accountSid !== account.accountSid) throw new SmsIngressPermanentError("SMS ingress payload has an invalid Twilio account.");
756
779
  return message;
@@ -768,47 +791,72 @@ function createSmsIngressSpool(params) {
768
791
  log: params.log
769
792
  });
770
793
  });
771
- const drain = createChannelIngressDrain({
794
+ const monitor = createChannelIngressMonitor({
772
795
  queue,
796
+ inspect: (form, context) => {
797
+ const eventId = resolveTwilioMessageSid(form);
798
+ if (!eventId) {
799
+ if (context.phase === "claim") throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
800
+ throw new Error("SMS webhook is missing MessageSid.");
801
+ }
802
+ const sender = resolveTwilioInboundSender(form);
803
+ return {
804
+ eventId,
805
+ laneKey: sender ? `sender:${sender}` : `event:${eventId}`
806
+ };
807
+ },
808
+ payload: {
809
+ version: SMS_INGRESS_PAYLOAD_VERSION,
810
+ serialize: (form) => form,
811
+ deserialize: (form) => form,
812
+ encode: ({ body }) => ({
813
+ version: SMS_INGRESS_PAYLOAD_VERSION,
814
+ form: body
815
+ }),
816
+ decode: (payload) => ({
817
+ version: payload.version,
818
+ body: payload.form
819
+ }),
820
+ createClaimError: (kind) => new SmsIngressPermanentError(kind === "invalid-version" ? "SMS ingress payload version is invalid." : "SMS ingress identity changed after durable admission.")
821
+ },
822
+ deliver: (_form, lifecycle, event) => deliver(parseSmsIngressForm(event.payload.form, params.account), bindIngressLifecycleToReplyOptions(lifecycle).turnAdoptionLifecycle, event.receivedAt),
823
+ pollIntervalMs: SMS_INGRESS_DRAIN_INTERVAL_MS,
824
+ retention: {
825
+ pruneIntervalMs: 0,
826
+ completedTtlMs: SMS_COMPLETED_TTL_MS,
827
+ completedMaxEntries: SMS_COMPLETED_MAX_ENTRIES,
828
+ failedTtlMs: SMS_FAILED_TTL_MS,
829
+ failedMaxEntries: SMS_FAILED_MAX_ENTRIES
830
+ },
831
+ appendRetryDelaysMs: [0],
832
+ waitForDeliveryIdleBeforeRepump: false,
833
+ waitForDeliveryIdleOnStop: false,
834
+ runPumpTask: runDetachedWebhookWork,
835
+ admissionMode: "durable-after-stop",
836
+ drain: {
837
+ onLog: (message) => params.log?.warn?.(message),
838
+ resolveNonRetryableFailure: (error) => error instanceof SmsIngressPermanentError ? {
839
+ reason: "invalid-payload",
840
+ message: error.message
841
+ } : null
842
+ },
773
843
  ...params.abortSignal ? { abortSignal: params.abortSignal } : {},
774
- ...params.log?.warn ? { onLog: (message) => params.log?.warn?.(message) } : {},
775
- resolveNonRetryableFailure: (error) => error instanceof SmsIngressPermanentError ? {
776
- reason: "invalid-payload",
777
- message: error.message
778
- } : null,
779
- dispatchClaimedEvent: async (event, lifecycle) => {
780
- await deliver(parseSmsIngressPayload(event.payload, params.account), bindIngressLifecycleToReplyOptions(lifecycle).turnAdoptionLifecycle, event.receivedAt);
781
- }
844
+ createStoppedError: () => /* @__PURE__ */ new Error("SMS ingress stopped."),
845
+ onError: (error) => params.log?.error?.(`SMS ingress drain failed: ${error instanceof Error ? error.message : String(error)}`)
782
846
  });
783
847
  return {
784
848
  enqueue: async (form) => {
785
- const receivedAt = Date.now();
786
- const eventId = resolveTwilioMessageSid(form);
787
- if (!eventId) throw new Error("SMS webhook is missing MessageSid.");
788
- const sender = resolveTwilioInboundSender(form);
789
- await queue.prune({
790
- completedTtlMs: SMS_COMPLETED_TTL_MS,
791
- completedMaxEntries: SMS_COMPLETED_MAX_ENTRIES,
792
- failedTtlMs: SMS_FAILED_TTL_MS,
793
- failedMaxEntries: SMS_FAILED_MAX_ENTRIES
794
- });
795
- const result = await queue.enqueue(eventId, {
796
- version: SMS_INGRESS_PAYLOAD_VERSION,
797
- form
798
- }, {
799
- receivedAt,
800
- laneKey: sender ? `sender:${sender}` : `event:${eventId}`
801
- });
849
+ const admitted = await monitor.admit(form);
850
+ if (admitted.kind === "ignored") throw new Error("SMS webhook admission was unexpectedly ignored.");
802
851
  return {
803
- kind: result.kind,
804
- duplicate: result.duplicate
852
+ kind: admitted.queueResult.kind,
853
+ duplicate: admitted.queueResult.duplicate
805
854
  };
806
855
  },
807
- drainOnce: async () => {
808
- await drain.drainOnce();
809
- },
810
- waitForIdle: drain.waitForIdle,
811
- dispose: () => drain.dispose()
856
+ start: monitor.start,
857
+ pause: monitor.pause,
858
+ waitForIdle: monitor.waitForIdle,
859
+ stop: monitor.stop
812
860
  };
813
861
  }
814
862
  //#endregion
@@ -903,9 +951,6 @@ function createSmsWebhookHandler(params) {
903
951
  return true;
904
952
  }
905
953
  if ((await params.ingress.enqueue(form)).duplicate) params.log?.warn?.(`SMS webhook ignored replayed message ${messageSid}`);
906
- runDetachedWebhookWork(() => params.ingress.drainOnce()).catch((err) => {
907
- params.log?.error?.(`SMS ingress drain failed: ${err instanceof Error ? err.message : String(err)}`);
908
- });
909
954
  respondTwiml(res, 200);
910
955
  return true;
911
956
  };
@@ -913,16 +958,34 @@ function createSmsWebhookHandler(params) {
913
958
  //#endregion
914
959
  //#region extensions/sms/src/gateway.ts
915
960
  const CHANNEL_ID$1 = "sms";
916
- const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
917
- const activeRoutes = /* @__PURE__ */ new Map();
918
961
  const activeRoutePaths = /* @__PURE__ */ new Map();
919
- function routeKey(account) {
920
- return `${account.accountId}:${normalizeWebhookPath(account.webhookPath)}`;
921
- }
962
+ const pendingRouteStops = /* @__PURE__ */ new Map();
922
963
  function normalizeWebhookPath(path) {
923
964
  const trimmed = path.trim();
924
965
  return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
925
966
  }
967
+ function stopSmsWebhookRoute(webhookPath, route) {
968
+ if (route.stopTask) return route.stopTask;
969
+ const pauseTask = route.ingress.pause();
970
+ route.unregisterRoute();
971
+ if (activeRoutePaths.get(webhookPath) === route) activeRoutePaths.delete(webhookPath);
972
+ const previousStop = pendingRouteStops.get(webhookPath) ?? Promise.resolve();
973
+ const stopTask = Promise.all([
974
+ previousStop,
975
+ route.ready,
976
+ pauseTask
977
+ ]).then(() => route.ingress.stop(), async (error) => {
978
+ await Promise.allSettled([route.ingress.stop()]);
979
+ throw error;
980
+ });
981
+ route.stopTask = stopTask;
982
+ pendingRouteStops.set(webhookPath, stopTask);
983
+ const clear = () => {
984
+ if (pendingRouteStops.get(webhookPath) === stopTask) pendingRouteStops.delete(webhookPath);
985
+ };
986
+ stopTask.then(clear, clear);
987
+ return stopTask;
988
+ }
926
989
  function collectSmsStartupWarnings(account) {
927
990
  const warnings = [];
928
991
  if (!account.accountSid || !account.authToken || !account.fromNumber && !account.messagingServiceSid) warnings.push("- SMS: accountSid, authToken, and fromNumber or messagingServiceSid are required.");
@@ -931,23 +994,20 @@ function collectSmsStartupWarnings(account) {
931
994
  if (account.dmPolicy === "open" && !account.allowFrom.includes("*")) warnings.push("- SMS: dmPolicy=open should set allowFrom=[\"*\"] or explicit sender numbers.");
932
995
  return warnings;
933
996
  }
934
- function registerSmsWebhookRoute(params) {
935
- const key = routeKey(params.account);
997
+ async function registerSmsWebhookRoute(params) {
936
998
  const webhookPath = normalizeWebhookPath(params.account.webhookPath);
937
- const currentPathOwner = activeRoutePaths.get(webhookPath);
938
- 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}.`);
939
- activeRoutes.get(key)?.();
940
- activeRoutePaths.delete(webhookPath);
941
- const ingress = createSmsIngressSpool(params);
942
- const requestDrain = () => {
943
- ingress.drainOnce().catch((error) => {
944
- params.log?.error?.(`SMS ingress drain failed: ${error instanceof Error ? error.message : String(error)}`);
945
- });
946
- };
947
- const drainTimer = setInterval(requestDrain, SMS_INGRESS_DRAIN_INTERVAL_MS);
948
- drainTimer.unref?.();
999
+ const currentRoute = activeRoutePaths.get(webhookPath);
1000
+ 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}.`);
1001
+ const predecessorStop = currentRoute ? stopSmsWebhookRoute(webhookPath, currentRoute) : pendingRouteStops.get(webhookPath) ?? Promise.resolve();
1002
+ const ingress = createSmsIngressSpool({
1003
+ cfg: params.cfg,
1004
+ account: params.account,
1005
+ channelRuntime: params.channelRuntime,
1006
+ ...params.log ? { log: params.log } : {}
1007
+ });
1008
+ let unregisterRoute;
949
1009
  try {
950
- const unregisterRoute = registerPluginHttpRoute({
1010
+ unregisterRoute = registerPluginHttpRoute({
951
1011
  path: webhookPath,
952
1012
  auth: "plugin",
953
1013
  pluginId: CHANNEL_ID$1,
@@ -958,22 +1018,34 @@ function registerSmsWebhookRoute(params) {
958
1018
  ingress
959
1019
  })
960
1020
  });
961
- const unregister = () => {
962
- clearInterval(drainTimer);
963
- ingress.dispose();
964
- unregisterRoute();
965
- activeRoutes.delete(key);
966
- if (activeRoutePaths.get(webhookPath) === params.account.accountId) activeRoutePaths.delete(webhookPath);
967
- };
968
- activeRoutes.set(key, unregister);
969
- activeRoutePaths.set(webhookPath, params.account.accountId);
970
- requestDrain();
971
- return unregister;
972
1021
  } catch (error) {
973
- clearInterval(drainTimer);
974
- ingress.dispose();
1022
+ await Promise.allSettled([predecessorStop, ingress.stop()]);
1023
+ throw error;
1024
+ }
1025
+ const route = {
1026
+ accountId: params.account.accountId,
1027
+ ingress,
1028
+ unregisterRoute,
1029
+ ready: Promise.resolve()
1030
+ };
1031
+ activeRoutePaths.set(webhookPath, route);
1032
+ route.ready = predecessorStop.then(() => {
1033
+ if (activeRoutePaths.get(webhookPath) === route && !route.stopTask) ingress.start();
1034
+ });
1035
+ const unregister = () => stopSmsWebhookRoute(webhookPath, route);
1036
+ const readinessAbort = new AbortController();
1037
+ const lifecycle = waitUntilAbort(AbortSignal.any([params.abortSignal, readinessAbort.signal]), unregister);
1038
+ try {
1039
+ await route.ready;
1040
+ } catch (error) {
1041
+ readinessAbort.abort();
1042
+ await Promise.allSettled([lifecycle]);
975
1043
  throw error;
976
1044
  }
1045
+ return {
1046
+ lifecycle,
1047
+ isActive: () => activeRoutePaths.get(webhookPath) === route
1048
+ };
977
1049
  }
978
1050
  async function startSmsGatewayAccount(params) {
979
1051
  if (!params.account.enabled) {
@@ -986,9 +1058,9 @@ async function startSmsGatewayAccount(params) {
986
1058
  return waitUntilAbort(params.abortSignal);
987
1059
  }
988
1060
  for (const warning of warnings) params.log?.warn?.(warning);
989
- const unregister = registerSmsWebhookRoute(params);
990
- params.log?.info?.(`Registered SMS webhook route ${params.account.webhookPath} for account ${params.account.accountId}`);
991
- return waitUntilAbort(params.abortSignal, unregister);
1061
+ const registration = await registerSmsWebhookRoute(params);
1062
+ if (registration.isActive()) params.log?.info?.(`Registered SMS webhook route ${params.account.webhookPath} for account ${params.account.accountId}`);
1063
+ return registration.lifecycle;
992
1064
  }
993
1065
  //#endregion
994
1066
  //#region extensions/sms/src/status.ts
@@ -1245,6 +1317,82 @@ function applySmsAccountConfig(params) {
1245
1317
  channels
1246
1318
  };
1247
1319
  }
1320
+ const smsSetupContract = defineChannelSetupContract({
1321
+ fields: {
1322
+ accountSid: {
1323
+ kind: "string",
1324
+ sensitive: true,
1325
+ cli: {
1326
+ flags: "--account-sid <sid>",
1327
+ description: "Twilio account SID"
1328
+ }
1329
+ },
1330
+ authToken: {
1331
+ kind: "string",
1332
+ sensitive: true,
1333
+ cli: {
1334
+ flags: "--auth-token <token>",
1335
+ description: "Twilio auth token"
1336
+ }
1337
+ },
1338
+ fromNumber: {
1339
+ kind: "string",
1340
+ cli: {
1341
+ flags: "--from-number <e164>",
1342
+ description: "Twilio sender phone number"
1343
+ }
1344
+ },
1345
+ messagingServiceSid: {
1346
+ kind: "string",
1347
+ cli: {
1348
+ flags: "--messaging-service-sid <sid>",
1349
+ description: "Twilio Messaging Service SID"
1350
+ }
1351
+ },
1352
+ defaultTo: {
1353
+ kind: "string",
1354
+ cli: {
1355
+ flags: "--default-to <e164>",
1356
+ description: "Default SMS recipient"
1357
+ }
1358
+ },
1359
+ webhookPath: {
1360
+ kind: "string",
1361
+ cli: {
1362
+ flags: "--webhook-path <path>",
1363
+ description: "SMS webhook path"
1364
+ }
1365
+ },
1366
+ publicWebhookUrl: {
1367
+ kind: "string",
1368
+ cli: {
1369
+ flags: "--public-webhook-url <url>",
1370
+ description: "Public SMS webhook URL"
1371
+ }
1372
+ },
1373
+ dmPolicy: {
1374
+ kind: "choice",
1375
+ choices: [
1376
+ "pairing",
1377
+ "allowlist",
1378
+ "open",
1379
+ "disabled"
1380
+ ],
1381
+ cli: {
1382
+ flags: "--dm-policy <policy>",
1383
+ description: "SMS DM policy"
1384
+ }
1385
+ },
1386
+ allowFrom: {
1387
+ kind: "string-list",
1388
+ cli: {
1389
+ flags: "--allow-from <numbers>",
1390
+ description: "Allowed SMS senders"
1391
+ }
1392
+ }
1393
+ },
1394
+ adapter: { applyAccountConfig: applySmsAccountConfig }
1395
+ });
1248
1396
  function createSmsReceipt(params) {
1249
1397
  const first = params.results[0];
1250
1398
  if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
@@ -1338,7 +1486,12 @@ const smsPlugin = createChatChannelPlugin({
1338
1486
  },
1339
1487
  reload: { configPrefixes: [`channels.${CHANNEL_ID}`] },
1340
1488
  configSchema: SmsChannelConfigSchema,
1341
- setup: { applyAccountConfig: applySmsAccountConfig },
1489
+ setup: { applyAccountConfig: ({ cfg, accountId, input }) => applySmsAccountConfig({
1490
+ cfg,
1491
+ accountId,
1492
+ input
1493
+ }) },
1494
+ setupContract: smsSetupContract,
1342
1495
  config: {
1343
1496
  ...smsConfigAdapter,
1344
1497
  inspectAccount: inspectSmsAccount,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/sms",
3
- "version": "2026.7.2-beta.3",
3
+ "version": "2026.7.2-beta.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/sms",
9
- "version": "2026.7.2-beta.3",
9
+ "version": "2026.7.2-beta.4",
10
10
  "dependencies": {
11
11
  "zod": "4.4.3"
12
12
  }
@@ -8,18 +8,6 @@
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
- },
23
11
  "configSchema": {
24
12
  "type": "object",
25
13
  "additionalProperties": false,
@@ -338,7 +326,8 @@
338
326
  },
339
327
  "fromNumber": {
340
328
  "label": "SMS From Number",
341
- "help": "Twilio SMS-capable phone number in E.164 format, for example +15551234567."
329
+ "help": "Twilio SMS-capable phone number in E.164 format, for example +15551234567.",
330
+ "presentation": "phone-number"
342
331
  },
343
332
  "messagingServiceSid": {
344
333
  "label": "Twilio Messaging Service SID",
@@ -346,7 +335,8 @@
346
335
  },
347
336
  "defaultTo": {
348
337
  "label": "SMS Default To Number",
349
- "help": "Optional default outbound phone number used when a send flow omits an explicit SMS target."
338
+ "help": "Optional default outbound phone number used when a send flow omits an explicit SMS target.",
339
+ "presentation": "phone-number"
350
340
  },
351
341
  "publicWebhookUrl": {
352
342
  "label": "SMS Public Webhook URL",
@@ -362,7 +352,17 @@
362
352
  },
363
353
  "allowFrom": {
364
354
  "label": "SMS Allow From",
365
- "help": "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open."
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"
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.3",
3
+ "version": "2026.7.2-beta.4",
4
4
  "description": "OpenClaw SMS channel plugin for Twilio text messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,6 +16,20 @@
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
+ },
19
33
  "label": "SMS",
20
34
  "selectionLabel": "SMS (Twilio)",
21
35
  "detailLabel": "Twilio SMS",
@@ -23,13 +37,97 @@
23
37
  "docsLabel": "sms",
24
38
  "blurb": "Twilio-backed SMS with inbound webhooks and outbound replies.",
25
39
  "order": 88,
26
- "quickstartAllowFrom": true
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
+ }
27
125
  },
28
126
  "compat": {
29
- "pluginApi": ">=2026.7.2-beta.3"
127
+ "pluginApi": ">=2026.7.2-beta.4"
30
128
  },
31
129
  "build": {
32
- "openclawVersion": "2026.7.2-beta.3",
130
+ "openclawVersion": "2026.7.2-beta.4",
33
131
  "bundledDist": false
34
132
  },
35
133
  "install": {
@@ -54,7 +152,7 @@
54
152
  "README.md"
55
153
  ],
56
154
  "peerDependencies": {
57
- "openclaw": ">=2026.7.2-beta.3"
155
+ "openclaw": ">=2026.7.2-beta.4"
58
156
  },
59
157
  "peerDependenciesMeta": {
60
158
  "openclaw": {