Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(wechat): 主人消息沿用伙伴权限并修正设置说明
nanaf8e1ab736fbd
diff --git a/apps/desktop/src/main/im/wechat/WechatIM.ts b/apps/desktop/src/main/im/wechat/WechatIM.tsindex 9220ea51eb..008a3c9d0c 100644--- a/apps/desktop/src/main/im/wechat/WechatIM.ts+++ b/apps/desktop/src/main/im/wechat/WechatIM.ts@@ -1185,14 +1185,18 @@ export class WechatIM extends BaseIM implements RichChannelIM {active.routeSessionId = sessionId;}},- turnPermissionPolicy: createWechatTurnPermissionPolicy(task.id, {- onInteractionStateChange: (state) => {- void this.#requireStore().setWaitingDesktop(- task.bindingEpoch,- task.id,- state === 'waiting',- );- },+ // Only credential-verified companion owners inherit the native mode.+ // Guests and standalone channels retain the mandatory turn policy.+ ...(companion && requesterIsOwner ? {} : {+ turnPermissionPolicy: createWechatTurnPermissionPolicy(task.id, {+ onInteractionStateChange: (state) => {+ void this.#requireStore().setWaitingDesktop(+ task.bindingEpoch,+ task.id,+ state === 'waiting',+ );+ },+ }),}),});} catch (error) {@@ -1367,7 +1371,7 @@ export class WechatIM extends BaseIM implements RichChannelIM {return;}if (companion && /^\/(?:permission|model|project)(?:\s|$)/.test(command)) {- await this.#commitSimpleReply(task, '请在 Cindy 的伙伴设置中调整模型和权限。');+ await this.#commitSimpleReply(task, '请在 Cindy 中打开这位伙伴:模型在伙伴设置中调整,权限在对话输入框下方切换。');return;}if (/^\/permission(?:\s|$)/.test(command)) {@@ -2072,8 +2076,8 @@ export function wechatPreDispatchFailureText(reason: string, companion = false):reason.includes(WECHAT_TURN_PERMISSION_POLICY_UNSUPPORTED)|| reason.includes('unsupported_turn_permission'))) {- return '当前伙伴的模型或权限模式不支持微信的逐次权限确认,消息无法启动。\n'- + '请主人在 Cindy 的伙伴设置中选择 Claude Code 或 Codex,并将权限设为自动审查或询问,然后重试。';+ return '这条消息需要逐次权限确认,但伙伴当前的模型或权限模式不支持,消息无法启动。\n'+ + '请主人在 Cindy 中打开这位伙伴,检查伙伴设置中的模型,并在对话输入框下方选择默认权限或自动审批。';}if (reason.includes(`${WECHAT_TURN_PERMISSION_POLICY_UNSUPPORTED}:agent`)) {// 当前权限模式若是换 Agent 后仍不兼容的档位(bypassPermissions / acceptEdits),diff --git a/apps/desktop/src/main/im/wechat/__tests__/WechatIM.test.ts b/apps/desktop/src/main/im/wechat/__tests__/WechatIM.test.tsindex cc1a6451d5..ca64b6072b 100644--- a/apps/desktop/src/main/im/wechat/__tests__/WechatIM.test.ts+++ b/apps/desktop/src/main/im/wechat/__tests__/WechatIM.test.ts@@ -12,6 +12,7 @@ import {beginInteractionRoute, installDesktopInteractionHandler, requestHostInteraction,} from '../../../maker-ipc/interactionRouter';import type { SharedPermission } from '../../../maker-ipc/sharedPermission';+import { encryptWechatContextToken } from '../contextCrypto';import { __testing, sessionIdFor, WechatIM, type WechatIMDeps } from '../WechatIM';const mediaMocks = vi.hoisted(() => ({@@ -27,6 +28,45 @@ vi.mock('../mediaStaging', async (importOriginal) => {});describe('WechatIM host boundary', () => {++ // Exercise the durable inbox through the public host lifecycle. Only the+ // credential-verified owner of a linked companion inherits native permissions.+ it.each([+ { companion: true, peer: 'owner', forcedPolicy: false },+ { companion: true, peer: 'guest', forcedPolicy: true },+ { companion: true, peer: '', forcedPolicy: true },+ { companion: false, peer: 'owner', forcedPolicy: true },+ ])('preserves the permission boundary: %j', async ({ companion, peer, forcedPolicy }) => {+ const { im, db } = restoredConnection(() => 0);+ let leased = false;+ vi.mocked(db.tx).mockImplementation((async (name: string) => {+ if (name !== 'wechatLeaseNextTask' || leased) return null;+ leased = true;+ return {+ id: 'permission-task', bindingEpoch: 'epoch', peerId: peer,+ sessionId: 'permission-session', conversationEpoch: 1,+ payloadJson: JSON.stringify({ text: 'hello', attachments: [], unsupportedMedia: [] }),+ context: encryptWechatContextToken('context', Buffer.alloc(32, 3), 'epoch', 'permission-task'),+ attempts: 0, receivedAt: 1, expiresAt: Date.now() + 60_000,+ };+ }) as DbClient['tx']);+ const dispatchAgentTurn = vi.fn(async (_input: {+ turnPermissionPolicy?: { confirmationSurface: string }; requesterIsOwner?: boolean;+ }) => ({ kind: 'accepted', terminal: Promise.resolve({ kind: 'done' }) }));+ im.attachTurnRuntime({ runner: {+ companionBotIdFor: () => companion ? 'cindy' : undefined,+ dispatchAgentTurn,+ } } as never);+ await im.init();+ try {+ await vi.waitFor(() => expect(dispatchAgentTurn).toHaveBeenCalledOnce());+ const input = dispatchAgentTurn.mock.calls[0]![0];+ expect(Boolean(input.turnPermissionPolicy)).toBe(forcedPolicy);+ expect(input.requesterIsOwner).toBe(companion ? peer === 'owner' : undefined);+ if (forcedPolicy) expect(input.turnPermissionPolicy?.confirmationSurface).toBe('channel');+ } finally { await im.dispose(); }+ });+it.each([{ text: '解释这张图', delivered: true },{ text: '', delivered: true },@@ -120,7 +160,7 @@ describe('WechatIM host boundary', () => {});it('distinguishes agent-unsupported from permission-mode-unsupported pre-dispatch failures', () => {- // Agent 未声明 turnPermissionPolicy(如 Pi):换权限模式无效,文案引导换 Agent。+ // 未声明 turnPermissionPolicy 的 Agent:换权限模式无效。expect(__testing.wechatPreDispatchFailureText('TURN_PERMISSION_POLICY_UNSUPPORTED:agent:ask')).toContain('换成 Claude Code 或 Codex',);@@ -157,8 +197,8 @@ describe('WechatIM host boundary', () => {'TURN_PERMISSION_POLICY_UNSUPPORTED:agent:bypassPermissions', true,);expect(companionFailure).toContain('伙伴设置');- expect(companionFailure).toContain('Claude Code 或 Codex');- expect(companionFailure).toContain('自动审查或询问');+ expect(companionFailure).toContain('对话输入框下方');+ expect(companionFailure).toContain('默认权限或自动审批');expect(companionFailure).not.toContain('/permission');});diff --git a/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx b/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsxindex 81eff85e4b..ac1801e398 100644--- a/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx+++ b/apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx@@ -73,7 +73,7 @@ export function ImChannelSettingsCard({return (<sectionclassName={cn(- 'overflow-hidden rounded-xl',+ 'overflow-hidden rounded-xl [container-type:inline-size]','border border-[var(--settings-theme-card-border)]','bg-[var(--settings-theme-card-bg)]',)}@@ -102,7 +102,7 @@ export function ImChannelSettingsCard({</span><span className="flex min-w-0 shrink-0 items-center gap-3">- {routeSummary ? <span className="hidden w-[220px] truncate text-right text-12 text-[var(--text-secondary)] md:block">+ {routeSummary ? <span className="hidden w-[220px] truncate text-right text-12 text-[var(--text-secondary)] [@container(min-width:600px)]:block">{routeSummary}</span> : null}{status}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex e5e321e289..9fe45aac97 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -4065,7 +4065,7 @@"assigned": "Replies come from the linked teammate","description": "Chat with {{name}} on WeChat, sharing memory and the main task. This computer’s WeChat connection can belong to one teammate at a time.","other": "WeChat is linked to another teammate. Remove that link in their connection settings or Personal WeChat settings first.",- "permissionNote": "WeChat keeps per-action permission checks. Choose Claude Code or Codex for this teammate, with Auto-review or Ask permissions.",+ "permissionNote": "Your WeChat messages to this teammate use its permission settings, including Full access. Change permissions below the teammate’s chat input in Cindy. Messages from other people remain restricted.","remove": "Remove teammate link","useExisting": "Use connected WeChat with {{name}}","updateFailed": "Could not update the link. Wait for WeChat tasks to finish, then retry and check that the teammate is available."diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex c634b6c660..ce62f8bcc8 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -4034,7 +4034,7 @@"assigned": "連携したチームメイトが返信します","description": "WeChat で {{name}} と話し、記憶とメインタスクを共有します。このパソコンの WeChat 接続を連携できるチームメイトは一度に 1 人です。","other": "WeChat は別のチームメイトと連携しています。そのチームメイトの接続設定、または個人 WeChat の設定で先に連携を解除してください。",- "permissionNote": "WeChat では操作ごとの権限確認を維持します。チームメイトに Claude Code または Codex を選び、権限を自動審査または確認に設定してください。",+ "permissionNote": "あなたが WeChat で送るメッセージには、完全アクセスを含むチームメイトの権限設定が適用されます。権限は Cindy のチームメイトとのチャット入力欄の下で変更できます。他の人のメッセージには引き続き権限制限が適用されます。","remove": "チームメイトとの連携を解除","useExisting": "接続済みの WeChat で {{name}} と話す","updateFailed": "連携を更新できませんでした。WeChat のタスクが終わってから再試行し、チームメイトが利用可能か確認してください。"diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 66f9c9d783..3e27287d8d 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -4034,7 +4034,7 @@"assigned": "연결된 팀메이트가 답장합니다","description": "WeChat에서 {{name}}와 대화하며 기억과 기본 작업을 공유합니다. 이 컴퓨터의 WeChat 연결은 한 번에 한 팀메이트에게만 연결할 수 있습니다.","other": "WeChat이 다른 팀메이트에게 연결되어 있습니다. 해당 팀메이트의 연결 설정이나 개인 WeChat 설정에서 먼저 연결을 해제하세요.",- "permissionNote": "WeChat은 작업별 권한 확인을 유지합니다. 팀메이트에 Claude Code 또는 Codex를 선택하고 권한을 자동 검토 또는 확인으로 설정하세요.",+ "permissionNote": "내가 WeChat에서 보내는 메시지에는 전체 액세스를 포함한 팀메이트의 권한 설정이 적용됩니다. Cindy의 팀메이트 채팅 입력란 아래에서 권한을 변경할 수 있습니다. 다른 사람이 보낸 메시지에는 기존 권한 제한이 유지됩니다.","remove": "팀메이트 연결 해제","useExisting": "연결된 WeChat으로 {{name}}와 대화","updateFailed": "연결을 변경하지 못했습니다. WeChat 작업이 끝난 뒤 다시 시도하고 팀메이트를 사용할 수 있는지 확인하세요."diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 0f0fe7389c..87f6a7dd33 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -4034,7 +4034,7 @@"assigned": "由绑定的伙伴回复","description": "在微信中与 {{name}} 对话,共用记忆和主任务。此电脑上的微信连接一次只能交给一位伙伴。","other": "微信已交给另一位伙伴。请先在该伙伴的连接设置或个人微信设置中移除绑定。",- "permissionNote": "微信继续使用逐次权限确认。请为伙伴选择 Claude Code 或 Codex,并使用自动审查或询问模式。",+ "permissionNote": "你在微信中发给伙伴的消息沿用伙伴的权限设置,包括完全访问。可在 Cindy 的伙伴对话输入框下方切换权限;其他人的消息仍受权限限制。","remove": "移除伙伴绑定","useExisting": "使用已连接的微信与 {{name}} 对话","updateFailed": "未能更新绑定。请等待微信中的任务结束后重试,并确认伙伴仍可用。"diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex d6cdcbde1a..c83a340cb0 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -4034,7 +4034,7 @@"assigned": "由繫結的夥伴回覆","description": "在微信中與 {{name}} 對話,共用記憶和主要任務。此電腦上的微信連線一次只能交給一位夥伴。","other": "微信已交給另一位夥伴。請先在該夥伴的連線設定或個人微信設定中移除繫結。",- "permissionNote": "微信繼續使用逐次權限確認。請為夥伴選擇 Claude Code 或 Codex,並使用自動審查或詢問模式。",+ "permissionNote": "你在微信中傳給夥伴的訊息沿用夥伴的權限設定,包括完全存取。可在 Cindy 的夥伴對話輸入框下方切換權限;其他人的訊息仍受權限限制。","remove": "移除夥伴繫結","useExisting": "使用已連線的微信與 {{name}} 對話","updateFailed": "無法更新繫結。請等微信中的工作結束後重試,並確認夥伴仍可用。"diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.mdindex fc7269e77e..85c5589ae6 100644--- a/docs/product-rules/cindy-bots-runtime.md+++ b/docs/product-rules/cindy-bots-runtime.md@@ -115,7 +115,7 @@ Telegram 设为全响应的群;设置页的人格与行为配置不带。移个人微信复用既有扫码授权通道:伙伴设置「消息平台」可连接或接管当前个人微信,单个本地账号只绑定一位伙伴;绑定只保存伙伴归属,不复制凭证、不创建第二份轮询。主人私聊进入主任务,其他私聊进入渠道专线。解除伙伴关联恢复个人微信独立路由,保留微信授权与原工作目录;有排队消息或运行中的任务时拒绝切换。-微信仍沿用渠道的逐轮权限确认约束,模型需为 Claude Code / Codex,权限需为自动审查或询问。+绑定伙伴后,经微信连接凭证确认的主人消息沿用伙伴的原生权限档(包括完全访问),Claude Code、Codex、Pi 使用同一入口,不额外挂逐轮强确认策略,也不改写伙伴权限。非主人、身份未知以及未绑定伙伴的个人微信仍保留原渠道逐轮权限约束;只有支持该策略的引擎与权限档才能执行。权限在 Cindy 的伙伴对话输入框下方切换,模型在伙伴设置中调整。实现与回归见 `im/wechat/WechatIM.ts`、`im/wechat/__tests__/WechatIM.test.ts`。绑定伙伴后,访客触发的工具权限仅由主人的 Desktop/同账号手机确认;不向访客发送权限提示或接受其授权回复。主人微信确认与访客普通问答保持原有行为。每条连接一份传输层实例(复用个人 bot 的各渠道适配器,凭证按连接 id 前缀隔离在本机安全存储),它说什么、记得什么、会什么、用什么模型,全部来自伙伴。主人私聊进该伙伴的 canonical 主任务;每个群 / 话题与