@openclaw/discord 2026.7.1 → 2026.7.2-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.
Files changed (92) hide show
  1. package/dist/action-runtime-api.js +1 -1
  2. package/dist/{allow-list-C-MqM-B_.js → allow-list-B7qOH5xu.js} +22 -1
  3. package/dist/{api-DPRqYi4Z.js → api--f62GFaS.js} +38 -23
  4. package/dist/api.js +15 -15
  5. package/dist/approval-custom-id-NYPYj9Po.js +58 -0
  6. package/dist/{approval-handler.runtime-Bw2pZNk1.js → approval-handler.runtime-DeyIiw5I.js} +28 -23
  7. package/dist/approval-message-safety-C-8BL6Kv.js +47 -0
  8. package/dist/{audit-MLpDpN3Z.js → audit-Df2w046a.js} +3 -3
  9. package/dist/{channel-actions-D_fjVUZ_.js → channel-actions-ChpBSRcu.js} +6 -4
  10. package/dist/{channel-actions.runtime-CVHlFqQg.js → channel-actions.runtime-D8V8tyCq.js} +41 -12
  11. package/dist/channel-config-api.js +1 -1
  12. package/dist/{channel-DGWPH5u3.js → channel-nYmJ7FKQ.js} +275 -62
  13. package/dist/channel-plugin-api.js +1 -1
  14. package/dist/{channel.setup-tZcpIn4e.js → channel.setup-DyihrqHH.js} +3 -3
  15. package/dist/{components-BIBizbtZ.js → components-BVrfRS-F.js} +78 -52
  16. package/dist/config-api-B18fR8M5.js +3 -0
  17. package/dist/{config-schema-BgIhO3ko.js → config-schema-_bUKcWRm.js} +42 -82
  18. package/dist/conversation-identity-BpkAzklg.js +94 -0
  19. package/dist/{directory-config-ByaUKL1f.js → directory-config-BUe-qq_C.js} +1 -1
  20. package/dist/directory-contract-api.js +1 -1
  21. package/dist/{directory-live-BX79ImQA.js → directory-live-DZByMdPO.js} +6 -6
  22. package/dist/{doctor-Bgoxm5AN.js → doctor-bMaWXFKu.js} +5 -4
  23. package/dist/doctor-contract-api.js +1 -1
  24. package/dist/{doctor-contract-CU7lnZTF.js → doctor-contract-wId6pV41.js} +41 -37
  25. package/dist/{handle-action.guild-admin-CgJSNVui.js → handle-action.guild-admin-C_PQcBEV.js} +12 -12
  26. package/dist/index.js +1 -1
  27. package/dist/legacy-state-migrations-api.js +24 -2
  28. package/dist/{manager.runtime-DaB-CTrt.js → manager.runtime-3RVMVkyx.js} +546 -154
  29. package/dist/{message-handler-DcgvugZt.js → message-handler-CIxWq5Yh.js} +8 -9
  30. package/dist/{message-handler.preflight-DvLXiYVH.js → message-handler.preflight-BI86IbHz.js} +46 -22
  31. package/dist/{message-handler.process-Cjf30P_B.js → message-handler.process-bPS_9_tb.js} +241 -107
  32. package/dist/{message-utils-B_3yA5bN.js → message-utils-D4j07taS.js} +2 -3
  33. package/dist/{outbound-adapter-82RWi_SR.js → outbound-adapter-Czny0Fae.js} +16 -68
  34. package/dist/outbound-components-oJKLj62G.js +99 -0
  35. package/dist/pluralkit-UXq1OyUI.js +40 -0
  36. package/dist/{probe-D1ImJEo2.js → probe-DxjMBeVG.js} +1 -1
  37. package/dist/{probe.runtime-B1dsEeBD.js → probe.runtime-Bc8Oo6e8.js} +1 -1
  38. package/dist/{provider-BkfbC9FQ.js → provider-DWvDNb4J.js} +702 -236
  39. package/dist/{provider-session.runtime-BDjyFw6Y.js → provider-session.runtime-D5pCGibh.js} +3 -3
  40. package/dist/provider.runtime-C2iIfbTs.js +2 -0
  41. package/dist/{resolve-allowlist-common-CWbE8XlH.js → resolve-allowlist-common-B9S8LLBd.js} +5 -5
  42. package/dist/{resolve-channels-CcpvWoRa.js → resolve-channels-BrkWOKdG.js} +7 -7
  43. package/dist/{resolve-users-DJamun9s.js → resolve-users-OjrXXvJP.js} +5 -5
  44. package/dist/{runtime-C6rRmQ6l.js → runtime-C618lis9.js} +223 -33
  45. package/dist/runtime-api.actions.js +2 -2
  46. package/dist/runtime-api.js +23 -23
  47. package/dist/runtime-api.lookup.js +5 -5
  48. package/dist/runtime-api.monitor-DSbfGnzS.js +6 -0
  49. package/dist/runtime-api.monitor.js +7 -7
  50. package/dist/runtime-api.send.js +5 -5
  51. package/dist/runtime-api.threads.js +5 -5
  52. package/dist/{send-iJ0B4bAX.js → send-BFpa_DHn.js} +21 -12
  53. package/dist/{send.components-D0I39utR.js → send.components-BaXQJKWT.js} +15 -10
  54. package/dist/{send.outbound-Bj61Q3a0.js → send.outbound-BlA6VzSE.js} +22 -12
  55. package/dist/{send.receipt-BpBQED_5.js → send.receipt-aegk69an.js} +59 -75
  56. package/dist/{send.shared-wAwMhHDN.js → send.shared-Xz7IMVpu.js} +44 -20
  57. package/dist/{sender-identity-CEsfDF0L.js → sender-identity-C62lBe18.js} +1 -1
  58. package/dist/session-binding-contract-api.js +1 -1
  59. package/dist/setup-plugin-api.js +1 -1
  60. package/dist/{shared-BQVKfnev.js → shared-BLYBt5SA.js} +3 -3
  61. package/dist/{subagent-hooks-B-bJxxGg.js → subagent-hooks-DKJ4p-Oy.js} +2 -2
  62. package/dist/subagent-hooks-api.js +1 -1
  63. package/dist/{system-events-DVnqSyTt.js → system-events-DKwfE-2z.js} +2 -2
  64. package/dist/{target-resolver-CwHaSLt3.js → target-resolver-BQyEHyeS.js} +2 -2
  65. package/dist/targets-DvItNIvP.js +3 -0
  66. package/dist/thread-binding-api-BDZJD4na.js +4 -0
  67. package/dist/thread-binding-api.js +1 -3
  68. package/dist/{thread-bindings-DsTxqu3E.js → thread-bindings-BbzjUuNB.js} +26 -43
  69. package/dist/{thread-bindings.discord-api-BjIf9lGs.js → thread-bindings.discord-api-DJD3qwIN.js} +8 -10
  70. package/dist/{thread-bindings.manager-Bwmtqc3E.js → thread-bindings.manager-BIBm6bQd.js} +4 -4
  71. package/dist/{thread-bindings.session-updates-Chs3HgGa.js → thread-bindings.session-updates-eRcJlzIU.js} +1 -1
  72. package/dist/{thread-bindings.state-iSWjCYjB.js → thread-bindings.state-9VAxhVf6.js} +3 -14
  73. package/dist/{timeouts-C5TBc_9x.js → timeouts-ZRc9Lw4y.js} +3 -15
  74. package/dist/timeouts.js +1 -1
  75. package/dist/{transcripts-source-BvvM5Ns9.js → transcripts-source-CLZ5X8fh.js} +1 -1
  76. package/dist/transcripts-source-api.js +1 -1
  77. package/dist/{typing-BVcJgILg.js → typing-BnYT7Szq.js} +2 -2
  78. package/node_modules/p-map/index.d.ts +155 -0
  79. package/node_modules/p-map/index.js +284 -0
  80. package/node_modules/p-map/license +9 -0
  81. package/node_modules/p-map/package.json +57 -0
  82. package/node_modules/p-map/readme.md +190 -0
  83. package/npm-shrinkwrap.json +16 -3
  84. package/openclaw.plugin.json +70 -2
  85. package/package.json +6 -4
  86. package/dist/config-api-JiPdJeb0.js +0 -2
  87. package/dist/conversation-identity-DWC5d8Sy.js +0 -272
  88. package/dist/pluralkit-DcD-3EcL.js +0 -24
  89. package/dist/preview-streaming-DXT8oJdo.js +0 -8
  90. package/dist/provider.runtime-WrJXikSv.js +0 -2
  91. package/dist/runtime-api.monitor-C2_WVtJf.js +0 -6
  92. package/dist/targets-69w7c3vU.js +0 -3
