





















@@ -2,6 +2,7 @@ import {
22DEFAULT_TIMING,
33type StatusReactionController,
44} from "openclaw/plugin-sdk/channel-feedback";
5+import type { CommandTurnContext } from "openclaw/plugin-sdk/channel-inbound";
56import { deliverInboundReplyWithMessageSendContext } from "openclaw/plugin-sdk/channel-message";
67import { hasVisibleInboundReplyDispatch } from "openclaw/plugin-sdk/inbound-reply-dispatch";
78import type { FinalizedMsgContext } from "openclaw/plugin-sdk/reply-runtime";
@@ -225,6 +226,7 @@ export function buildWhatsAppInboundContext(params: {
225226combinedBody: string;
226227commandBody?: string;
227228commandAuthorized?: boolean;
229+commandTurn?: CommandTurnContext;
228230commandSource?: "text";
229231conversationId: string;
230232groupHistory?: GroupHistoryEntry[];
@@ -280,7 +282,12 @@ export function buildWhatsAppInboundContext(params: {
280282SenderId: params.sender.id ?? params.sender.e164,
281283SenderE164: params.sender.e164,
282284CommandAuthorized: params.commandAuthorized,
283-CommandSource: params.commandSource,
285+CommandTurn: params.commandTurn,
286+CommandSource:
287+params.commandSource ??
288+(params.commandTurn?.source === "native" || params.commandTurn?.source === "text"
289+ ? params.commandTurn.source
290+ : undefined),
284291ReplyThreading: params.replyThreading,
285292WasMentioned: params.msg.wasMentioned,
286293GroupSystemPrompt: params.groupSystemPrompt,
@@ -294,6 +301,43 @@ export function buildWhatsAppInboundContext(params: {
294301return result;
295302}
296303304+function normalizeCommandTurnFromContext(value: unknown): CommandTurnContext | undefined {
305+if (!value || typeof value !== "object") {
306+return undefined;
307+}
308+const record = value as Partial<CommandTurnContext>;
309+const kind = record.kind;
310+const source = record.source;
311+if (kind === "native" && source === "native" && typeof record.authorized === "boolean") {
312+return {
313+kind: "native",
314+source: "native",
315+authorized: record.authorized,
316+commandName: typeof record.commandName === "string" ? record.commandName : undefined,
317+body: typeof record.body === "string" ? record.body : undefined,
318+};
319+}
320+if (kind === "text-slash" && source === "text" && typeof record.authorized === "boolean") {
321+return {
322+kind: "text-slash",
323+source: "text",
324+authorized: record.authorized,
325+commandName: typeof record.commandName === "string" ? record.commandName : undefined,
326+body: typeof record.body === "string" ? record.body : undefined,
327+};
328+}
329+if (kind === "normal" && source === "message") {
330+return {
331+kind: "normal",
332+source: "message",
333+authorized: false,
334+commandName: typeof record.commandName === "string" ? record.commandName : undefined,
335+body: typeof record.body === "string" ? record.body : undefined,
336+};
337+}
338+return undefined;
339+}
340+297341export function resolveWhatsAppDmRouteTarget(params: {
298342msg: WebInboundMsg;
299343senderE164?: string;
@@ -427,6 +471,7 @@ export async function dispatchWhatsAppBufferedReply(params: {
427471params.context.CommandSource === "native" || params.context.CommandSource === "text"
428472 ? params.context.CommandSource
429473 : undefined;
474+const sourceReplyCommandTurn = normalizeCommandTurnFromContext(params.context.CommandTurn);
430475const sourceReplyCommandAuthorized =
431476typeof params.context.CommandAuthorized === "boolean"
432477 ? params.context.CommandAuthorized
@@ -437,6 +482,7 @@ export async function dispatchWhatsAppBufferedReply(params: {
437482cfg: params.cfg,
438483ctx: {
439484ChatType: sourceReplyChatType,
485+CommandTurn: sourceReplyCommandTurn,
440486CommandSource: sourceReplyCommandSource,
441487CommandAuthorized: sourceReplyCommandAuthorized,
442488},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。