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

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,18 +3,21 @@ 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";
11
- import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, hasConfiguredAccountValue, listCombinedAccountIds, resolveAccountEntry, resolveListedDefaultAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
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";
12
14
  import { parseStrictInteger } from "openclaw/plugin-sdk/number-runtime";
13
15
  import { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
14
16
  import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMultiAccountChannelSchema, requireOpenAllowFrom } from "openclaw/plugin-sdk/channel-config-schema";
15
17
  import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
16
18
  import { z } from "zod";
17
19
  import { createFixedWindowRateLimiter, readRequestBodyWithLimit, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
20
+ import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
18
21
  import { resolveStableChannelMessageIngress } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
22
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
20
23
  import { createHmac } from "node:crypto";
@@ -22,10 +25,9 @@ import * as querystring from "node:querystring";
22
25
  import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
23
26
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
24
27
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
25
- import { runDetachedWebhookWork } from "openclaw/plugin-sdk/webhook-request-guards";
26
28
  //#region extensions/sms/src/phone.ts
27
29
  function normalizeSmsPhoneNumber(raw) {
28
- const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "");
30
+ const trimmed = raw.trim().replace(/^(?:sms|twilio-sms):/i, "").trim();
29
31
  if (!trimmed) return "";
30
32
  return (trimmed.startsWith("+") ? trimmed : `+${trimmed}`).replace(/[^\d+]/g, "");
31
33
  }
@@ -69,30 +71,16 @@ function hasBaseAccount(channelCfg) {
69
71
  process.env.TWILIO_MESSAGING_SERVICE_SID
70
72
  ].some((value) => hasConfiguredAccountValue(value)) || hasConfiguredSecretInput(channelCfg?.authToken);
71
73
  }
72
- function listSmsAccountIds(cfg) {
73
- const channelCfg = getChannelConfig(cfg);
74
- return listCombinedAccountIds({
75
- configuredAccountIds: Object.keys(channelCfg?.accounts ?? {}),
76
- implicitAccountId: hasBaseAccount(channelCfg) ? DEFAULT_ACCOUNT_ID$1 : void 0
77
- });
78
- }
79
- function resolveDefaultSmsAccountId(cfg) {
80
- const channelCfg = getChannelConfig(cfg);
81
- return resolveListedDefaultAccountId({
82
- accountIds: listSmsAccountIds(cfg),
83
- configuredDefaultAccountId: normalizeOptionalAccountId(channelCfg?.defaultAccount)
84
- });
85
- }
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
+ });
86
79
  function resolveSmsAccount(cfg, accountId) {
87
80
  const channelCfg = getChannelConfig(cfg) ?? {};
88
81
  const id = normalizeOptionalAccountId(accountId) ?? resolveDefaultSmsAccountId(cfg);
89
82
  const accountConfig = resolveAccountEntry(channelCfg.accounts, id);
90
- const merged = resolveMergedAccountConfig({
91
- channelConfig: { ...channelCfg },
92
- accounts: channelCfg.accounts ? Object.fromEntries(Object.entries(channelCfg.accounts).map(([accountKey, account]) => [accountKey, { ...account }])) : void 0,
93
- accountId: id,
94
- omitKeys: ["defaultAccount"]
95
- });
83
+ const merged = resolveMergedSmsAccountConfig(cfg, id);
96
84
  const useEnvFallbacks = id === DEFAULT_ACCOUNT_ID$1;
97
85
  const envAccountSid = useEnvFallbacks ? process.env.TWILIO_ACCOUNT_SID : void 0;
98
86
  const envAuthToken = useEnvFallbacks ? process.env.TWILIO_AUTH_TOKEN : void 0;
@@ -182,7 +170,8 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
182
170
  },
183
171
  fromNumber: {
184
172
  label: "SMS From Number",
185
- help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567."
173
+ help: "Twilio SMS-capable phone number in E.164 format, for example +15551234567.",
174
+ presentation: "phone-number"
186
175
  },
187
176
  messagingServiceSid: {
188
177
  label: "Twilio Messaging Service SID",
@@ -190,7 +179,8 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
190
179
  },
191
180
  defaultTo: {
192
181
  label: "SMS Default To Number",
193
- help: "Optional default outbound phone number used when a send flow omits an explicit SMS target."
182
+ help: "Optional default outbound phone number used when a send flow omits an explicit SMS target.",
183
+ presentation: "phone-number"
194
184
  },
