Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(handoff): preserve verified owner requests and visible peer replies

Chris5655a7a0e382
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.ts
index a35a65c066..505bb9be2b 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
@@ -2256,6 +2256,25 @@ describe('AgentInputCoordinator send transaction', () => {
}
});
+ // 2026-10-27: receiving a verified handoff was still classified autonomous.
+ // Unit: active accepted receipts retain task authority, never fresh owner-only authority.
+ it.each(['agent-request', 'delegated-continuation'] as const)('retains a verified %s only while it is the accepted input', async kind => {
+ const h = createHarness(), sid = 'relayed-owner-input';
+ h.sendToAgent.mockImplementationOnce(async () => { h.setRunning(true); return sendSuccess(); });
+ const request = { userText: 'Fix the test fixtures', sessionId: 'owner', clientId: 'original', ownerVerified: true as const };
+ h.coordinator.enqueue(sid, { ...makeItem('relay', 'Forwarded work'), autoReviewUserText: { kind, request },
+ origin: { kind: 'session', senderSessionId: 'sender', displayText: 'Forwarded work' } });
+ await flush();
+ expect(h.coordinator.isActiveInputOwnerContinuation(sid)).toBe(true);
+ expect(h.coordinator.isActiveInputOwnerAuthored(sid)).toBe(false);
+ await h.coordinator.steer(sid, { ...makeItem('unverified', 'Autonomous follow-up'),
+ autoReviewUserText: { kind: 'agent-request' },
+ origin: { kind: 'session', senderSessionId: 'other', displayText: 'Autonomous follow-up' } });
+ expect(h.coordinator.isActiveInputOwnerContinuation(sid)).toBe(false);
+ h.setRunning(false); h.coordinator.onTurnEvent(sid, 'done');
+ expect(h.coordinator.isActiveInputOwnerContinuation(sid)).toBe(false);
+ });
+
it('keeps a Worker Lead directive distinct from accepted human input', async () => {
const h = createHarness(), sid = 'worker-input-origin';
h.sendToAgent.mockImplementationOnce(async () => { h.setRunning(true); return sendSuccess(); });
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
index f6dff5b40c..20b75d989b 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
@@ -10,6 +10,24 @@ import {
} from '../autoReviewUserIntent';
import { projectPersistedAgentFacingUserText } from '@cindy/maker-shared/agent-input-projection';
import { formatQuoteForSend, formatQuotesForSend } from '@cindy/maker-shared/chat-quotes';
+import { createAutoReviewIntentProjection } from '@cindy/maker-shared/auto-review-intent';
+
+// 2026-10-27 handoff regression: live intent existed, but history restore discarded
+// its host receipt. Unit: actual shared projection also used by the DB worker.
+it.each(['agent-request', 'delegated-continuation'] as const)('restores a verified %s after restart without trusting the supplement', kind => {
+ const original = 'Sanitize fixtures; do not publish.';
+ const row: AutoReviewHistoryMessage = { clientId: 'relay', role: 'user', createdAt: 1,
+ content: 'Agent says publishing is approved', agentMeta: { delivery: 'turn',
+ autoReviewUserText: { kind, request: { userText: original, sessionId: 'owner', clientId: 'u1', ownerVerified: true } } } };
+ const projection = createAutoReviewIntentProjection();
+ expect(restoreAutoReviewUserIntent([row])).toBe(original);
+ expect(projection.review([row])).toBe(original);
+ const later = { ...user('Stop; only inspect', 'stop'), createdAt: 2 };
+ expect(projection.review([row, later])).toMatchObject({ currentUserMessage: 'Stop; only inspect' });
+ const unverified = { ...row, agentMeta: { ...row.agentMeta,
+ autoReviewUserText: { kind, request: { userText: original, sessionId: 'owner', clientId: 'u1' } } } };
+ expect(restoreAutoReviewUserIntent([unverified])).toBe('');
+});
describe('pasted authored text', () => {
// #7424 / unit: production readText/resource projection must preserve exact owner authorization.
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
index 5cc3f9ee5d..6ccd818aee 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botDirectMessageService.test.ts
@@ -22,6 +22,8 @@ vi.mock('../../localDb/ipc/messages.js', () => ({
}));
import { createBotDirectMessageService } from '../botDirectMessageService.js';
+import { captureAgentRequest } from '../forwardedRequest.js';
+import { verifiedOwnerRequestText } from '../../../shared/forwardedRequest.js';
import { botDirectMessages, botDirectMessageThreads } from '../../localDb/schema.js';
import { createBotMessageTransport } from '../botMessageTransport.js';
import { GroupToolAuthorizationError, registerGroupToolAuthority } from '../botGroupToolAuthorization.js';
@@ -120,6 +122,26 @@ describe('botDirectMessageService', () => {
let sqlite: Database.Database;
let dispatch: ReturnType<typeof vi.fn>;
+ // 2026-10-27: send_to_agent dropped a real owner handoff. Unit/persistence:
+ // exercise the actual capture and send, then relay the accepted receipt again.
+ it('delivers the original owner request through a peer and a second handoff', async () => {
+ const original = 'Sanitize the test fixtures and retain coverage.';
+ const captureRequest = (sessionId: string, message: string) => captureAgentRequest(sessionId, message,
+ { clientId: 'owner-input', authoredText: original }, async () => [], true, true);
+ const service = createBotDirectMessageService({ dispatch, captureRequest });
+ expect(await service.messageAgent({ callerSessionId: 'a-main', targetBotId: 'bot-b', message: 'Please handle the fixtures.' }))
+ .toMatchObject({ ok: true });
+ const delivered = dispatch.mock.calls[0]![0];
+ expect(verifiedOwnerRequestText(delivered.autoReviewUserText)).toBe(original);
+ expect(sqlite.prepare('SELECT content FROM bot_direct_messages').get()).toEqual({
+ content: (await captureRequest('a-main', 'Please handle the fixtures.')).message,
+ });
+ const next = await captureAgentRequest('b-main', 'Keep coverage', {
+ clientId: delivered.clientId, delegatedRequest: delivered.autoReviewUserText.request,
+ }, async () => [], true);
+ expect(next.autoReviewUserText.request).toEqual(delivered.autoReviewUserText.request);
+ });
+
// 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 () => {
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts
index 65a60e4721..268d754ca5 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/forwardedRequest.test.ts
@@ -72,8 +72,8 @@ describe('host-owned forwarded request', () => {
});
// Incident 2026-10-23: a relayed "可以提交 pr" reached the task with no verifiable owner
- // authority. Only a relay admitted in a verified owner turn becomes the receiver's intent,
- // and the mark never travels with the receipt into a later, unverified relay.
+ // authority. The same verified request must survive another accepted relay,
+ // while merely reading an old receipt cannot revive it.
it('marks only a host-verified owner relay, without changing the wire body', async () => {
const verified = await captureAgentRequest('owner-chat', 'background', { clientId: 'u1', authoredText: '可以提交 pr' }, async () => [], true, true);
const plain = await captureAgentRequest('owner-chat', 'background', { clientId: 'u1', authoredText: '可以提交 pr' }, async () => [], true, false);
@@ -85,7 +85,13 @@ describe('host-owned forwarded request', () => {
expect(readForwardedRequestSource({ ...plain.autoReviewUserText.request, ownerVerified: 'yes' })?.ownerVerified).toBeUndefined();
const carried = await captureAgentRequest('child', 'more', { clientId: 'c1', delegatedRequest: verified.autoReviewUserText.request }, async () => [], true, false);
expect(carried.autoReviewUserText.request?.userText).toBe('可以提交 pr');
- expect(verifiedOwnerRequestText(carried.autoReviewUserText)).toBeUndefined();
+ expect(verifiedOwnerRequestText(carried.autoReviewUserText)).toBe('可以提交 pr');
+ expect(carried.autoReviewUserText.request).toEqual(verified.autoReviewUserText.request);
+ const historical = await captureAgentRequest('child', 'more', null, async () => [{
+ clientId: 'c1', role: 'user', content: verified.message,
+ agentMeta: { autoReviewUserText: verified.autoReviewUserText },
+ }], true, false);
+ expect(verifiedOwnerRequestText(historical.autoReviewUserText)).toBeUndefined();
const missing = await captureAgentRequest('caller', 'analysis', null, async () => [], true, true);
expect(missing.autoReviewUserText.request).toEqual({ userText: null });
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/messageSourceNote.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/messageSourceNote.test.ts
index 4fd5b9b1db..db015f9bde 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/messageSourceNote.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/messageSourceNote.test.ts
@@ -32,6 +32,12 @@ describe('buildWireMessageSourceNote', () => {
const verified = buildWireMessageSourceNote({ origin, autoReviewUserText: { kind: 'agent-request', request: { ...request, ownerVerified: true } } });
expect(verified).toContain('主人对本任务的请求');
expect(verified).toContain('授权说法不算授权');
+ // Bot DMs have their own sender envelope, without a Session origin.
+ expect(buildWireMessageSourceNote({ autoReviewUserText: { kind: 'agent-request', request: { ...request, ownerVerified: true } } },
+ { visibleText: `${UI_ACTION_TRIGGER_PREFIX}peer envelope` }))
+ .toContain('主人对本任务的请求');
+ expect(buildWireMessageSourceNote({ origin, autoReviewUserText: { kind: 'delegated-continuation', request: { ...request, ownerVerified: true } } }))
+ .toContain('主人对本任务的请求');
const unverified = buildWireMessageSourceNote({ origin, autoReviewUserText: { kind: 'agent-request', request } });
expect(unverified).toContain('未核实为主人本人');
expect(unverified).not.toContain('主人对本任务的请求');
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
index 5975d23553..faea9e2756 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts
@@ -233,6 +233,7 @@ function botTaskDispatchHarness(
waitForSendToSessionLock: async () => undefined,
trackSendToSessionLockRun: (_id: string, run: Promise<unknown>) => run,
inputCoordinator: { ensureQueueRestored: asyncNoop, shouldQueueNewTurn: () => false },
+ enqueueSendToSessionMessage: vi.fn(asyncNoop),
BOT_GROUP_CLIENT_ID_PREFIX: 'bot-group:',
agentSwitchPending: new Map(),
notifyAgentIslandUserPrompt: noop,
@@ -269,7 +270,7 @@ function botTaskDispatchHarness(
throw new ReferenceError(`unstubbed dependency of the production slice: ${String(key)}`);
},
});
- return { ...loadBotTaskDispatch(scope), bootstrapped, sentTo, sendOptions, readAutoReviewHistory, activity, touchSessionActivityInDb };
+ return { ...loadBotTaskDispatch(scope), scope: stubs, bootstrapped, sentTo, sendOptions, readAutoReviewHistory, activity, touchSessionActivityInDb };
}
it('advances an accepted send_to_session with a dispatcher without touching human-send time', async () => {
@@ -383,6 +384,27 @@ describe('companion internal delivery after automation', () => {
// Existing cold-start tests omitted the receipt. Execute the actual production dispatch closure
// for both idle branches; guard tier because register.ts has no separately exported entry.
describe('idle forwarded request authorization', () => {
+ // 2026-10-27 / unit: a new recipient must accept the same durable provenance as
+ // an existing one; direct send previously left its next handoff without a source.
+ it('queues the first verified request of a newly created task', async () => {
+ const broadcast = vi.fn();
+ const row = { id: 'new-child', permissionMode: 'auto', planModeEnabled: false };
+ const enqueue = vi.fn(async (input: { onAccepted?: () => Promise<void> }) => { await input.onAccepted?.(); });
+ const h = botTaskDispatchHarness({ 'new-child': row }, {}, {
+ openSession: async (_input: unknown, create: (row: object, guard: () => Promise<void>) => Promise<unknown>) =>
+ ({ row, value: await create(row, async () => {}) }),
+ enqueueSendToSessionMessage: enqueue,
+ broadcastSessionCreated: broadcast,
+ });
+ const receipt = { kind: 'agent-request', request: {
+ userText: 'Inspect fixtures', sessionId: 'owner', clientId: 'u1', ownerVerified: true } };
+ expect(await h.sendToSessionInternal({ message: 'envelope', autoReviewUserText: receipt,
+ createDefaults: { agentKind: 'codex', model: 'fixture', workingDir: '/tmp/fixture', permissionMode: 'auto' },
+ })).toMatchObject({ ok: true, targetSessionId: 'new-child', wakeKind: 'created' });
+ expect(enqueue).toHaveBeenCalledWith(expect.objectContaining({ targetSessionId: 'new-child', autoReviewUserText: receipt }));
+ expect(h.sendOptions).toHaveLength(0);
+ expect(broadcast).toHaveBeenCalledWith('new-child');
+ });
it.each([
['live', 'agent-request'], ['resumed', 'agent-request'],
['live', 'delegated-continuation'], ['resumed', 'delegated-continuation'],
@@ -413,7 +435,7 @@ describe('idle forwarded request authorization', () => {
// Incident 2026-10-23: the owner's relayed "可以提交 pr" reached the task with an empty
// review intent. A relay the sending host verified carries exactly the owner's words.
- it.each(['live', 'resumed'] as const)('%s dispatch reviews a verified owner relay against the owner words', async path => {
+ it.each(['live', 'resumed'] as const)('%s dispatch keeps a verified owner relay on the durable input path', async path => {
const live: Record<string, object> = path === 'live' ? { child: {
id: 'child', agentKind: 'claude-code', remoteHostId: null,
isTurnRunning: () => false, getStatus: () => 'active',
@@ -424,7 +446,11 @@ describe('idle forwarded request authorization', () => {
autoReviewUserText: { kind: 'agent-request', request: {
userText: 'Submit the PR.', sessionId: 'source', clientId: 'owner-input', ownerVerified: true } },
});
- expect(h.sendOptions[0]?.[AUTO_REVIEW_USER_INTENT]).toBe('Submit the PR.');
+ expect(h.scope.enqueueSendToSessionMessage).toHaveBeenCalledWith(expect.objectContaining({
+ targetSessionId: 'child', autoReviewUserText: { kind: 'agent-request', request: {
+ userText: 'Submit the PR.', sessionId: 'source', clientId: 'owner-input', ownerVerified: true } },
+ }));
+ expect(h.sendOptions).toHaveLength(0);
expect(h.readAutoReviewHistory).not.toHaveBeenCalled();
});
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts
index 330c8ce4ce..c657adc999 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts
@@ -754,14 +754,14 @@ describe('production Session event pipeline', () => {
}
});
- it('retains accepted private-message visibility for independent Pi notices', async () => {
+ it('keeps independent Pi notices visible after a peer message', async () => {
const h = harness();
h.deps.redactEventForRenderer.mockImplementation((value) => value);
h.deps.agentInputCoordinatorHolder.getActiveInputClientId.mockReturnValue('bot-dm:private-input');
h.emit(event('text', { text: 'Extension result', isFinal: true }, {
source: 'pi', standaloneText: true, turnScope: 'background',
}));
- expect(effects.fn('onStandaloneTextEvent')).toHaveBeenCalledWith('task', 'Extension result', { botPrivateReply: true });
+ expect(effects.fn('onStandaloneTextEvent')).toHaveBeenCalledWith('task', 'Extension result', { botPrivateReply: false });
await h.dispose();
});
@@ -2258,7 +2258,7 @@ describe('Bot adapters in the shared event pipeline', () => {
await h.dispose();
});
- it('preserves private input provenance in persistence and broadcast before done clears the active input', () => {
+ it('keeps peer replies visible in persistence and broadcast before done clears the input', () => {
const h = harness();
h.deps.agentInputCoordinatorHolder.getActiveInputClientId.mockReturnValue('bot-dm:thread:delivery');
h.deps.agentInputCoordinatorHolder.onTurnEvent.mockImplementation(() => {
@@ -2268,11 +2268,11 @@ describe('Bot adapters in the shared event pipeline', () => {
// The reply also records which input it answers (companion chats can show it above the reply).
expect(h.deps.broadcastToAllWindows).toHaveBeenLastCalledWith('maker:event', expect.objectContaining({
event: expect.objectContaining({ agentMeta: expect.objectContaining({
- botPrivateReply: true, replyToClientId: 'bot-dm:thread:delivery' }) }),
+ botPrivateReply: false, replyToClientId: 'bot-dm:thread:delivery' }) }),
}));
h.emit(event('done'));
expect(h.deps.broadcastToAllWindows).toHaveBeenCalledWith('maker:event', expect.objectContaining({
- event: expect.objectContaining({ type: 'done', agentMeta: expect.objectContaining({ botPrivateReply: true }) }),
+ event: expect.objectContaining({ type: 'done', agentMeta: expect.objectContaining({ botPrivateReply: false }) }),
}));
});
diff --git a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
index 211a9abe57..b93cc4791d 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -261,6 +261,7 @@ export interface AgentInputSendOpts {
* 也不参与任何权限判定;刻意不复用 `origin`(那是 scheduler 的 turn origin)。
*/
sourceOrigin?: AgentInputQueuedMessage['origin'];
+ [FORWARDED_REQUEST_RECEIPT]?: AgentInputQueuedMessage['autoReviewUserText'];
sourcePlugin?: AgentInputQueuedMessage['sourcePlugin'];
sharedTaskAuthor?: AgentInputQueuedMessage['sharedTaskAuthor'];
/** Main-owned clear token captured when this input became active. */
@@ -1375,7 +1376,12 @@ export class AgentInputCoordinator {
* Host actions such as app update.
*/
isActiveInputOwnerContinuation(sessionId: string): boolean {
- return this.activeInputHasOwnerAuthor(sessionId, true);
+ const item = this.states.get(sessionId)?.activeTurn?.item;
+ // A relay is not fresh owner input (updates and other owner-only actions
+ // still use isActiveInputOwnerAuthored), but task actions retain its scope.
+ const relayed = !!item && !item.sourcePlugin && !item.sharedTaskAuthor
+ && verifiedOwnerRequestText(item.autoReviewUserText) !== undefined;
+ return relayed || this.activeInputHasOwnerAuthor(sessionId, true);
}
private activeInputHasOwnerAuthor(sessionId: string, allowContinuation: boolean): boolean {
@@ -2654,6 +2660,10 @@ export class AgentInputCoordinator {
...(appMessageGuard ? { [MCP_APP_MESSAGE_GUARD]: appMessageGuard } : {}),
...(item.sharedTaskAuthor ? { sharedTaskAuthor: item.sharedTaskAuthor } : {}),
[AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(item),
+ ...(verifiedOwnerRequestText(item.autoReviewUserText) !== undefined ? {
+ [AUTO_REVIEW_USER_INTENT]: verifiedOwnerRequestText(item.autoReviewUserText),
+ [FORWARDED_REQUEST_RECEIPT]: item.autoReviewUserText,
+ } : {}),
...(item.autoReviewUserText && typeof item.autoReviewUserText === 'object' && item.autoReviewUserText.kind === 'delegated-continuation'
? { [AUTO_REVIEW_DELEGATED_CONTINUATION]: true as const } : {}),
...(typeof item.autoReviewUserText !== 'object' && readAutoReviewUserText(item.persistedContent) === null
@@ -5125,6 +5135,8 @@ export class AgentInputCoordinator {
} } : {}),
...(head.supersedesUserClientId ? { retryUserClientId: head.supersedesUserClientId } : {}),
[AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(head),
+ ...(verifiedOwnerRequestText(head.autoReviewUserText) !== undefined
+ ? { [AUTO_REVIEW_USER_INTENT]: verifiedOwnerRequestText(head.autoReviewUserText) } : {}),
...(head.autoReviewUserText && typeof head.autoReviewUserText === 'object' && head.autoReviewUserText.kind === 'delegated-continuation'
? { [AUTO_REVIEW_DELEGATED_CONTINUATION]: true as const } : {}),
messageUuid: active.messageUuid,
diff --git a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts b/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
index 220f7ae571..e6f19c7a49 100644
--- a/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
+++ b/apps/desktop/src/main/maker-ipc/botDirectMessageService.ts
@@ -110,6 +110,8 @@ export interface BotMessageTransport {
export interface BotDirectMessageServiceDeps {
transport?: BotMessageTransport;
+ /** Capture the accepted caller input, never model-written claims of approval. */
+ captureRequest?: (sessionId: string, supplement: string) => Promise<CapturedAgentRequest>;
dispatch: (params: {
autoReviewUserText?: AgentRequestReceipt;
targetSessionId: string;
@@ -478,11 +480,15 @@ export function createBotDirectMessageService(deps: BotDirectMessageServiceDeps)
return failed('INVALID_ARGS', `message 必须为 1-${MAX_MESSAGE_CHARS} 个字符`);
}
- // 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,
+ const captured: CapturedAgentRequest = remoteSender ? { message: rawMessage,
autoReviewUserText: { kind: 'agent-request',
- ...(remoteSender?.requestSource ? { request: remoteSender.requestSource } : {}) } };
+ ...(remoteSender.requestSource ? { request: remoteSender.requestSource } : {}) } }
+ : await deps.captureRequest?.(input.callerSessionId, rawMessage)
+ ?? { message: rawMessage, autoReviewUserText: { kind: 'agent-request' } };
+ // No original words means a normal peer message, including on older peers
+ // whose optional requestSource validator requires a quotation envelope.
+ if (captured.autoReviewUserText.request?.userText === null)
+ captured.autoReviewUserText = { kind: 'agent-request' };
const message = captured.message;
const caller = remoteSender ? {
diff --git a/apps/desktop/src/main/maker-ipc/forwardedRequest.ts b/apps/desktop/src/main/maker-ipc/forwardedRequest.ts
index 3d4767f9bd..774bb0dc5a 100644
--- a/apps/desktop/src/main/maker-ipc/forwardedRequest.ts
+++ b/apps/desktop/src/main/maker-ipc/forwardedRequest.ts
@@ -38,14 +38,14 @@ export async function ownerChannelInputEvidence(
return text?.trim() ? { clientId: lane.inputClientId, authoredText: text } : null;
}
-/** Only companion task instructions opt in. Accepted input wins over queued text; model labels are not evidence. */
+/** Host request handoffs 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,
- /** The Host admitted this call as the owner's own request (teammate principal `owner`). */
+ /** The host admitted this call as the owner's request or its accepted continuation. */
ownerVerified = false,
): Promise<CapturedAgentRequest> {
if (!preserveUserRequest) return { message: supplement, autoReviewUserText: { kind: 'agent-request' } };
@@ -66,10 +66,12 @@ export async function captureAgentRequest(
...(delegated ? { delegatedRequest: delegated } : {}),
}) : { userText: null };
}
- // Verification belongs to this relay's turn, never to an earlier receipt it carries forward.
+ // An accepted relay still names the same owner request. Only the current
+ // input can carry that evidence; a historical fallback cannot revive it.
const request: ForwardedRequestSource = { ...source };
delete request.ownerVerified;
- if (ownerVerified && request.userText !== null) request.ownerVerified = true;
+ if ((ownerVerified || active?.delegatedRequest?.ownerVerified === true) && request.userText !== null)
+ request.ownerVerified = true;
return { message: formatForwardedRequest(request, supplement),
autoReviewUserText: { kind: 'agent-request', request } };
}
diff --git a/apps/desktop/src/main/maker-ipc/messageSourceNote.ts b/apps/desktop/src/main/maker-ipc/messageSourceNote.ts
index eca016a424..78ef3a5c45 100644
--- a/apps/desktop/src/main/maker-ipc/messageSourceNote.ts
+++ b/apps/desktop/src/main/maker-ipc/messageSourceNote.ts
@@ -35,7 +35,8 @@ export interface WireMessageSourceFields {
* Its header calls the owner's words background; this host-verified fact says otherwise.
*/
function forwardedRequestClause(receipt: unknown): string | null {
- if (!receipt || typeof receipt !== 'object' || (receipt as { kind?: unknown }).kind !== 'agent-request') return null;
+ if (!receipt || typeof receipt !== 'object' ||
+ !['agent-request', 'delegated-continuation'].includes(String((receipt as { kind?: unknown }).kind))) return null;
const source = readForwardedRequestSource((receipt as { request?: unknown }).request);
if (!source || typeof source.userText !== 'string') return null;
return source.ownerVerified
@@ -54,11 +55,14 @@ export function buildWireMessageSourceNote(
opts: { visibleText?: string; autoResume?: boolean } = {},
): string | null {
if (!fields || opts.autoResume) return null;
- if (opts.visibleText !== undefined && isSyntheticTriggerText(opts.visibleText.trimStart()))
+ const clause = !fields.sourcePlugin && !fields.sharedTaskAuthor
+ ? forwardedRequestClause(fields.autoReviewUserText) : null;
+ // Peer inputs are hidden from the timeline, but their owner evidence must
+ // still reach the model. Other synthetic triggers remain unannotated.
+ if (!clause && opts.visibleText !== undefined && isSyntheticTriggerText(opts.visibleText.trimStart()))
return null;
const note = buildMessageSourceNote(messageSourceSenderFromMeta(fields));
- const clause = note ? forwardedRequestClause(fields.autoReviewUserText) : null;
- return clause ? `${note}${clause}` : note;
+ return clause ? `${note ?? '[消息来源] '}${clause}` : note;
}
/** 宽容读取主机透传的设备来源(未知平台 / 缺 id 返回 undefined)。 */
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 614549f0fd..39fae59b0f 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -7,7 +7,7 @@ import { readWorkerProjectContext, createWorkerWorktree, rememberWorkerProject,
import type { WorkerWorktreeRequest } from '../../shared/orca-worker-project';
import { captureAgentRequest as captureRequest, ownerChannelInputEvidence, type CapturedAgentRequest } from './forwardedRequest.js';
import { readChannelToolScope } from '../im/shared/channelToolScope.js';
-import { verifiedOwnerRequestText, type AgentRequestReceipt } from '../../shared/forwardedRequest.js';
+import { FORWARDED_REQUEST_RECEIPT, verifiedOwnerRequestText, type AgentRequestReceipt } from '../../shared/forwardedRequest.js';
import { configureBotTodoDispatch, settleBotTodoForSession } from './botTodoAccess.js';
import { createBotTodoDispatch } from './botTodoDispatch.js';
import {
@@ -4821,12 +4821,13 @@ export async function captureSessionAgentRequest(sessionId: string, supplement:
const active = agentInputCoordinatorHolder?.getAcceptedInputProvenance(sessionId) ?? null;
const lane = readChannelToolScope({ sessionId, sessionInstanceId: getMakerIfReady()?.getSession(sessionId)?.instanceId });
const principal = taskActionPrincipal(sessionId);
- // Only a companion's task instructions forward the owner's words. Ordinary
- // sessions (including scheduled runs and child results) keep their own body.
+ // Authorship follows the accepted request, not the sender's companion badge.
+ // Ordinary task handoffs must preserve it too; autonomous notifications stay plain.
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 ownerVerified = !!companion && principal === 'owner';
+ inArray(botSessionLinks.role, ['canonical', 'group', 'channel', 'thread', 'routine']), isNull(botSessionLinks.archivedAt))).limit(1);
+ const ownerVerified = companion ? principal === 'owner'
+ : agentInputCoordinatorHolder?.isActiveInputOwnerContinuation(sessionId) === true;
const evidence = active ?? (ownerVerified ? await ownerChannelInputEvidence(lane, async (clientId) => {
const [row] = await getDbClient().drizzle.select({ content: messages.content }).from(messages)
.where(and(eq(messages.sessionId, sessionId), eq(messages.clientId, clientId), eq(messages.role, 'user'),
@@ -4835,7 +4836,8 @@ export async function captureSessionAgentRequest(sessionId: string, supplement:
return row ? extractPlainText(row.content) : null;
}) : null);
const request = await captureRequest(sessionId, supplement, evidence,
- () => listMessagesForAgentHandoff(sessionId, 1, undefined, 'user'), !!companion, ownerVerified);
+ () => listMessagesForAgentHandoff(sessionId, 1, undefined, 'user'),
+ !!companion || ownerVerified || active?.delegatedRequest?.ownerVerified === true, ownerVerified);
if (!isDataOwnerBroadcastScopeCurrent(scope)) throw new Error('Data owner changed before request capture');
return request;
}
@@ -12279,42 +12281,56 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const clientId = createId();
createdPreviewSessionId = session.id;
createdPreviewClientId = clientId;
- const sendResult = await sendUserMessageWithAwaitedGitBaseline(session, message, clientId, {
- planMode: false,
- beforeProviderStart: assertTaskActionCurrent,
- onAccepted: async () => {
- await assertTaskActionCurrent();
- notifyAgentIslandUserPrompt(session, persistedContent ?? message, {
- source: 'send_to_session:create:onPersisting',
- clientId,
- });
- createdPreviewStarted = true;
- await createDbMessage(session.id, {
- clientId,
- role: 'user',
- content: persistedContent ?? message,
- ...(inputAgentMeta ? { agentMeta: inputAgentMeta } : {}),
- });
- // F4: send_to_session 的 create 分支也建了一条用户可见新会话(有 title + 落了 user
- // 消息),同属"新建会话需同步所有窗侧栏"的 purpose。广播跟 user row 持久化
- // 保持同一个 accepted 边界,避免后续 handle.send 失败时侧栏漏刷新。
- // (jump/resume 分支是既有 session 重建,不在此发,见 wakeKind:'resumed' 分支。)
- broadcastSessionCreated(session.id);
- },
- onDispatching: () => dispatchAgentIslandUserPrompt(session.id),
- }, directSource);
- if (createdPreviewStarted) {
- if (sendResult.accepted) {
- commitAgentIslandUserPrompt(session.id, clientId);
- } else {
- rollbackAgentIslandUserPrompt(
- session.id,
- clientId,
- 'send_to_session:create:not-dispatched',
- );
+ if (verifiedOwnerRequestText(params.autoReviewUserText) !== undefined) {
+ // New tasks need the same accepted-input provenance as busy and idle
+ // recipients, so further handoffs cannot lose the original request.
+ const meta = await maker.getSessionMeta(session.id);
+ const dbRow = await getSessionRowSnapshot(session.id);
+ if (!meta || !dbRow) throw new Error('Created session metadata unavailable');
+ await enqueueSendToSessionMessage({ targetSessionId: session.id, message,
+ persistedContent: persistedContent ?? message, clientId, meta, dbRow,
+ origin: queuedOrigin, sourcePlugin, autoReviewUserText: params.autoReviewUserText,
+ onAccepted: async () => { broadcastSessionCreated(session.id); },
+ taskActionDeliveryGuard: params.taskActionDeliveryGuard,
+ });
+ } else {
+ const sendResult = await sendUserMessageWithAwaitedGitBaseline(session, message, clientId, {
+ planMode: false,
+ beforeProviderStart: assertTaskActionCurrent,
+ onAccepted: async () => {
+ await assertTaskActionCurrent();
+ notifyAgentIslandUserPrompt(session, persistedContent ?? message, {
+ source: 'send_to_session:create:onPersisting',
+ clientId,
+ });
+ createdPreviewStarted = true;
+ await createDbMessage(session.id, {
+ clientId,
+ role: 'user',
+ content: persistedContent ?? message,
+ ...(inputAgentMeta ? { agentMeta: inputAgentMeta } : {}),
+ });
+ // F4: send_to_session 的 create 分支也建了一条用户可见新会话(有 title + 落了 user
+ // 消息),同属"新建会话需同步所有窗侧栏"的 purpose。广播跟 user row 持久化
+ // 保持同一个 accepted 边界,避免后续 handle.send 失败时侧栏漏刷新。
+ // (jump/resume 分支是既有 session 重建,不在此发,见 wakeKind:'resumed' 分支。)
+ broadcastSessionCreated(session.id);
+ },
+ onDispatching: () => dispatchAgentIslandUserPrompt(session.id),
+ }, directSource);
+ if (createdPreviewStarted) {
+ if (sendResult.accepted) {
+ commitAgentIslandUserPrompt(session.id, clientId);
+ } else {
+ rollbackAgentIslandUserPrompt(
+ session.id,
+ clientId,
+ 'send_to_session:create:not-dispatched',
+ );
+ }
}
+ assertDesktopSendDispatched(sendResult, 'send_to_session create');
}
- assertDesktopSendDispatched(sendResult, 'send_to_session create');
log.info('sendToSession created new session', {
dispatcherSessionId,
newSessionId: session.id,
@@ -12420,7 +12436,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// Pending selections also need the canonical send transaction: it consumes the intent,
// then refreshes queued createOpts from DB before starting the target harness.
// enqueue does not await dispatch, so the drain can acquire this lock after we return.
- if (params.files?.length || params.forceQueue || explicitClientId?.startsWith('bot-dm:') || explicitClientId?.startsWith(BOT_GROUP_CLIENT_ID_PREFIX) || explicitClientId?.startsWith('bot-authorization-resume:') || inputCoordinator.shouldQueueNewTurn(targetSessionId) || agentSwitchPending.get(targetSessionId)) {
+ if (params.files?.length || params.forceQueue || verifiedOwnerRequestText(params.autoReviewUserText) !== undefined || explicitClientId?.startsWith('bot-dm:') || explicitClientId?.startsWith(BOT_GROUP_CLIENT_ID_PREFIX) || explicitClientId?.startsWith('bot-authorization-resume:') || inputCoordinator.shouldQueueNewTurn(targetSessionId) || agentSwitchPending.get(targetSessionId)) {
lockStage = 'enqueue-queued-message';
const qClientId = explicitClientId ?? createId();
await enqueueSendToSessionMessage({
@@ -12993,6 +13009,7 @@ 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) => {
@@ -18781,6 +18798,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
*/
sourceDevice?: unknown;
sourceOrigin?: unknown;
+ [FORWARDED_REQUEST_RECEIPT]?: AgentRequestReceipt;
sourcePlugin?: unknown;
sharedTaskAuthor?: unknown;
expectedClearBoundaryMs?: number | null;
@@ -18872,6 +18890,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const steerSourceNote = shouldPrependMobileClientPromptNote(normalized, sess.agentKind)
? buildWireMessageSourceNote({
origin: so.sourceOrigin,
+ autoReviewUserText: so[FORWARDED_REQUEST_RECEIPT],
sourcePlugin: so.sourcePlugin,
sharedTaskAuthor: so.sharedTaskAuthor,
})
diff --git a/apps/desktop/src/main/maker-ipc/sessionEventPreparation.ts b/apps/desktop/src/main/maker-ipc/sessionEventPreparation.ts
index 457d9abd5a..c6d220464a 100644
--- a/apps/desktop/src/main/maker-ipc/sessionEventPreparation.ts
+++ b/apps/desktop/src/main/maker-ipc/sessionEventPreparation.ts
@@ -52,9 +52,9 @@ import {
import type { UsageLimitAutoResume } from './usageLimitAutoResume.js';
import { isBotGroupClientId } from '../../shared/botGroupChat.js';
-/** Bot DMs and group-lane turns answer an internal channel, not the user watching this Session. */
+/** Group-lane output belongs in its group. A DM input is hidden, but its answer belongs to the owner. */
function isBotPrivateInput(clientId: string): boolean {
- return clientId.startsWith('bot-dm:') || isBotGroupClientId(clientId);
+ return isBotGroupClientId(clientId);
}
interface DismissedInteraction {
diff --git a/apps/desktop/src/shared/forwardedRequest.ts b/apps/desktop/src/shared/forwardedRequest.ts
index 9fe07ce581..6caf350bb0 100644
--- a/apps/desktop/src/shared/forwardedRequest.ts
+++ b/apps/desktop/src/shared/forwardedRequest.ts
@@ -4,6 +4,7 @@ import zhCN from '../renderer/i18n/locales/zh-CN/common.json';
import zhTW from '../renderer/i18n/locales/zh-TW/common.json';
import ja from '../renderer/i18n/locales/ja/common.json';
import ko from '../renderer/i18n/locales/ko/common.json';
+export { verifiedOwnerRequestText } from '@cindy/maker-shared/auto-review-intent';
// The same locale resources serve persisted text and host task context.
const FORWARDED_REQUEST_COPY = {
@@ -20,8 +21,8 @@ export interface ForwardedRequestSource {
sessionId?: string;
clientId?: string;
/**
- * The sending host admitted this relay in a turn it verified as the owner's own request
- * (teammate principal `owner`). Only then does the receiver treat userText as the owner's
+ * The sending host admitted this relay as the owner's request or its accepted continuation.
+ * Only then does the receiver treat userText as the owner's
* request for this task. Optional on the wire; older hosts drop or never send it.
*/
ownerVerified?: true;
@@ -43,14 +44,6 @@ export function readForwardedRequestSource(value: unknown): ForwardedRequestSour
...(source.ownerVerified === true ? { ownerVerified: true as const } : {}) };
}
-/** The owner's words of a verified relay, for the receiver's auto-review intent. Never other text. */
-export function verifiedOwnerRequestText(receipt: unknown): string | undefined {
- if (!receipt || typeof receipt !== 'object' || (receipt as { kind?: unknown }).kind !== 'agent-request') return undefined;
- const source = readForwardedRequestSource((receipt as { request?: unknown }).request);
- return source?.ownerVerified && typeof source.userText === 'string' && source.userText.trim()
- ? source.userText : undefined;
-}
-
/** JSON string quoting keeps an agent-written label inside the supplement. No trimming or summarizing. */
export function formatForwardedRequest(source: ForwardedRequestSource, supplement: string, locale: SupportedLocale = DEFAULT_LOCALE): string {
const copy = FORWARDED_REQUEST_COPY[locale];
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index bd29fa8d76..151886a462 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -3742,3 +3742,12 @@ contacts 在每次 begin 投递前核对原元素仍连接、仍声明 contacts
路径的部分抬指使用 released IDs;仅发送剩余触点的 touchMove 不会释放缺失手指。
这与 contacts DOM 事件始终表示「全部仍按下触点」的约定不同;以真实 Electron 的
部分抬指、完整结束和取消回归核对,不能只靠 CDP mock 推断浏览器行为。
+
+## 主人请求跨任务连续性(2026-10-28)
+
+沿用可选 `requestSource.ownerVerified` 和持久 `autoReviewUserText` 回执,不新增字段或 migration。
+伙伴私信开始携带当前已接受的主人请求;原话与正文包装仍按旧接收端的逐字验证。无原话时不传空回执。
+当前接受的核实回执可继续转交,`agent-request` 与 `delegated-continuation` 的审核投影保持同一原话。
+旧接收端仍可能丢弃核实状态或把接收回复标成私密;完整修复需要执行交接的宿主升级。
+账号、群与 IM 发言人校验、权限档、Plan、输入代次和撤销校验保持不变。
+不改变连接恢复或重放策略;单次派发失败只影响该请求,不重启连接或扩大设备访问。
diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.md
index 2e40976d5f..01e90acb09 100644
--- a/docs/product-rules/agent-user-parity.md
+++ b/docs/product-rules/agent-user-parity.md
@@ -104,8 +104,9 @@ Worker 工具省略 working_dir 时保持继承 Lead 任务记录目录,不跟
- 协议与兼容见 [`../dev-rules/protocol-compatibility.md`](../dev-rules/protocol-compatibility.md)
「Agent 跨电脑管理定时任务与发消息」。
-仅伙伴代主人向任务下达要求时,由宿主附上可核实的用户原话,工具参数承载必要的轻度补充;
-普通任务互发、自动化、回传与伙伴通话保持正常正文,无原话不加空栏。来源回执不提供执行授权。
+伙伴或普通任务代主人下达要求时,由宿主附上当前输入中可核实的用户原话,工具参数承载必要的轻度补充;
+自主消息、自动化与回传保持正常正文,无原话不加空栏。伙伴通话和继续转交已核实请求
+保留同一来源;接收任务沿用原请求范围和当前权限档,不增加交接确认。来源回执不是新的执行权限档。
详见 [消息来源](message-source.md#跨任务请求与伙伴通话的原话2026-10-202026-10-21-收窄)。
### 模型速度
diff --git a/docs/product-rules/message-source.md b/docs/product-rules/message-source.md
index 11e6e788f7..d14b93583f 100644
--- a/docs/product-rules/message-source.md
+++ b/docs/product-rules/message-source.md
@@ -54,9 +54,9 @@ Agent 用 `send_to_session` 把消息发给另一台电脑上的既有任务时
## 跨任务请求与伙伴通话的原话(2026-10-20,2026-10-21 收窄)
-只有伙伴代主人向任务下达要求时,宿主才附上可核实的用户原话,伙伴仅作必要的轻度补充,
-不得改写原意或扩大范围。适用于伙伴发起的 `send_to_session`、插话、后台任务启动与追问;
-普通任务互发、自动化通知、结果和交互回传、`send_to_agent` 的伙伴通话保持正常正文。
+伙伴或普通任务代主人下达要求时,宿主附上当前已接受输入中可核实的用户原话,Agent 仅作必要的轻度补充,
+不得改写原意或扩大范围。适用于 `send_to_session`、插话、后台任务启动与追问、`send_to_agent`;
+自动化通知、结果和交互回传、自主讨论保持正常正文。继续转交已核实请求时保留同一来源。
没有可核实原话时同样直接发送正文,不生成空的「用户原话」栏或「来源缺失」提示。
这不改变仅在当次派发添加的 `[消息来源]` 说明和界面的来源标签。
@@ -75,7 +75,7 @@ Agent 用 `send_to_session` 把消息发给另一台电脑上的既有任务时
原有内部委派续接保留独立语义。共享访客不接收回执里的私有任务标识。
- 2026-10-23:只有伙伴在宿主核实的主人代办轮里转达时,回执带 `ownerVerified`。接收任务的 Auto
审核以这句原话为意图,`[消息来源]` 说明写明原话就是主人对本任务的请求、补充只是背景;正文三行
- 格式不变(旧接收端逐字比对)。凭证不随旧回执传递。规则见 [伙伴代表谁](teammate-authority.md)。
+ 格式不变(旧接收端逐字比对)。2026-10-28 修订:当前已接受输入里的凭证随同一请求继续传递,不能因交接降权;历史回看本身不恢复旧授权。规则见 [伙伴代表谁](teammate-authority.md)。
- 同账号跨电脑仅在带真实原话时附可选 `requestSource`;接收端继续校验它与正文一致,兼容
五语及最初中文格式。没有回执时保留原始正文,不猜原话。旧接收端仍可能添加旧空栏,消除
该显示需要接收端更新;不新增必填协议字段或数据库迁移。
@@ -127,3 +127,9 @@ Agent 用 `send_to_session` 把消息发给另一台电脑上的既有任务时
同一模型连续回复不重复标记。记录来自宿主派发时的实际模型,不能用当前选择器的值回填历史。
跨引擎沿用已有交接分隔,隐藏的例行检查和内部协调不额外产生可见模型提示。
桌面与手机使用同一份历史记录。缺少实际模型记录的旧消息不推测补标。
+
+### 伙伴私信回复可见性(2026-10-28)
+
+`bot-dm:` 隐藏的是来信及内部通讯入口,不再给接收伙伴的助手答复盖 `botPrivateReply`。
+正常结果、需要主人处理的说明沿既有落库、广播、伙伴预览和云端镜像路径显示;内部消息戳仍不产生未读。
+群专线的答复仍属于原群。旧记录不批量改写,不把旧确认补发为新的请求。
diff --git a/docs/product-rules/teammate-authority.md b/docs/product-rules/teammate-authority.md
index ecf6bb7edd..6a9dd7db3c 100644
--- a/docs/product-rules/teammate-authority.md
+++ b/docs/product-rules/teammate-authority.md
@@ -19,9 +19,9 @@
| 身份 | 宿主依据 | 能做什么 |
| --- | --- | --- |
-| 主人代办 | 本轮是主人亲手输入(含同账号手机 / 另一台电脑);群里经 Chat Server 实时核验为主人;IM 专线逐轮租约的 `requesterIsOwner`;主人这一轮被自动续跑或零输出重试 | 像主人本人一样操作主人的任务:找到任务、发话、追加需求、停止、改名、归档、开后台任务等 |
+| 主人代办 | 本轮是主人亲手输入(含同账号手机 / 另一台电脑);群里经 Chat Server 实时核验为主人;IM 专线逐轮租约的 `requesterIsOwner`;主人这一轮被自动续跑或零输出重试;当前已接受输入携带宿主核实的主人原话回执 | 像主人本人一样操作主人的任务:找到任务、发话、追加需求、停止、改名、归档、开后台任务等 |
| 受托 | 主人自己设的例行任务(含导入的自动化);伙伴自己当 Lead 时收到本团队 Worker 的回报 | 按那条常驻指令或那个团队办事;Auto 审核以例行任务的指令为意图 |
-| 自主 | 其它一切:宿主唤醒的跟进与查待办、别的伙伴发来的消息、群成员 / IM 外人、无法核实的转入 | 只动自己的东西,见下表 |
+| 自主 | 其它一切:宿主唤醒的跟进与查待办、没有主人请求凭证的伙伴来信、群成员 / IM 外人、无法核实的转入 | 只动自己的东西,见下表 |
IM 专线有逐轮租约时以租约为准,桌面看起来像主人的输入不能覆盖它。群专线没有实时主人核验时,
写工具照旧直接失败。
@@ -50,10 +50,15 @@ IM 专线有逐轮租约时以租约为准,桌面看起来像主人的输入
已知边界:宿主只能确定性地限定**目标**。「按原目标接着做」还是「追加新要求」属于消息内容,
Auto 档由审核器结合例行任务指令判断,Full Access 不审,靠伙伴指引约束。
-## 转达主人原话(sudo 凭证)
+## 转达主人原话(请求来源)
-- 只有在主人代办轮里由伙伴转达时,宿主才在回执上标 `ownerVerified`。凭证属于这一次转达,
- 不随旧回执继续传递;自主轮转出去的原话不带这个标记。
+- 主人代办轮由宿主在回执上标 `ownerVerified`。伙伴私信、任务委派和后续转交沿用同一份原话及
+ `sessionId/clientId`;当前已接受输入中的核实结果不会因为换了接收任务或伙伴而降权。
+ 仅从旧历史读到回执、没有当前受托输入时,不恢复旧请求;自主触发、插件与共享访客不能自行生成凭证。
+- 接收方的任务写工具把这类输入视为原请求的继续,仍按当前权限档审风险;不要求主人重复复述。
+ 它不等同于主人刚刚亲手输入,应用更新等专门要求本人输入的操作保持原有边界。
+- 空闲、繁忙和新建任务共用持久输入协调器,插话、重试及历史恢复都保留原话;审核上下文不采用 Agent 补充
+ 里的授权说法。原话不明或缺少背景时,先按来源任务查上下文,只有仍缺少必要决定才向主人提问。
- IM 轮次不经过输入协调器:原话取自 IM 运行器写在逐轮租约上的本轮落库消息(`inputClientId`),
只在租约的发言人是主人时读取。
- 主人输入被自动续跑(包括生成的「继续」消息)仍算主人代办,但不算新的主人输入,
diff --git a/packages/lizi-mcps/src/xdt-helper/send_to_session.ts b/packages/lizi-mcps/src/xdt-helper/send_to_session.ts
index 35e6e6e82c..33b5a06d6f 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(
- "要发送的消息。伙伴代用户下达任务要求时,宿主另附可核实的用户原话;只补充必要上下文,保留原意和范围,不复述授权、不要求对方回传。普通任务与自动化消息按正文发送。",
+ "要发送的消息。当前输入属于主人请求或已核实转交时,宿主保留同一份用户原话;只补充必要上下文,不扩大范围或要求重复确认。缺少背景先查看来源任务。自主消息、自动化通知和结果回传按正文发送。",
),
message_purpose: z.enum(["coordination", "user-visible"]).optional().describe(
"委派子任务发给发起伙伴默认 coordination:原始来信隐藏,伙伴处理后的进度和结果可直接正常回复。user-visible 让来信本身可见。其他普通任务默认保持可见;coordination 仅限宿主核实的委派关系,不改变操作权限。正常完成自动回传,无需重发。",
diff --git a/packages/maker-shared/src/autoReviewIntent.ts b/packages/maker-shared/src/autoReviewIntent.ts
index 204a20b685..5f5f874645 100644
--- a/packages/maker-shared/src/autoReviewIntent.ts
+++ b/packages/maker-shared/src/autoReviewIntent.ts
@@ -55,6 +55,11 @@ export function splitAutoReviewUserReferences(intent: AutoReviewUserIntent): {
return sharedProjection().splitReferences(intent);
}
+/** Read only a host-owned receipt, never model text or a wire-supplied approval. */
+export function verifiedOwnerRequestText(receipt: unknown): string | undefined {
+ return sharedProjection().verifiedOwnerRequestText(receipt);
+}
+
let sharedProjectionInstance: ReturnType<typeof createAutoReviewIntentProjection> | undefined;
function sharedProjection(): ReturnType<typeof createAutoReviewIntentProjection> {
return (sharedProjectionInstance ??= createAutoReviewIntentProjection());
@@ -74,6 +79,18 @@ export function createAutoReviewIntentProjection() {
const OMITTED_USER_INTENT =
"User message omitted because it exceeds the review budget; it cannot establish authorization.";
+ // Kept inside the factory because database workers evaluate its source.
+ function verifiedOwnerRequestText(receipt: unknown): string | undefined {
+ if (!receipt || typeof receipt !== "object" || !("kind" in receipt) ||
+ !["agent-request", "delegated-continuation"].includes(String(receipt.kind)) || !("request" in receipt)) return undefined;
+ const source = receipt.request;
+ if (!source || typeof source !== "object" || !("ownerVerified" in source) || source.ownerVerified !== true ||
+ !("sessionId" in source) || typeof source.sessionId !== "string" || !source.sessionId ||
+ !("clientId" in source) || typeof source.clientId !== "string" || !source.clientId ||
+ !("userText" in source) || typeof source.userText !== "string" || !source.userText.trim()) return undefined;
+ return source.userText;
+ }
+
function compactCurrentUserIntent(
text: string,
maxChars = MAX_USER_INTENT_CHARS,
@@ -304,7 +321,8 @@ export function createAutoReviewIntentProjection() {
const receipt = meta?.autoReviewUserText;
return !!(meta?.autoResume || meta?.contextRebuild ||
(receipt && typeof receipt === "object" && "kind" in receipt &&
- (receipt.kind === "scheduled-continuation" || receipt.kind === "delegated-continuation")));
+ (receipt.kind === "scheduled-continuation" ||
+ (receipt.kind === "delegated-continuation" && verifiedOwnerRequestText(receipt) === undefined))));
}
function restoreAutoReviewUserIntent(
@@ -344,11 +362,14 @@ export function createAutoReviewIntentProjection() {
if (message.role !== "user") continue;
// An already-persisted retry is the same input, not a second authorization.
if (current && message.clientId === current.clientId) {
- if (message.agentMeta?.autoReviewUserText !== latest) return "";
+ const receipt = message.agentMeta?.autoReviewUserText;
+ if ((typeof receipt === "string" ? receipt : verifiedOwnerRequestText(receipt)) !== latest) return "";
replayed = true;
}
const meta = message.agentMeta;
- const text = meta?.autoReviewUserText;
+ const receipt = meta?.autoReviewUserText;
+ const text = typeof receipt === "string" ? receipt
+ : !meta?.sourcePlugin && !meta?.sharedTaskAuthor ? verifiedOwnerRequestText(receipt) : undefined;
if (typeof text === "string" && text.startsWith("[UI_ACTION_TRIGGER]"))
omitted = true;
// delivery/wire alone are not authorship proof: plugin rewrites have the same shape.
@@ -394,6 +415,7 @@ export function createAutoReviewIntentProjection() {
// Empty authored receipts reset earlier resource consent and need ordering too.
const authored =
typeof receipt === "string" ||
+ verifiedOwnerRequestText(receipt) !== undefined ||
(receipt &&
typeof receipt === "object" &&
"text" in receipt &&
@@ -421,16 +443,18 @@ export function createAutoReviewIntentProjection() {
omitted = true;
}
} else if (m.role === "user") {
+ const relayed = !m.agentMeta?.sourcePlugin && !m.agentMeta?.sharedTaskAuthor
+ ? verifiedOwnerRequestText(receipt) : undefined;
// Legacy UI triggers and literal user text share this string receipt.
// Keep restrictions, but do not let ambiguous provenance establish Auto consent.
if (typeof receipt === "string" && receipt.startsWith("[UI_ACTION_TRIGGER]"))
omitted = true;
if (
- typeof receipt === "string" &&
+ (typeof receipt === "string" || relayed !== undefined) &&
["turn", "steer"].includes(String(m.agentMeta?.delivery))
) {
if (readAutoReviewUserText(m.content) === null) intent = "";
- intent = appendAutoReviewUserIntent(intent, receipt);
+ intent = appendAutoReviewUserIntent(intent, typeof receipt === "string" ? receipt : relayed!);
} else {
omitted = true;
}
@@ -461,6 +485,7 @@ export function createAutoReviewIntentProjection() {
splitReferences: splitAutoReviewUserReferences,
append: appendAutoReviewUserIntent,
readText: readAutoReviewUserText,
+ verifiedOwnerRequestText,
restore: restoreAutoReviewUserIntent,
ambiguousAnswers,
isSynthetic,