@@ -1,10 +1,12 @@
1
- import { C as RequestClient, F as serializePayload, I as Embed, Nt as getGuild, Pt as getGuildMember, T as RateLimitError, _t as getChannel, dt as createChannelMessage, i as resolveDiscordReplyMessageId, ot as createUserDmChannel, st as getCurrentUser, u as chunkDiscordTextWithMode } from "./send.receipt-BpBQED_5.js";
1
+ import { D as RateLimitError, Ft as getGuild, It as getGuildMember, L as serializePayload, R as Embed, T as RequestClient, ct as createUserDmChannel, i as resolveDiscordReplyMessageId, lt as getCurrentUser, pt as createChannelMessage, u as chunkDiscordTextWithMode, yt as getChannel } from "./send.receipt-aegk69an.js";
2
2
  import { a as mergeDiscordAccountConfig, p as normalizeDiscordToken, s as resolveDiscordAccount } from "./accounts-P19jm1lf.js";
3
- import { t as parseAndResolveDiscordTarget } from "./target-resolver-CwHaSLt3.js";
3
+ import { t as parseAndResolveDiscordTarget } from "./target-resolver-BQyEHyeS.js";
4
4
  import { normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
6
6
  import { ChannelType, MessageFlags, PermissionFlagsBits } from "discord-api-types/v10";
7
7
  import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
8
+ import { randomBytes } from "node:crypto";
9
+ import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
8
10
  import { collectErrorGraphCandidates, extractErrorCode, formatErrorMessage, readErrorName } from "openclaw/plugin-sdk/error-runtime";
9
11
  import { PollLayoutType } from "discord-api-types/payloads/v10";
10
12
  import { buildOutboundMediaLoadOptions, extensionForMime, normalizePollDurationHours, normalizePollInput } from "openclaw/plugin-sdk/media-runtime";
@@ -116,6 +118,13 @@ const DISCORD_RETRYABLE_ERROR_CODES = /* @__PURE__ */ new Set([
116
118
  "UND_ERR_SOCKET"
117
119
  ]);
118
120
  const DISCORD_TRANSIENT_MESSAGE_RE = /\b(?:bad gateway|fetch failed|network error|networkerror|service unavailable|socket hang up|temporarily unavailable|timed out|timeout)\b|connection (?:closed|reset|refused)/i;
121
+ const DISCORD_PRECONNECT_ERROR_CODES = /* @__PURE__ */ new Set([
122
+ "EAI_AGAIN",
123
+ "ECONNREFUSED",
124
+ "ENETUNREACH",
125
+ "ENOTFOUND",
126
+ "UND_ERR_CONNECT_TIMEOUT"
127
+ ]);
119
128
  const log = createSubsystemLogger("discord/retry");
120
129
  function readDiscordErrorStatus(err) {
121
130
  if (!err || typeof err !== "object") return;
@@ -133,6 +142,18 @@ function isRetryableDiscordTransientError(err) {
133
142
  }
134
143
  return false;
135
144
  }
145
+ function isRetryableDiscordPreConnectError(err) {
146
+ if (err instanceof RateLimitError) return true;
147
+ for (const candidate of collectErrorGraphCandidates(err, (current) => [current.cause, current.error])) {
148
+ if (readDiscordErrorStatus(candidate) === 429) return true;
149
+ const code = extractErrorCode(candidate);
150
+ if (code && DISCORD_PRECONNECT_ERROR_CODES.has(code.toUpperCase())) return true;
151
+ }
152
+ return false;
153
+ }
154
+ function resolveDiscordRetryPredicate(safety) {
155
+ return safety === "non-idempotent-create" ? isRetryableDiscordPreConnectError : isRetryableDiscordTransientError;
156
+ }
136
157
  function isRetryableDiscordGatewayTransportError(err) {
137
158
  if (!isRetryableDiscordTransientError(err) || err instanceof RateLimitError) return false;
138
159
  return !collectErrorGraphCandidates(err, (current) => [current.cause, current.error]).some((candidate) => readDiscordErrorStatus(candidate) !== void 0);
@@ -143,7 +164,8 @@ function createDiscordRetryRunner(params) {
143
164
  ...params.retry
144
165
  });
145
166
  const attempts = retryConfig.attempts > 1 ? retryConfig.attempts + DISCORD_GATEWAY_RECONNECT_EXTRA_ATTEMPTS : retryConfig.attempts;
146
- return (fn, label) => {
167
+ return (fn, label, options) => {
168
+ const isRetryable = resolveDiscordRetryPredicate(options?.safety ?? "idempotent");
147
169
  let observedGatewayDisconnect = false;
148
170
  const runRequest = async () => {
149
171
  observedGatewayDisconnect ||= params.isGatewayDisconnected?.() === true;
@@ -158,7 +180,7 @@ function createDiscordRetryRunner(params) {
158
180
  ...retryConfig,
159
181
  attempts,
160
182
  label,
161
- shouldRetry: (err, attempt) => isRetryableDiscordTransientError(err) && (attempt < retryConfig.attempts || observedGatewayDisconnect && isRetryableDiscordGatewayTransportError(err)),
183
+ shouldRetry: (err, attempt) => isRetryable(err) && (attempt < retryConfig.attempts || observedGatewayDisconnect && isRetryableDiscordGatewayTransportError(err)),
162
184
  retryAfterMs: (err) => err instanceof RateLimitError ? err.retryAfter * 1e3 : void 0,
163
185
  onRetry: params.verbose ? (info) => {
164
186
  const maxAttempts = observedGatewayDisconnect ? attempts : retryConfig.attempts;
@@ -529,6 +551,9 @@ const DISCORD_MAX_EVENT_COVER_BYTES = 8 * 1024 * 1024;
529
551
  //#region extensions/discord/src/send.message-request.ts
530
552
  const SUPPRESS_EMBEDS_FLAG = MessageFlags.SuppressEmbeds;
531
553
  const SUPPRESS_NOTIFICATIONS_FLAG = MessageFlags.SuppressNotifications;
554
+ function createDiscordMessageNonce() {
555
+ return randomBytes(12).toString("hex");
556
+ }
532
557
  function resolveDiscordSendComponents(params) {
533
558
  if (!params.components || !params.isFirst) return;
534
559
  return typeof params.components === "function" ? params.components(params.text) : params.components;
@@ -560,12 +585,16 @@ function resolveDiscordMessageFlags(params) {
560
585
  return flags || void 0;
561
586
  }
562
587
  function buildDiscordMessageRequest(params) {
588
+ const payload = buildDiscordMessagePayload(params);
589
+ const nonce = params.endpoint === "create-message" ? params.nonce ?? createDiscordMessageNonce() : void 0;
563
590
  return stripUndefinedFields({
564
- ...serializePayload(buildDiscordMessagePayload(params)),
591
+ ...serializePayload(payload),
565
592
  ...params.replyTo ? { message_reference: {
566
593
  message_id: params.replyTo,
567
594
  fail_if_not_exists: false
568
- } } : {}
595
+ } } : {},
596
+ nonce,
597
+ enforce_nonce: nonce ? true : void 0
569
598
  });
570
599
  }
571
600
  function stripUndefinedFields(value) {
@@ -687,9 +716,9 @@ async function resolveDiscordTargetChannelId(raw, opts) {
687
716
  const { rest, request } = createDiscordClient(opts);
688
717
  return await resolveChannelId(rest, recipient, request);
689
718
  }
690
- async function resolveDiscordChannelType(rest, channelId) {
719
+ async function resolveDiscordChannel(rest, channelId) {
691
720
  try {
692
- return (await getChannel(rest, channelId))?.type;
721
+ return await getChannel(rest, channelId);
693
722
  } catch {
694
723
  return;
695
724
  }
@@ -702,12 +731,6 @@ function buildDiscordTextChunks(text, opts = {}) {
702
731
  chunkMode: opts.chunkMode
703
732
  }));
704
733
  }
705
- function toDiscordFileBlob(data) {
706
- if (data instanceof Blob) return data;
707
- const arrayBuffer = new ArrayBuffer(data.byteLength);
708
- new Uint8Array(arrayBuffer).set(data);
709
- return new Blob([arrayBuffer]);
710
- }
711
734
  async function sendDiscordText(params) {
712
735
  const { rest, channelId, text, request, reply, maxLinesPerMessage, components, embeds, allowedMentions, chunkMode, silent, suppressEmbeds, maxChars, onResult } = params;
713
736
  if (!text.trim()) throw new Error("Message must be non-empty for Discord sends");
@@ -732,6 +755,7 @@ async function sendDiscordText(params) {
732
755
  suppressEmbeds: suppressEmbeds && !chunkEmbeds?.length
733
756
  });
734
757
  const body = buildDiscordMessageRequest({
758
+ endpoint: "create-message",
735
759
  text: chunk,
736
760
  components: chunkComponents,
737
761
  embeds: chunkEmbeds,
@@ -740,12 +764,12 @@ async function sendDiscordText(params) {
740
764
  replyTo: chunkReplyTo
741
765
  });
742
766
  return {
743
- result: await request(() => createChannelMessage(rest, channelId, { body }), "text"),
767
+ result: await request(() => createChannelMessage(rest, channelId, { body }), "text", { safety: "nonce-protected-create" }),
744
768
  replyToId: chunkReplyTo
745
769
  };
746
770
  };
747
771
  if (chunks.length === 1) {
748
- const { result, replyToId } = await sendChunk(chunks[0], true);
772
+ const { result, replyToId } = await sendChunk(expectDefined(chunks.at(0), "single Discord text chunk"), true);
749
773
  await onResult?.(result, "text", replyToId);
750
774
  return {
751
775
  ...result,
@@ -781,7 +805,6 @@ async function sendDiscordMedia(params) {
781
805
  maxChars
782
806
  }) : [];
783
807
  const caption = chunks[0] ?? "";
784
- const fileData = toDiscordFileBlob(media.buffer);
785
808
  const captionComponents = resolveDiscordSendComponents({
786
809
  components,
787
810
  text: caption,
@@ -792,6 +815,7 @@ async function sendDiscordMedia(params) {
792
815
  isFirst: true
793
816
  });
794
817
  const body = buildDiscordMessageRequest({
818
+ endpoint: "create-message",
795
819
  text: caption,
796
820
  components: captionComponents,
797
821
  embeds: captionEmbeds,
@@ -802,13 +826,13 @@ async function sendDiscordMedia(params) {
802
826
  }),
803
827
  replyTo: resolveDiscordReplyMessageId(reply, true),
804
828
  files: [{
805
- data: fileData,
829
+ data: media.buffer,
806
830
  name: resolvedFileName
807
831
  }]
808
832
  });
809
833
  let res;
810
834
  try {
811
- res = await request(() => createChannelMessage(rest, channelId, { body }), "media");
835
+ res = await request(() => createChannelMessage(rest, channelId, { body }), "media", { safety: "nonce-protected-create" });
812
836
  } catch (err) {
813
837
  if (!isDiscordUploadTooLargeError(err)) throw err;
814
838
  return sendDiscordText({
@@ -860,4 +884,4 @@ function formatReactionEmoji(emoji) {
860
884
  return buildReactionIdentifier(emoji);
861
885
  }
862
886
  //#endregion
863
- export { hasAllGuildPermissionsDiscord as A, DISCORD_REST_TIMEOUT_MS as B, DISCORD_MAX_STICKER_BYTES as C, canViewDiscordGuildChannel as D, canManageGuildRoleDiscord as E, createDiscordClient as F, registerGateway as G, withValidatedDiscordProxy as H, createDiscordRestClient as I, unregisterGateway as K, createDiscordRuntimeAccountContext as L, hasAnyGuildPermissionDiscord as M, isThreadChannelType as N, fetchChannelPermissionsDiscord as O, parseAndResolveChannelRecipient as P, resolveDiscordClientAccountContext as R, DISCORD_MAX_EVENT_COVER_BYTES as S, canManageGuildMemberRoleDiscord as T, clearGateways as U, validateDiscordProxyUrl as V, getGateway as W, resolveDiscordMessageFlags as _, normalizeDiscordPollInput as a, stripUndefinedFields as b, normalizeStickerIds as c, resolveDiscordTargetChannelId as d, sendDiscordMedia as f, buildDiscordMessageRequest as g, SUPPRESS_NOTIFICATIONS_FLAG as h, formatReactionEmoji as i, hasAnyChannelPermissionDiscord as j, fetchMemberGuildPermissionsDiscord as k, resolveChannelId as l, toDiscordFileBlob as m, buildDiscordTextChunks as n, normalizeEmojiName as o, sendDiscordText as p, buildReactionIdentifier as r, normalizeReactionEmoji as s, buildDiscordSendError as t, resolveDiscordChannelType as u, resolveDiscordSendComponents as v, DiscordSendError as w, DISCORD_MAX_EMOJI_BYTES as x, resolveDiscordSendEmbeds as y, resolveDiscordRest as z };
887
+ export { hasAllGuildPermissionsDiscord as A, DISCORD_REST_TIMEOUT_MS as B, DISCORD_MAX_STICKER_BYTES as C, canViewDiscordGuildChannel as D, canManageGuildRoleDiscord as E, createDiscordClient as F, registerGateway as G, withValidatedDiscordProxy as H, createDiscordRestClient as I, unregisterGateway as K, createDiscordRuntimeAccountContext as L, hasAnyGuildPermissionDiscord as M, isThreadChannelType as N, fetchChannelPermissionsDiscord as O, parseAndResolveChannelRecipient as P, resolveDiscordClientAccountContext as R, DISCORD_MAX_EVENT_COVER_BYTES as S, canManageGuildMemberRoleDiscord as T, clearGateways as U, validateDiscordProxyUrl as V, getGateway as W, resolveDiscordMessageFlags as _, normalizeDiscordPollInput as a, stripUndefinedFields as b, normalizeStickerIds as c, resolveDiscordTargetChannelId as d, sendDiscordMedia as f, createDiscordMessageNonce as g, buildDiscordMessageRequest as h, formatReactionEmoji as i, hasAnyChannelPermissionDiscord as j, fetchMemberGuildPermissionsDiscord as k, resolveChannelId as l, SUPPRESS_NOTIFICATIONS_FLAG as m, buildDiscordTextChunks as n, normalizeEmojiName as o, sendDiscordText as p, buildReactionIdentifier as r, normalizeReactionEmoji as s, buildDiscordSendError as t, resolveDiscordChannel as u, resolveDiscordSendComponents as v, DiscordSendError as w, DISCORD_MAX_EMOJI_BYTES as x, resolveDiscordSendEmbeds as y, resolveDiscordRest as z };
@@ -1,4 +1,4 @@
1
- import { b as formatDiscordUserTag } from "./allow-list-C-MqM-B_.js";
1
+ import { x as formatDiscordUserTag } from "./allow-list-B7qOH5xu.js";
2
2
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/discord/src/monitor/sender-identity.ts
4
4
  function resolveDiscordWebhookId(message) {
@@ -1,2 +1,2 @@
1
- import { i as testing, n as createThreadBindingManager } from "./thread-bindings.manager-Bwmtqc3E.js";
1
+ import { i as testing, n as createThreadBindingManager } from "./thread-bindings.manager-BIBm6bQd.js";
2
2
  export { createThreadBindingManager, testing as discordThreadBindingTesting };
@@ -1,2 +1,2 @@
1
- import { t as discordSetupPlugin } from "./channel.setup-tZcpIn4e.js";
1
+ import { t as discordSetupPlugin } from "./channel.setup-DyihrqHH.js";
2
2
  export { discordSetupPlugin };
@@ -1,8 +1,8 @@
1
1
  import { t as inspectDiscordAccount } from "./account-inspect-DDZtT5C8.js";
2
2
  import { a as mergeDiscordAccountConfig, c as resolveDiscordAccountAllowFrom, d as resolveDiscordAccountDmPolicy, n as isDiscordAccountEnabledForRuntime, o as resolveDefaultDiscordAccountId, r as listDiscordAccountIds, s as resolveDiscordAccount, u as resolveDiscordAccountDisabledReason } from "./accounts-P19jm1lf.js";
3
3
  import { i as getChatChannelMeta, o as resolveConfiguredFromCredentialStatuses } from "./channel-api-CAJ0wMoV.js";
4
- import { t as DiscordChannelConfigSchema } from "./config-schema-BgIhO3ko.js";
5
- import { n as normalizeCompatibilityConfig } from "./doctor-contract-CU7lnZTF.js";
4
+ import { t as DiscordChannelConfigSchema } from "./config-schema-_bUKcWRm.js";
5
+ import { n as normalizeCompatibilityConfig } from "./doctor-contract-wId6pV41.js";
6
6
  import { n as secretTargetRegistryEntries, t as collectRuntimeConfigAssignments } from "./secret-config-contract-BDNrRWvd.js";
7
7
  import { n as unsupportedSecretRefSurfacePatterns, t as collectUnsupportedSecretRefConfigCandidates } from "./security-contract-DSHk7I2w.js";
8
8
  import { t as deriveLegacySessionChatType } from "./session-contract-BO5tlIdl.js";
@@ -66,7 +66,7 @@ const DISCORD_LEGACY_CONFIG_RULES = [];
66
66
  //#endregion
67
67
  //#region extensions/discord/src/shared.ts
68
68
  const DISCORD_CHANNEL = "discord";
69
- const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-Bgoxm5AN.js"));
69
+ const loadDiscordDoctorModule = createLazyRuntimeModule(() => import("./doctor-bMaWXFKu.js"));
70
70
  const discordDoctor = {
71
71
  dmAllowFromMode: "topOnly",
72
72
  groupModel: "route",
@@ -1,6 +1,6 @@
1
- import { Jt as __exportAll } from "./send.receipt-BpBQED_5.js";
1
+ import { Xt as __exportAll } from "./send.receipt-aegk69an.js";
2
2
  import { s as resolveDiscordAccount } from "./accounts-P19jm1lf.js";
3
- import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-DsTxqu3E.js";
3
+ import { n as autoBindSpawnedDiscordSubagent, o as unbindThreadBindingsBySessionKey, r as listThreadBindingsBySessionKey } from "./thread-bindings-BbzjUuNB.js";
4
4
  import { normalizeOptionalLowercaseString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { formatThreadBindingDisabledError, formatThreadBindingSpawnDisabledError, resolveThreadBindingSpawnPolicy } from "openclaw/plugin-sdk/conversation-runtime";
6
6
  //#region extensions/discord/src/subagent-hooks.ts
@@ -1,6 +1,6 @@
1
1
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
2
2
  //#region extensions/discord/subagent-hooks-api.ts
3
- const loadDiscordSubagentHooksModule = createLazyRuntimeModule(() => import("./subagent-hooks-B-bJxxGg.js").then((n) => n.i));
3
+ const loadDiscordSubagentHooksModule = createLazyRuntimeModule(() => import("./subagent-hooks-DKJ4p-Oy.js").then((n) => n.i));
4
4
  function registerDiscordSubagentHooks(api) {
5
5
  api.on("subagent_ended", async (event) => {
6
6
  const { handleDiscordSubagentEnded } = await loadDiscordSubagentHooksModule();
@@ -1,5 +1,5 @@
1
- import { d as discord_exports } from "./send.receipt-BpBQED_5.js";
2
- import { b as formatDiscordUserTag } from "./allow-list-C-MqM-B_.js";
1
+ import { d as discord_exports } from "./send.receipt-aegk69an.js";
2
+ import { x as formatDiscordUserTag } from "./allow-list-B7qOH5xu.js";
3
3
  //#region extensions/discord/src/monitor/system-events.ts
4
4
  function resolveDiscordSystemEvent(message, location) {
5
5
  switch (message.type) {
@@ -1,6 +1,6 @@
1
- import { Jt as __exportAll, Kt as parseDiscordTarget, o as allowFromContainsDiscordUserId } from "./send.receipt-BpBQED_5.js";
1
+ import { Jt as parseDiscordTarget, Xt as __exportAll, o as allowFromContainsDiscordUserId } from "./send.receipt-aegk69an.js";
2
2
  import { c as resolveDiscordAccountAllowFrom, s as resolveDiscordAccount } from "./accounts-P19jm1lf.js";
3
- import { i as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-BX79ImQA.js";
3
+ import { i as rememberDiscordDirectoryUser, r as listDiscordDirectoryPeersLive } from "./directory-live-DZByMdPO.js";
4
4
  import { buildMessagingTarget } from "openclaw/plugin-sdk/channel-targets";
5
5
  //#region extensions/discord/src/send-target-parsing.ts
6
6
  const parseDiscordSendTarget = (raw, options = {}) => parseDiscordTarget(raw, options);
@@ -0,0 +1,3 @@
1
+ import "./send.receipt-aegk69an.js";
2
+ import "./target-resolver-BQyEHyeS.js";
3
+ export {};
@@ -0,0 +1,4 @@
1
+ //#region extensions/discord/src/thread-binding-api.ts
2
+ const defaultTopLevelPlacement = "child";
3
+ //#endregion
4
+ export { defaultTopLevelPlacement as t };
@@ -1,4 +1,2 @@
1
- //#region extensions/discord/thread-binding-api.ts
2
- const defaultTopLevelPlacement = "child";
3
- //#endregion
1
+ import { t as defaultTopLevelPlacement } from "./thread-binding-api-BDZJD4na.js";
4
2
  export { defaultTopLevelPlacement };
@@ -1,13 +1,14 @@
1
- import { Jt as __exportAll, Kt as parseDiscordTarget } from "./send.receipt-BpBQED_5.js";
2
- import "./targets-69w7c3vU.js";
3
- import { A as shouldPersistBindingMutations, C as resolveThreadBindingIdleTimeoutMs$1, D as saveBindingsToDisk, E as resolveThreadBindingMaxAgeMs$1, T as resolveThreadBindingMaxAgeExpiresAt, d as isRecentlyUnboundThreadWebhookMessage, g as rememberRecentUnboundWebhookEcho, h as normalizeThreadId, n as MANAGERS_BY_ACCOUNT_ID, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, w as resolveThreadBindingInactivityExpiresAt, y as removeBindingRecord } from "./thread-bindings.state-iSWjCYjB.js";
4
- import { n as setThreadBindingMaxAgeBySessionKey, r as resolveBindingIdsForTargetSession, t as setThreadBindingIdleTimeoutBySessionKey } from "./thread-bindings.session-updates-Chs3HgGa.js";
5
- import { _ as formatThreadBindingDurationLabel, b as resolveThreadBindingThreadName, g as resolveThreadBindingPersonaFromRecord, h as resolveThreadBindingPersona, s as resolveChannelIdForBinding, y as resolveThreadBindingIntroText } from "./thread-bindings.discord-api-BjIf9lGs.js";
6
- import { i as testing, n as createThreadBindingManager, r as getThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-Bwmtqc3E.js";
1
+ import { Jt as parseDiscordTarget, Xt as __exportAll } from "./send.receipt-aegk69an.js";
2
+ import "./targets-DvItNIvP.js";
3
+ import { A as shouldPersistBindingMutations, C as resolveThreadBindingIdleTimeoutMs$1, D as saveBindingsToDisk, E as resolveThreadBindingMaxAgeMs$1, T as resolveThreadBindingMaxAgeExpiresAt, d as isRecentlyUnboundThreadWebhookMessage, g as rememberRecentUnboundWebhookEcho, h as normalizeThreadId, n as MANAGERS_BY_ACCOUNT_ID, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, w as resolveThreadBindingInactivityExpiresAt, y as removeBindingRecord } from "./thread-bindings.state-9VAxhVf6.js";
4
+ import { n as setThreadBindingMaxAgeBySessionKey, r as resolveBindingIdsForTargetSession, t as setThreadBindingIdleTimeoutBySessionKey } from "./thread-bindings.session-updates-eRcJlzIU.js";
5
+ import { _ as formatThreadBindingDurationLabel, b as resolveThreadBindingThreadName, g as resolveThreadBindingPersonaFromRecord, h as resolveThreadBindingPersona, s as resolveChannelIdForBinding, y as resolveThreadBindingIntroText } from "./thread-bindings.discord-api-DJD3qwIN.js";
6
+ import { i as testing, n as createThreadBindingManager, r as getThreadBindingManager, t as createNoopThreadBindingManager } from "./thread-bindings.manager-BIBm6bQd.js";
7
7
  import { normalizeOptionalLowercaseString, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
8
8
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
9
9
  import { resolveThreadBindingIdleTimeoutMs, resolveThreadBindingMaxAgeMs, resolveThreadBindingsEnabled } from "openclaw/plugin-sdk/conversation-runtime";
10
10
  import { readAcpSessionEntry } from "openclaw/plugin-sdk/acp-runtime";
11
+ import pMap from "p-map";
11
12
  //#region extensions/discord/src/monitor/thread-bindings.config.ts
12
13
  function resolveDiscordThreadBindingIdleTimeoutMs(params) {
13
14
  const accountId = normalizeAccountId(params.accountId);
@@ -30,23 +31,6 @@ function resolveDiscordThreadBindingMaxAgeMs(params) {
30
31
  //#endregion
31
32
  //#region extensions/discord/src/monitor/thread-bindings.lifecycle.ts
32
33
  const ACP_STARTUP_HEALTH_PROBE_CONCURRENCY_LIMIT = 8;
33
- async function mapWithConcurrency(params) {
34
- if (params.items.length === 0) return [];
35
- const limit = Math.max(1, Math.floor(params.limit));
36
- const resultsByIndex = /* @__PURE__ */ new Map();
37
- let nextIndex = 0;
38
- const runWorker = async () => {
39
- for (;;) {
40
- const index = nextIndex;
41
- nextIndex += 1;
42
- if (index >= params.items.length) return;
43
- resultsByIndex.set(index, await params.worker(params.items[index], index));
44
- }
45
- };
46
- const workers = Array.from({ length: Math.min(limit, params.items.length) }, () => runWorker());
47
- await Promise.all(workers);
48
- return params.items.map((_item, index) => resultsByIndex.get(index));
49
- }
50
34
  function listThreadBindingsForAccount(accountId) {
51
35
  const manager = getThreadBindingManager(accountId);
52
36
  if (!manager) return [];
@@ -177,28 +161,27 @@ async function reconcileAcpThreadBindingsOnStartup(params) {
177
161
  });
178
162
  }
179
163
  if (params.healthProbe && probeTargets.length > 0) {
180
- const probeResults = await mapWithConcurrency({
181
- items: probeTargets,
182
- limit: ACP_STARTUP_HEALTH_PROBE_CONCURRENCY_LIMIT,
183
- worker: async ({ binding, sessionKey, session }) => {
184
- try {
185
- return {
186
- binding,
187
- status: (await params.healthProbe?.({
188
- cfg: params.cfg,
189
- accountId: manager.accountId,
190
- sessionKey,
191
- binding,
192
- session
193
- }))?.status ?? "uncertain"
194
- };
195
- } catch {
196
- return {
164
+ const probeResults = await pMap(probeTargets, async ({ binding, sessionKey, session }) => {
165
+ try {
166
+ return {
167
+ binding,
168
+ status: (await params.healthProbe?.({
169
+ cfg: params.cfg,
170
+ accountId: manager.accountId,
171
+ sessionKey,
197
172
  binding,
198
- status: "uncertain"
199
- };
200
- }
173
+ session
174
+ }))?.status ?? "uncertain"
175
+ };
176
+ } catch {
177
+ return {
178
+ binding,
179
+ status: "uncertain"
180
+ };
201
181
  }
182
+ }, {
183
+ concurrency: ACP_STARTUP_HEALTH_PROBE_CONCURRENCY_LIMIT,
184
+ stopOnError: true
202
185
  });
203
186
  for (const probeResult of probeResults) if (probeResult.status === "stale") staleBindings.push(probeResult.binding);
204
187
  }
@@ -1,12 +1,13 @@
1
- import { _t as getChannel, at as createChannelWebhook, qt as resolveDiscordChannelId } from "./send.receipt-BpBQED_5.js";
2
- import { I as createDiscordRestClient } from "./send.shared-wAwMhHDN.js";
3
- import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-iJ0B4bAX.js";
4
- import { t as sendMessageDiscord } from "./send.outbound-Bj61Q3a0.js";
5
- import { M as toReusableWebhookKey, _ as rememberReusableWebhook, i as REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL, t as BINDINGS_BY_THREAD_ID } from "./thread-bindings.state-iSWjCYjB.js";
1
+ import { Yt as resolveDiscordChannelId, st as createChannelWebhook, yt as getChannel } from "./send.receipt-aegk69an.js";
2
+ import { I as createDiscordRestClient } from "./send.shared-Xz7IMVpu.js";
3
+ import { c as sendWebhookMessageDiscord, u as createThreadDiscord } from "./send-BFpa_DHn.js";
4
+ import { t as sendMessageDiscord } from "./send.outbound-BlA6VzSE.js";
5
+ import { M as toReusableWebhookKey, _ as rememberReusableWebhook, i as REUSABLE_WEBHOOKS_BY_ACCOUNT_CHANNEL, t as BINDINGS_BY_THREAD_ID } from "./thread-bindings.state-9VAxhVf6.js";
6
6
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  import { ChannelType } from "discord-api-types/v10";
8
8
  import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
9
9
  import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
10
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
10
11
  import { SYSTEM_MARK } from "openclaw/plugin-sdk/text-chunking";
11
12
  import { formatThreadBindingDurationLabel, resolveThreadBindingFarewellText, resolveThreadBindingIntroText, resolveThreadBindingThreadName } from "openclaw/plugin-sdk/conversation-runtime";
12
13
  //#region extensions/discord/src/monitor/thread-bindings.persona.ts
@@ -16,7 +17,7 @@ function normalizePersonaLabel(value) {
16
17
  return value.replace(/\s+/g, " ").trim() || void 0;
17
18
  }
18
19
  function resolveThreadBindingPersona(params) {
19
- return `${SYSTEM_MARK} ${normalizePersonaLabel(params.label) || normalizePersonaLabel(params.agentId) || "agent"}`.slice(0, THREAD_BINDING_PERSONA_MAX_CHARS);
20
+ return truncateUtf16Safe(`${SYSTEM_MARK} ${normalizePersonaLabel(params.label) || normalizePersonaLabel(params.agentId) || "agent"}`, THREAD_BINDING_PERSONA_MAX_CHARS);
20
21
  }
21
22
  function resolveThreadBindingPersonaFromRecord(record) {
22
23
  return resolveThreadBindingPersona({
@@ -227,10 +228,7 @@ async function resolveChannelIdForBinding(params) {
227
228
  }
228
229
  async function createThreadForBinding(params) {
229
230
  try {
230
- return (normalizeOptionalString((await createThreadDiscord(params.channelId, {
231
- name: params.threadName,
232
- autoArchiveMinutes: 60
233
- }, {
231
+ return (normalizeOptionalString((await createThreadDiscord(params.channelId, { name: params.threadName }, {
234
232
  cfg: params.cfg,
235
233
  accountId: params.accountId,
236
234
  token: params.token
@@ -1,7 +1,7 @@
1
- import { Jt as __exportAll, _t as getChannel, qt as resolveDiscordChannelId } from "./send.receipt-BpBQED_5.js";
2
- import { I as createDiscordRestClient } from "./send.shared-wAwMhHDN.js";
3
- import { C as resolveThreadBindingIdleTimeoutMs$1, D as saveBindingsToDisk, E as resolveThreadBindingMaxAgeMs$1, F as THREAD_BINDINGS_SWEEP_INTERVAL_MS, N as DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS, O as setBindingRecord, S as resolveBindingRecordKey, T as resolveThreadBindingMaxAgeExpiresAt, b as resetThreadBindingsForTests, c as ensureBindingsLoaded, g as rememberRecentUnboundWebhookEcho, h as normalizeThreadId, k as shouldDefaultPersist, l as forgetThreadBindingToken, m as normalizeThreadBindingDurationMs, n as MANAGERS_BY_ACCOUNT_ID, p as normalizeTargetKind, r as PERSIST_BY_ACCOUNT_ID, s as THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, v as rememberThreadBindingToken, w as resolveThreadBindingInactivityExpiresAt, x as resolveBindingIdsForSession, y as removeBindingRecord } from "./thread-bindings.state-iSWjCYjB.js";
4
- import { a as isThreadArchived, b as resolveThreadBindingThreadName, c as summarizeDiscordError, i as isDiscordThreadGoneError, n as createWebhookForChannel, o as maybeSendBindingMessage, r as findReusableWebhook, s as resolveChannelIdForBinding, t as createThreadForBinding, v as resolveThreadBindingFarewellText } from "./thread-bindings.discord-api-BjIf9lGs.js";
1
+ import { Xt as __exportAll, Yt as resolveDiscordChannelId, yt as getChannel } from "./send.receipt-aegk69an.js";
2
+ import { I as createDiscordRestClient } from "./send.shared-Xz7IMVpu.js";
3
+ import { C as resolveThreadBindingIdleTimeoutMs$1, D as saveBindingsToDisk, E as resolveThreadBindingMaxAgeMs$1, F as THREAD_BINDINGS_SWEEP_INTERVAL_MS, N as DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS, O as setBindingRecord, S as resolveBindingRecordKey, T as resolveThreadBindingMaxAgeExpiresAt, b as resetThreadBindingsForTests, c as ensureBindingsLoaded, g as rememberRecentUnboundWebhookEcho, h as normalizeThreadId, k as shouldDefaultPersist, l as forgetThreadBindingToken, m as normalizeThreadBindingDurationMs, n as MANAGERS_BY_ACCOUNT_ID, p as normalizeTargetKind, r as PERSIST_BY_ACCOUNT_ID, s as THREAD_BINDING_TOUCH_PERSIST_MIN_INTERVAL_MS, t as BINDINGS_BY_THREAD_ID, u as getThreadBindingToken, v as rememberThreadBindingToken, w as resolveThreadBindingInactivityExpiresAt, x as resolveBindingIdsForSession, y as removeBindingRecord } from "./thread-bindings.state-9VAxhVf6.js";
4
+ import { a as isThreadArchived, b as resolveThreadBindingThreadName, c as summarizeDiscordError, i as isDiscordThreadGoneError, n as createWebhookForChannel, o as maybeSendBindingMessage, r as findReusableWebhook, s as resolveChannelIdForBinding, t as createThreadForBinding, v as resolveThreadBindingFarewellText } from "./thread-bindings.discord-api-DJD3qwIN.js";
5
5
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { normalizeAccountId, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
7
7
  import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
@@ -1,4 +1,4 @@
1
- import { A as shouldPersistBindingMutations, D as saveBindingsToDisk, O as setBindingRecord, c as ensureBindingsLoaded, t as BINDINGS_BY_THREAD_ID, x as resolveBindingIdsForSession } from "./thread-bindings.state-iSWjCYjB.js";
1
+ import { A as shouldPersistBindingMutations, D as saveBindingsToDisk, O as setBindingRecord, c as ensureBindingsLoaded, t as BINDINGS_BY_THREAD_ID, x as resolveBindingIdsForSession } from "./thread-bindings.state-9VAxhVf6.js";
2
2
  import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
3
3
  //#region extensions/discord/src/monitor/thread-bindings.session-shared.ts
4
4
  function normalizeNonNegativeMs(raw) {
@@ -89,7 +89,7 @@ function normalizePersistedBinding(threadIdKey, raw) {
89
89
  const value = raw;
90
90
  const threadId = normalizeThreadId(value.threadId ?? threadIdKey);
91
91
  const channelId = normalizeOptionalString(value.channelId) ?? "";
92
- const targetSessionKey = normalizeOptionalString(value.targetSessionKey) ?? normalizeOptionalString(value.sessionKey) ?? "";
92
+ const targetSessionKey = normalizeOptionalString(value.targetSessionKey) ?? "";
93
93
  if (!threadId || !channelId || !targetSessionKey) return null;
94
94
  const accountId = normalizeAccountId(value.accountId);
95
95
  const targetKind = normalizeTargetKind(value.targetKind, targetSessionKey);
@@ -103,17 +103,6 @@ function normalizePersistedBinding(threadIdKey, raw) {
103
103
  const idleTimeoutMs = typeof value.idleTimeoutMs === "number" && Number.isFinite(value.idleTimeoutMs) ? Math.max(0, Math.floor(value.idleTimeoutMs)) : void 0;
104
104
  const maxAgeMs = typeof value.maxAgeMs === "number" && Number.isFinite(value.maxAgeMs) ? Math.max(0, Math.floor(value.maxAgeMs)) : void 0;
105
105
  const metadata = value.metadata && typeof value.metadata === "object" ? { ...value.metadata } : void 0;
106
- const legacyExpiresAt = typeof value.expiresAt === "number" && Number.isFinite(value.expiresAt) ? Math.max(0, Math.floor(value.expiresAt ?? 0)) : void 0;
107
- let migratedIdleTimeoutMs = idleTimeoutMs;
108
- let migratedMaxAgeMs = maxAgeMs;
109
- if (migratedIdleTimeoutMs === void 0 && migratedMaxAgeMs === void 0 && legacyExpiresAt != null) if (legacyExpiresAt <= 0) {
110
- migratedIdleTimeoutMs = 0;
111
- migratedMaxAgeMs = 0;
112
- } else {
113
- const baseBoundAt = boundAt > 0 ? boundAt : lastActivityAt;
114
- migratedIdleTimeoutMs = 0;
115
- migratedMaxAgeMs = Math.max(1, legacyExpiresAt - Math.max(0, baseBoundAt));
116
- }
117
106
  const record = {
118
107
  accountId,
119
108
  channelId,
@@ -128,8 +117,8 @@ function normalizePersistedBinding(threadIdKey, raw) {
128
117
  if (label !== void 0) record.label = label;
129
118
  if (webhookId !== void 0) record.webhookId = webhookId;
130
119
  if (webhookToken !== void 0) record.webhookToken = webhookToken;
131
- if (migratedIdleTimeoutMs !== void 0) record.idleTimeoutMs = migratedIdleTimeoutMs;
132
- if (migratedMaxAgeMs !== void 0) record.maxAgeMs = migratedMaxAgeMs;
120
+ if (idleTimeoutMs !== void 0) record.idleTimeoutMs = idleTimeoutMs;
121
+ if (maxAgeMs !== void 0) record.maxAgeMs = maxAgeMs;
133
122
  if (metadata !== void 0) record.metadata = metadata;
134
123
  return record;
135
124
  }
@@ -22,26 +22,14 @@ function isAbortError(error) {
22
22
  }
23
23
  function mergeAbortSignals(signals) {
24
24
  const activeSignals = signals.filter((signal) => Boolean(signal));
25
- if (activeSignals.length === 0) return;
26
- if (activeSignals.length === 1) return activeSignals[0];
27
- if (typeof AbortSignal.any === "function") return AbortSignal.any(activeSignals);
28
- const fallbackController = new AbortController();
29
- for (const signal of activeSignals) if (signal.aborted) {
30
- fallbackController.abort();
31
- return fallbackController.signal;
32
- }
33
- const abortFallback = () => {
34
- fallbackController.abort();
35
- for (const signal of activeSignals) signal.removeEventListener("abort", abortFallback);
36
- };
37
- for (const signal of activeSignals) signal.addEventListener("abort", abortFallback, { once: true });
38
- return fallbackController.signal;
25
+ return activeSignals.length > 1 ? AbortSignal.any(activeSignals) : activeSignals[0];
39
26
  }
40
27
  /** @deprecated Discord no longer uses this for channel-owned message run timeouts. */
41
28
  async function runDiscordTaskWithTimeout(params) {
42
29
  const timeoutMs = params.timeoutMs === void 0 ? void 0 : resolveTimerTimeoutMs(params.timeoutMs, 0, 0);
43
30
  const timeoutAbortController = timeoutMs ? new AbortController() : void 0;
44
- const mergedAbortSignal = mergeAbortSignals([...params.abortSignals ?? [], timeoutAbortController?.signal]);
31
+ const abortSignals = [...params.abortSignals ?? [], timeoutAbortController?.signal].filter((signal) => Boolean(signal));
32
+ const mergedAbortSignal = abortSignals.length > 1 ? AbortSignal.any(abortSignals) : abortSignals[0];
45
33
  let timedOut = false;
46
34
  let timeoutHandle = null;
47
35
  const runPromise = params.run(mergedAbortSignal).catch((error) => {
package/dist/timeouts.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-C5TBc_9x.js";
1
+ import { i as DISCORD_DEFAULT_LISTENER_TIMEOUT_MS, n as DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, r as DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, t as DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS } from "./timeouts-ZRc9Lw4y.js";
2
2
  export { DISCORD_ATTACHMENT_IDLE_TIMEOUT_MS, DISCORD_ATTACHMENT_TOTAL_TIMEOUT_MS, DISCORD_DEFAULT_INBOUND_WORKER_TIMEOUT_MS, DISCORD_DEFAULT_LISTENER_TIMEOUT_MS };
@@ -1,4 +1,4 @@
1
- import { Jt as __exportAll } from "./send.receipt-BpBQED_5.js";
1
+ import { Xt as __exportAll } from "./send.receipt-aegk69an.js";
2
2
  //#region extensions/discord/src/voice/transcripts-source.ts
3
3
  var transcripts_source_exports = /* @__PURE__ */ __exportAll({
4
4
  discordVoiceTranscriptsSourceProvider: () => discordVoiceTranscriptsSourceProvider,
@@ -1,2 +1,2 @@
1
- import { t as discordVoiceTranscriptsSourceProvider } from "./transcripts-source-BvvM5Ns9.js";
1
+ import { t as discordVoiceTranscriptsSourceProvider } from "./transcripts-source-CLZ5X8fh.js";
2
2
  export { discordVoiceTranscriptsSourceProvider };
@@ -1,5 +1,5 @@
1
- import { Jt as __exportAll, wt as sendChannelTyping } from "./send.receipt-BpBQED_5.js";
2
- import { l as raceWithTimeout } from "./timeouts-C5TBc_9x.js";
1
+ import { Et as sendChannelTyping, Xt as __exportAll } from "./send.receipt-aegk69an.js";
2
+ import { l as raceWithTimeout } from "./timeouts-ZRc9Lw4y.js";
3
3
  //#region extensions/discord/src/monitor/typing.ts
4
4
  var typing_exports = /* @__PURE__ */ __exportAll({ sendTyping: () => sendTyping });
5
5
  const DISCORD_TYPING_START_TIMEOUT_MS = 5e3;