


























@@ -4,7 +4,7 @@ import {
44resolveEnvelopeFormatOptions,
55} from "openclaw/plugin-sdk/channel-inbound";
66import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
7-import { runPreparedInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch";
7+import { runInboundReplyTurn } from "openclaw/plugin-sdk/inbound-reply-dispatch";
88import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
99import { getAgentScopedMediaLocalRoots } from "openclaw/plugin-sdk/media-runtime";
1010import { createNonExitingRuntime, logVerbose } from "openclaw/plugin-sdk/runtime-env";
@@ -270,83 +270,97 @@ export async function dispatchDiscordComponentEvent(params: {
270270startId: params.replyToId,
271271});
272272273-await runPreparedInboundReplyTurn({
273+await runInboundReplyTurn({
274274channel: "discord",
275275 accountId,
276-routeSessionKey: sessionKey,
277- storePath,
278- ctxPayload,
279- recordInboundSession,
280-record: {
281-updateLastRoute: interactionCtx.isDirectMessage
282- ? {
283-sessionKey: route.mainSessionKey,
284-channel: "discord",
285-to:
286-resolveDiscordComponentOriginatingTo(interactionCtx) ??
287-`user:${interactionCtx.userId}`,
288- accountId,
289-mainDmOwnerPin: pinnedMainDmOwner
290- ? {
291-ownerRecipient: pinnedMainDmOwner,
292-senderRecipient: interactionCtx.userId,
293-onSkip: ({ ownerRecipient, senderRecipient }) => {
294-logVerbose(
295-`discord: skip main-session last route for ${senderRecipient} (pinned owner ${ownerRecipient})`,
296-);
297-},
298-}
299- : undefined,
300-}
301- : undefined,
302-onRecordError: (err) => {
303-logVerbose(`discord: failed updating component session meta: ${String(err)}`);
304-},
305-},
306-runDispatch: () =>
307-dispatchReplyWithBufferedBlockDispatcher({
308-ctx: ctxPayload,
309-cfg: ctx.cfg,
310-replyOptions: { onModelSelected },
311-dispatcherOptions: {
312- ...replyPipeline,
313-humanDelay: resolveHumanDelayConfig(ctx.cfg, agentId),
314-deliver: async (payload) => {
315-const replyToId = replyReference.use();
316-await deliverDiscordReply({
317-cfg: ctx.cfg,
318-replies: [payload],
319-target: deliverTarget,
320- token,
321- accountId,
322-rest: interaction.client.rest,
323- runtime,
324- replyToId,
325- replyToMode,
326- textLimit,
327-maxLinesPerMessage: resolveDiscordMaxLinesPerMessage({
328-cfg: ctx.cfg,
329-discordConfig: ctx.discordConfig,
276+raw: interaction,
277+adapter: {
278+ingest: () => ({
279+id: interaction.id,
280+rawText: ctxPayload.RawBody ?? "",
281+textForAgent: ctxPayload.BodyForAgent,
282+textForCommands: ctxPayload.CommandBody,
283+raw: interaction,
284+}),
285+resolveTurn: () => ({
286+channel: "discord",
287+ accountId,
288+routeSessionKey: sessionKey,
289+ storePath,
290+ ctxPayload,
291+ recordInboundSession,
292+record: {
293+updateLastRoute: interactionCtx.isDirectMessage
294+ ? {
295+sessionKey: route.mainSessionKey,
296+channel: "discord",
297+to:
298+resolveDiscordComponentOriginatingTo(interactionCtx) ??
299+`user:${interactionCtx.userId}`,
330300 accountId,
331-}),
332- tableMode,
333-chunkMode: resolveChunkMode(ctx.cfg, "discord", accountId),
334- mediaLocalRoots,
335-});
336-replyReference.markSent();
337-},
338-onReplyStart: async () => {
339-try {
340-const { sendTyping } = await loadTypingRuntime();
341-await sendTyping({ rest: feedbackRest, channelId: typingChannelId });
342-} catch (err) {
343-logVerbose(`discord: typing failed for component reply: ${String(err)}`);
344-}
345-},
346-onError: (err) => {
347-logError(`discord component dispatch failed: ${String(err)}`);
301+mainDmOwnerPin: pinnedMainDmOwner
302+ ? {
303+ownerRecipient: pinnedMainDmOwner,
304+senderRecipient: interactionCtx.userId,
305+onSkip: ({ ownerRecipient, senderRecipient }) => {
306+logVerbose(
307+`discord: skip main-session last route for ${senderRecipient} (pinned owner ${ownerRecipient})`,
308+);
309+},
310+}
311+ : undefined,
312+}
313+ : undefined,
314+onRecordError: (err) => {
315+logVerbose(`discord: failed updating component session meta: ${String(err)}`);
348316},
349317},
318+runDispatch: () =>
319+dispatchReplyWithBufferedBlockDispatcher({
320+ctx: ctxPayload,
321+cfg: ctx.cfg,
322+replyOptions: { onModelSelected },
323+dispatcherOptions: {
324+ ...replyPipeline,
325+humanDelay: resolveHumanDelayConfig(ctx.cfg, agentId),
326+deliver: async (payload) => {
327+const replyToId = replyReference.use();
328+await deliverDiscordReply({
329+cfg: ctx.cfg,
330+replies: [payload],
331+target: deliverTarget,
332+ token,
333+ accountId,
334+rest: interaction.client.rest,
335+ runtime,
336+ replyToId,
337+ replyToMode,
338+ textLimit,
339+maxLinesPerMessage: resolveDiscordMaxLinesPerMessage({
340+cfg: ctx.cfg,
341+discordConfig: ctx.discordConfig,
342+ accountId,
343+}),
344+ tableMode,
345+chunkMode: resolveChunkMode(ctx.cfg, "discord", accountId),
346+ mediaLocalRoots,
347+});
348+replyReference.markSent();
349+},
350+onReplyStart: async () => {
351+try {
352+const { sendTyping } = await loadTypingRuntime();
353+await sendTyping({ rest: feedbackRest, channelId: typingChannelId });
354+} catch (err) {
355+logVerbose(`discord: typing failed for component reply: ${String(err)}`);
356+}
357+},
358+onError: (err) => {
359+logError(`discord component dispatch failed: ${String(err)}`);
360+},
361+},
362+}),
350363}),
364+},
351365});
352366}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。