Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(feishu): tell the companion when the group speaker is the owner
Zhao Dengfengd8ac23f09b7a
diff --git a/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts b/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.tsindex 357e674403..c9705cc508 100644--- a/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts+++ b/apps/desktop/src/main/im/feishu/__tests__/feishuAdapter.test.ts@@ -725,6 +725,7 @@ describe('feishu group lane adapter hooks', () => {chatKind: 'group',chatId: 'oc_note1',senderId: 'ou_owner',+ senderIsOwner: true,toolsHint,});await vi.waitFor(() => expect(getChatName).toHaveBeenCalledWith('oc_note1'));@@ -734,13 +735,20 @@ describe('feishu group lane adapter hooks', () => {chatId: 'oc_note1',chatName: '产品群',senderId: 'ou_owner',+ senderIsOwner: true,toolsHint,});// 预取失败不影响本条, 也不抛错。getChatName.mockRejectedValueOnce(new Error('no permission'));expect(await adapter.channelNoteSourceFor?.(groupEvent({ senderId: 'g/oc_note2', chatId: 'oc_note2' })),- ).toEqual({ chatKind: 'group', chatId: 'oc_note2', senderId: 'ou_owner', toolsHint });+ ).toEqual({ chatKind: 'group', chatId: 'oc_note2', senderId: 'ou_owner', senderIsOwner: true, toolsHint });+ // 群成员发言不标主人。+ expect(+ await adapter.channelNoteSourceFor?.(+ groupEvent({ senderId: 'g/oc_note2', chatId: 'oc_note2', speaker: { id: 'ou_m', name: '', isOwner: false } }),+ ),+ ).toEqual({ chatKind: 'group', chatId: 'oc_note2', senderId: 'ou_m', toolsHint });});it('channelToolScopeFor: 作用域钉在触发消息所在的 chat / 话题, 主人身份只认 Main 校验过的 speaker / owner', () => {diff --git a/apps/desktop/src/main/im/feishu/adapter.ts b/apps/desktop/src/main/im/feishu/adapter.tsindex 59738b4017..f86441fe06 100644--- a/apps/desktop/src/main/im/feishu/adapter.ts+++ b/apps/desktop/src/main/im/feishu/adapter.ts@@ -411,6 +411,8 @@ export function buildFeishuAdapter(chatId: lane.chatId,...(chatName ? { chatName } : {}),...(event.speaker?.id ? { senderId: event.speaker.id } : {}),+ // 群里认出主人只能靠这一句: 发言人只有 open_id, 模型无从自行核对。+ ...(event.speaker?.isOwner === true ? { senderIsOwner: true } : {}),toolsHint,};},diff --git a/apps/desktop/src/main/im/shared/__tests__/channelNote.test.ts b/apps/desktop/src/main/im/shared/__tests__/channelNote.test.tsindex f994825eac..58aefdf378 100644--- a/apps/desktop/src/main/im/shared/__tests__/channelNote.test.ts+++ b/apps/desktop/src/main/im/shared/__tests__/channelNote.test.ts@@ -95,6 +95,21 @@ describe('guest direct messages', () => {});});+describe('group owner speaker', () => {+ // #7519: 群里只有 open_id, 不写「是主人」时伙伴只能把主人当普通成员。+ it('says the Main-verified group speaker is the owner, and stays silent otherwise', () => {+ expect(+ buildImChannelNote('feishu', { chatKind: 'group', chatId: 'oc_x', senderId: 'ou_o', senderIsOwner: true }),+ ).toBe('[渠道说明] 系统追加,不是用户消息。本条来自飞书群 (chat_id: oc_x),发言人 (user_id: ou_o),是主人。');+ expect(+ buildImChannelNote('feishu', { chatKind: 'group', chatId: 'oc_x', senderId: 'ou_m', senderIsOwner: false }),+ ).toBe('[渠道说明] 系统追加,不是用户消息。本条来自飞书群 (chat_id: oc_x),发言人 (user_id: ou_m)。');+ expect(+ imChannelNoteSourceFromEvent({ chatId: 'c1', speaker: { id: 'u2', name: 'Ann', isOwner: false } }),+ ).toEqual({ chatKind: 'group', chatId: 'c1', senderId: 'u2', senderName: 'Ann' });+ });+});+describe('imMessageOriginFor', () => {it('captures who spoke and where for the UI, falling back to sender-only before the note is known', () => {const event = {@@ -146,7 +161,7 @@ describe('imChannelNoteSourceFromEvent', () => {speaker: { id: 'u1', name: 'u1', isOwner: true },interactionSource: { chatName: 'cid1' },}),- ).toEqual({ chatKind: 'group', chatId: 'cid1', senderId: 'u1' });+ ).toEqual({ chatKind: 'group', chatId: 'cid1', senderIsOwner: true, senderId: 'u1' });expect(imChannelNoteSourceFromEvent({ chatId: 'cid1', speaker: { id: 'u1', name: 'Ann', isOwner: true } },diff --git a/apps/desktop/src/main/im/shared/__tests__/earlyUserMessagePersist.test.ts b/apps/desktop/src/main/im/shared/__tests__/earlyUserMessagePersist.test.tsindex 7cb5b49360..99f2945270 100644--- a/apps/desktop/src/main/im/shared/__tests__/earlyUserMessagePersist.test.ts+++ b/apps/desktop/src/main/im/shared/__tests__/earlyUserMessagePersist.test.ts@@ -155,6 +155,7 @@ describe('messageHandler early user-message persist', () => {expect(turnArgs(h.runAgentTurn).channelNoteSource).toEqual({chatKind: 'group',chatId: 'oc_chat',+ senderIsOwner: true,senderId: 'ou_y',});expect(turnArgs(h.runAgentTurn).text).toBe('出行要注意什么吗');diff --git a/apps/desktop/src/main/im/shared/channelNote.ts b/apps/desktop/src/main/im/shared/channelNote.tsindex c4b3be6dfd..0a12f3112e 100644--- a/apps/desktop/src/main/im/shared/channelNote.ts+++ b/apps/desktop/src/main/im/shared/channelNote.ts@@ -26,6 +26,8 @@ export interface ImChannelNoteSource {/*** 发言人是不是主人。私聊缺省就是主人(不写); 伙伴自有 bot 对外开放后外部用户的* 私聊置 false —— 说明里写明发言人并点出不是主人, 模型才不会把陌生人当成主人。+ * 群里 Main 核验过的主人发言置 true, 说明点出是主人(与 Telegram / 钉钉 `[发言人]`+ * 行的「主人」同源); 否则伙伴只能把群里的主人当普通成员。*/senderIsOwner?: boolean;/**@@ -57,15 +59,18 @@ export function buildImChannelNote(channel: string, source: ImChannelNoteSource));const where = source.chatKind === 'group' ? `${label}群${chatRef}` : `${label}私聊${chatRef}`;const guestDm = source.chatKind === 'direct' && source.senderIsOwner === false;+ const groupOwner = source.chatKind === 'group' && source.senderIsOwner === true;const senderRef =source.chatKind === 'group' || guestDm? formatSourceRef(source.senderName, 'user_id', source.senderId): '';const sender = senderRef- ? `,发言人${senderRef}${guestDm ? ',不是主人' : ''}`+ ? `,发言人${senderRef}${guestDm ? ',不是主人' : groupOwner ? ',是主人' : ''}`: guestDm? ',发言人不是主人'- : '';+ : groupOwner+ ? ',发言人是主人'+ : '';const tools = source.toolsHint?.trim() ? `${source.toolsHint.trim()}` : '';return `[渠道说明] 系统追加,不是用户消息。本条来自${where}${sender}。${tools}`.replace(/ {2,}/g, ' ');}@@ -151,6 +156,7 @@ export function imChannelNoteSourceFromEvent();return {...group,+ ...(event.speaker.isOwner === true ? { senderIsOwner: true } : {}),...(senderId ? { senderId } : {}),...(senderName ? { senderName } : {}),};diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.mdindex 4a1deef570..39a60cf07a 100644--- a/docs/product-rules/cindy-bots-runtime.md+++ b/docs/product-rules/cindy-bots-runtime.md@@ -198,7 +198,8 @@ Discord 传输层只放行主人,钉钉群里被 @ 时成员也能触发(成`/permission` 三条,单源见 `im/shared/botCommands.ts` 的 `isCompanionManagedCommand`。别人说的不冒充主人:专线里主人与群成员 / 外部用户的消息落在同一条任务,每条消息的 `imSource.origin` 存谁、在哪说的(与发给模型的 `[渠道说明]` / `[发言人]` 同源),任务面板的卡头对非主人消息写出发言人与群名,主人消息沿用-「Cindy · 来自 X」;外部用户私聊的渠道说明写明发言人并点出「不是主人」,不再按 speaker 有无把私聊误判成群。+「Cindy · 来自 X」;外部用户私聊的渠道说明写明发言人并点出「不是主人」,不再按 speaker 有无把私聊误判成群;+群里 Main 核验过的主人发言,渠道说明点出「是主人」(Telegram / 钉钉在 `[发言人]` 行标注),否则伙伴只能把群里的主人当成员。「消息平台」页每条连接下有「隐藏任务」小节:列出这条连接名下的主人私聊(伙伴主任务)与各群 / 话题 / 外部用户私聊专线,每条可「重新开始」——复用伙伴已有的 `restartBotCanonicalRuntime` 交接(同一条任务、记录与记忆不删,下一条消息换干净的原生会话),不另写换会话逻辑,见 `im/shared/botImLaneRuntime.ts`。