@openclaw/sms 2026.9.7 → 2026.10.1-beta.1

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,5 +1,5 @@
1
1
  import { t as getSmsRuntime } from "./runtime-BBlPgBIF.mjs";
2
- import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-AlRQ6LtX.mjs";
2
+ import { h as assertSmsCredentialOwnerAvailable, n as TWILIO_MMS_MAX_BYTES } from "./twilio-DLNDolQb.mjs";
3
3
  import { collectErrorGraphCandidates } from "openclaw/plugin-sdk/error-runtime";
4
4
  import { resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
5
5
  import { createHash } from "node:crypto";
@@ -0,0 +1,44 @@
1
+ import { collectConditionalChannelFieldAssignments, createChannelSecretContract, hasOwnProperty } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
2
+ //#region extensions/sms/src/secret-contract.ts
3
+ const DEFAULT_ACCOUNT_ID = "default";
4
+ function hasTopLevelSmsAccount(channel) {
5
+ for (const field of [
6
+ "accountSid",
7
+ "fromNumber",
8
+ "messagingServiceSid",
9
+ "defaultTo"
10
+ ]) if (typeof channel[field] === "string" && channel[field].trim().length > 0) return true;
11
+ return false;
12
+ }
13
+ function hasEnvBackedDefaultSmsAccount(env) {
14
+ for (const name of [
15
+ "TWILIO_ACCOUNT_SID",
16
+ "TWILIO_AUTH_TOKEN",
17
+ "TWILIO_PHONE_NUMBER",
18
+ "TWILIO_SMS_FROM",
19
+ "TWILIO_MESSAGING_SERVICE_SID"
20
+ ]) if (typeof env[name] === "string" && env[name].trim().length > 0) return true;
21
+ return false;
22
+ }
23
+ const channelSecrets = createChannelSecretContract({
24
+ channelKey: "sms",
25
+ account: ["authToken"],
26
+ channel: ["authToken"],
27
+ collect(params) {
28
+ const { channel: sms, surface } = params;
29
+ const hasExplicitDefaultAccount = surface.accounts.some(({ accountId }) => accountId === DEFAULT_ACCOUNT_ID);
30
+ const topLevelSmsAccountActive = (hasTopLevelSmsAccount(sms) || hasEnvBackedDefaultSmsAccount(params.context.env)) && !hasExplicitDefaultAccount;
31
+ collectConditionalChannelFieldAssignments({
32
+ ...params,
33
+ field: "authToken",
34
+ topLevelActiveWithoutAccounts: true,
35
+ topLevelInheritedAccountActive: ({ account, enabled }) => topLevelSmsAccountActive || enabled && !hasOwnProperty(account, "authToken"),
36
+ accountActive: ({ enabled }) => enabled,
37
+ topInactiveReason: "no enabled SMS surface inherits this top-level authToken.",
38
+ accountInactiveReason: "SMS account is disabled."
39
+ });
40
+ }
41
+ });
42
+ const { secretTargetRegistryEntries, collectRuntimeConfigAssignments } = channelSecrets;
43
+ //#endregion
44
+ export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };
@@ -1,6 +1,6 @@
1
1
  import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
