Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 对账注入改白名单判定,堵住 /compact 与合成续跑漏网
Kafeifei587c5d593bb5
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.tsindex bebc118a95..943eee36d3 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts@@ -1445,7 +1445,9 @@ describe('session-agent-switch handoff injection', () => {});const transaction = createMakerSendTransaction(deps);- await transaction.sendToAgentAccepted('session-1', { type: 'user', content: '新消息' }, undefined, {});+ await transaction.sendToAgentAccepted('session-1', { type: 'user', content: '新消息' }, undefined, {+ persistUserMessage: { clientId: 'client-1', content: '新消息' },+ });expect(session.send).toHaveBeenCalledWith({ type: 'user', content: 'RECONCILE-NOTE\n\nHANDOFF-TEXT\n\n新消息' },expect.anything(),@@ -1475,6 +1477,31 @@ describe('session-agent-switch handoff injection', () => {expect.anything(),);+ // /compact 等斜杠控制消息(白名单判据:落库内容以 '/' 开头)+ await transaction.sendToAgentAccepted('session-1', { type: 'user', content: '/compact' }, undefined, {+ persistUserMessage: { clientId: 'c3', content: '/compact' },+ });+ expect(session.send).toHaveBeenLastCalledWith(+ { type: 'user', content: '/compact' },+ expect.anything(),+ );++ // coordinator 的合成续跑指令([UI_ACTION_TRIGGER] 前缀)+ await transaction.sendToAgentAccepted('session-1', { type: 'user', content: '[UI_ACTION_TRIGGER]Continue' }, undefined, {+ persistUserMessage: { clientId: 'c4', content: '[UI_ACTION_TRIGGER]Continue' },+ });+ expect(session.send).toHaveBeenLastCalledWith(+ { type: 'user', content: '[UI_ACTION_TRIGGER]Continue' },+ expect.anything(),+ );++ // 不落可显示 user 行的派发(无 persistUserMessage)+ await transaction.sendToAgentAccepted('session-1', { type: 'user', content: '内部控制' }, undefined, {});+ expect(session.send).toHaveBeenLastCalledWith(+ { type: 'user', content: '内部控制' },+ expect.anything(),+ );+// 内部派发路径不应触发对账查询expect(peekPlanReconcileNote).not.toHaveBeenCalled();});diff --git a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts b/apps/desktop/src/main/maker-ipc/makerSendTransaction.tsindex 47143f3e38..8f75fce334 100644--- a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts+++ b/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts@@ -746,18 +746,31 @@ export function createMakerSendTransaction(deps: MakerSendTransactionDeps): Make: normalized;// 计划对账:旧的未收口计划让 agent 顺手交代(更新/修订/清掉)。位置在交接段// 之前——两段各自带"以下是用户的新消息"式结束标记,对账在外层不破坏交接正文。- // 只对普通用户开启的新轮次注入:scheduler 定时消息(origin)、自动续跑- // (persistUserMessage.autoResume)都是内部派发,它们的"用户消息"不代表用户- // 换了话题,注入会让自动轮次去动一份用户没打算收的计划。+ // 只对"用户真的开口"的普通新轮次注入,判定用白名单而非枚举内部来源+ // (scheduler/auto-resume/compact/UI 触发续跑…漏一个就会让自动轮次去动+ // 一份用户没打算收的计划):+ // - 排除一切带内部来源标记的派发(origin / autoResume);+ // - 排除斜杠控制消息(/compact 等,以 '/' 开头的纯指令)与合成触发+ // ([UI_ACTION_TRIGGER] 前缀,coordinator 的续跑指令);+ // - 只在消息即将作为可显示 user 行落库(persistUserMessage.content 非空)+ // 时注入——内部控制轮次都不落可显示 user 行。// 失败静默跳过:对账是锦上添花,不能挡发送。const soForReconcile = (outgoingSendOpts ?? {}) as MakerSendOptions;- const isInternalDispatch =- soForReconcile.origin !== undefined ||- soForReconcile.persistUserMessage?.autoResume === true ||- soForReconcile.persistUserMessage?.origin !== undefined;- const planReconcileNote = isInternalDispatch- ? null- : ((await deps.peekPlanReconcileNote?.(sessionId).catch(() => null)) ?? null);+ const reconcilePersistContent =+ typeof soForReconcile.persistUserMessage?.content === 'string'+ ? soForReconcile.persistUserMessage.content+ : null;+ const isOrdinaryUserTurn =+ soForReconcile.origin === undefined &&+ soForReconcile.persistUserMessage?.autoResume !== true &&+ soForReconcile.persistUserMessage?.origin === undefined &&+ reconcilePersistContent !== null &&+ reconcilePersistContent.length > 0 &&+ !reconcilePersistContent.startsWith('/') &&+ !reconcilePersistContent.startsWith('[UI_ACTION_TRIGGER]');+ const planReconcileNote = isOrdinaryUserTurn+ ? ((await deps.peekPlanReconcileNote?.(sessionId).catch(() => null)) ?? null)+ : null;const withPlanReconcile = planReconcileNote? prependNoteToWireUserMessage(withHandoff as HandoffWireMessage, planReconcileNote): withHandoff;