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(plugins): preserve human resource boundaries in delegated review

Dashd6891acc15fa
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/messagesListCursor.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/messagesListCursor.test.ts
index e98a2c211f..667ed61356 100644
--- a/apps/desktop/src/main/localDb/ipc/__tests__/messagesListCursor.test.ts
+++ b/apps/desktop/src/main/localDb/ipc/__tests__/messagesListCursor.test.ts
@@ -325,17 +325,19 @@ describe('local-db:messages:list cursor', () => {
} finally { sqlite.close(); }
});
- it('filters authenticated empty receipts before the authorization limit but retains ambiguous legacy rows', async () => {
+ it('filters typed continuations but retains empty human resource boundaries and ambiguous rows', async () => {
const sqlite = createDb();
try {
insertCostMessage(sqlite, { id: 'restriction', role: 'user', createdAt: 1,
agentMeta: { autoReviewUserText: 'Do not delete files.', delivery: 'turn' } });
insertCostMessage(sqlite, { id: 'legacy', role: 'user', createdAt: 2,
agentMeta: { autoReviewUserText: '' } });
+ insertCostMessage(sqlite, { id: 'human-resource', role: 'user', createdAt: 2.5,
+ agentMeta: { autoReviewUserText: '', delivery: 'turn', origin: { kind: 'orca' } } });
for (let i = 0; i < 120; i++) insertCostMessage(sqlite, { id: `delegated-${i}`, role: 'user', createdAt: i + 3,
- agentMeta: { autoReviewUserText: '', delivery: i % 2 ? 'turn' : 'steer' } });
- expect((await listMessagesForAgentHandoff('s1', 2, undefined, 'authorization')).map(row => row.clientId))
- .toEqual(['restriction', 'legacy']);
+ agentMeta: { autoReviewUserText: { kind: 'delegated-continuation' }, delivery: i % 2 ? 'turn' : 'steer' } });
+ expect((await listMessagesForAgentHandoff('s1', 3, undefined, 'authorization')).map(row => row.clientId))
+ .toEqual(['restriction', 'legacy', 'human-resource']);
expect((await listMessagesForAgentHandoff('s1', 1, undefined, 'user')).map(row => row.clientId))
.toEqual(['delegated-119']);
} finally { sqlite.close(); }
diff --git a/apps/desktop/src/main/localDb/ipc/messages.ts b/apps/desktop/src/main/localDb/ipc/messages.ts
index 3bbfb02580..e33efac5f3 100644
--- a/apps/desktop/src/main/localDb/ipc/messages.ts
+++ b/apps/desktop/src/main/localDb/ipc/messages.ts
@@ -2532,15 +2532,11 @@ export async function listMessagesForAgentHandoff(
ELSE ${messages.createdAt} END ELSE ${messages.createdAt} END`;
// Scheduled executions are not owner messages. Exclude them before LIMIT so
// a long-running heartbeat cannot push its authorizing request out of history.
- // Host-captured empty turn/steer receipts also carry no user intent (plugin/Orca messages).
+ // Empty human receipts can reset resource authorization; only protected typed continuations are skipped.
// Keep malformed/unknown rows: restoration must still invalidate ambiguous consent.
const notScheduledExecution = sql`CASE WHEN ${messages.role} = 'user'
AND json_valid(${messages.agentMeta}) THEN CASE
- WHEN json_extract(${messages.agentMeta}, '$.autoReviewUserText.kind') = 'scheduled-continuation'
- THEN 0
- WHEN json_type(${messages.agentMeta}, '$.autoReviewUserText') = 'text'
- AND json_extract(${messages.agentMeta}, '$.autoReviewUserText') = ''
- AND json_extract(${messages.agentMeta}, '$.delivery') IN ('turn', 'steer')
+ WHEN json_extract(${messages.agentMeta}, '$.autoReviewUserText.kind') IN ('scheduled-continuation', 'delegated-continuation')
THEN 0 ELSE 1 END ELSE 1 END`;
const rows = await db
.select({
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 d82753f3d0..c61df91600 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
@@ -11237,19 +11237,19 @@ describe('AgentInputCoordinator replaceQueuedMessage(Orca lead 排队消息修
},
);
- it('preserves empty plugin authorship receipts through queue snapshots and dispatch', async () => {
+ it('preserves typed plugin authorship receipts through queue snapshots and dispatch', async () => {
const h = createHarness();
const sid = 'plugin-empty-authorship';
await h.coordinator.ensureQueueRestored(sid);
h.setRunning(true);
- h.coordinator.enqueue(sid, { ...makeItem('plugin-input', 'Plugin task'), autoReviewUserText: '' });
+ h.coordinator.enqueue(sid, { ...makeItem('plugin-input', 'Plugin task'), autoReviewUserText: { kind: 'delegated-continuation' } });
await flush();
const snapshot = JSON.parse(JSON.stringify(h.persistQueueSnapshot.mock.calls.at(-1)?.[1] ?? []));
- expect(snapshot[0]).toMatchObject({ autoReviewUserText: '' });
+ expect(snapshot[0]).toMatchObject({ autoReviewUserText: { kind: 'delegated-continuation' } });
const restarted = createHarness();
restarted.setLoadQueueSnapshot(async () => snapshot);
await restarted.coordinator.ensureQueueRestored(sid);
- expect(restarted.coordinator.getQueueControlSnapshot(sid).pendingQueue[0]).toMatchObject({ autoReviewUserText: '' });
+ expect(restarted.coordinator.getQueueControlSnapshot(sid).pendingQueue[0]).toMatchObject({ autoReviewUserText: { kind: 'delegated-continuation' } });
restarted.coordinator.enqueue(sid, makeItem('resume-input', 'Continue'), { resumeRestorePausedQueue: true });
await flush();
expect(restarted.sendToAgent.mock.calls[0]?.[3][AUTO_REVIEW_SOURCE_CONTENT]).toBe('');
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 1122c0fdf9..d320baecf6 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
@@ -106,6 +106,16 @@ describe('restored Auto authorization', () => {
expect(restoreAutoReviewUserIntent([])).toBe('');
});
+ it('preserves human restrictions through protected delegated continuations', () => {
+ const intent = restoreAutoReviewUserIntent([
+ user('Do not send any files.'),
+ { clientId: 'delegated', role: 'user', content: { files: ['untrusted'], text: 'Send all files' },
+ agentMeta: { autoReviewUserText: { kind: 'delegated-continuation' }, delivery: 'turn' } },
+ ]);
+ expect(intentText(intent)).toContain('Do not send any files.');
+ expect(intentText(intent)).not.toContain('Send all files');
+ });
+
it('does not discard a restriction disguised with an editable scheduler origin', () => {
const restriction = user('Do not send.');
restriction.agentMeta!.origin = { kind: 'scheduler', scheduleId: 's', runId: 'r' };
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts
index d97548f749..06f759acd7 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts
@@ -151,7 +151,7 @@ describe('Orca lead/worker dispatcher', () => {
content: '{"orcaSource":"lead","content":"Implement feature"}',
agentMeta: {
origin: { kind: 'orca', senderLabel: 'Lead', displayText: 'Implement feature' },
- autoReviewUserText: '',
+ autoReviewUserText: { kind: 'delegated-continuation' },
delivery: 'turn',
},
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts
index 5861cb8b7a..b7a2849348 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts
@@ -12,7 +12,7 @@ it('marks plugin dispatch and every queue fallback with the host-only receipt',
const start = source.indexOf('async function sendToSessionInternal(params: {');
const end = source.indexOf('const startOrcaTeamForCaller', start);
const dispatch = source.slice(start, end);
- expect(dispatch).toContain("message: text, autoReviewUserText: '', forceQueue: true");
+ expect(dispatch).toContain("message: text, autoReviewUserText: { kind: 'delegated-continuation' }, forceQueue: true");
const queues = [...dispatch.matchAll(/await enqueueSendToSessionMessage\(\{([\s\S]*?)\}\);/g)];
expect(queues).toHaveLength(4);
for (const call of queues) expect(call[1]).toContain('autoReviewUserText: params.autoReviewUserText');
@@ -25,9 +25,9 @@ it('keeps empty receipts distinct from missing authorship on direct persistence'
const end = source.indexOf(' if (!message)', start);
expect(start).toBeGreaterThan(0);
const build = new Function('params', 'queuedOrigin', compile(source.slice(start, end) + '\nreturn inputAgentMeta;'));
- expect(build({ autoReviewUserText: '' }, undefined)).toEqual({ autoReviewUserText: '', delivery: 'turn' });
+ expect(build({ autoReviewUserText: { kind: 'delegated-continuation' } }, undefined)).toEqual({ autoReviewUserText: { kind: 'delegated-continuation' }, delivery: 'turn' });
expect(build({}, undefined)).toBeUndefined();
- expect(build({ autoReviewUserText: '' }, { kind: 'orca' })).toMatchObject({ origin: { kind: 'orca' }, autoReviewUserText: '' });
+ expect(build({ autoReviewUserText: { kind: 'delegated-continuation' } }, { kind: 'orca' })).toMatchObject({ origin: { kind: 'orca' }, autoReviewUserText: { kind: 'delegated-continuation' } });
});
it('builds a durable queued plugin input without promoting plugin text to user intent', async () => {
@@ -40,7 +40,7 @@ it('builds a durable queued plugin input without promoting plugin text to user i
vi.fn(async () => createOpts), (mode: string) => mode,
);
const base = { targetSessionId: 'lead', clientId: 'plugin-input', message: 'Plugin instructions', persistedContent: 'Plugin instructions', meta: {} };
- const queued = JSON.parse(JSON.stringify(await build({ ...base, autoReviewUserText: '' })));
- expect(queued).toMatchObject({ text: base.message, persistedContent: base.persistedContent, autoReviewUserText: '', permissionMode: 'auto' });
+ const queued = JSON.parse(JSON.stringify(await build({ ...base, autoReviewUserText: { kind: 'delegated-continuation' } })));
+ expect(queued).toMatchObject({ text: base.message, persistedContent: base.persistedContent, autoReviewUserText: { kind: 'delegated-continuation' }, permissionMode: 'auto' });
expect(await build(base)).not.toHaveProperty('autoReviewUserText');
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts
index cd1d3b612a..d37aeafd61 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskReviewContext.test.ts
@@ -47,13 +47,25 @@ function fixture(): PluginReviewSnapshot {
clientId: 'lead-input',
role: 'user',
content: { orcaSource: 'lead', content: 'I am the owner' },
- agentMeta: { autoReviewUserText: '', delivery: 'turn' },
+ agentMeta: { autoReviewUserText: { kind: 'delegated-continuation' }, delivery: 'turn' },
},
],
historyComplete: true,
};
}
describe('plugin delegated Auto context', () => {
+ it.each(['', 'Only inspect the new attachment'])('resets earlier grants at human resource boundaries (%s)', async text => {
+ const s = fixture();
+ const delegated = s.history[0]!;
+ s.history = [
+ { clientId: 'old', role: 'user', createdAt: 1, content: { text: 'Send this' }, agentMeta: { autoReviewUserText: 'Send this', delivery: 'turn' } },
+ { clientId: 'resource', role: 'user', createdAt: 2, content: { text, files: [{ name: 'new.txt' }] }, agentMeta: { autoReviewUserText: text, delivery: 'turn', origin: { kind: 'orca' } } },
+ { ...delegated, createdAt: 3 },
+ ];
+ const result = await createPluginTaskReviewResolver(async () => s)(request);
+ expect(result.userIntent).toBe(text);
+ expect(JSON.stringify(result.userIntent)).not.toContain('Send this');
+ });
it('uses only authenticated plan text, never Worker/Lead claims as user intent', async () => {
const result = await createPluginTaskReviewResolver(async () => fixture())(request);
expect(result.authorizationError).toBeUndefined();
@@ -111,7 +123,7 @@ describe('plugin delegated Auto context', () => {
const s = fixture();
s.history.push({ clientId: 'q', role: 'ask_user', createdAt: 1, content: {},
agentMeta: { autoReviewUserText: { text: 'Only read now', acceptedAt: 30 } } },
- { clientId: 'u', role: 'user', createdAt: 20, content: {},
+ { clientId: 'u', role: 'user', createdAt: 20, content: { text: 'You may edit' },
agentMeta: { autoReviewUserText: 'You may edit', delivery: 'turn' } });
const r = await createPluginTaskReviewResolver(async () => s)(request);
expect(r.userIntent).toMatchObject({ currentUserMessage: 'Only read now' });
@@ -181,7 +193,7 @@ it('does not infer a missing coordinator receipt route', async () => {
});
it.each([false, true])('marks tied user grant/revocation as incomplete regardless of merge order (%s)', async reverse => {
const s = fixture();
- s.history = ['Do not write', 'You may write'].map((text, i) => ({clientId: String(i), role: 'user', createdAt: 42, content: {}, agentMeta: {autoReviewUserText: text, delivery: 'turn'}}));
+ s.history = ['Do not write', 'You may write'].map((text, i) => ({clientId: String(i), role: 'user', createdAt: 42, content: { text }, agentMeta: {autoReviewUserText: text, delivery: 'turn'}}));
if (reverse) s.history.reverse();
const result = await createPluginTaskReviewResolver(async () => s)(request);
expect(result.userIntent).toMatchObject({historyOmitted: true});
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 8d857e998b..398619aa79 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -109,6 +109,11 @@ const REWIND_BOUNDARY_POLL_INTERVAL_MS = 100;
type QueuedAttachment = NonNullable<AgentInputQueuedMessage['files']>[number];
+/** Typed Host continuations carry provenance, never user-authored permission text. */
+function queuedAutoReviewText(item: AgentInputQueuedMessage): string {
+ return typeof item.autoReviewUserText === 'string' ? item.autoReviewUserText : '';
+}
+
function isMakerImageAttachment(file: Pick<QueuedAttachment, 'category' | 'ext'>): boolean {
return getAgentInputAttachmentBlockType(file.category, file.ext) === 'image';
}
@@ -2194,9 +2199,9 @@ export class AgentInputCoordinator {
);
await this.deps.steerToAgent(sessionId, buildMakerUserMessage(item, referenceContexts), {
...(item.sharedTaskAuthor ? { sharedTaskAuthor: item.sharedTaskAuthor } : {}),
- [AUTO_REVIEW_SOURCE_CONTENT]: item.autoReviewUserText ?? '',
+ [AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(item),
...(readAutoReviewUserText(item.persistedContent) === null
- ? { [AUTO_REVIEW_USER_INTENT]: item.autoReviewUserText ?? '' } : {}),
+ ? { [AUTO_REVIEW_USER_INTENT]: queuedAutoReviewText(item) } : {}),
messageUuid,
userName: item.userName,
signal: AbortSignal.any([inputBoundarySignal, steerAbort.signal]),
@@ -4549,7 +4554,7 @@ export class AgentInputCoordinator {
const preVendorDispatchAt = Math.max(0, Date.now() - 1);
const result = await this.deps.sendToAgent(sessionId, makerUserMessage, head.createOpts, {
...(head.supersedesUserClientId ? { retryUserClientId: head.supersedesUserClientId } : {}),
- [AUTO_REVIEW_SOURCE_CONTENT]: head.autoReviewUserText ?? '',
+ [AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(head),
messageUuid: active.messageUuid,
userName: head.userName,
...(head.toolsDisabled === true ? { toolsDisabled: true } : {}),
diff --git a/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts b/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts
index 5bb09fb3fd..cc10cb71ed 100644
--- a/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts
+++ b/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts
@@ -134,7 +134,7 @@ export function restoreAutoReviewUserIntent(
// Keep intervening human restrictions; do not let repeated heartbeats erase them.
// Use the protected receipt, not origin (which the renderer can edit).
const receipt = message.agentMeta?.autoReviewUserText as Record<string, unknown> | undefined;
- if (receipt?.kind === 'scheduled-continuation') continue;
+ if (receipt?.kind === 'scheduled-continuation' || receipt?.kind === 'delegated-continuation') 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 '';
diff --git a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
index 7133a9493a..8c80a1c4ba 100644
--- a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
@@ -678,7 +678,7 @@ async function sendPersistedUserMessageToSession<TSessionMeta>(
clientId,
role: 'user',
content: dbContent,
- agentMeta: { ...(origin ? { origin } : {}), autoReviewUserText: '', delivery: 'turn' },
+ agentMeta: { ...(origin ? { origin } : {}), autoReviewUserText: { kind: 'delegated-continuation' }, delivery: 'turn' },
});
await deps.beginDirectTurnChangeSet(session.id, clientId);
turnChangeSetStarted = true;
@@ -741,7 +741,7 @@ function buildQueuedOrcaInterAgentMessage(params: {
return {
clientId: params.clientId,
text: params.agentMessageText,
- autoReviewUserText: '',
+ autoReviewUserText: { kind: 'delegated-continuation' },
persistedContent: params.persistedContent,
model: params.createOpts.model,
effort: params.createOpts.effort ?? '',
diff --git a/apps/desktop/src/main/maker-ipc/pluginTaskReviewContext.ts b/apps/desktop/src/main/maker-ipc/pluginTaskReviewContext.ts
index fe613deeed..7f604cc008 100644
--- a/apps/desktop/src/main/maker-ipc/pluginTaskReviewContext.ts
+++ b/apps/desktop/src/main/maker-ipc/pluginTaskReviewContext.ts
@@ -5,7 +5,7 @@ import {
type AutoReviewUserIntent,
} from '@cindy/maker-core';
import type { PluginTeamPlan, PluginTaskRoute } from '../../shared/pluginTasks.js';
-import type { AutoReviewHistoryMessage } from './autoReviewUserIntent.js';
+import { readAutoReviewUserText, type AutoReviewHistoryMessage } from './autoReviewUserIntent.js';
export interface PluginReviewSnapshot {
pluginId: string;
@@ -62,12 +62,13 @@ export function pluginReviewUserIntent(snapshot: PluginReviewSnapshot): AutoRevi
typeof receipt === 'string' &&
['turn', 'steer'].includes(String(m.agentMeta?.delivery))
) {
- if (receipt) intent = appendAutoReviewUserIntent(intent, receipt);
+ if (readAutoReviewUserText(m.content) === null) intent = '';
+ intent = appendAutoReviewUserIntent(intent, receipt);
} else if (!(
receipt &&
typeof receipt === 'object' &&
'kind' in receipt &&
- receipt.kind === 'scheduled-continuation'
+ (receipt.kind === 'scheduled-continuation' || receipt.kind === 'delegated-continuation')
)) {
omitted = true;
}
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index c5f9095ba3..fe09bf926d 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -8892,7 +8892,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
onAcceptedCommit?: () => void | Promise<void>;
origin?: AgentInputQueuedMessage['origin'];
/** Host-only receipt: plugin-authored input is not user-authored permission. */
- autoReviewUserText?: '';
+ autoReviewUserText?: { kind: 'delegated-continuation' };
authorizationGuard?: BotAuthorizationInputGuard;
createDefaults?: SendToSessionCreateDefaults;
/** 安全调用方可要求新会话不比来源会话拥有更高的权限。 */
@@ -10233,7 +10233,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
},
dispatch: async (pluginId, taskId, clientId, text) => {
assertPlugin(pluginId);
- const outcome = await sendToSessionInternal({ targetSessionId: taskId, clientId, message: text, autoReviewUserText: '', forceQueue: true, onAccepted: async () => { assertPlugin(pluginId); await pluginTaskServiceForCurrentOwner!().assertDispatch(pluginId, taskId); assertPlugin(pluginId); } });
+ const outcome = await sendToSessionInternal({ targetSessionId: taskId, clientId, message: text, autoReviewUserText: { kind: 'delegated-continuation' }, forceQueue: true, onAccepted: async () => { assertPlugin(pluginId); await pluginTaskServiceForCurrentOwner!().assertDispatch(pluginId, taskId); assertPlugin(pluginId); } });
await awaitAgentInputQueueSnapshotPersistence(taskId);
assertCurrent();
return outcome;
@@ -10776,7 +10776,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
onAcceptedCommit?: () => void | Promise<void>;
origin?: AgentInputQueuedMessage['origin'];
/** Host-only receipt: plugin-authored input is not user-authored permission. */
- autoReviewUserText?: '';
+ autoReviewUserText?: { kind: 'delegated-continuation' };
authorizationGuard?: BotAuthorizationInputGuard;
}): Promise<void> {
const queued = await buildSessionControlInputItem(params);
@@ -10817,7 +10817,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
files?: AgentInputQueuedMessage['files'];
origin?: AgentInputQueuedMessage['origin'];
/** Host-only receipt: plugin-authored input is not user-authored permission. */
- autoReviewUserText?: '';
+ autoReviewUserText?: { kind: 'delegated-continuation' };
toolsDisabled?: boolean;
}): Promise<AgentInputQueuedMessage> {
const createOpts = await buildCreateOptsForQueuedSession(params.targetSessionId, params.meta, params.inheritTargetPlanMode);
diff --git a/apps/desktop/src/shared/agentInputQueue.ts b/apps/desktop/src/shared/agentInputQueue.ts
index 74f01f5b74..8ecda98ad3 100644
--- a/apps/desktop/src/shared/agentInputQueue.ts
+++ b/apps/desktop/src/shared/agentInputQueue.ts
@@ -235,7 +235,7 @@ export interface AgentInputQueuedMessage {
/** Host-stamped attribution, retained in durable queue snapshots and messages. */
sharedTaskAuthor?: SharedTaskAuthor;
/** Host-captured authored text before plugin/reference decoration; omitted from wire projections. */
- autoReviewUserText?: string;
+ autoReviewUserText?: string | { kind: 'delegated-continuation' };
/** Host-owned text-only input; retained by queue persistence and retry. */
toolsDisabled?: boolean;
clientId: string;
diff --git a/docs/dev-rules/plugin-task-api-implementation.md b/docs/dev-rules/plugin-task-api-implementation.md
index 49fb726d2b..589ee3537c 100644
--- a/docs/dev-rules/plugin-task-api-implementation.md
+++ b/docs/dev-rules/plugin-task-api-implementation.md
@@ -79,9 +79,9 @@ Host 只接受经绑定插件身份写入的自有创建收据;已登记计划
团队归属和计划匹配;异步结果返回前再次核对。真实用户限制来自 Host 保存的作者凭据,
不从 Orca 消息、模型声称或工具参数恢复。缺少旧作者凭据时标注历史不完整,不猜测授权。
插件文字放在独立 `delegatedTask` 字段,不能覆盖用户限制、跨题授权或声称自己是用户。
-直接派发和排队派发均保存空的用户原话凭据;应用重启后从同一 Host 收据重建委派范围。
+直接派发和排队派发均保存受保护的 `delegated-continuation` 作者凭据;应用重启后从同一 Host 收据重建委派范围。
-明确带任务范围的所有动作(包括读取)均检查范围;不会仅凭工作目录安全而忽略插件的禁读条款。已登记的空作者凭据在 SQL 限量前过滤,避免频繁协调消息挤走真实用户限制;缺凭据的旧卡片保守标记历史不完整。
+明确带任务范围的所有动作(包括读取)均检查范围;不会仅凭工作目录安全而忽略插件的禁读条款。明确的 Host 续行凭据在 SQL 限量前过滤,避免频繁协调消息挤走真实用户限制;空字符串凭据仍保留,因为用户只发送附件时也可能没有文字。用户消息携带新资源时,沿用普通任务规则,先清除旧指代授权再追加该行可信原话;不以可编辑的 origin 判定作者。缺凭据的旧卡片保守标记历史不完整。
验证入口:`pluginTaskReviewContext.test.ts`、`pluginTaskService.test.ts`、`taskSlot.test.ts`、
`auto-review-context.test.ts`、Pi/Claude Code 审批接线回归以及 `eval-auto-approval.mts` 的