@openclaw/discord 2026.7.2-beta.7 → 2026.8.1-beta.3

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 (114) hide show
  1. package/dist/{account-inspect-SXiCBCgP.js → account-inspect-D5xmUpnj.js} +49 -43
  2. package/dist/account-inspect-api.js +1 -1
  3. package/dist/accounts-DNl-oCEw.js +371 -0
  4. package/dist/action-runtime-api.js +1 -1
  5. package/dist/{active-turn-thread-route-MlKWp8RD.js → active-turn-thread-route-fmHl1HNd.js} +9 -11
  6. package/dist/{activities-api-DTKsuDxf.js → activities-api-KCBAmWxD.js} +133 -175
  7. package/dist/activities-api.js +1 -1
  8. package/dist/{allow-list-DzKrtfah.js → allow-list-BDMimASD.js} +2 -3
  9. package/dist/{api-DnrK9gML.js → api-DNVbJyEy.js} +7 -2
  10. package/dist/api.js +18 -18
  11. package/dist/{approval-handler.runtime-HymvFTYn.js → approval-handler.runtime-B12RCYr8.js} +6 -6
  12. package/dist/{approval-message-safety-DEyKVsAw.js → approval-message-safety-XGFPbDoI.js} +89 -3
  13. package/dist/{audit-CjsrabP8.js → audit-Yc7eZDd6.js} +5 -5
  14. package/dist/{channel-actions-uXFTJX3o.js → channel-actions-Dr2QI8Bf.js} +11 -7
  15. package/dist/{channel-actions.runtime-CIYU90sl.js → channel-actions.runtime-CODTvo7c.js} +99 -97
  16. package/dist/{channel-vKa-76xY.js → channel-cXYzGc4L.js} +102 -104
  17. package/dist/channel-config-api.js +1 -1
  18. package/dist/channel-plugin-api.js +1 -1
  19. package/dist/{channel.setup-CmcwZ_qd.js → channel.setup-CSiwnMgs.js} +16 -54
  20. package/dist/{outbound-session-route-H-HoyH5U.js → components-ezGKo_Yh.js} +69 -142
  21. package/dist/{config-schema-WHRQcY19.js → config-schema-DC5kDtQ5.js} +42 -11
  22. package/dist/conversation-binding-route-D6rCQ5S0.js +43 -0
  23. package/dist/{directory-config-D_LojtCe.js → directory-config-XyCfoqLg.js} +2 -2
  24. package/dist/directory-contract-api.js +1 -1
  25. package/dist/{directory-live-Bw5Ephzv.js → directory-live-Df0NbFJB.js} +7 -4
  26. package/dist/{doctor-Bc4S1qyd.js → doctor-DYY31GrO.js} +34 -13
  27. package/dist/{doctor-contract-CCFMIDk9.js → doctor-contract-DsWvKIXF.js} +2 -3
  28. package/dist/doctor-contract-api.js +147 -2
  29. package/dist/{handle-action.guild-admin-D6VRRW-C.js → handle-action.guild-admin-6Tvvinsa.js} +4 -7
  30. package/dist/{inbound-event-delivery-CEPlt2uz.js → inbound-event-delivery-De2qxTrP.js} +4 -25
  31. package/dist/index.js +5 -4
  32. package/dist/{message-handler-CeiSulIw.js → message-handler-B61q5MOF.js} +118 -33
  33. package/dist/{message-handler.preflight-DibgQFf2.js → message-handler.preflight-Bzg_Hawz.js} +75 -61
  34. package/dist/{message-handler.process-Dnc_oz9y.js → message-handler.process--4_712Ec.js} +236 -296
  35. package/dist/{message-utils-BgTwT_q7.js → message-utils-BXLLnFl6.js} +34 -35
  36. package/dist/{model-picker-preference-primitives-D25pnCOu.js → model-picker-preference-primitives-BHT1LkR_.js} +3 -3
  37. package/dist/{outbound-adapter-DtE-i2OJ.js → outbound-adapter-DxHTOqiN.js} +157 -68
  38. package/dist/{outbound-components-C7GVyfPh.js → outbound-components-B2PL0ooH.js} +3 -3
  39. package/dist/owner-access-Bg41VzAf.js +107 -0
  40. package/dist/{pluralkit-CD4B11JB.js → pluralkit-dUl4v1X3.js} +1 -1
  41. package/dist/{preflight-audio-BjnQZ5yS.js → preflight-audio-DrnqFA8U.js} +22 -28
  42. package/dist/{probe-BeWKhjqX.js → probe-BTdtVRwU.js} +37 -13
  43. package/dist/probe.runtime-Dq5-PRKT.js +2 -0
  44. package/dist/{provider-DfQJX3z5.js → provider-DlK_ynqt.js} +1131 -2021
  45. package/dist/{provider-session.runtime-Bo88k0pV.js → provider-session.runtime-CvvphHvs.js} +3 -3
  46. package/dist/provider.runtime-CzKGRiAF.js +2 -0
  47. package/dist/realtime-session.runtime-ysbMG8v7.js +1351 -0
  48. package/dist/{resolve-allowlist-common-DHERApxi.js → resolve-allowlist-common-DIVXbD1P.js} +3 -3
  49. package/dist/{resolve-channels-BjepAj8b.js → resolve-channels-CGeUoIqb.js} +4 -4
  50. package/dist/{resolve-users-Bc28htgt.js → resolve-users-BtKxLUZv.js} +3 -3
  51. package/dist/{chunk-DX4jpFQP.js → retry-DNsVTeTo.js} +308 -131
  52. package/dist/{runtime-BmW_j_hl.js → runtime-CQovMsH3.js} +12 -15
  53. package/dist/{runtime-_aRC6V2s.js → runtime-D71_VFLr.js} +49 -58
  54. package/dist/runtime-api.actions.js +2 -2
  55. package/dist/runtime-api.js +23 -23
  56. package/dist/runtime-api.lookup.js +5 -5
  57. package/dist/runtime-api.monitor-CzeTYF32.js +6 -0
  58. package/dist/runtime-api.monitor.js +6 -5
  59. package/dist/runtime-api.send.js +6 -6
  60. package/dist/runtime-api.threads.js +5 -6
  61. package/dist/sdk-runtime-37OU6_Yh.js +369 -0
  62. package/dist/{secret-config-contract-B1akrlyY.js → secret-config-contract-B3i6WxV5.js} +53 -25
  63. package/dist/secret-contract-api.js +1 -1
  64. package/dist/security-audit-contract-api.js +1 -1
  65. package/dist/{security-audit.runtime-CPN0xFYz.js → security-audit.runtime-BVKF9VtY.js} +1 -1
  66. package/dist/{send-CdkZ6zeW.js → send-rQIffSYu.js} +180 -91
  67. package/dist/{send.components-5uqwkjgE.js → send.components-ChK1wS7w.js} +32 -46
  68. package/dist/{send.outbound-D-80Ej-t.js → send.outbound-HIkgji_7.js} +57 -34
  69. package/dist/{send.reactions-CtlmGd_o.js → send.reactions-gmJ6yFPo.js} +14 -21
  70. package/dist/{send.receipt-CuwRrpFz.js → send.receipt-Cnhoautb.js} +29 -1
  71. package/dist/{send.shared-jpvAG_u6.js → send.shared-B3fpaLWJ.js} +112 -181
  72. package/dist/{sender-identity-mG_zsdox.js → sender-identity-BJtfyise.js} +1 -1
  73. package/dist/setup-entry.js +0 -5
  74. package/dist/setup-plugin-api.js +1 -1
  75. package/dist/{shared-CXF1tup1.js → shared-CaAaoksy.js} +27 -23
  76. package/dist/subagent-hooks-CNT2ZJTJ.js +49 -0
  77. package/dist/subagent-hooks-api.js +2 -6
  78. package/dist/subagent-progress-FPLqBY1s.js +110 -0
  79. package/dist/{system-events-DdUqf91B.js → system-events-Nuwoq_au.js} +2 -2
  80. package/dist/{target-resolver-C3s_2m0t.js → target-resolver-DIXShHaZ.js} +3 -3
  81. package/dist/targets-B2pf49zc.js +3 -0
  82. package/dist/{thread-bindings-C-M-ly7P.js → thread-bindings-VlymUnbz.js} +29 -28
  83. package/dist/{thread-bindings.manager-DYvSlrva.js → thread-bindings.manager-CngsgErq.js} +258 -29
  84. package/dist/{thread-bindings.session-updates-DAIlp7Px.js → thread-bindings.session-updates-CJb-BpPL.js} +1 -1
  85. package/dist/{thread-bindings.state-Cgi5uRn-.js → thread-bindings.state-D8OMdk4O.js} +3 -16
  86. package/dist/threading-DU6pgeGm.js +456 -0
  87. package/dist/transcripts-source-DeIMNbRh.js +265 -0
  88. package/dist/transcripts-source-api.js +7 -2
  89. package/dist/{typing--Mzo2kM7.js → typing-oLiS5Z13.js} +1 -1
  90. package/dist/voice-runtime-CjNFaynA.js +2549 -0
  91. package/openclaw.plugin.json +215 -25
  92. package/package.json +15 -11
  93. package/skills/discord/SKILL.md +22 -115
  94. package/dist/accounts-DJTf1LtA.js +0 -219
  95. package/dist/channel-api-CAJ0wMoV.js +0 -21
  96. package/dist/legacy-state-migrations-api.js +0 -138
  97. package/dist/manager.runtime-Bjav3pfC.js +0 -3655
  98. package/dist/preflight-audio.runtime-CoCXMM8r.js +0 -7
  99. package/dist/probe.runtime-DqFGFMbZ.js +0 -2
  100. package/dist/provider.runtime-Cy7XZmyh.js +0 -2
  101. package/dist/runtime-api.monitor-CCRubd3-.js +0 -5
  102. package/dist/session-binding-contract-api.js +0 -2
  103. package/dist/subagent-hooks-Dxy7Fmnq.js +0 -120
  104. package/dist/subagent-progress-DI3sYLLo.js +0 -664
  105. package/dist/targets-Dv_RN7vT.js +0 -3
  106. package/dist/thread-bindings.discord-api-BoDNqamb.js +0 -246
  107. package/dist/transcripts-source-DIKGsTGT.js +0 -123
  108. package/node_modules/p-map/index.d.ts +0 -155
  109. package/node_modules/p-map/index.js +0 -285
  110. package/node_modules/p-map/license +0 -9
  111. package/node_modules/p-map/package.json +0 -57
  112. package/node_modules/p-map/readme.md +0 -190
  113. package/dist/{audit-core-xwjIczO0.js → audit-core-BCX8UeFH.js} +1 -1
  114. package/dist/{security-audit-jGnJF__m.js → security-audit-BfJhAXZp.js} +1 -1