2
2
  import { PlatformMessageNotDispatchedError, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
- import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { asNullableObjectRecord, isRecord, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { createAccountListHelpers, resolveChannelMediaMaxBytes } from "openclaw/plugin-sdk/account-helpers";
5
5
  import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, hasConfiguredAccountValue, resolveAccountEntry } from "openclaw/plugin-sdk/account-resolution";
6
6
  import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
@@ -12,6 +12,7 @@ import * as querystring from "node:querystring";
12
12
  import { redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
13
13
  import { readResponseTextPrefix, readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
14
14
  import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
15
+ import { safeParseJson } from "openclaw/plugin-sdk/text-utility-runtime";
15
16
  import { readRequestBodyWithLimit } from "openclaw/plugin-sdk/webhook-ingress";
16
17
  import { assertSecretOwnerAvailable } from "openclaw/plugin-sdk/channel-secret-owner-runtime";
17
18
  import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
@@ -242,17 +243,12 @@ function firstStringish(value) {
242
243
  return typeof first === "number" ? String(first) : "";
243
244
  }
244
245
  function parseTwilioApiError(text) {
245
- try {
246
- const parsed = JSON.parse(text);
247
- if (!parsed || typeof parsed !== "object") return {};
248
- const record = parsed;
249
- return {
250
- code: typeof record.code === "number" ? record.code : void 0,
251
- message: typeof record.message === "string" ? record.message : void 0
252
- };
253
- } catch {
254
- return {};
255
- }
246
+ const record = asNullableObjectRecord(safeParseJson(text));
247
+ if (!record) return {};
248
+ return {
249
+ code: typeof record.code === "number" ? record.code : void 0,
250
+ message: typeof record.message === "string" ? record.message : void 0
251
+ };
256
252
  }
257
253
  function parseTwilioSuccessPayload(text) {
258
254
  if (!text.trim()) return {};
@@ -410,12 +406,6 @@ async function readTwilioApiResponseText(response) {
410
406
  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)`) });
411
407
  return new TextDecoder().decode(body);
412
408
  }
413
- function normalizeRequestHeaders(headers) {
414
- if (!headers) return {};
415
- if (headers instanceof Headers) return Object.fromEntries(headers.entries());
416
- if (Array.isArray(headers)) return Object.fromEntries(headers.map(([key, value]) => [key, value]));
417
- return Object.fromEntries(Object.entries(headers));
418
- }
419
409
  function assertTwilioRequestCredentialsAvailable(account) {
420
410
  try {
421
411
  assertSmsCredentialOwnerAvailable(account);
@@ -427,7 +417,7 @@ async function requestTwilioApi(params) {
427
417
  const init = {
428
418
  ...params.init,
429
419
  headers: {
430
- ...normalizeRequestHeaders(params.init?.headers),
420
+ ...params.init?.headers,
431
421
  authorization: basicAuthHeader(params.account)
432
422
  }
433
423
  };
@@ -498,17 +488,9 @@ function parseTwilioMessagingService(record) {
498
488
  };
499
489
  }
500
490
  function parseTwilioListPayload(text, key, parseEntry) {
501
- if (!text.trim()) return [];
502
- let parsed;
503
- try {
504
- parsed = JSON.parse(text);
505
- } catch {
506
- return [];
507
- }
508
- if (!parsed || typeof parsed !== "object") return [];
509
- const items = parsed[key];
491
+ const items = asNullableObjectRecord(safeParseJson(text))?.[key];
510
492
  if (!Array.isArray(items)) return [];
511
- return items.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))).map(parseEntry);
493
+ return items.filter(isRecord).map(parseEntry);
512
494
  }
513
495
  async function listTwilioIncomingPhoneNumbers(params) {
514
496
  const query = new URLSearchParams();
@@ -532,13 +514,8 @@ async function retrieveTwilioMessagingService(params) {
532
514
  timeoutMs: params.timeoutMs
533
515
  });
534
516
  if (!response.ok) throw new TwilioSmsApiError(response.status, response.text, "messaging-service lookup");
535
- let parsed;
536
- try {
537
- parsed = JSON.parse(response.text);
538
- } catch {
539
- throw new Error("Twilio Messaging Service lookup returned malformed JSON.");
540
- }
541
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Twilio Messaging Service lookup returned malformed JSON.");
517
+ const parsed = safeParseJson(response.text);
518
+ if (!isRecord(parsed)) throw new Error("Twilio Messaging Service lookup returned malformed JSON.");
542
519
  return parseTwilioMessagingService(parsed);
543
520
  }
544
521
  async function listTwilioMessages(params) {
@@ -1,6 +1,6 @@
1
1
  import { t as getSmsRuntime } from "./.setup/runtime-BBlPgBIF.mjs";
2
- import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-AlRQ6LtX.mjs";
3
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-Cp0f-YPc.mjs";
2
+ import { C as normalizeSmsAllowFrom, S as looksLikeSmsPhoneNumber, _ as isSmsAccountConfigured, a as listTwilioIncomingPhoneNumbers, b as resolveSmsAccount, c as resolveTwilioInboundSender, d as respondTwiml, f as retrieveTwilioMessagingService, g as inspectSmsAccount, h as assertSmsCredentialOwnerAvailable, i as buildTwilioInboundMessage, l as resolveTwilioMessageSid, m as verifyTwilioSignature, o as listTwilioMessages, p as sendSmsViaTwilio, r as TWIML_CONTENT_TYPE, s as readTwilioWebhookForm, t as TWILIO_MESSAGE_BODY_MAX_LENGTH, u as resolveTwilioWebhookSignatureUrl, v as listSmsAccountIds, w as normalizeSmsPhoneNumber, x as resolveTwilioStatusCallbackUrl, y as resolveDefaultSmsAccountId } from "./.setup/twilio-DLNDolQb.mjs";
3
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./.setup/secret-contract-BEWVid4f.mjs";
4
4
  import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
5
5
  import { createHybridChannelConfigAdapter, createScopedDmSecurityResolver } from "openclaw/plugin-sdk/channel-config-helpers";
6
6
  import { buildChannelOutboundSessionRoute, createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
@@ -17,12 +17,12 @@ import { AllowFromListSchema, DmPolicySchema, buildChannelConfigSchema, buildMul
17
17
  import { requireChannelOpenAllowFrom } from "openclaw/plugin-sdk/extension-shared";
18
18
  import { z } from "zod";
19
19
  import { createHash } from "node:crypto";
20
+ import { withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
20
21
  import { createFixedWindowRateLimiter, isRequestBodyLimitError, registerPluginHttpRoute, resolveRequestClientIp } from "openclaw/plugin-sdk/webhook-ingress";
21
22
  import { channelBlockedPatch, channelReadyPatch, channelStoppedPatch } from "openclaw/plugin-sdk/gateway-runtime";
22
23
  import { createWebhookInFlightLimiter, runDetachedWebhookWork, sendHttpRequestRejection } from "openclaw/plugin-sdk/webhook-request-guards";
23
24
  import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
24
25
  import { createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
25
- import { withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
26
26
  //#region extensions/sms/src/config-schema.ts
27
27
  const SecretInputSchema = buildSecretInputSchema();
28
28
  const SmsAccountConfigSchema = z.object({
@@ -461,7 +461,7 @@ async function prepareSmsMediaAttempt(params) {
461
461
  });
462
462
  let hostedMedia;
463
463
  try {
464
- const { prepareHostedSmsMedia } = await import("./.setup/media-Cmf2YTCW.mjs");
464
+ const { prepareHostedSmsMedia } = await import("./.setup/media-fLUYh_H2.mjs");
465
465
  assertSmsCredentialOwnerAvailable(params.account);
466
466
  const prepared = await prepareHostedSmsMedia({
467
467
  account: params.account,
@@ -572,7 +572,7 @@ async function dispatchSmsInboundEvent(params) {
572
572
  params.log?.warn?.(`SMS sender ${from} is not authorized`);
573
573
  return;
574
574
  }
575
- const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-Cmf2YTCW.mjs")).materializeSmsInboundMedia({
575
+ const materialized = params.msg.media.length > 0 || (params.msg.unavailableMediaCount ?? 0) > 0 ? await (await import("./.setup/media-fLUYh_H2.mjs")).materializeSmsInboundMedia({
576
576
  account: params.account,
577
577
  msg: params.msg,
578
578
  mediaRuntime: params.channelRuntime,
@@ -1075,7 +1075,7 @@ async function registerSmsWebhookRoute(params) {
1075
1075
  throwOnFailure: true,
1076
1076
  log: (msg) => params.log?.info?.(msg),
1077
1077
  handler: async (req, res) => {
1078
- const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-Cmf2YTCW.mjs");
1078
+ const { tryHandleHostedSmsMediaRequest } = await import("./.setup/media-fLUYh_H2.mjs");
1079
1079
  if (await tryHandleHostedSmsMediaRequest(req, res, params.account.accountId)) return true;
1080
1080
  return await webhookHandler(req, res);
1081
1081
  }
@@ -1,2 +1,2 @@
1
- import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries, t as channelSecrets } from "./.setup/secret-contract-Cp0f-YPc.mjs";
1
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries, t as channelSecrets } from "./.setup/secret-contract-BEWVid4f.mjs";
2
2
  export { channelSecrets, collectRuntimeConfigAssignments, secretTargetRegistryEntries };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/sms",
3
- "version": "2026.9.7",
3
+ "version": "2026.10.1-beta.1",
4
4
  "description": "OpenClaw SMS/MMS channel plugin for Twilio messages.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -123,17 +123,17 @@
123
123
  }
124
124
  },
125
125
  "compat": {
126
- "pluginApi": ">=2026.9.7"
126
+ "pluginApi": ">=2026.10.1-beta.1"
127
127
  },
128
128
  "build": {
129
- "openclawVersion": "2026.9.7",
129
+ "openclawVersion": "2026.10.1-beta.1",
130
130
  "bundledDist": false
131
131
  },
132
132
  "install": {
133
133
  "clawhubSpec": "clawhub:@openclaw/sms",
134
134
  "npmSpec": "@openclaw/sms",
135
135
  "defaultChoice": "npm",
136
- "minHostVersion": ">=2026.6.9",
136
+ "minHostVersion": ">=2026.9.8",
137
137
  "allowInvalidConfigRecovery": true
138
138
  },
139
139
  "release": {
@@ -152,7 +152,7 @@
152
152
  "assets/activity.svg"
153
153
  ],
154
154
  "peerDependencies": {
155
- "openclaw": ">=2026.9.7"
155
+ "openclaw": ">=2026.10.1-beta.1"
156
156
  },
157
157
  "peerDependenciesMeta": {
158
158
  "openclaw": {
@@ -1,53 +0,0 @@
1
- import { collectConditionalChannelFieldAssignments, createChannelSecretTargetRegistryEntries, getChannelSurface, hasOwnProperty } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
2
- //#region extensions/sms/src/secret-contract.ts
3
- const DEFAULT_ACCOUNT_ID = "default";
4
- const secretTargetRegistryEntries = createChannelSecretTargetRegistryEntries({
5
- channelKey: "sms",
6
- account: ["authToken"],
7
- channel: ["authToken"]
8
- });
9
- function hasTopLevelSmsAccount(channel) {
10
- for (const field of [
11
- "accountSid",
12
- "fromNumber",
13
- "messagingServiceSid",
14
- "defaultTo"
15
- ]) if (typeof channel[field] === "string" && channel[field].trim().length > 0) return true;
16
- return false;
17
- }
18
- function hasEnvBackedDefaultSmsAccount(env) {
19
- for (const name of [
20
- "TWILIO_ACCOUNT_SID",
21
- "TWILIO_AUTH_TOKEN",
22
- "TWILIO_PHONE_NUMBER",
23
- "TWILIO_SMS_FROM",
24
- "TWILIO_MESSAGING_SERVICE_SID"
25
- ]) if (typeof env[name] === "string" && env[name].trim().length > 0) return true;
26
- return false;
27
- }
28
- function collectRuntimeConfigAssignments(params) {
29
- const resolved = getChannelSurface(params.config, "sms");
30
- if (!resolved) return;
31
- const { channel: sms, surface } = resolved;
32
- const hasExplicitDefaultAccount = surface.accounts.some(({ accountId }) => accountId === DEFAULT_ACCOUNT_ID);
33
- const topLevelSmsAccountActive = (hasTopLevelSmsAccount(sms) || hasEnvBackedDefaultSmsAccount(params.context.env)) && !hasExplicitDefaultAccount;
34
- collectConditionalChannelFieldAssignments({
35
- channelKey: "sms",
36
- field: "authToken",
37
- channel: sms,
38
- surface,
39
- defaults: params.defaults,
40
- context: params.context,
41
- topLevelActiveWithoutAccounts: true,
42
- topLevelInheritedAccountActive: ({ account, enabled }) => topLevelSmsAccountActive || enabled && !hasOwnProperty(account, "authToken"),
43
- accountActive: ({ enabled }) => enabled,
44
- topInactiveReason: "no enabled SMS surface inherits this top-level authToken.",
45
- accountInactiveReason: "SMS account is disabled."
46
- });
47
- }
48
- const channelSecrets = {
49
- secretTargetRegistryEntries,
50
- collectRuntimeConfigAssignments
51
- };
52
- //#endregion
53
- export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };