Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(handoff): narrow owner-quotation formatting to companion task instructions
zqchrise1a1a199fa0a
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex bffcb93b12..a27a7c093d 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -1,8 +1,6 @@import { captureAgentRequest } from '../../../maker-ipc/forwardedRequest';import { admitTaskAction, TaskActionAuthorizationError } from '../../../maker-ipc/taskActionAuthorization';import { formatForwardedRequest } from '../../../../shared/forwardedRequest';-const forwarded = (text: string) => formatForwardedRequest({ userText: null }, text);-const supplement = (text: string): string => JSON.parse(text.split('\n').find(line => line.startsWith('Agent supplement:'))!.slice('Agent supplement:'.length));import { AcceptedCallbackDispatchCancelled, runAcceptedCallback } from '../../../maker-ipc/acceptedCallbackRunner';import { setSessionOpeningModelAdmission } from '../../sessionOpening';import { ScriptTarget, transpileModule } from 'typescript';@@ -5478,7 +5476,7 @@ describe('Bot Session task end-to-end runtime', () => {if (boundary === 'valid') {expect(result).toMatchObject({ ok: true });expect(operation === 'edit' ? replace : remove).toHaveBeenCalledOnce();- if (operation === 'edit') expect(queue[0].persistedContent).toBe(forwarded('Updated input'));+ if (operation === 'edit') expect(queue[0].persistedContent).toBe('Updated input');else expect(queue).toEqual([]);expect(runtime.flushInput).toHaveBeenCalledOnce();} else {@@ -6328,6 +6326,8 @@ describe('Bot Session task end-to-end runtime', () => {await seedPair();const runtime = createDelegationRuntime({replyFor: () => '结论:三个版本都兼容。',+ captureRequest: (id, text) => captureAgentRequest(id, text,+ { clientId: 'owner-input', authoredText: '查一下兼容矩阵,不要发布。' }, async () => [], true),});try {const delegated = await runtime.delegation.startSessionTask({@@ -6371,7 +6371,9 @@ describe('Bot Session task end-to-end runtime', () => {const completionDispatch = runtime.dispatch.mock.calls.map(([params]) => params).find((params) => params.clientId === completionClientId);- expect(supplement(completionDispatch!.message).startsWith('[任务回执]')).toBe(true);+ expect(completionDispatch!.message.startsWith('[任务回执]')).toBe(true);+ expect(completionDispatch!.message).not.toContain('User’s original words:');+ expect(completionDispatch!.autoReviewUserText).toEqual({ kind: 'agent-request' });expect(completionDispatch?.persistedContent).toBe(`${UI_ACTION_TRIGGER_PREFIX}${completionDispatch?.message}`);// 发起方那一侧也真的被唤醒了(否则「结果回到 A 的对话」只是写了一行数据库)。expect(runtime.started.some((turn) => turn.sessionId === 'session-1')).toBe(true);@@ -7338,7 +7340,7 @@ describe('Bot Session task end-to-end runtime', () => {let original = ' 只检查\n不要发布 ';let unavailable = true;const captureRequest = (id: string, text: string) => captureAgentRequest(id, text,- { clientId: 'human', authoredText: original }, async () => []);+ { clientId: 'human', authoredText: original }, async () => [], true);const runtime = createDelegationRuntime({ captureRequest, transientUnavailable: () => unavailable });let restored: ReturnType<typeof createDelegationRuntime> | undefined;try {@@ -7372,9 +7374,9 @@ describe('Bot Session task end-to-end runtime', () => {const result = await runtime.delegation.messageSessionTask('session-1', task.delegationId, { kind: 'message', text });expect(result).toMatchObject({ ok: true, childSessionId: task.childSessionId });const sent = runtime.dispatch.mock.calls.filter(([input]) => input.targetSessionId === task.childSessionId).at(-1)![0];- expect(sent.persistedContent).toBe(forwarded(text));- expect(supplement(sent.message).split(objective)).toHaveLength(2);- expect(supplement(sent.message).split(text)).toHaveLength(2);+ expect(sent.persistedContent).toBe(text);+ expect(sent.message.split(objective)).toHaveLength(2);+ expect(sent.message.split(text)).toHaveLength(2);expect(sent.message).not.toContain('Previous objective:');expect(sent.message).not.toContain('R'.repeat(100));if (index > 1) expect(sent.message).not.toContain(`Follow-up ${index - 1}: `);@@ -7382,8 +7384,8 @@ describe('Bot Session task end-to-end runtime', () => {}const inputs = h.sqlite!.prepare("SELECT content FROM messages WHERE session_id = ? AND role = 'user' ORDER BY rowid").all(task.childSessionId) as Array<{ content: string }>;expect(inputs).toHaveLength(71);- expect(inputs[0].content).toBe(forwarded(objective));- for (let index = 1; index <= 70; index += 1) expect(supplement(inputs[index].content).startsWith(`Follow-up ${index}: `)).toBe(true);+ expect(inputs[0].content).toBe(objective);+ for (let index = 1; index <= 70; index += 1) expect(inputs[index].content.startsWith(`Follow-up ${index}: `)).toBe(true);} finally { runtime.dispose(); }});@@ -7398,7 +7400,7 @@ describe('Bot Session task end-to-end runtime', () => {{ kind: 'message', text: `Queued requirement ${index}.`, idempotencyKey: `input-${index}` })).toMatchObject({ ok: true });}const inputs = h.sqlite!.prepare("SELECT content FROM messages WHERE session_id = ? AND role = 'user' ORDER BY rowid").all(task.childSessionId);- expect(inputs).toEqual(['Stable objective.', 'Queued requirement 1.', 'Queued requirement 2.'].map(text => ({ content: forwarded(text) })));+ expect(inputs).toEqual(['Stable objective.', 'Queued requirement 1.', 'Queued requirement 2.'].map(text => ({ content: text })));expect(h.sqlite!.prepare('SELECT objective FROM bot_delegations WHERE id = ?').pluck().get(task.delegationId)).toBe('Stable objective.');expect(runtime.started.filter(turn => turn.sessionId === task.childSessionId)).toHaveLength(3);} finally { runtime.dispose(); }@@ -7454,9 +7456,9 @@ describe('Bot Session task end-to-end runtime', () => {const oldRows = h.sqlite!.prepare('SELECT id, content FROM messages WHERE session_id = ? ORDER BY rowid').all(task.childSessionId);expect(await runtime.delegation.messageSessionTask('session-1', task.delegationId, { kind: 'message', text: 'Only this new request.' })).toMatchObject({ ok: true });const sent = runtime.dispatch.mock.calls.filter(([input]) => input.targetSessionId === task.childSessionId).at(-1)![0];- expect(sent.persistedContent).toBe(forwarded('Only this new request.'));+ expect(sent.persistedContent).toBe('Only this new request.');expect(sent.message).not.toContain(legacy);- if (history === 'available') expect(supplement(sent.message)).toContain(objective);+ if (history === 'available') expect(sent.message).toContain(objective);else {expect(sent.message).toContain('could not be recovered');expect(sent.message).not.toContain(objective);@@ -7487,7 +7489,7 @@ describe('Bot Session task end-to-end runtime', () => {expect(sent).toHaveLength(1);expect(sent[0][0].message).toContain(objective);expect(sent[0][0].message).toContain(text);- if (boundary === 'queued') expect(sent[0][0].persistedContent).toBe(forwarded(text));+ if (boundary === 'queued') expect(sent[0][0].persistedContent).toBe(text);else {expect(sent[0][0].message).toContain('Do not repeat completed tool actions');expect(sent[0][0].persistedContent).not.toBe(text);@@ -7495,7 +7497,7 @@ describe('Bot Session task end-to-end runtime', () => {}await after.delegation.restore();expect(after.started.filter(turn => turn.sessionId === task.childSessionId)).toHaveLength(1);- expect(h.sqlite!.prepare("SELECT COUNT(*) FROM messages WHERE session_id = ? AND role = 'user' AND content = ?").pluck().get(task.childSessionId, forwarded(text))).toBe(1);+ expect(h.sqlite!.prepare("SELECT COUNT(*) FROM messages WHERE session_id = ? AND role = 'user' AND content = ?").pluck().get(task.childSessionId, text)).toBe(1);} finally { after.dispose(); }});@@ -7859,11 +7861,11 @@ describe('Bot Session task end-to-end runtime', () => {const edit = (id: string) => runtime.delegation.messageSessionTask('session-1', task.delegationId, { kind: 'edit', queuedMessageId: id, text: 'revised' });expect(await edit('foreign')).toMatchObject({ ok: false, errorCode: 'NOT_AUTHORIZED' });expect(await edit('mine')).toMatchObject({ ok: true, delivery: 'queued' });- expect(queue[0].persistedContent).toBe(forwarded('revised'));+ expect(queue[0].persistedContent).toBe('revised');consumingClientIds.push('mine');expect(await edit('mine')).toMatchObject({ ok: false, errorCode: 'MESSAGE_CONSUMING' });expect(await runtime.delegation.getSessionTask('session-1', task.delegationId, 'mine'))- .toMatchObject({ task: { queue: [{ queuedMessageId: 'mine', message: forwarded('revised'), consuming: true }], message_receipt: { state: 'consuming' } } });+ .toMatchObject({ task: { queue: [{ queuedMessageId: 'mine', message: 'revised', consuming: true }], message_receipt: { state: 'consuming' } } });consumingClientIds.length = 0;expect(await runtime.delegation.messageSessionTask('session-1', task.delegationId, { kind: 'withdraw', queuedMessageId: 'mine' })).toMatchObject({ ok: true, delivery: 'withdrawn' });@@ -8686,13 +8688,13 @@ describe('Bot Session task end-to-end runtime', () => {targetSessionId: started.childSessionId,clientId: childClientId,// 来源由 origin 统一表达(派发时主机前置 `[消息来源]`),正文不再手写前缀。- message: forwarded(instruction),- persistedContent: forwarded(instruction),+ message: instruction,+ persistedContent: instruction,}));const readMessage = (sessionId: string, clientId: string) => h.sqlite!.prepare('SELECT role, content, agent_meta AS agentMeta FROM messages WHERE session_id = ? AND client_id = ?',).get(sessionId, clientId) as { role: string; content: string; agentMeta: string };- expect(supplement(readMessage(started.childSessionId, childClientId).content)).toBe(instruction);+ expect(readMessage(started.childSessionId, childClientId).content).toBe(instruction);const trace = readMessage('session-1', `bot-delegation-interject-mirror:${started.delegationId}:follow-up-1`);expect(trace).toMatchObject({ role: 'assistant', content: '' });expect(JSON.parse(trace.agentMeta).botCollaboration.role).toBe('interjection');diff --git a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.tsindex 8830e369aa..8a1b8f161c 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/agent-input-coordinator.test.ts@@ -1,4 +1,4 @@-import { FORWARDED_REQUEST_RECEIPT, formatForwardedRequest } from '../../../shared/forwardedRequest.js';+import { FORWARDED_REQUEST_RECEIPT } from '../../../shared/forwardedRequest.js';import { BOT_GROUP_CLIENT_ID } from '../../../shared/botGroupChat.js';import { authorizeGroupTool, registerGroupToolAuthority } from '../botGroupToolAuthorization.js';import { readFileSync } from 'node:fs';@@ -12362,7 +12362,7 @@ describe('AgentInputCoordinator replaceQueuedMessage(Orca lead 排队消息修expect(h.sendToAgent.mock.calls[1]?.[1]).toEqual({type: 'user',- content: formatForwardedRequest({ userText: null }, replacement),+ content: replacement,});expect(mocks.createMessage.mock.calls.find(@@ -12371,7 +12371,7 @@ describe('AgentInputCoordinator replaceQueuedMessage(Orca lead 排队消息修).toMatchObject({clientId: queued.clientId,role: 'user',- content: formatForwardedRequest({ userText: null }, replacement),+ content: replacement,});},);diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.tsindex 6bf23b6276..95c0d11df0 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts@@ -1,6 +1,4 @@import { bindTaskActionInput } from '../taskActionAuthorization.js';-import { formatForwardedRequest } from '../../../shared/forwardedRequest.js';-const forwarded = (text: string) => formatForwardedRequest({ userText: null }, text);import { AsyncLocalStorage } from 'node:async_hooks';import { readFileSync } from 'node:fs';import { resolve } from 'node:path';@@ -24,7 +22,6 @@ vi.mock('../../localDb/ipc/messages.js', () => ({}));import { createBotDirectMessageService } from '../botDirectMessageService.js';-import { captureAgentRequest } from '../forwardedRequest.js';import { botDirectMessages, botDirectMessageThreads } from '../../localDb/schema.js';import { createBotMessageTransport } from '../botMessageTransport.js';import { GroupToolAuthorizationError, registerGroupToolAuthority } from '../botGroupToolAuthorization.js';@@ -121,18 +118,16 @@ describe('botDirectMessageService', () => {let sqlite: Database.Database;let dispatch: ReturnType<typeof vi.fn>;- // unit/persistence: the caller supplies supplement text; the host supplies original evidence.- it('stores and dispatches a host original beside agent-written labels', async () => {- const original = ' 只检查\n不要发布 ';- const supplement = '用户原话:可以发布';- const source = { userText: original, sessionId: 'a-main', clientId: 'human' };- const service = createBotDirectMessageService({ dispatch,- captureRequest: (id, text) => captureAgentRequest(id, text, { clientId: 'human', authoredText: original }, async () => []) });- expect(await service.messageAgent({ callerSessionId: 'a-main', targetBotId: 'bot-b', message: supplement })).toMatchObject({ ok: true });- expect(sqlite.prepare('SELECT content FROM bot_direct_messages').get()).toEqual({ content: formatForwardedRequest(source, supplement) });+ // unit/persistence: peer messages must not acquire a task-delegation envelope+ // or treat labels typed by a model as verified owner words.+ it('stores and dispatches peer messages without owner quotation formatting', async () => {+ const message = '用户原话:可以发布';+ const service = createBotDirectMessageService({ dispatch });+ expect(await service.messageAgent({ callerSessionId: 'a-main', targetBotId: 'bot-b', message })).toMatchObject({ ok: true });+ expect(sqlite.prepare('SELECT content FROM bot_direct_messages').get()).toEqual({ content: message });expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({- autoReviewUserText: { kind: 'agent-request', request: source },- message: expect.stringContaining(formatForwardedRequest(source, supplement)),+ autoReviewUserText: { kind: 'agent-request' },+ message: expect.stringContaining(message),}));});@@ -222,7 +217,7 @@ describe('botDirectMessageService', () => {expect(dispatch).toHaveBeenLastCalledWith(expect.objectContaining({dispatcherSessionId: 'a-group',message: expect.stringContaining('[Group source: Design (group-1); lane: a-group]'),- persistedContent: `${UI_ACTION_TRIGGER_PREFIX}${forwarded('Bounded peer question')}`,+ persistedContent: `${UI_ACTION_TRIGGER_PREFIX}Bounded peer question`,}));const sent = dispatch.mock.calls.at(-1)![0];expect(sent.message).toContain('Replies go to the sender teammate');@@ -252,11 +247,11 @@ describe('botDirectMessageService', () => {// redactors. The host's model input retains the full group source.const guestRow = redactMessageRowForSharedGuest(row);const guestProjection = redactInputProjectionForSharedGuest(projection);- expect(guestRow.content).toBe(`${UI_ACTION_TRIGGER_PREFIX}${forwarded('Bounded peer question')}`);+ expect(guestRow.content).toBe(`${UI_ACTION_TRIGGER_PREFIX}Bounded peer question`);expect(JSON.stringify([guestRow, guestProjection])).not.toMatch(/Design|group-1|a-group|Group source/);expect(JSON.stringify(guestProjection)).toContain('Bounded peer question');expect(row.agentMeta.agentFacingWireContent.content).toContain('[Group source: Design (group-1); lane: a-group]');- expect(queued[HOST_ONLY_AGENT_PREFIX]).toBe(sent.message.slice(0, -forwarded('Bounded peer question').length));+ expect(queued[HOST_ONLY_AGENT_PREFIX]).toBe(sent.message.slice(0, -'Bounded peer question'.length));release();dispatch.mockImplementationOnce(async params => {await params.onAccepted?.();@@ -699,7 +694,8 @@ describe('botDirectMessageService', () => {expect(header).toMatch(/^\[Direct message from Cindy Bot "[^\n]+" \(bot-a\)\]$/);expect(header.length).toBeLessThanOrEqual(180);expect(envelope.split('\n\n')).toHaveLength(2);- expect(envelope).toContain('Agent supplement:"hello"');+ expect(envelope).toContain('hello');+ expect(envelope).not.toContain('Agent supplement:');});it.each([@@ -873,8 +869,8 @@ describe('botDirectMessageService', () => {closeReason: 'message-limit',messageCount: 12,messages: expect.arrayContaining([- expect.objectContaining({ sequence: 1, content: forwarded('message 1') }),- expect.objectContaining({ sequence: 12, content: forwarded('message 12') }),+ expect.objectContaining({ sequence: 1, content: 'message 1' }),+ expect.objectContaining({ sequence: 12, content: 'message 12' }),]),},});@@ -1177,7 +1173,7 @@ describe('cross-device teammate messages', () => {await atLeft(() => left.restore());expect(leftDb.prepare('SELECT delivery_status FROM bot_direct_messages').get()).toEqual({ delivery_status: 'pending' });const again = await atRight(() => right.receiveRemote({ controllerDeviceId: 'left', senderBotId: 'bot-a',- targetBotId: 'bot-b', message: forwarded('one'), requestSource: { userText: null }, messageId: result.messageId! }));+ targetBotId: 'bot-b', message: 'one', messageId: result.messageId! }));expect(again).toMatchObject({ ok: true, accepted: true });expect(rightDispatch).toHaveBeenCalledOnce();expect(await atRight(() => right.receiveRemote({ controllerDeviceId: 'left', senderBotId: 'bot-a',@@ -1240,7 +1236,7 @@ describe('cross-device teammate messages', () => {expect(rightDispatch).not.toHaveBeenCalled();const sent = await atLeft(() => left.messageAgent({ callerSessionId: 'a-main', targetBotId: 'right::bot-b', message: 'one' }));const proof = { controllerDeviceId: 'right', senderBotId: 'bot-a', targetBotId: 'bot-b',- message: forwarded('one'), messageId: sent.messageId! };+ message: 'one', messageId: sent.messageId! };expect(await atLeft(() => left.verifyRemoteMessage(proof))).toBe(true);expect(await atLeft(() => left.verifyRemoteMessage({ ...proof, controllerDeviceId: 'third' }))).toBe(false);leftDb.prepare("UPDATE bot_profiles SET status='paused' WHERE id='bot-a'").run();diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.tsindex 38e71826f9..c12b39afab 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botTaskCoordination.test.ts@@ -115,17 +115,16 @@ it('uses the registered host entry for both quiet and explicitly visible delegat{ clientId: request.clientId, authoredText: request.userText }, async () => []));await dispatch({ dispatcherSessionId: 'child', targetSessionId: 'parent', message: 'Agreement' });expect(send).toHaveBeenLastCalledWith(expect.objectContaining({ forceQueue: true, botTaskCoordination: receipt,- persistedContent: '[UI_ACTION_TRIGGER]' + formatForwardedRequest(request, 'Agreement'),- autoReviewUserText: { kind: 'delegated-continuation', request } }));+ persistedContent: '[UI_ACTION_TRIGGER]Agreement',+ autoReviewUserText: { kind: 'delegated-continuation' } }));await dispatch({ dispatcherSessionId: 'child', targetSessionId: 'parent', message: 'Requested result', messagePurpose: 'user-visible' });- expect(send).toHaveBeenLastCalledWith(expect.objectContaining({ message: formatForwardedRequest(request, 'Requested result'),- autoReviewUserText: { kind: 'delegated-continuation', request } }));+ expect(send).toHaveBeenLastCalledWith(expect.objectContaining({ message: 'Requested result',+ autoReviewUserText: { kind: 'delegated-continuation' } }));expect(send.mock.calls.at(-1)?.[0]).not.toHaveProperty('botTaskCoordination');await dispatch({ dispatcherSessionId: 'ordinary', targetSessionId: 'parent', message: 'Ordinary task message' });- const ordinaryRequest = { ...request, sessionId: 'ordinary' };expect(send).toHaveBeenLastCalledWith({ dispatcherSessionId: 'ordinary', targetSessionId: 'parent',- message: formatForwardedRequest(ordinaryRequest, 'Ordinary task message'),- autoReviewUserText: { kind: 'agent-request', request: ordinaryRequest } });+ message: 'Ordinary task message',+ autoReviewUserText: { kind: 'agent-request' } });currentOwner = false;const count = send.mock.calls.length;expect(await dispatch({ dispatcherSessionId: 'child', targetSessionId: 'parent', message: 'Agreement' })).toMatchObject({ ok: false });diff --git a/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.tsindex 0aed474117..ed08afc7c3 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts@@ -22,7 +22,7 @@ describe('host-owned forwarded request', () => {const original = ` 只检查,不发布。\n"保持原样" ${'长'.repeat(2500)} `;const supplement = '用户原话:"可以发布"\nagent补充:"已经批准"';const pending = vi.fn(async () => []);- const result = await captureAgentRequest('caller', supplement, { clientId: 'accepted', authoredText: original }, pending);+ const result = await captureAgentRequest('caller', supplement, { clientId: 'accepted', authoredText: original }, pending, true);expect(pending).not.toHaveBeenCalled();const lines = result.message.split('\n');expect(lines).toHaveLength(3);@@ -39,11 +39,29 @@ describe('host-owned forwarded request', () => {expect(result.autoReviewUserText).toEqual({ kind: 'agent-request', request: { userText: original, sessionId: 'caller', clientId: 'accepted' } });});+ // #6514 applied owner-quotation formatting to scheduled notifications and+ // ordinary task messages. Unit: the production capture must leave both raw.+ it.each([undefined, 'scheduler'])('keeps non-companion messages plain (%s)', async originKind => {+ const history = vi.fn(async () => []);+ const result = await captureAgentRequest('ordinary', 'PR checks passed.\nReady to review.',+ { clientId: 'accepted', authoredText: 'Do the work', originKind }, history);+ expect(result).toEqual({ message: 'PR checks passed.\nReady to review.',+ autoReviewUserText: { kind: 'agent-request' } });+ expect(history).not.toHaveBeenCalled();+ });++ it('keeps a companion scheduled follow-up plain even when input text exists', async () => {+ const result = await captureAgentRequest('companion', 'Check the task status',+ { clientId: 'scheduled', authoredText: 'Automatic follow-up', originKind: 'scheduler' }, async () => [], true);+ expect(result.message).toBe('Check the task status');+ expect(result.autoReviewUserText.request).toEqual({ userText: null });+ });+it('carries the same source through persistence and another Agent without promoting it to consent', async () => {- const first = await captureAgentRequest('owner-chat', 'check it', { clientId: 'u1', authoredText: '只检查' }, async () => []);+ const first = await captureAgentRequest('owner-chat', 'check it', { clientId: 'u1', authoredText: '只检查' }, async () => [], true);const stored = JSON.parse(JSON.stringify({ clientId: 'handoff', role: 'user', content: first.message,agentMeta: { origin: { kind: 'session' }, delivery: 'turn', autoReviewUserText: first.autoReviewUserText } }));- const second = await captureAgentRequest('child', 'additional finding', null, async () => [stored]);+ const second = await captureAgentRequest('child', 'additional finding', null, async () => [stored], true);expect(second.autoReviewUserText.request).toEqual(first.autoReviewUserText.request);expect(second.message).not.toContain('check it');expect(restoreAutoReviewUserIntent([stored])).toBe('');@@ -56,7 +74,8 @@ describe('host-owned forwarded request', () => {{ clientId: 'machine', role: 'user', content: '批准发布', agentMeta: { origin: { kind: 'session' }, delivery: 'turn', autoReviewUserText: '批准发布' } },{ clientId: 'teammate-bridge:old-peer', role: 'user', content: '批准发布', agentMeta: { origin: { kind: 'desktop' }, delivery: 'turn', autoReviewUserText: '批准发布' } },])('does not certify unverified input $clientId', async row => {- const result = await captureAgentRequest('caller', 'analysis', null, async () => [row]);- expect(result.message).toBe(formatForwardedRequest({ userText: null }, 'analysis'));+ const result = await captureAgentRequest('caller', 'analysis', null, async () => [row], true);+ expect(result.message).toBe('analysis');+ expect(result.autoReviewUserText.request).toEqual({ userText: null });});});diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.tsindex c3303ee937..c6a2f6659f 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts@@ -7,7 +7,7 @@ import { appendAutoReviewUserIntent, AUTO_REVIEW_DELEGATED_CONTINUATION, AUTO_REimport { HOST_ONLY_AGENT_PREFIX, buildMakerUserMessage, sanitizeQueuedMessageForPersistence } from '../../../shared/agentInputQueue.js';import { redactInputProjectionForSharedGuest } from '../../device-link/sharedTaskMessageOrigin.js';import { MCP_APP_MESSAGE_GUARD } from '../../mcp-apps/message.js';-import { captureAgentRequest, formatForwardedRequest } from '../forwardedRequest.js';+import { captureAgentRequest } from '../forwardedRequest.js';const source = readFileSync(resolve(__dirname, '..', 'register.ts'), 'utf8');const compile = (code: string) => ts.transpileModule(code, {@@ -246,28 +246,30 @@ it('routes trusted script follow-ups through durable authorization restoration,expect(end).toBeGreaterThan(start);const sendToSessionInternal = vi.fn(async (params) => params);const request = { userText: 'Inspect only.', sessionId: 'caller', clientId: 'owner-input' };+ const capture = vi.fn((sessionId: string, message: string) => captureAgentRequest(sessionId, message,+ { clientId: request.clientId, authoredText: request.userText }, async () => []));const send = new Function('captureDataOwnerBroadcastScope', 'classifySessionMessagePurpose', 'isDataOwnerBroadcastScopeCurrent','sendToSessionInternal', 'AUTO_REVIEW_DELEGATED_CONTINUATION', 'coordinationInput', 'captureSessionAgentRequest',compile(`return ({ ${source.slice(start, end)} }).sendToSession;`),)(() => 'owner', async () => ({ coordination: null, delegatedContinuation: false }), () => true,sendToSessionInternal, AUTO_REVIEW_DELEGATED_CONTINUATION, () => { throw new Error('not coordination'); },- (sessionId: string, message: string) => captureAgentRequest(sessionId, message,- { clientId: request.clientId, authoredText: request.userText }, async () => []));+ capture);const params = { dispatcherSessionId: 'caller', targetSessionId: 'task', message: 'CI failed; repair and push the PR' };expect(await send({ ...params, [AUTO_REVIEW_DELEGATED_CONTINUATION]: true })).toMatchObject({- message: formatForwardedRequest(request, params.message),- autoReviewUserText: { kind: 'delegated-continuation', request },+ message: params.message,+ autoReviewUserText: { kind: 'delegated-continuation' },forceQueue: true,resumeWithStoredPermissionMode: true,});+ expect(capture).not.toHaveBeenCalled();const untrusted = await send({ ...params, AUTO_REVIEW_DELEGATED_CONTINUATION: true });expect(untrusted).toMatchObject({- message: formatForwardedRequest(request, params.message),- autoReviewUserText: { kind: 'agent-request', request },+ message: params.message,+ autoReviewUserText: { kind: 'agent-request' },});expect(untrusted).not.toHaveProperty('forceQueue');expect(untrusted).not.toHaveProperty('resumeWithStoredPermissionMode');expect(await send({ dispatcherSessionId: 'caller', message: 'new task', [AUTO_REVIEW_DELEGATED_CONTINUATION]: true }))- .toMatchObject({ autoReviewUserText: { kind: 'agent-request', request } });+ .toMatchObject({ autoReviewUserText: { kind: 'agent-request' } });});diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionControlService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionControlService.test.tsindex fa3166c16a..0e6516a903 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionControlService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionControlService.test.ts@@ -1,5 +1,4 @@import { formatForwardedRequest } from '../../../shared/forwardedRequest.js';-const forwarded = (text: string) => formatForwardedRequest({ userText: null }, text);import { describe, expect, it, vi } from 'vitest';import type { SessionActivitySnapshot } from '@cindy/maker-shared/session-activity';@@ -224,8 +223,8 @@ describe('session control domain service', () => {'queued-1',expect.objectContaining({clientId: 'queued-1',- text: forwarded('after'),- origin: expect.objectContaining({ displayText: forwarded('after') }),+ text: 'after',+ origin: expect.objectContaining({ displayText: 'after' }),}),expect.objectContaining({clientId:'queued-1',text:'before'}),);@@ -299,10 +298,10 @@ describe('session control domain service', () => {'target','queued-1',expect.objectContaining({- text: forwarded(replacement),- persistedContent: forwarded(replacement),- chatMessage: expect.objectContaining({ content: forwarded(replacement) }),- origin: expect.objectContaining({ displayText: forwarded(replacement) }),+ text: replacement,+ persistedContent: replacement,+ chatMessage: expect.objectContaining({ content: replacement }),+ origin: expect.objectContaining({ displayText: replacement }),}),queued,);@@ -321,10 +320,10 @@ describe('session control domain service', () => {const updated = rebuildSessionQueueItem(queued, 'replacement');expect(JSON.parse(updated.persistedContent)).toMatchObject({- text: forwarded('replacement'),+ text: 'replacement',files: [{ name: 'notes.txt', path: '/repo/notes.txt' }],});- expect(updated.origin).toMatchObject({ kind: 'session', displayText: forwarded('replacement') });+ expect(updated.origin).toMatchObject({ kind: 'session', displayText: 'replacement' });});it('edits only the supplement and preserves an existing delegated continuation receipt', () => {diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionHandoffIpc.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionHandoffIpc.test.tsindex e04a8cf792..9a6de6e133 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionHandoffIpc.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionHandoffIpc.test.ts@@ -1,3 +1,4 @@+import { captureAgentRequest } from '../forwardedRequest.js';import { createRemoteSessionHandoff } from '../../mcp-integrations/sessionHandoffRemote.js';import { validateRemoteTaskActionReceipt } from '../remoteTaskActionReceipt.js';import { bindTaskActionInput, settleTaskActionInput, taskActionInputGuard } from '../taskActionAuthorization.js';@@ -94,12 +95,12 @@ describe('maker:session:handoff (receiving computer)', () => {clientId: 'remote-task-action:receipt-one', forceQueue: true, taskActionDeliveryGuard: expect.any(Function),targetSessionId: 'local-task',autoReviewUserText: { kind: 'agent-request', request: { userText: null } },- message: formatForwardedRequest({ userText: null }, 'hello'),+ message: 'hello',origin: {kind: 'session',senderSessionId: 'device-A::sender-1',senderSessionTitle: 'PR 跟进',- displayText: formatForwardedRequest({ userText: null }, 'hello'),+ displayText: 'hello',},// 另一台电脑的来信不能借恢复把任务提到 bypass。resumeWithStoredPermissionMode: true,@@ -209,7 +210,8 @@ describe('maker:session:handoff (receiving computer)', () => {// Review regression, unit/protocol: successful queued deliveries used to exhaust// the pending-receipt limit. Exercise both real transport ends, body binding and cleanup.-it('releases consumed receipts without allowing replay, including formatted owner requests', async () => {+it('releases consumed receipts without allowing replay for quoted owner requests and plain automation', async () => {+ let includeOriginal = true;let lastWire: unknown;let pending: AgentInputQueuedMessage | undefined;const handle = createSessionHandoffHandler({@@ -223,8 +225,9 @@ it('releases consumed receipts without allowing replay, including formatted owne});const send = createRemoteSessionHandoff({captureAccess: () => () => {},- captureRequest: async () => ({ message: formatForwardedRequest({ userText: 'Owner request', sessionId: 'sender', clientId: 'owner-input' }, 'Agent supplement'),- autoReviewUserText: { kind: 'agent-request', request: { userText: 'Owner request', sessionId: 'sender', clientId: 'owner-input' } } }),+ captureRequest: (sessionId, message) => captureAgentRequest(sessionId, message,+ { clientId: 'owner-input', authoredText: 'Owner request', originKind: includeOriginal ? 'desktop' : 'scheduler' },+ async () => [], true),invoke: async (_device, _channel, args) => {if ((args[0] as { action?: string }).action === 'task-action-capability')return { ok: true, result: { taskActionVersion: 1 } };@@ -233,8 +236,13 @@ it('releases consumed receipts without allowing replay, including formatted owne},});for (let i = 0; i < 260; i++) {+ includeOriginal = i % 2 === 0;expect(await send({ deviceId: 'target-device', sessionId: 'target' },{ message: 'Agent supplement', sender: async () => ({ sessionId: 'sender' }) })).toMatchObject({ ok: true });+ if (!includeOriginal) {+ expect(lastWire).not.toHaveProperty('requestSource');+ expect(pending!.text).toBe('Agent supplement');+ }if (i === 0) expect(await handle('target-device', lastWire)).toMatchObject({ ok: false });await taskActionInputGuard('target', pending!)!(); // pre-persist after sender returned queuedawait taskActionInputGuard('target', pending!)!(); // pre-vendordiff --git a/apps/desktop/src/main/maker-ipc/botDelegationService.ts b/apps/desktop/src/main/maker-ipc/botDelegationService.tsindex a66ee84499..5d22c97dc6 100644--- a/apps/desktop/src/main/maker-ipc/botDelegationService.ts+++ b/apps/desktop/src/main/maker-ipc/botDelegationService.ts@@ -1065,17 +1065,14 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {const completionSnapshot = (await getDbClient().drizzle.select({ snapshot: botDelegations.permissionSnapshotJson }).from(botDelegations).where(eq(botDelegations.id, params.id)).get())?.snapshot ?? '{}';- const requestSource = readForwardedRequestSource(readSessionTaskInput({- runSequence: params.runSequence, permissionSnapshotJson: completionSnapshot,- })?.requestSource) ?? { userText: null };- const completionMessage = formatForwardedRequest(requestSource, buildDelegationCompletionMessage({+ const completionMessage = buildDelegationCompletionMessage({id: params.id,objective: params.objective,status: params.status,resultSummary: params.resultSummary,artifacts,lastError: params.lastError,- }));+ });try {if (!(await completionStillPending())) {clearCompletionRetryTimer(params.id);@@ -1213,7 +1210,7 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {const dispatched = await deps.dispatch({targetSessionId,message: completionMessage,- autoReviewUserText: { kind: 'agent-request', request: requestSource },+ autoReviewUserText: { kind: 'agent-request' },persistedContent: `${UI_ACTION_TRIGGER_PREFIX}${completionMessage}`,clientId: BOT_DELEGATION_CLIENT_ID.completionRun(params.id, params.runSequence),});@@ -1671,14 +1668,13 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {if (!stillPending()|| (row.childSessionId && heldSessionIds.has(row.childSessionId))) return;// 同任务回执:模型正文不带隐藏前缀,落库 / 排队可见内容保留它。- const requestSource = readForwardedRequestSource(readSessionTaskInput(row)?.requestSource) ?? { userText: null };- const message = formatForwardedRequest(requestSource, [+ const message = [`[任务需要你处理] task_id: ${row.id}`,`类型: ${pending.request.kind}`,pending.summary,pending.request.kind === 'permission' ? `请求工具: ${pending.request.toolName}` : '','你是用户的代理。能按用户已表达的意图安全决定,就用 `message_session_task` 直接回答;拿不准才用一句人话问用户。不要让用户去子任务窗口处理,也不要复述内部编号。',- ].filter(Boolean).join('\n\n'));+ ].filter(Boolean).join('\n\n');// A group task asks in its group: the owner opens the task from the card to answer.// Tool names and arguments stay on this computer; only a question's words are shared.const home = groupHomeOf(row.permissionSnapshotJson);@@ -1720,7 +1716,7 @@ export function createBotDelegationService(deps: BotDelegationServiceDeps) {? await deps.dispatch({targetSessionId: requesterSessionId,message,- autoReviewUserText: { kind: 'agent-request', request: requestSource },+ autoReviewUserText: { kind: 'agent-request' },persistedContent: `${UI_ACTION_TRIGGER_PREFIX}${message}`,clientId: `bot-delegation-interaction:${row.id}:${pending.requestId}`,})diff --git a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts b/apps/desktop/src/main/maker-ipc/botDirectMessageService.tsindex 17da22faeb..afd7d3e7d5 100644--- a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts+++ b/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts@@ -1,4 +1,4 @@-import { formatForwardedRequest, captureAgentRequest, type CapturedAgentRequest } from './forwardedRequest.js';+import type { CapturedAgentRequest } from './forwardedRequest.js';import { matchesForwardedRequest, readForwardedRequestSource, type AgentRequestReceipt, type ForwardedRequestSource } from '../../shared/forwardedRequest.js';import { parseBotPeerAddress, botPeerAddress, MAX_BOT_PEER_ADDRESS_CHARS } from '../../shared/botPeerAddress.js';import { isCompanionShadowed } from '../companion-cloud/homes.js';@@ -104,7 +104,6 @@ export interface BotMessageTransport {}export interface BotDirectMessageServiceDeps {- captureRequest?: (sessionId: string, supplement: string) => Promise<CapturedAgentRequest>;transport?: BotMessageTransport;dispatch: (params: {autoReviewUserText?: AgentRequestReceipt;@@ -474,12 +473,12 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)return failed('INVALID_ARGS', `message 必须为 1-${MAX_MESSAGE_CHARS} 个字符`);}- const captured = remoteSender- ? { message: remoteSender.requestSource ? rawMessage : formatForwardedRequest({ userText: null }, rawMessage),- autoReviewUserText: { kind: 'agent-request' as const, request: remoteSender.requestSource ?? { userText: null } } }- : await (deps.captureRequest ?? ((id, text) => captureAgentRequest(id, text, null, async () => [])))(input.callerSessionId, input.message);+ // A peer conversation is not a delegated owner instruction. Preserve old+ // verified envelopes when receiving them, but never wrap a new message.+ const captured: CapturedAgentRequest = { message: rawMessage,+ autoReviewUserText: { kind: 'agent-request',+ ...(remoteSender?.requestSource ? { request: remoteSender.requestSource } : {}) } };const message = captured.message;- if (message.length > 200_000) return failed('INVALID_ARGS', '原话与补充合计过长,消息未发送');const caller = remoteSender ? {botId: remoteSender.id, botName: remoteSender.name, sessionSource: 'bot',diff --git a/apps/desktop/src/main/maker-ipc/forwardedRequest.ts b/apps/desktop/src/main/maker-ipc/forwardedRequest.tsindex abb3f88ddf..0966fa0294 100644--- a/apps/desktop/src/main/maker-ipc/forwardedRequest.ts+++ b/apps/desktop/src/main/maker-ipc/forwardedRequest.ts@@ -24,13 +24,15 @@ export function requestSourceFromInput(sessionId: string, input: RequestInputEvireturn { userText: null };}-/** The active accepted input wins over newer queued text. Legacy/model-labelled text is never evidence. */+/** Only companion task instructions opt in. Accepted input wins over queued text; model labels are not evidence. */export async function captureAgentRequest(sessionId: string,supplement: string,active: RequestInputEvidence | null,readLatestInput: () => Promise<AutoReviewHistoryMessage[]>,+ preserveUserRequest = false,): Promise<CapturedAgentRequest> {+ if (!preserveUserRequest) return { message: supplement, autoReviewUserText: { kind: 'agent-request' } };let source: ForwardedRequestSource;if (active) source = requestSourceFromInput(sessionId, active);else {@@ -52,7 +54,8 @@ export async function captureAgentRequest(autoReviewUserText: { kind: 'agent-request', request: source } };}-/** New envelopes follow this host's resolved UI language; authored contents are never translated. */+/** Quote only a real owner request. Missing-source envelopes remain readable through the shared legacy validator. */export function formatForwardedRequest(source: ForwardedRequestSource, supplement: string): string {- return formatLocalizedForwardedRequest(source, supplement, getResolvedMainLocale());+ return source.userText === null ? supplement+ : formatLocalizedForwardedRequest(source, supplement, getResolvedMainLocale());}diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex bb6ff84e34..88c87f35e0 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -4459,8 +4459,13 @@ export function getSessionInputProvenance(sessionId: string) {export async function captureSessionAgentRequest(sessionId: string, supplement: string): Promise<CapturedAgentRequest> {const scope = captureDataOwnerBroadcastScope();const active = agentInputCoordinatorHolder?.getAcceptedInputProvenance(sessionId) ?? null;+ // Only a companion's task instructions forward the owner's words. Ordinary+ // sessions (including scheduled runs and child results) keep their own body.+ const [companion] = await getDbClient().drizzle.select({ role: botSessionLinks.role })+ .from(botSessionLinks).where(and(eq(botSessionLinks.sessionId, sessionId),+ inArray(botSessionLinks.role, ['canonical', 'group', 'channel']), isNull(botSessionLinks.archivedAt))).limit(1);const request = await captureRequest(sessionId, supplement, active,- () => listMessagesForAgentHandoff(sessionId, 1, undefined, 'user'));+ () => listMessagesForAgentHandoff(sessionId, 1, undefined, 'user'), !!companion);if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new Error('Data owner changed before request capture');return request;}@@ -12102,7 +12107,6 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)});botDirectMessageServiceHolder = createBotDirectMessageService({- captureRequest: captureSessionAgentRequest,transport: createBotMessageTransport({ selfDeviceId: getSelfDeviceId,listDevices: () => handleListDevices(deviceDirectoryDeps()), invoke: invokeBotPeer }),discardQueuedDelivery: async (sessionId, clientId, assertOwner) => {@@ -16378,7 +16382,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)getSessionRuntime: (params) => sessionControlService.getSessionRuntime(params),setSessionRuntime: (params) => sessionControlService.setSessionRuntime(params),sendToSession: async (params) => {- const request = await captureSessionAgentRequest(params.dispatcherSessionId ?? '', params.message);+ // A script follow-up may name a companion as its dispatcher while no+ // owner turn is active. Never quote that companion's stale last input.+ const request: CapturedAgentRequest = params[AUTO_REVIEW_DELEGATED_CONTINUATION]+ ? { message: params.message, autoReviewUserText: { kind: 'agent-request' } }+ : await captureSessionAgentRequest(params.dispatcherSessionId ?? '', params.message);params = { ...params, message: request.message };const ownerScope = captureDataOwnerBroadcastScope();let classification: Awaited<ReturnType<typeof classifySessionMessagePurpose>>;diff --git a/apps/desktop/src/main/maker-ipc/sessionHandoffIpc.ts b/apps/desktop/src/main/maker-ipc/sessionHandoffIpc.tsindex 9b2732c119..48ea66e671 100644--- a/apps/desktop/src/main/maker-ipc/sessionHandoffIpc.ts+++ b/apps/desktop/src/main/maker-ipc/sessionHandoffIpc.ts@@ -1,4 +1,3 @@-import { formatForwardedRequest } from './forwardedRequest.js';import { ipcMain } from 'electron';import { matchesForwardedRequest, readForwardedRequestSource, type AgentRequestReceipt } from '../../shared/forwardedRequest.js';import { DL_SESSION_HANDOFF_CHANNEL } from '@cindy/device-link';@@ -67,7 +66,7 @@ export function createSessionHandoffHandler(deps: {const requestSource = readForwardedRequestSource(request.requestSource);if (request.requestSource !== undefined && (!requestSource || !matchesForwardedRequest(requestSource, body)))throwIpcError('INVALID_PARAMS', 'Request source does not match the forwarded body');- const message = requestSource ? body : formatForwardedRequest({ userText: null }, body);+ const message = body;const sender = requireObject(request.sender, 'sender');// 任务 id 是不透明字符串(IM 任务的 id 可以很长);只拒绝会伪造设备前缀或说明结构的写法。const senderSessionId = boundedString(sender.sessionId, 'sender.sessionId', 512);diff --git a/apps/desktop/src/main/mcp-integrations/sessionHandoffRemote.ts b/apps/desktop/src/main/mcp-integrations/sessionHandoffRemote.tsindex 32f9f39bd2..99e4e74a17 100644--- a/apps/desktop/src/main/mcp-integrations/sessionHandoffRemote.ts+++ b/apps/desktop/src/main/mcp-integrations/sessionHandoffRemote.ts@@ -177,7 +177,8 @@ export function createRemoteSessionHandoff(deps: {const wire: RemoteSessionHandoffRequest = {sessionId: target.sessionId,message: captured?.message ?? request.message,- ...(captured ? { requestSource: captured.autoReviewUserText.request } : {}),+ ...(captured?.autoReviewUserText.request?.userText != null+ ? { requestSource: captured.autoReviewUserText.request } : {}),sender,taskActionReceipt,};diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.mdindex 597446e088..0e8aa045e3 100644--- a/docs/product-rules/agent-user-parity.md+++ b/docs/product-rules/agent-user-parity.md@@ -84,9 +84,9 @@ Worker 工具省略 working_dir 时保持继承 Lead 任务记录目录,不跟- 协议与兼容见 [`../dev-rules/protocol-compatibility.md`](../dev-rules/protocol-compatibility.md)「Agent 跨电脑管理定时任务与发消息」。-跨任务发送、插话、排队编辑及伙伴请求的正文由宿主保留用户原话,工具参数仅承载 Agent 补充;-本机和同账号跨电脑沿用相同格式。来源回执不提供执行授权,旧端缺失来源时不猜测原话。-详见 [消息来源](message-source.md#跨任务请求与伙伴通话的原话2026-10-20)。+仅伙伴代主人向任务下达要求时,由宿主附上可核实的用户原话,工具参数承载必要的轻度补充;+普通任务互发、自动化、回传与伙伴通话保持正常正文,无原话不加空栏。来源回执不提供执行授权。+详见 [消息来源](message-source.md#跨任务请求与伙伴通话的原话2026-10-202026-10-21-收窄)。### 模型速度diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.mdindex 877774ea4d..74b46cc601 100644--- a/docs/product-rules/cindy-bots-runtime.md+++ b/docs/product-rules/cindy-bots-runtime.md@@ -1046,7 +1046,8 @@ Desktop 的 Bot Market 随安装包提供预制原生包入口,复用同一 im### 请求原话与 Agent 补充(2026-10-20)-后台任务的启动、追问、带消息恢复以及伙伴私聊请求使用宿主生成的「用户原话 / agent补充」正文。-原话来自已接收的用户输入或继承的宿主回执;启动与重试冻结同一来源,排队编辑只改补充。+仅伙伴代主人派活、追问及带消息恢复时,有可核实原话才附「用户原话 / Agent补充」,补充应轻度且不改原意。+普通任务与自动化、结果及交互回传、伙伴私聊保持正常正文;无原话不显示空栏或缺来源说明。+原话来自已接收的用户输入或继承的宿主回执;启动与重试冻结同一来源,委派队列编辑只改补充。启动提示保留任务信息,不追加通用行为教程。具体持久化、跨电脑兼容及权限边界见-[消息来源](message-source.md#跨任务请求与伙伴通话的原话2026-10-20)。+[消息来源](message-source.md#跨任务请求与伙伴通话的原话2026-10-202026-10-21-收窄)。diff --git a/docs/product-rules/message-source.md b/docs/product-rules/message-source.mdindex 3218a03c3e..689f09c8b5 100644--- a/docs/product-rules/message-source.md+++ b/docs/product-rules/message-source.md@@ -52,25 +52,26 @@ Agent 用 `send_to_session` 把消息发给另一台电脑上的既有任务时对端,按不可信文本清洗。它同样只用于归属展示,不是权限判据。来源任务不在查看者能直接打开的位置,标签只显示来源与 id,不提供跳转。-## 跨任务请求与伙伴通话的原话(2026-10-20)--`send_to_session`、插话/排队编辑、后台任务启动/追问/带消息恢复/结果与交互回传和-`send_to_agent` 的请求正文由宿主统一生成「用户原话」与「agent补充」。-两栏使用 JSON 字符串引用,保留换行、引号和首尾空格;补充中写出的同名标签仍属于补充。-这两栏是持久化正文,独立于仅在当次派发添加的 `[消息来源]` 说明。-标签、来源说明与启动上下文按发送宿主的界面语言提供简中、繁中、英文、日文与韩文;原话和-补充正文不翻译。接收端独立识别五语格式(含最初的中文格式),不要求两台电脑语言一致。-历史正文保留发送时语言,不因后来切换界面语言而重写。--- 原话取当前已接收输入的宿主记录,优先于尚未消费的排队消息。再次转交沿用受保护的来源回执;- 重启后从消息回执恢复。模型工具只接收补充参数,不提供填写或改写原话的参数。-- 无可核验原话时留空并说明来源缺失;不从模型写的标签、旧版裸消息或兼容桥接正文猜原话。-- 编辑排队请求只改补充,原话与来源保持不变。后台任务初次派发和重试使用同一份来源快照。+## 跨任务请求与伙伴通话的原话(2026-10-20,2026-10-21 收窄)++只有伙伴代主人向任务下达要求时,宿主才附上可核实的用户原话,伙伴仅作必要的轻度补充,+不得改写原意或扩大范围。适用于伙伴发起的 `send_to_session`、插话、后台任务启动与追问;+普通任务互发、自动化通知、结果和交互回传、`send_to_agent` 的伙伴通话保持正常正文。+没有可核实原话时同样直接发送正文,不生成空的「用户原话」栏或「来源缺失」提示。+这不改变仅在当次派发添加的 `[消息来源]` 说明和界面的来源标签。++- 原话来自伙伴当前已接收输入的宿主记录,优先于尚未消费的排队消息;来源回执与正文分开。+ 自动化输入不从更早的用户消息补造本轮原话。模型工具不提供填写或改写原话的参数。+- 有原话的伙伴委派仍使用「用户原话 / Agent补充」两栏和 JSON 字符串引用,保留换行、引号和+ 首尾空格;补充里的同名标签不成为原话。标签使用发送宿主的界面语言,原话与补充不翻译。+- 编辑已有委派队列只改补充,原话保持不变;启动与重试沿用该轮来源快照。普通队列编辑仍为+ 正常正文。历史消息不批量改写。- `agentMeta.autoReviewUserText` 的 `agent-request` 回执只记录来源,不恢复旧授权、不授予新权限;- 原有内部委派续接仍保留其独立语义。共享访客不接收该回执里的私有任务标识。-- 同账号跨电脑通道可携带可选 `requestSource`,接收端检查它与保留正文一致。旧发送端没有回执时,- 全文作为补充;旧接收端仍能读两栏正文,但不承诺继续传递来源回执。无需数据库迁移。-- 后台任务启动提示只包含任务信息、原话和补充,不额外追加通用执行、沟通或交付教程。+ 原有内部委派续接保留独立语义。共享访客不接收回执里的私有任务标识。+- 同账号跨电脑仅在带真实原话时附可选 `requestSource`;接收端继续校验它与正文一致,兼容+ 五语及最初中文格式。没有回执时保留原始正文,不猜原话。旧接收端仍可能添加旧空栏,消除+ 该显示需要接收端更新;不新增必填协议字段或数据库迁移。+- 后台任务启动提示只包含任务信息及必要内容,不追加通用执行、沟通或交付教程。## 界面diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.tsindex 9defab72ab..7324e33485 100644--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts@@ -394,7 +394,7 @@ function registerStartSessionTaskEntry(effort: z.string().max(64).optional(),fast_mode: z.union([z.boolean(), z.literal('ultrafast')]).optional(),}).strict().optional(),- instruction: z.string().min(1).max(12_000).describe('Agent supplement. The host preserves the accepted user message separately and formats both fields; this text is never certified as the user’s words.'),+ instruction: z.string().min(1).max(12_000).describe('Task instruction. When a teammate delegates the user’s request, the host separately preserves verified original words. Add only necessary context; keep the user’s intent and scope.'),title: z.string().min(1).max(120).optional(),working_dir: z.string().min(1).max(1_024).optional(),use_worktree: z.boolean().optional(),@@ -496,7 +496,7 @@ function registerSendToAgentEntry(inputShape: {// deviceId (80) + separator (2) + existing Bot profile ID (128).target_id: z.string().min(1).max(210),- message: z.string().min(1).max(12_000).describe('Agent supplement. The host supplies the verified original user text separately.'),+ message: z.string().min(1).max(12_000).describe('The message to send to the teammate.'),},handler: async ({ target_id, message }) => {const callerSessionId = resolveLiziMcpSessionContext(sessionCtx).sessionId;diff --git a/packages/lizi-mcps/src/xdt-helper/send_to_session.ts b/packages/lizi-mcps/src/xdt-helper/send_to_session.tsindex 356651b9e9..25f996cb55 100644--- a/packages/lizi-mcps/src/xdt-helper/send_to_session.ts+++ b/packages/lizi-mcps/src/xdt-helper/send_to_session.ts@@ -188,7 +188,7 @@ export function registerSendToSessionTool(.string().min(1).describe(- "Agent 补充内容。宿主自动从当前已接收输入保留用户原话,并生成用户原话 / agent补充两栏;本字段全部归入 agent补充。",+ "要发送的消息。伙伴代用户下达任务要求时,宿主另附可核实的用户原话;只补充必要上下文,保留原意和范围。普通任务与自动化消息按正文发送。",),message_purpose: z.enum(["coordination", "user-visible"]).optional().describe("委派子任务发给发起伙伴默认 coordination:送达模型但内部文字不进正文或通知。user-visible 用于用户要求的结果、需要用户介入的消息。其他普通任务默认保持可见;coordination 仅限宿主核实的委派关系。正常完成自动回传,无需重发。",