






















@@ -6,8 +6,7 @@ import {
66} from "openclaw/plugin-sdk/channel-message";
77import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
88import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
9-import { kindFromMime } from "openclaw/plugin-sdk/media-runtime";
10-import { resolveOutboundAttachmentFromUrl } from "openclaw/plugin-sdk/media-runtime";
9+import { kindFromMime, resolveOutboundAttachmentFromUrl } from "openclaw/plugin-sdk/media-runtime";
1110import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
1211import { convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
1312import { stripInlineDirectiveTagsForDelivery } from "openclaw/plugin-sdk/text-chunking";
@@ -48,6 +47,7 @@ type IMessageSendOpts = {
4847type IMessageSendResult = {
4948messageId: string;
5049sentText: string;
50+echoText?: string;
5151receipt: MessageReceipt;
5252};
5353@@ -94,13 +94,13 @@ function resolveMessageId(result: Record<string, unknown> | null | undefined): s
9494return raw ? raw.trim() : null;
9595}
969697-function resolveDeliveredIMessageText(text: string, mediaContentType?: string): string {
97+function resolveOutboundEchoText(text: string, mediaContentType?: string): string | undefined {
9898if (text.trim()) {
9999return text;
100100}
101101const kind = kindFromMime(mediaContentType ?? undefined);
102102if (!kind) {
103-return text;
103+return undefined;
104104}
105105return kind === "image" ? "<media:image>" : `<media:${kind}>`;
106106}
@@ -187,6 +187,7 @@ export async function sendMessageIMessage(
187187 : 16 * 1024 * 1024;
188188let message = text ?? "";
189189let filePath: string | undefined;
190+let mediaContentType: string | undefined;
190191191192if (opts.mediaUrl?.trim()) {
192193const resolveAttachmentFn = opts.resolveAttachmentImpl ?? resolveOutboundAttachmentFromUrl;
@@ -195,7 +196,7 @@ export async function sendMessageIMessage(
195196readFile: opts.mediaReadFile,
196197});
197198filePath = resolved.path;
198-message = resolveDeliveredIMessageText(message, resolved.contentType ?? undefined);
199+mediaContentType = resolved.contentType ?? undefined;
199200}
200201201202if (!message.trim() && !filePath) {
@@ -224,6 +225,7 @@ export async function sendMessageIMessage(
224225if (!message.trim() && !filePath) {
225226throw new Error("iMessage send requires text or media");
226227}
228+const echoText = resolveOutboundEchoText(message, filePath ? mediaContentType : undefined);
227229const resolvedReplyToId = sanitizeReplyToId(opts.replyToId);
228230const params: Record<string, unknown> = {
229231text: message,
@@ -266,7 +268,7 @@ export async function sendMessageIMessage(
266268if (echoScope) {
267269rememberPersistedIMessageEcho({
268270scope: echoScope,
269-text: message,
271+text: echoText,
270272messageId: resolvedId ?? undefined,
271273});
272274}
@@ -293,6 +295,7 @@ export async function sendMessageIMessage(
293295return {
294296 messageId,
295297sentText: message,
298+ ...(echoText ? { echoText } : {}),
296299receipt: createIMessageSendReceipt({
297300 messageId,
298301 target,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。