@@ -1,7 +1,7 @@
1
- import { r as listDiscordAccountIds, t as createDiscordActionGate } from "./accounts-DJTf1LtA.js";
2
- import { h as readDiscordComponentSpec } from "./outbound-session-route-H-HoyH5U.js";
3
- import { t as inspectDiscordAccount } from "./account-inspect-SXiCBCgP.js";
4
- import { i as withDiscordInboundEventDeliveryMetadata } from "./inbound-event-delivery-CEPlt2uz.js";
1
+ import { m as readDiscordComponentSpec } from "./components-ezGKo_Yh.js";
2
+ import { r as listDiscordAccountIds, t as createDiscordActionGate } from "./accounts-DNl-oCEw.js";
3
+ import { t as inspectDiscordAccount } from "./account-inspect-D5xmUpnj.js";
4
+ import { r as withDiscordInboundEventDeliveryMetadata } from "./inbound-event-delivery-De2qxTrP.js";
5
5
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { createUnionActionGate } from "openclaw/plugin-sdk/channel-actions";
7
7
  import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
@@ -31,6 +31,7 @@ function isTrustedRequesterGuildAdminAction(action) {
31
31
  //#region extensions/discord/src/channel-actions.ts
32
32
  const localExecutionActions = /* @__PURE__ */ new Set([
33
33
  "send",
34
+ "poll",
34
35
  "upload-file",
35
36
  "thread-reply",
36
37
  "sticker",
@@ -41,7 +42,7 @@ const localExecutionActions = /* @__PURE__ */ new Set([
41
42
  function resolveDiscordActionExecutionMode({ action }) {
42
43
  return localExecutionActions.has(action) ? "local" : "gateway";
43
44
  }
44
- const loadDiscordChannelActionsRuntime = createLazyRuntimeModule(() => import("./channel-actions.runtime-CIYU90sl.js"));
45
+ const loadDiscordChannelActionsRuntime = createLazyRuntimeModule(() => import("./channel-actions.runtime-CODTvo7c.js"));
45
46
  function listDiscoverableDiscordAccounts(cfg) {
46
47
  return listDiscordAccountIds(cfg).map((accountId) => inspectDiscordAccount({
47
48
  cfg,
@@ -144,8 +145,10 @@ function describeDiscordMessageTool({ cfg, accountId }) {
144
145
  };
145
146
  }
146
147
  const discordMessageActions = {
148
+ providerOwnedReadGates: true,
147
149
  resolveExecutionMode: resolveDiscordActionExecutionMode,
148
150
  describeMessageTool: describeDiscordMessageTool,
151
+ supportsAction: ({ action }) => action !== "poll",
149
152
  requiresTrustedRequesterSender: ({ action, toolContext }) => Boolean(toolContext) && isTrustedRequesterGuildAdminAction(action),
150
153
  extractToolSend: ({ args }) => {
151
154
  const action = normalizeOptionalString(args.action) ?? "";
@@ -185,7 +188,7 @@ const discordMessageActions = {
185
188
  }
186
189
  };
187
190
  },
188
- handleAction: async ({ action, params, cfg, accountId, requesterAccountId, requesterSenderId, senderIsOwner, toolContext, mediaAccess, mediaLocalRoots, mediaReadFile, sessionKey, inboundEventKind, conversationReadOrigin }) => {
191
+ handleAction: async ({ action, params, cfg, accountId, requesterAccountId, requesterSenderId, senderIsOwner, toolContext, mediaAccess, mediaLocalRoots, mediaReadFile, sessionKey, inboundEventKind, conversationReadOrigin, reply }) => {
189
192
  return await (await loadDiscordChannelActionsRuntime()).handleDiscordMessageAction({
190
193
  action,
191
194
  params,
@@ -200,7 +203,8 @@ const discordMessageActions = {
200
203
  ...sessionKey ? { sessionKey } : {},
201
204
  ...inboundEventKind ? { inboundEventKind } : {},
202
205
  ...requesterAccountId ? { requesterAccountId } : {},
203
- ...conversationReadOrigin ? { conversationReadOrigin } : {}
206
+ ...conversationReadOrigin ? { conversationReadOrigin } : {},
207
+ ...reply ? { reply } : {}
204
208
  });
205
209
  }
206
210
  };
@@ -1,17 +1,17 @@
1
- import { u as resolveDiscordChannelId } from "./chunk-DX4jpFQP.js";
2
- import { a as buildDiscordPresentationComponents, i as buildDiscordInteractiveComponents } from "./outbound-session-route-H-HoyH5U.js";
3
- import { a as readDiscordAutoArchiveDurationParam, t as handleDiscordAction } from "./runtime-_aRC6V2s.js";
4
- import "./targets-Dv_RN7vT.js";
1
+ import { i as buildDiscordPresentationComponents, r as buildDiscordInteractiveComponents } from "./components-ezGKo_Yh.js";
2
+ import { A as resolveDiscordChannelId, k as parseDiscordTarget } from "./accounts-DNl-oCEw.js";
3
+ import { a as readDiscordAutoArchiveDurationParam, t as handleDiscordAction } from "./runtime-D71_VFLr.js";
4
+ import "./targets-B2pf49zc.js";
5
5
  import "./action-runtime-api.js";
6
- import { r as notifyDiscordInboundEventOutboundSuccess } from "./inbound-event-delivery-CEPlt2uz.js";
7
- import { r as isDiscordComponentSpecWithinMessageLimit, t as DISCORD_PRESENTATION_CAPABILITIES } from "./outbound-components-C7GVyfPh.js";
8
- import { t as tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin-D6VRRW-C.js";
9
- import { n as notifyDiscordActiveTurnThreadCreated, r as notifyDiscordActiveTurnThreadReplyDelivered } from "./active-turn-thread-route-MlKWp8RD.js";
6
+ import { t as discordInboundEventDelivery } from "./inbound-event-delivery-De2qxTrP.js";
7
+ import { r as isDiscordComponentSpecWithinMessageLimit, t as DISCORD_PRESENTATION_CAPABILITIES } from "./outbound-components-B2PL0ooH.js";
8
+ import { t as tryHandleDiscordMessageActionGuildAdmin } from "./handle-action.guild-admin-6Tvvinsa.js";
9
+ import { n as notifyDiscordActiveTurnThreadCreated, r as notifyDiscordActiveTurnThreadReplyDelivered } from "./active-turn-thread-route-fmHl1HNd.js";
10
10
  import { normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
11
11
  import { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
12
- import { adaptMessagePresentationForChannel, normalizeLegacyInteractiveReply, normalizeMessagePresentation, renderMessagePresentationFallbackText } from "openclaw/plugin-sdk/interactive-runtime";
13
12
  import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
14
- import { readPositiveIntegerParam, readStringArrayParam, readStringParam as readStringParam$1 } from "openclaw/plugin-sdk/agent-runtime";
13
+ import { adaptMessagePresentationForChannel, normalizeLegacyInteractiveReply, normalizeMessagePresentation, renderMessagePresentationFallbackText } from "openclaw/plugin-sdk/interactive-runtime";
14
+ import { readPositiveIntegerParam, readStringArrayParam, readStringParam } from "openclaw/plugin-sdk/agent-runtime";
15
15
  //#region extensions/discord/src/actions/handle-action.ts
16
16
  const providerId = "discord";
17
17
  function withCurrentSourceReplyRoute(result) {
@@ -31,7 +31,7 @@ function readCurrentDiscordTarget(toolContext) {
31
31
  }
32
32
  async function handleDiscordMessageAction(ctx) {
33
33
  const { action, params, cfg } = ctx;
34
- const accountId = ctx.accountId ?? readStringParam$1(params, "accountId");
34
+ const accountId = ctx.accountId ?? readStringParam(params, "accountId");
35
35
  const readContext = ctx.requesterAccountId && ctx.toolContext?.currentChannelProvider && ctx.toolContext.currentChannelId ? {
36
36
  requesterAccountId: ctx.requesterAccountId,
37
37
  currentChannelProvider: ctx.toolContext.currentChannelProvider,
@@ -45,30 +45,49 @@ async function handleDiscordMessageAction(ctx) {
45
45
  mediaAccess: ctx.mediaAccess,
46
46
  mediaLocalRoots: ctx.mediaLocalRoots,
47
47
  mediaReadFile: ctx.mediaReadFile,
48
+ ...ctx.reply ? { reply: ctx.reply } : {},
48
49
  ...readPolicyOptions
49
50
  };
50
- const notifyVisibleOutbound = (to, fallbackSessionKey) => notifyDiscordInboundEventOutboundSuccess({
51
- sessionKey: ctx.sessionKey ?? fallbackSessionKey ?? void 0,
52
- to,
53
- accountId,
54
- inboundEventKind: ctx.inboundEventKind
55
- });
51
+ const notifyVisibleOutbound = (result, to, fallbackSessionKey) => {
52
+ if ((result.details && typeof result.details === "object" && !Array.isArray(result.details) ? result.details : void 0)?.ok !== true) return;
53
+ discordInboundEventDelivery.notify({
54
+ sessionKey: ctx.sessionKey ?? fallbackSessionKey ?? void 0,
55
+ to,
56
+ accountId,
57
+ inboundEventKind: ctx.inboundEventKind
58
+ });
59
+ };
60
+ const withAdoptedThreadReplyRoute = (result, to, fallbackSessionKey) => {
61
+ if ((result.details && typeof result.details === "object" && !Array.isArray(result.details) ? result.details : void 0)?.ok !== true) return result;
62
+ let target;
63
+ try {
64
+ target = parseDiscordTarget(to, { defaultKind: "channel" });
65
+ } catch {
66
+ return result;
67
+ }
68
+ if (target?.kind === "channel" && notifyDiscordActiveTurnThreadReplyDelivered({
69
+ sessionKey: ctx.sessionKey ?? fallbackSessionKey,
70
+ accountId,
71
+ threadId: target.id
72
+ })) return withCurrentSourceReplyRoute(result);
73
+ return result;
74
+ };
56
75
  const readTarget = () => {
57
- const target = readStringParam$1(params, "channelId") ?? readStringParam$1(params, "to") ?? readCurrentDiscordTarget(ctx.toolContext);
76
+ const target = readStringParam(params, "channelId") ?? readStringParam(params, "to") ?? readCurrentDiscordTarget(ctx.toolContext);
58
77
  if (!target) throw new Error("Discord channel target is required (use channel:<id>).");
59
78
  return target;
60
79
  };
61
80
  const resolveChannelId = () => resolveDiscordChannelId(readTarget());
62
81
  const readSendTarget = () => {
63
- const target = readStringParam$1(params, "to") ?? readStringParam$1(params, "target") ?? readCurrentDiscordTarget(ctx.toolContext);
82
+ const target = readStringParam(params, "to") ?? readStringParam(params, "target") ?? readCurrentDiscordTarget(ctx.toolContext);
64
83
  if (!target) throw new Error("Discord channel target is required (use channel:<id>).");
65
84
  return target;
66
85
  };
67
86
  if (action === "send") {
68
87
  const to = readSendTarget();
69
88
  const asVoice = readBooleanParam(params, "asVoice") === true;
70
- const mediaUrl = readStringParam$1(params, "media", { trim: false }) ?? readStringParam$1(params, "path", { trim: false }) ?? readStringParam$1(params, "filePath", { trim: false });
71
- const requestedContent = readStringParam$1(params, "message", { allowEmpty: true });
89
+ const mediaUrl = readStringParam(params, "media", { trim: false }) ?? readStringParam(params, "path", { trim: false }) ?? readStringParam(params, "filePath", { trim: false });
90
+ const requestedContent = readStringParam(params, "message", { allowEmpty: true });
72
91
  const presentation = params.components == null ? normalizeMessagePresentation(params.presentation) : void 0;
73
92
  const adaptedPresentation = presentation ? adaptMessagePresentationForChannel({
74
93
  presentation,
@@ -84,23 +103,23 @@ async function handleDiscordMessageAction(ctx) {
84
103
  const rawComponents = presentationFellBack ? void 0 : params.components ?? presentationComponents ?? buildDiscordInteractiveComponents(normalizeLegacyInteractiveReply(params.interactive));
85
104
  const hasComponents = Boolean(rawComponents) && (typeof rawComponents === "function" || typeof rawComponents === "object");
86
105
  const components = hasComponents ? rawComponents : void 0;
87
- const content = readStringParam$1(params, "message", {
88
- required: !asVoice && !hasComponents && !mediaUrl && !presentationFellBack,
106
+ const rawEmbeds = params.embeds;
107
+ const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : void 0;
108
+ const content = readStringParam(params, "message", {
109
+ required: !asVoice && !hasComponents && !embeds?.length && !mediaUrl && !presentationFellBack,
89
110
  allowEmpty: true
90
111
  });
91
112
  const deliveryContent = presentationFellBack && adaptedPresentation ? renderMessagePresentationFallbackText({
92
113
  text: content,
93
114
  presentation: adaptedPresentation
94
115
  }) : content;
95
- const filename = readStringParam$1(params, "filename");
96
- const replyTo = readStringParam$1(params, "replyTo");
97
- const rawEmbeds = params.embeds;
98
- const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : void 0;
116
+ const filename = readStringParam(params, "filename");
117
+ const replyTo = readStringParam(params, "replyTo");
99
118
  const silent = readBooleanParam(params, "silent") === true;
100
119
  const suppressEmbeds = readBooleanParam(params, "suppressEmbeds");
101
- const sessionKey = readStringParam$1(params, "__sessionKey");
102
- const agentId = readStringParam$1(params, "__agentId");
103
- const threadName = readStringParam$1(params, "threadName");
120
+ const sessionKey = readStringParam(params, "__sessionKey");
121
+ const agentId = readStringParam(params, "__agentId");
122
+ const threadName = readStringParam(params, "threadName");
104
123
  const result = await handleDiscordAction({
105
124
  action: "sendMessage",
106
125
  accountId: accountId ?? void 0,
@@ -118,20 +137,23 @@ async function handleDiscordMessageAction(ctx) {
118
137
  __sessionKey: sessionKey ?? void 0,
119
138
  __agentId: agentId ?? void 0
120
139
  }, cfg, actionOptions);
121
- notifyVisibleOutbound(to, sessionKey);
122
- return result;
140
+ notifyVisibleOutbound(result, to, sessionKey);
141
+ return withAdoptedThreadReplyRoute(result, to, sessionKey);
123
142
  }
124
143
  if (action === "upload-file") {
125
144
  const to = readSendTarget();
126
- const mediaUrl = readStringParam$1(params, "filePath", { trim: false }) ?? readStringParam$1(params, "path", { trim: false }) ?? readStringParam$1(params, "media", { trim: false });
127
- if (!mediaUrl) throw new Error("upload-file requires filePath, path, or media.");
128
- const content = readStringParam$1(params, "message", { allowEmpty: true }) ?? readStringParam$1(params, "content", { allowEmpty: true });
129
- const filename = readStringParam$1(params, "filename");
130
- const replyTo = readStringParam$1(params, "replyTo");
145
+ const mediaUrl = readStringParam(params, "filePath", { trim: false }) ?? readStringParam(params, "path", { trim: false }) ?? readStringParam(params, "media", { trim: false });
146
+ if (!mediaUrl) {
147
+ if (readStringParam(params, "buffer", { trim: false })) throw new Error("Use action: \"send\" for base64 buffer attachments; upload-file requires filePath, path, or media.");
148
+ throw new Error("upload-file requires filePath, path, or media.");
149
+ }
150
+ const content = readStringParam(params, "message", { allowEmpty: true }) ?? readStringParam(params, "content", { allowEmpty: true }) ?? readStringParam(params, "caption", { allowEmpty: true });
151
+ const filename = readStringParam(params, "filename");
152
+ const replyTo = readStringParam(params, "replyTo");
131
153
  const silent = readBooleanParam(params, "silent") === true;
132
154
  const suppressEmbeds = readBooleanParam(params, "suppressEmbeds");
133
- const sessionKey = readStringParam$1(params, "__sessionKey");
134
- const agentId = readStringParam$1(params, "__agentId");
155
+ const sessionKey = readStringParam(params, "__sessionKey");
156
+ const agentId = readStringParam(params, "__agentId");
135
157
  const result = await handleDiscordAction({
136
158
  action: "sendMessage",
137
159
  accountId: accountId ?? void 0,
@@ -145,27 +167,8 @@ async function handleDiscordMessageAction(ctx) {
145
167
  __sessionKey: sessionKey ?? void 0,
146
168
  __agentId: agentId ?? void 0
147
169
  }, cfg, actionOptions);
148
- notifyVisibleOutbound(to, sessionKey);
149
- return result;
150
- }
151
- if (action === "poll") {
152
- const to = readStringParam$1(params, "to", { required: true });
153
- const question = readStringParam$1(params, "pollQuestion", { required: true });
154
- const answers = readStringArrayParam(params, "pollOption", { required: true });
155
- const allowMultiselect = readBooleanParam(params, "pollMulti");
156
- const durationHours = readPositiveIntegerParam(params, "pollDurationHours");
157
- const result = await handleDiscordAction({
158
- action: "poll",
159
- accountId: accountId ?? void 0,
160
- to,
161
- question,
162
- answers,
163
- allowMultiselect,
164
- durationHours: durationHours ?? void 0,
165
- content: readStringParam$1(params, "message")
166
- }, cfg, actionOptions);
167
- notifyVisibleOutbound(to);
168
- return result;
170
+ notifyVisibleOutbound(result, to, sessionKey);
171
+ return withAdoptedThreadReplyRoute(result, to, sessionKey);
169
172
  }
170
173
  if (action === "react") {
171
174
  const messageId = normalizeOptionalStringifiedId(resolveReactionMessageId({
@@ -173,7 +176,7 @@ async function handleDiscordMessageAction(ctx) {
173
176
  toolContext: ctx.toolContext
174
177
  })) ?? "";
175
178
  if (!messageId) throw new Error("messageId required. Provide messageId explicitly or react to the current inbound message.");
176
- const emoji = readStringParam$1(params, "emoji", { allowEmpty: true });
179
+ const emoji = readStringParam(params, "emoji", { allowEmpty: true });
177
180
  const remove = readBooleanParam(params, "remove");
178
181
  return await handleDiscordAction({
179
182
  action: "react",
@@ -185,7 +188,7 @@ async function handleDiscordMessageAction(ctx) {
185
188
  }, cfg, actionOptions);
186
189
  }
187
190
  if (action === "reactions") {
188
- const messageId = readStringParam$1(params, "messageId", { required: true });
191
+ const messageId = readStringParam(params, "messageId", { required: true });
189
192
  const limit = readPositiveIntegerParam(params, "limit");
190
193
  return await handleDiscordAction({
191
194
  action: "reactions",
@@ -202,14 +205,14 @@ async function handleDiscordMessageAction(ctx) {
202
205
  accountId: accountId ?? void 0,
203
206
  channelId: resolveChannelId(),
204
207
  limit,
205
- before: readStringParam$1(params, "before"),
206
- after: readStringParam$1(params, "after"),
207
- around: readStringParam$1(params, "around")
208
+ before: readStringParam(params, "before"),
209
+ after: readStringParam(params, "after"),
210
+ around: readStringParam(params, "around")
208
211
  }, cfg, actionOptions);
209
212
  }
210
213
  if (action === "edit") {
211
- const messageId = readStringParam$1(params, "messageId", { required: true });
212
- const content = readStringParam$1(params, "message", { required: true });
214
+ const messageId = readStringParam(params, "messageId", { required: true });
215
+ const content = readStringParam(params, "message", { required: true });
213
216
  return await handleDiscordAction({
214
217
  action: "editMessage",
215
218
  accountId: accountId ?? void 0,
@@ -219,7 +222,7 @@ async function handleDiscordMessageAction(ctx) {
219
222
  }, cfg, actionOptions);
220
223
  }
221
224
  if (action === "delete") {
222
- const messageId = readStringParam$1(params, "messageId", { required: true });
225
+ const messageId = readStringParam(params, "messageId", { required: true });
223
226
  return await handleDiscordAction({
224
227
  action: "deleteMessage",
225
228
  accountId: accountId ?? void 0,
@@ -228,7 +231,7 @@ async function handleDiscordMessageAction(ctx) {
228
231
  }, cfg, actionOptions);
229
232
  }
230
233
  if (action === "pin" || action === "unpin" || action === "list-pins") {
231
- const messageId = action === "list-pins" ? void 0 : readStringParam$1(params, "messageId", { required: true });
234
+ const messageId = action === "list-pins" ? void 0 : readStringParam(params, "messageId", { required: true });
232
235
  return await handleDiscordAction({
233
236
  action: action === "pin" ? "pinMessage" : action === "unpin" ? "unpinMessage" : "listPins",
234
237
  accountId: accountId ?? void 0,
@@ -242,9 +245,9 @@ async function handleDiscordMessageAction(ctx) {
242
245
  channelId: resolveChannelId()
243
246
  }, cfg, actionOptions);
244
247
  if (action === "thread-create") {
245
- const name = readStringParam$1(params, "threadName", { required: true });
246
- const messageId = readStringParam$1(params, "messageId");
247
- const content = readStringParam$1(params, "message");
248
+ const name = readStringParam(params, "threadName", { required: true });
249
+ const messageId = readStringParam(params, "messageId");
250
+ const content = readStringParam(params, "message");
248
251
  const autoArchiveMinutes = readDiscordAutoArchiveDurationParam(params, "autoArchiveMin");
249
252
  const appliedTags = readStringArrayParam(params, "appliedTags");
250
253
  const result = await handleDiscordAction({
@@ -258,19 +261,21 @@ async function handleDiscordMessageAction(ctx) {
258
261
  appliedTags: appliedTags ?? void 0
259
262
  }, cfg, actionOptions);
260
263
  const details = result.details && typeof result.details === "object" && !Array.isArray(result.details) ? result.details : void 0;
261
- const threadId = typeof details?.thread?.id === "string" ? details.thread.id : void 0;
262
- await notifyDiscordActiveTurnThreadCreated({
263
- sessionKey: ctx.sessionKey,
264
- accountId,
265
- sourceChannelId: resolveChannelId(),
266
- sourceMessageId: messageId,
267
- threadId
268
- });
269
- notifyVisibleOutbound(resolveChannelId());
264
+ if (details?.ok === true) {
265
+ const threadId = typeof details.thread?.id === "string" ? details.thread.id : void 0;
266
+ await notifyDiscordActiveTurnThreadCreated({
267
+ sessionKey: ctx.sessionKey,
268
+ accountId,
269
+ sourceChannelId: resolveChannelId(),
270
+ sourceMessageId: messageId,
271
+ threadId
272
+ });
273
+ }
274
+ notifyVisibleOutbound(result, resolveChannelId());
270
275
  return result;
271
276
  }
272
277
  if (action === "sticker") {
273
- const to = readStringParam$1(params, "to", { required: true });
278
+ const to = readStringParam(params, "to", { required: true });
274
279
  const stickerIds = readStringArrayParam(params, "stickerId", {
275
280
  required: true,
276
281
  label: "sticker-id"
@@ -280,34 +285,31 @@ async function handleDiscordMessageAction(ctx) {
280
285
  accountId: accountId ?? void 0,
281
286
  to,
282
287
  stickerIds,
283
- content: readStringParam$1(params, "message")
288
+ content: readStringParam(params, "message")
284
289
  }, cfg, actionOptions);
285
- notifyVisibleOutbound(to);
290
+ notifyVisibleOutbound(result, to);
286
291
  return result;
287
292
  }
288
293
  if (action === "set-presence") return await handleDiscordAction({
289
294
  action: "setPresence",
290
295
  accountId: accountId ?? void 0,
291
- status: readStringParam$1(params, "status"),
292
- activityType: readStringParam$1(params, "activityType"),
293
- activityName: readStringParam$1(params, "activityName"),
294
- activityUrl: readStringParam$1(params, "activityUrl"),
295
- activityState: readStringParam$1(params, "activityState")
296
+ status: readStringParam(params, "status"),
297
+ activityType: readStringParam(params, "activityType"),
298
+ activityName: readStringParam(params, "activityName"),
299
+ activityUrl: readStringParam(params, "activityUrl"),
300
+ activityState: readStringParam(params, "activityState")
296
301
  }, cfg, actionOptions);
297
302
  const adminResult = await tryHandleDiscordMessageActionGuildAdmin({
298
303
  ctx,
299
304
  resolveChannelId,
300
- readPolicyOptions
305
+ readPolicyOptions,
306
+ actionOptions
301
307
  });
302
308
  if (adminResult !== void 0) {
303
309
  if (action === "thread-reply") {
304
- const threadId = readStringParam$1(params, "threadId") ?? readTarget();
305
- notifyVisibleOutbound(threadId);
306
- if (notifyDiscordActiveTurnThreadReplyDelivered({
307
- sessionKey: ctx.sessionKey,
308
- accountId,
309
- threadId
310
- })) return withCurrentSourceReplyRoute(adminResult);
310
+ const threadId = readStringParam(params, "threadId") ?? readTarget();
311
+ notifyVisibleOutbound(adminResult, threadId);
312
+ return withAdoptedThreadReplyRoute(adminResult, threadId);
311
313
  }
312
314
  return adminResult;
313
315
  }