195
185
  publicWebhookUrl: {
196
186
  label: "SMS Public Webhook URL",
@@ -206,8 +196,12 @@ const SmsChannelConfigSchema = buildChannelConfigSchema(buildMultiAccountChannel
206
196
  },
207
197
  allowFrom: {
208
198
  label: "SMS Allow From",
209
- help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open."
199
+ help: "Allowed sender phone numbers in E.164 format, or * when dmPolicy is open.",
200
+ presentation: "phone-number"
210
201
  },
202
+ "accounts.*.fromNumber": { presentation: "phone-number" },
203
+ "accounts.*.defaultTo": { presentation: "phone-number" },
204
+ "accounts.*.allowFrom.*": { presentation: "phone-number" },
211
205
  textChunkLimit: {
212
206
  label: "SMS Text Chunk Limit",
213
207
  help: "Maximum characters per outbound SMS chunk before OpenClaw splits long replies."
@@ -584,6 +578,7 @@ async function sendSmsTextChunks(params) {
584
578
  //#region extensions/sms/src/inbound.ts
585
579
  const CHANNEL_ID$2 = "sms";
586
580
  async function authorizeSmsSender(params) {
581
+ const commandRequested = params.channelRuntime.commands.shouldComputeCommandAuthorized(params.rawBody, params.cfg);
587
582
  return await resolveStableChannelMessageIngress({
588
583
  channelId: CHANNEL_ID$2,
589
584
  accountId: params.account.accountId,
@@ -603,7 +598,11 @@ async function authorizeSmsSender(params) {
603
598
  },
604
599
  event: { mayPair: true },
605
600
  dmPolicy: params.account.dmPolicy,
606
- allowFrom: params.account.allowFrom
601
+ allowFrom: params.account.allowFrom,
602
+ command: commandRequested ? {
603
+ cfg: params.cfg,
604
+ modeWhenAccessGroupsOff: "configured"
605
+ } : void 0
607
606
  });
608
607
  }
609
608
  async function issueSmsPairingChallenge(params) {
@@ -639,7 +638,8 @@ async function dispatchSmsInboundEvent(params) {
639
638
  cfg: params.cfg,
640
639
  account: params.account,
641
640
  channelRuntime: params.channelRuntime,
642
- from
641
+ from,
642
+ rawBody: params.msg.body
643
643
  });
644
644
  if (!auth.senderAccess.allowed) {
645
645
  if (auth.senderAccess.decision === "pairing") {
@@ -664,6 +664,9 @@ async function dispatchSmsInboundEvent(params) {
664
664
  }
665
665
  });
666
666
  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);
667
670
  await params.channelRuntime.inbound.run({
668
671
  channel: CHANNEL_ID$2,
669
672
  accountId: params.account.accountId,
@@ -705,8 +708,15 @@ async function dispatchSmsInboundEvent(params) {
705
708
  commandBody: input.textForCommands,
706
709
  bodyForAgent: input.textForAgent
707
710
  },
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,
708
717
  extra: {
709
718
  MessageSid: params.msg.messageSid,
719
+ SenderE164: from,
710
720
  To: params.msg.to
711
721
  }
712
722
  });
@@ -743,14 +753,14 @@ async function dispatchSmsInboundEvent(params) {
743
753
  //#endregion
744
754
  //#region extensions/sms/src/ingress-spool.ts
745
755
  const SMS_INGRESS_PAYLOAD_VERSION = 1;
756
+ const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
746
757
  const SMS_COMPLETED_TTL_MS = 1440 * 60 * 1e3;
747
758
  const SMS_COMPLETED_MAX_ENTRIES = 2e4;
748
759
  const SMS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
749
760
  const SMS_FAILED_MAX_ENTRIES = 1e3;
750
761
  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);
762
+ function parseSmsIngressForm(form, account) {
763
+ const message = buildTwilioInboundMessage(form);
754
764
  if (!message) throw new SmsIngressPermanentError("SMS ingress payload is invalid.");
755
765
  if (message.accountSid && message.accountSid !== account.accountSid) throw new SmsIngressPermanentError("SMS ingress payload has an invalid Twilio account.");
756
766
  return message;
@@ -768,47 +778,72 @@ function createSmsIngressSpool(params) {
768
778
  log: params.log
769
779
  });
770
780
  });
