惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
J
Java Code Geeks
Vercel News
Vercel News
A
About on SuperTechFans
G
Google Developers Blog
C
Check Point Blog
腾讯CDC
N
Netflix TechBlog - Medium
博客园 - 司徒正美
S
SegmentFault 最新的问题
D
DataBreaches.Net
博客园_首页
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
量子位
雷峰网
雷峰网
IT之家
IT之家
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
H
Help Net Security
宝玉的分享
宝玉的分享
博客园 - 叶小钗

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat(whatsapp): support native outbound mentions (#73961)...
openclaw-clo · 2026-05-03 · via Recent Commits to openclaw:main

@@ -40,6 +40,12 @@ import {

4040

} from "./extract.js";

4141

import { attachEmitterListener, closeInboundMonitorSocket } from "./lifecycle.js";

4242

import { downloadInboundMedia, downloadQuotedInboundMedia } from "./media.js";

43+

import {

44+

addWhatsAppOutboundMentionsToContent,

45+

mayContainWhatsAppOutboundMention,

46+

resolveWhatsAppOutboundMentions,

47+

type WhatsAppOutboundMentionParticipant,

48+

} from "./outbound-mentions.js";

4349

import { DisconnectReason, isJidGroup, saveMediaBuffer } from "./runtime-api.js";

4450

import { createWebSendApi } from "./send-api.js";

4551

import { normalizeWhatsAppSendResult } from "./send-result.js";

@@ -57,6 +63,7 @@ type WhatsAppGroupMetadataCacheEntry = {

5763

export type WhatsAppGroupMetadataCache = Map<string, WhatsAppGroupMetadataCacheEntry>;

5864

type LocalGroupMetadataCacheEntry = WhatsAppGroupMetadataCacheEntry & {

5965

participants?: string[];

66+

mentionParticipants?: WhatsAppOutboundMentionParticipant[];

6067

};

61686269

function rememberGroupMetadataCacheEntry<T extends WhatsAppGroupMetadataCacheEntry>(

@@ -355,18 +362,26 @@ export async function attachWebInboxToSocket(

355362

};

356363357364

const summarizeGroupMeta = async (meta: GroupMetadata) => {

358-

const participants =

359-

(

360-

await Promise.all(

361-

meta.participants?.map(async (p) => {

362-

const mapped = await resolveInboundJid(p.id);

363-

return mapped ?? p.id;

364-

}) ?? [],

365-

)

366-

).filter(Boolean) ?? [];

365+

const participantEntries = await Promise.all(

366+

meta.participants?.map(async (p) => {

367+

const mapped = await resolveInboundJid(p.id);

368+

return {

369+

display: mapped ?? p.id,

370+

mention: {

371+

id: p.id,

372+

lid: p.lid,

373+

phoneNumber: p.phoneNumber,

374+

e164: mapped,

375+

} satisfies WhatsAppOutboundMentionParticipant,

376+

};

377+

}) ?? [],

378+

);

379+

const participants = participantEntries.map((entry) => entry.display).filter(Boolean);

380+

const mentionParticipants = participantEntries.map((entry) => entry.mention);

367381

return {

368382

subject: meta.subject,

369383

participants,

384+

mentionParticipants,

370385

expires: Date.now() + GROUP_META_TTL_MS,

371386

};

372387

};

@@ -384,7 +399,7 @@ export async function attachWebInboxToSocket(

384399

return cached;

385400

}

386401

try {

387-

const meta = await sock.groupMetadata(jid);

402+

const meta = await (getCurrentSock() ?? sock).groupMetadata(jid);

388403

const entry = await summarizeGroupMeta(meta);

389404

rememberGroupMetadataCacheEntry(groupMetadataCache, jid, {

390405

subject: entry.subject,

@@ -410,6 +425,43 @@ export async function attachWebInboxToSocket(

410425

}

411426

};

412427428+

const resolveOutboundMentionsForGroup = async (

429+

jid: string,

430+

text: string,

431+

): Promise<{ text: string; mentionedJids: string[] }> => {

432+

if (!isGroupJid(jid) || !mayContainWhatsAppOutboundMention(text)) {

433+

return { text, mentionedJids: [] };

434+

}

435+

const meta = await getGroupMeta(jid);

436+

return resolveWhatsAppOutboundMentions({

437+

chatJid: jid,

438+

text,

439+

participants: meta.mentionParticipants,

440+

});

441+

};

442+443+

const applyOutboundMentionsToContent = async (

444+

jid: string,

445+

content: AnyMessageContent,

446+

): Promise<AnyMessageContent> => {

447+

if ("text" in content && typeof content.text === "string") {

448+

const resolved = await resolveOutboundMentionsForGroup(jid, content.text);

449+

return addWhatsAppOutboundMentionsToContent(

450+

{ ...content, text: resolved.text } as AnyMessageContent,

451+

resolved.mentionedJids,

452+

);

453+

}

454+

const caption = (content as { caption?: unknown }).caption;

455+

if (typeof caption === "string") {

456+

const resolved = await resolveOutboundMentionsForGroup(jid, caption);

457+

return addWhatsAppOutboundMentionsToContent(

458+

{ ...content, caption: resolved.text } as AnyMessageContent,

459+

resolved.mentionedJids,

460+

);

461+

}

462+

return content;

463+

};

464+413465

type NormalizedInboundMessage = {

414466

id?: string;

415467

remoteJid: string;

@@ -632,14 +684,23 @@ export async function attachWebInboxToSocket(

632684

}

633685

};

634686

const reply = async (text: string, options?: MiscMessageGenerationOptions) => {

635-

const result = await sendTrackedMessage(chatJid, { text }, options);

687+

const resolved = await resolveOutboundMentionsForGroup(chatJid, text);

688+

const result = await sendTrackedMessage(

689+

chatJid,

690+

addWhatsAppOutboundMentionsToContent({ text: resolved.text }, resolved.mentionedJids),

691+

options,

692+

);

636693

return normalizeWhatsAppSendResult(result, "text");

637694

};

638695

const sendMedia = async (

639696

payload: AnyMessageContent,

640697

options?: MiscMessageGenerationOptions,

641698

) => {

642-

const result = await sendTrackedMessage(chatJid, payload, options);

699+

const result = await sendTrackedMessage(

700+

chatJid,

701+

await applyOutboundMentionsToContent(chatJid, payload),

702+

options,

703+

);

643704

return normalizeWhatsAppSendResult(result, "media");

644705

};

645706

const timestamp = inbound.messageTimestampMs;

@@ -856,6 +917,7 @@ export async function attachWebInboxToSocket(

856917

},

857918

},

858919

defaultAccountId: options.accountId,

920+

resolveOutboundMentions: ({ jid, text }) => resolveOutboundMentionsForGroup(jid, text),

859921

});

860922861923

return {