771
- const drain = createChannelIngressDrain({
781
+ const monitor = createChannelIngressMonitor({
772
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
+ },
773
830
  ...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
- }
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)}`)
782
833
  });
783
834
  return {
784
835
  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
- });
836
+ const admitted = await monitor.admit(form);
837
+ if (admitted.kind === "ignored") throw new Error("SMS webhook admission was unexpectedly ignored.");
802
838
  return {
803
- kind: result.kind,
804
- duplicate: result.duplicate
839
+ kind: admitted.queueResult.kind,
840
+ duplicate: admitted.queueResult.duplicate
805
841
  };
806
842
  },
807
- drainOnce: async () => {
808
- await drain.drainOnce();
809
- },
810
- waitForIdle: drain.waitForIdle,
811
- dispose: () => drain.dispose()
843
+ start: monitor.start,
844
+ pause: monitor.pause,
845
+ waitForIdle: monitor.waitForIdle,
846
+ stop: monitor.stop
812
847
  };
813
848
  }
814
849
  //#endregion
@@ -903,9 +938,6 @@ function createSmsWebhookHandler(params) {
903
938
  return true;
904
939
  }
905
940
  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
941
  respondTwiml(res, 200);
910
942
  return true;
911
943
  };
@@ -913,16 +945,34 @@ function createSmsWebhookHandler(params) {
913
945
  //#endregion
914
946
  //#region extensions/sms/src/gateway.ts
915
947
  const CHANNEL_ID$1 = "sms";
916
- const SMS_INGRESS_DRAIN_INTERVAL_MS = 500;
917
- const activeRoutes = /* @__PURE__ */ new Map();
918
948
  const activeRoutePaths = /* @__PURE__ */ new Map();
919
- function routeKey(account) {
920
- return `${account.accountId}:${normalizeWebhookPath(account.webhookPath)}`;
921
- }
949
+ const pendingRouteStops = /* @__PURE__ */ new Map();
922
950
  function normalizeWebhookPath(path) {
923
951
  const trimmed = path.trim();
924
952
  return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
925
953
  }
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
+ }
926
976
  function collectSmsStartupWarnings(account) {
927
977
  const warnings = [];
928
978
  if (!account.accountSid || !account.authToken || !account.fromNumber && !account.messagingServiceSid) warnings.push("- SMS: accountSid, authToken, and fromNumber or messagingServiceSid are required.");
@@ -931,23 +981,20 @@ function collectSmsStartupWarnings(account) {
931
981
  if (account.dmPolicy === "open" && !account.allowFrom.includes("*")) warnings.push("- SMS: dmPolicy=open should set allowFrom=[\"*\"] or explicit sender numbers.");
932
982
  return warnings;
933
983
  }
934
- function registerSmsWebhookRoute(params) {
935
- const key = routeKey(params.account);
984
+ async function registerSmsWebhookRoute(params) {
936
985
  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?.();
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;
949
996
  try {
950
- const unregisterRoute = registerPluginHttpRoute({
997
+ unregisterRoute = registerPluginHttpRoute({
951
998
  path: webhookPath,
952
999
  auth: "plugin",
953
1000
  pluginId: CHANNEL_ID$1,
@@ -958,22 +1005,34 @@ function registerSmsWebhookRoute(params) {
958
1005
  ingress
959
1006
  })
960
1007
  });
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
1008
  } catch (error) {
973
- clearInterval(drainTimer);
974
- ingress.dispose();
1009
+ await Promise.allSettled([predecessorStop, ingress.stop()]);
975
1010
  throw error;
976
1011
  }
1012
+ const route = {
1013
+ 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();
1021
+ });
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
1035
+ };
977
1036
  }
978
1037
  async function startSmsGatewayAccount(params) {
979
1038
  if (!params.account.enabled) {
@@ -986,9 +1045,9 @@ async function startSmsGatewayAccount(params) {
986
1045
  return waitUntilAbort(params.abortSignal);
987
1046
  }
988
1047
  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);
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;
992
1051
  }
993
1052
  //#endregion
994
1053
  //#region extensions/sms/src/status.ts
@@ -1245,6 +1304,82 @@ function applySmsAccountConfig(params) {
1245
1304
  channels
1246
1305
  };
1247
1306
  }
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
+ });
1248
1383
  function createSmsReceipt(params) {
1249
1384
  const first = params.results[0];
1250
1385
  if (!first) throw new Error("SMS send did not return a Twilio Message SID.");
@@ -1338,7 +1473,12 @@ const smsPlugin = createChatChannelPlugin({
1338
1473
  },
1339
1474
  reload: { configPrefixes: [`channels.${CHANNEL_ID}`] },
1340
1475
  configSchema: SmsChannelConfigSchema,
1341
- setup: { applyAccountConfig: applySmsAccountConfig },
1476
+ setup: { applyAccountConfig: ({ cfg, accountId, input }) => applySmsAccountConfig({
1477
+ cfg,
1478
+ accountId,
1479
+ input
1480
+ }) },
1481
+ setupContract: smsSetupContract,
1342
1482
  config: {
1343
1483
  ...smsConfigAdapter,
1344
1484
  inspectAccount: inspectSmsAccount,
@@ -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.5",
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.5"
30
128
  },
31
129
  "build": {
32
- "openclawVersion": "2026.7.2-beta.3",
130
+ "openclawVersion": "2026.7.2-beta.5",
33
131
  "bundledDist": false
34
132
  },
35
133
  "install": {
@@ -50,11 +148,10 @@
50
148
  "files": [
51
149
  "dist/**",
52
150
  "openclaw.plugin.json",
53
- "npm-shrinkwrap.json",
54
151
  "README.md"
55
152
  ],
56
153
  "peerDependencies": {
57
- "openclaw": ">=2026.7.2-beta.3"
154
+ "openclaw": ">=2026.7.2-beta.5"
58
155
  },
59
156
  "peerDependenciesMeta": {
60
157
  "openclaw": {
@@ -1,24 +0,0 @@
1
- {
2
- "name": "@openclaw/sms",
3
- "version": "2026.7.2-beta.3",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "@openclaw/sms",
9
- "version": "2026.7.2-beta.3",
10
- "dependencies": {
11
- "zod": "4.4.3"
12
- }
13
- },
14
- "node_modules/zod": {
15
- "version": "4.4.3",
16
- "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
17
- "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",
18
- "license": "MIT",
19
- "funding": {
20
- "url": "https://github.com/sponsors/colinhacks"
21
- }
22
- }
23
- }
24
- }