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): restore delegated intent and reject late plans

Dash14837bff76bc
diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.ts
index 80596d1676..cc7a125be1 100644
--- a/apps/desktop/src/main/cindy-brain/forge.ts
+++ b/apps/desktop/src/main/cindy-brain/forge.ts
@@ -3912,7 +3912,7 @@ const r = await cindy.agent.requestSchedule({
\`label, workingDir, route, task\`。可选 \`task\` 是插件提供的工作范围(每段最多 8000 字符),
不是用户原话。Host 核对已批准启用的插件、自有主任务、真实 Worker 归属、模型和目录后,
将范围单独交给 Auto 审阅;仍逐动作审批,用户限制、撤权和只读设置始终优先。
-计划不可改写;旧计划只允许一次补齐缺失的 task,不改变 label、目录、路由或并发。
+计划须在首次派发或创建 Worker 前登记,之后不可改写(包括补填 task);需要不同范围时创建新任务。
缺少该字段的存量计划继续可读,不会从 Agent 消息推导额外授权。
计划不授予目录权限。Worker 仅可使用宿主任务目录及解析后仍在其中的子目录、插件 AI 配置目录或用户亲选的确切目录;Library 绑定不自动变成 Agent 工作根。宿主在登记和创建时均复核。
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 c61df91600..c5d7adcfa9 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,5 @@
import { AUTO_REVIEW_SOURCE_CONTENT, AUTO_REVIEW_USER_INTENT, appendAutoReviewUserIntent } from '@cindy/maker-core';
+import { AUTO_REVIEW_DELEGATED_CONTINUATION } from '../autoReviewUserIntent.js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { AgentInputCoordinator } from '../agent-input-coordinator.js';
import {
@@ -6273,6 +6274,19 @@ describe('AgentInputCoordinator steer transaction', () => {
expect(appendAutoReviewUserIntent('Send this.', 'decorated', opts)).toBe('Inspect the new image.');
});
+ it('keeps delegated steer distinct from an empty human resource replacement', async () => {
+ const h=createHarness();
+ h.coordinator.enqueue('delegated-steer',makeItem('human','Do not deploy'));
+ await flush();
+ await h.coordinator.steer('delegated-steer',{
+ ...makeItem('agent','Deploy now',{persistedContent:JSON.stringify({orcaSource:'lead',content:'Deploy now'})}),
+ autoReviewUserText:{kind:'delegated-continuation'},
+ });
+ const opts=h.steerToAgent.mock.calls[0][2];
+ expect(opts[AUTO_REVIEW_DELEGATED_CONTINUATION]).toBe(true);
+ expect(opts[AUTO_REVIEW_USER_INTENT]).toBeUndefined();
+ });
+
it('screens same-turn steers through ghost hooks: rewrite injects and persists the rewritten text', async () => {
const h = createHarness();
h.setAgentKind('codex');
@@ -11253,6 +11267,7 @@ describe('AgentInputCoordinator replaceQueuedMessage(Orca lead 排队消息修
restarted.coordinator.enqueue(sid, makeItem('resume-input', 'Continue'), { resumeRestorePausedQueue: true });
await flush();
expect(restarted.sendToAgent.mock.calls[0]?.[3][AUTO_REVIEW_SOURCE_CONTENT]).toBe('');
+ expect(restarted.sendToAgent.mock.calls[0]?.[3][AUTO_REVIEW_DELEGATED_CONTINUATION]).toBe(true);
});
it('编辑保留主机接收时间,清空边界后的条目崩溃恢复时不会被误删', async () => {
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 d320baecf6..35dc26b6c0 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { AUTO_REVIEW_SOURCE_CONTENT, AUTO_REVIEW_USER_INTENT, MAIN_OWNED_SEND_CONTEXT } from '@cindy/maker-core';
import {
+ AUTO_REVIEW_DELEGATED_CONTINUATION,
restoreAutoReviewUserIntent,
restoreAutoReviewSteerIntent,
type AutoReviewHistoryMessage,
@@ -23,6 +24,20 @@ function user(text: string, clientId = text): AutoReviewHistoryMessage {
const current = { clientId: 'latest', content: { text: '修吧,改完跑相关测试。' } };
describe('steer authorization restoration', () => {
+ it.each([false, true])('restores delegated history without treating it as human input (unavailable=%s)', async unavailable => {
+ const intent = await restoreAutoReviewSteerIntent('Deploy now', {
+ [AUTO_REVIEW_SOURCE_CONTENT]: '', [AUTO_REVIEW_DELEGATED_CONTINUATION]: true,
+ }, async () => {
+ if (unavailable) throw new Error('unavailable');
+ return [user('Edit src.'), user('Do not deploy.')];
+ });
+ if (unavailable) expect(intent).toBe('');
+ else {
+ expect(intentText(intent)).toContain('Edit src.');
+ expect(intentText(intent)).toContain('Do not deploy.');
+ expect(intentText(intent)).not.toContain('Deploy now');
+ }
+ });
it.each([false, true])('restores prior restrictions for queued/direct input (direct=%s)', async (direct) => {
const options = direct
? { [MAIN_OWNED_SEND_CONTEXT]: { origin: { kind: 'desktop' as const }, rawChannelText: 'continue' } }
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts
index 9ac0d98896..3bed63ab30 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/makerSendTransaction.test.ts
@@ -15,6 +15,7 @@ import { CODEX_RESUME_NOT_READY_WIRE_MESSAGE } from '@cindy/maker-shared/agent-i
import { formatQuotesForSend, stripChatQuoteMarkerLines } from '@cindy/maker-shared/chat-quotes';
import type { AgentInputQueuedMessage } from '../../../shared/agentInputQueue';
import { describe, expect, it, vi } from 'vitest';
+import { AUTO_REVIEW_DELEGATED_CONTINUATION } from '../autoReviewUserIntent.js';
import {
createMakerSendTransaction,
restoreTrustedDesktopQueuedOrigin,
@@ -2514,6 +2515,18 @@ describe('session-agent-switch handoff injection', () => {
expect(appendAutoReviewUserIntent('Send the old image.', 'decorated', opts)).toBe('修改这张图片。');
});
+ it.each([false, true])('restores queued delegated history without a new human message (unavailable=%s)', async unavailable => {
+ const {deps,session}=createDeps({readAutoReviewHistory:async()=>{
+ if(unavailable) throw new Error('unavailable');
+ return [{clientId:'human',role:'user',content:{text:'Do not deploy'},agentMeta:{delivery:'turn',autoReviewUserText:'Do not deploy'}}];
+ }});
+ await createMakerSendTransaction(deps).sendToAgentAccepted('session-1','Deploy now',undefined,{
+ [AUTO_REVIEW_SOURCE_CONTENT]:'',[AUTO_REVIEW_DELEGATED_CONTINUATION]:true,
+ });
+ const opts=vi.mocked(session.send).mock.calls[0]![1]!;
+ expect(opts[AUTO_REVIEW_USER_INTENT]).toBe(unavailable?'':'Do not deploy');
+ });
+
it.each([false, true])('restores scheduled intent from owner history, not the prompt (unavailable=%s)', async (unavailable) => {
const { deps, session } = createDeps({ readAutoReviewHistory: vi.fn(async () => {
if (unavailable) throw new Error('history unavailable');
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 06f759acd7..fdd40a3caa 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts
@@ -1,4 +1,5 @@
import type { SessionSendOptions, SessionSendResult, UserMessage } from '@cindy/maker-core';
+import { AUTO_REVIEW_USER_INTENT } from '@cindy/maker-core';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { AgentInputQueuedMessage } from '../../../shared/agentInputQueue.js';
@@ -116,6 +117,14 @@ beforeEach(() => {
});
describe('Orca lead/worker dispatcher', () => {
+ it.each([false, true])('restores human restrictions for ordinary direct continuation (unavailable=%s)', async unavailable => {
+ const h = createHarness({readAutoReviewHistory: async () => {
+ if(unavailable) throw new Error('unavailable');
+ return [{clientId:'human',role:'user',content:{text:'Do not deploy'},agentMeta:{delivery:'turn',autoReviewUserText:'Do not deploy'}}];
+ }});
+ await h.dispatcher.dispatchOrEnqueueOrcaInterAgentMessage({targetSessionId:'target-session',rawContent:'Deploy now',source:'lead',senderLabel:'Lead',workerId:'worker-1',meta:{source:'orca',context:'test'}});
+ expect(h.liveSession.send.mock.calls[0]?.[1]?.[AUTO_REVIEW_USER_INTENT]).toBe(unavailable ? '' : 'Do not deploy');
+ });
it('runs direct accepted side effects after DB persistence and before vendor turn release', async () => {
const h = createHarness();
const commit = vi.fn();
@@ -191,6 +200,7 @@ describe('Orca lead/worker dispatcher', () => {
expect(result).toMatchObject({ ok: true, mode: 'dispatched' });
expect(prepareUnhealthySession).toHaveBeenCalledWith('target-session');
expect(h.deps.sendToSessionInternal).toHaveBeenCalledWith(expect.objectContaining({
+ autoReviewUserText: {kind:'delegated-continuation'},
targetSessionId: 'target-session',
clientId: 'client-1',
}));
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 b7a2849348..3202100ecd 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskAuthorshipWiring.test.ts
@@ -8,6 +8,17 @@ const compile = (code: string) => ts.transpileModule(code, {
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None },
}).outputText;
+it('restores human authorization for both live and cold internal delegated sends', () => {
+ for(const target of ['live','session']) {
+ const start=source.lastIndexOf(`sendUserMessageWithAwaitedGitBaseline(${target}, message, clientId, {`);
+ expect(start).toBeGreaterThan(0);
+ const options=source.slice(start,source.indexOf('onAccepted: persistUserMessage',start));
+ expect(options).toContain('params.autoReviewUserText');
+ expect(options).toContain('[AUTO_REVIEW_SOURCE_CONTENT]:');
+ expect(options).toContain('restoreAutoReviewUserIntent(await readAutoReviewHistory(targetSessionId).catch(() => []))');
+ }
+});
+
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);
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts
index 82d9f53551..7e0408ed10 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskService.test.ts
@@ -508,6 +508,16 @@ it('keeps taskless plans immutable instead of retroactively granting scope', asy
expect(JSON.parse(f.rows.get(task.taskId)!.payload).teamPlan).toEqual(old);
});
+it.each(['sent', 'running', 'queued', 'workers'])('rejects late initial plan registration after %s', async state => {
+ const f=fixture(),task=await f.create();
+ if(state==='sent') await f.send();
+ if(state==='running') vi.mocked(f.deps.inspect).mockResolvedValue({execution:f.execution,pending:[]});
+ if(state==='queued') vi.mocked(f.deps.inspect).mockResolvedValue({execution:null,pending:[{clientId:'queued'}]});
+ if(state==='workers') f.deps.assertTeamPlanUnstarted=async()=>{throw new Error('Workers already exist');};
+ await expect(f.service.setTeamPlan('p',task.taskId,{concurrency:1,task:'Coordinate',items:[]})).rejects.toThrow();
+ expect(JSON.parse(f.rows.get(task.taskId)!.payload).teamPlan).toBeUndefined();
+});
+
it('registers a complete scope once and permits only identical replays', async () => {
const f=fixture(),task=await f.create();
const plan={concurrency:2,task:'Coordinate',items:[{label:'sample',workingDir:'/answer',route:f.route,task:'Run tests'}]};
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 398619aa79..e3d72a9260 100644
--- a/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
+++ b/apps/desktop/src/main/maker-ipc/agent-input-coordinator.ts
@@ -31,7 +31,7 @@ import { redactSensitiveText } from '@cindy/maker-shared/error-redaction';
import { isUnsupportedResponsesImageErrorPayload } from '@cindy/responses-chat-bridge';
import { isPiImageInputUnsupportedError } from '../../shared/inputError.js';
import { createLogger } from '../logger.js';
-import { readAutoReviewUserText } from './autoReviewUserIntent.js';
+import { AUTO_REVIEW_DELEGATED_CONTINUATION, readAutoReviewUserText } from './autoReviewUserIntent.js';
import { createMessage as createDbMessage } from '../localDb/ipc/messages.js';
import { touchUserSendInDb } from '../localDb/ipc/sessions.js';
import {
@@ -199,6 +199,7 @@ function hasRetryableQueuedContent(item: AgentInputQueuedMessage): boolean {
}
export interface AgentInputSendOpts {
+ readonly [AUTO_REVIEW_DELEGATED_CONTINUATION]?: true;
/** Main-owned identity of the zero-output user turn being replaced. */
retryUserClientId?: string;
toolsDisabled?: boolean;
@@ -2200,7 +2201,9 @@ export class AgentInputCoordinator {
await this.deps.steerToAgent(sessionId, buildMakerUserMessage(item, referenceContexts), {
...(item.sharedTaskAuthor ? { sharedTaskAuthor: item.sharedTaskAuthor } : {}),
[AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(item),
- ...(readAutoReviewUserText(item.persistedContent) === null
+ ...(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
? { [AUTO_REVIEW_USER_INTENT]: queuedAutoReviewText(item) } : {}),
messageUuid,
userName: item.userName,
@@ -4555,6 +4558,8 @@ export class AgentInputCoordinator {
const result = await this.deps.sendToAgent(sessionId, makerUserMessage, head.createOpts, {
...(head.supersedesUserClientId ? { retryUserClientId: head.supersedesUserClientId } : {}),
[AUTO_REVIEW_SOURCE_CONTENT]: queuedAutoReviewText(head),
+ ...(head.autoReviewUserText && typeof head.autoReviewUserText === 'object' && head.autoReviewUserText.kind === 'delegated-continuation'
+ ? { [AUTO_REVIEW_DELEGATED_CONTINUATION]: true as const } : {}),
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 cc10cb71ed..6d028f2e29 100644
--- a/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts
+++ b/apps/desktop/src/main/maker-ipc/autoReviewUserIntent.ts
@@ -3,6 +3,9 @@ import type { AutoReviewUserIntent, SendOptions, UserMessage } from '@cindy/make
import { joinChatQuoteTextSegments, parseChatQuoteSegments } from '@cindy/maker-shared/chat-quotes';
import { projectPersistedAgentFacingUserText } from '@cindy/maker-shared/agent-input-projection';
+/** Main-only projection of a protected delegated receipt; never accepted from wire input. */
+export const AUTO_REVIEW_DELEGATED_CONTINUATION = Symbol('autoReviewDelegatedContinuation');
+
/** Existing transcript projection, already filtered by the database's clear/rewind boundary. */
export interface AutoReviewHistoryMessage {
clientId: string;
@@ -25,7 +28,7 @@ function interactionAnswer(message: AutoReviewHistoryMessage): { text: string; a
/** Both queued and direct steers may reach a freshly reattached harness. */
export async function restoreAutoReviewSteerIntent(
content: string | ReadonlyArray<{ type: string; [key: string]: unknown }>,
- options: SendOptions,
+ options: SendOptions & { readonly [AUTO_REVIEW_DELEGATED_CONTINUATION]?: true },
readHistory: () => Promise<AutoReviewHistoryMessage[]>,
): Promise<AutoReviewUserIntent | undefined> {
options.signal?.throwIfAborted();
@@ -33,6 +36,11 @@ export async function restoreAutoReviewSteerIntent(
if (options[AUTO_REVIEW_USER_INTENT] !== undefined) return options[AUTO_REVIEW_USER_INTENT];
const context = options[MAIN_OWNED_SEND_CONTEXT];
if (context && context.origin.kind !== 'desktop') return undefined;
+ if (options[AUTO_REVIEW_DELEGATED_CONTINUATION]) {
+ const history = await readHistory().catch(() => []);
+ options.signal?.throwIfAborted();
+ return restoreAutoReviewUserIntent(history);
+ }
const text = options[AUTO_REVIEW_SOURCE_CONTENT] ?? context?.rawChannelText;
if (typeof text !== 'string') return undefined;
const history = await readHistory().catch(() => []);
diff --git a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts b/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts
index 70ea5577cf..c76ae151b2 100644
--- a/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts
+++ b/apps/desktop/src/main/maker-ipc/makerSendTransaction.ts
@@ -51,7 +51,7 @@ import {
} from './extraDirsValidator.js';
import type { MakerSessionCreateOpts } from './sessionRequest.js';
import type { CindyLearnInvocationGrant } from '../learn-host/invocationGrant.js';
-import { currentAutoReviewResourceIntent, readAutoReviewUserText, restoreAutoReviewUserIntent, type AutoReviewHistoryMessage } from './autoReviewUserIntent.js';
+import { AUTO_REVIEW_DELEGATED_CONTINUATION, currentAutoReviewResourceIntent, readAutoReviewUserText, restoreAutoReviewUserIntent, type AutoReviewHistoryMessage } from './autoReviewUserIntent.js';
type CreateOpts = MakerSessionCreateOpts;
@@ -232,6 +232,7 @@ export function revokeTrustedDesktopQueuedOrigin(item: AgentInputQueuedMessage):
}
type MakerSendOptions = {
+ readonly [AUTO_REVIEW_DELEGATED_CONTINUATION]?: true;
retryUserClientId?: string;
toolsDisabled?: boolean;
readonly [AUTO_REVIEW_SOURCE_CONTENT]?: UserMessage['content'];
@@ -1325,6 +1326,11 @@ export function createMakerSendTransaction(deps: MakerSendTransactionDeps): Make
return restoreAutoReviewUserIntent(history);
} : undefined;
if (resolveScheduledIntent) restoredAutoReviewIntent = undefined;
+ if (!resolveScheduledIntent && restoredAutoReviewIntent === undefined && so[AUTO_REVIEW_DELEGATED_CONTINUATION]
+ && (!mainOwnedSendContext || mainOwnedSendContext.origin.kind === 'desktop')) {
+ const history = await deps.readAutoReviewHistory?.(sessionId).catch(() => []) ?? [];
+ restoredAutoReviewIntent = restoreAutoReviewUserIntent(history);
+ }
if (!resolveScheduledIntent && restoredAutoReviewIntent === undefined && isOrdinaryUserTurn && trustedUserText !== undefined
&& (!mainOwnedSendContext || mainOwnedSendContext.origin.kind === 'desktop')) {
let history: AutoReviewHistoryMessage[] = [];
diff --git a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
index 8c80a1c4ba..6d06a18137 100644
--- a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts
@@ -2,7 +2,8 @@ import {
formatAgentMessage,
formatOrcaCommunicationMessage,
} from '@cindy/orca-workflow';
-import { AUTO_REVIEW_SOURCE_CONTENT } from '@cindy/maker-core';
+import { AUTO_REVIEW_SOURCE_CONTENT, AUTO_REVIEW_USER_INTENT } from '@cindy/maker-core';
+import { restoreAutoReviewUserIntent, type AutoReviewHistoryMessage } from './autoReviewUserIntent.js';
import type { AgentKind, SessionSendOptions, SessionSendResult, UserMessage } from '@cindy/maker-core';
import type {
@@ -116,6 +117,7 @@ export type OrcaInterAgentSendToSessionInternalResult =
/** 通过既有 sendToSessionInternal 重建或排队目标 session 时传入的最小参数。 */
export interface OrcaInterAgentSendToSessionInternalParams {
+ autoReviewUserText: { kind: 'delegated-continuation' };
targetSessionId: string;
message: string;
persistedContent: string;
@@ -134,6 +136,7 @@ export interface OrcaInterAgentDispatcherLogger {
/** Orca dispatcher 的 I/O 边界,register.ts 只负责注入 DB、Maker、queue 和 role 解析能力。 */
export interface OrcaInterAgentDispatcherDeps<TSessionMeta> {
+ readAutoReviewHistory?: (sessionId: string) => Promise<AutoReviewHistoryMessage[]>;
createId: () => string;
getSessionMeta: (sessionId: string) => Promise<TSessionMeta | null>;
getSessionRowSnapshot: (sessionId: string) => Promise<OrcaInterAgentSessionRowSnapshot | null>;
@@ -422,6 +425,7 @@ export function createOrcaInterAgentDispatcher<TSessionMeta>(
try {
const sendToInternal = async (): Promise<DispatchOrcaInterAgentMessageResult> => {
const result = await deps.sendToSessionInternal({
+ autoReviewUserText: { kind: 'delegated-continuation' },
targetSessionId: params.targetSessionId,
message: agentMessageText,
persistedContent,
@@ -667,11 +671,13 @@ async function sendPersistedUserMessageToSession<TSessionMeta>(
): Promise<CollabDirectDispatchResult> {
const { session, dbContent, agentMessage, clientId = deps.createId(), source, context, origin, onAccepted } = params;
let turnChangeSetStarted = false;
+ const humanIntent = restoreAutoReviewUserIntent(await deps.readAutoReviewHistory?.(session.id).catch(() => []) ?? []);
const result = await resolveCollabDispatchResult(
() => session.send(agentMessage, {
planMode: false,
throwOnStartFailure: true,
[AUTO_REVIEW_SOURCE_CONTENT]: '',
+ [AUTO_REVIEW_USER_INTENT]: humanIntent,
onAccepted: async () => {
// maker-core 会在 vendor handle.send 前 await 此 hook;必须先落库,再运行 accepted 副作用。
await deps.createDbMessage(session.id, {
diff --git a/apps/desktop/src/main/maker-ipc/pluginTaskService.ts b/apps/desktop/src/main/maker-ipc/pluginTaskService.ts
index e8412d4d2f..af2786becc 100644
--- a/apps/desktop/src/main/maker-ipc/pluginTaskService.ts
+++ b/apps/desktop/src/main/maker-ipc/pluginTaskService.ts
@@ -239,7 +239,9 @@ export function createPluginTaskService(deps: PluginTaskServiceDeps) {
await ownTask(pluginId,taskId);
const row = (await deps.store.get(taskId))!;
const data = JSON.parse(row.payload);
- if (data.teamPlan && hash(data.teamPlan) !== hash(plan)) return fail('IDEMPOTENCY_CONFLICT', 'Team plan is immutable');
+ if (data.teamPlan && hash(data.teamPlan) !== hash(plan)) {
+ return fail('IDEMPOTENCY_CONFLICT', 'Team plan is immutable');
+ }
if (data.teamPlan) return {ok:true};
if ((await deps.store.forSession(taskId)).length) return fail('TASK_BUSY', 'Register the team plan before sending input');
const observed = await deps.inspect(taskId);
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index fe09bf926d..fd9d1c2e63 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -63,7 +63,7 @@ import {
piSubagentRunRoot,
} from '@cindy/maker-core/pi-subagent-runs';
import { AUTO_REVIEW_SOURCE_CONTENT, AUTO_REVIEW_USER_INTENT, INHERITED_CAPABILITY_SELECTION, MAIN_OWNED_SEND_CONTEXT } from '@cindy/maker-core';
-import { readAutoReviewUserText, restoreAutoReviewSteerIntent, restoreAutoReviewUserIntent } from './autoReviewUserIntent.js';
+import { AUTO_REVIEW_DELEGATED_CONTINUATION, readAutoReviewUserText, restoreAutoReviewSteerIntent, restoreAutoReviewUserIntent } from './autoReviewUserIntent.js';
import type {
AgentEvent,
AgentKind,
@@ -9420,6 +9420,10 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
lockStage = 'live-send';
try {
const sendResult = await sendUserMessageWithAwaitedGitBaseline(live, message, clientId, {
+ ...(params.autoReviewUserText ? {
+ [AUTO_REVIEW_SOURCE_CONTENT]: '',
+ [AUTO_REVIEW_USER_INTENT]: restoreAutoReviewUserIntent(await readAutoReviewHistory(targetSessionId).catch(() => [])),
+ } : {}),
planMode: false,
onAccepted: persistUserMessage,
onDispatching: () => dispatchAgentIslandUserPrompt(targetSessionId),
@@ -9530,6 +9534,10 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const { session } = await bootstrapSession(createOpts);
await markOrcaRoleIfNeeded(session.id, createOpts.orcaRole);
const sendResult = await sendUserMessageWithAwaitedGitBaseline(session, message, clientId, {
+ ...(params.autoReviewUserText ? {
+ [AUTO_REVIEW_SOURCE_CONTENT]: '',
+ [AUTO_REVIEW_USER_INTENT]: restoreAutoReviewUserIntent(await readAutoReviewHistory(targetSessionId).catch(() => [])),
+ } : {}),
planMode: false,
onAccepted: persistUserMessage,
onDispatching: () => dispatchAgentIslandUserPrompt(targetSessionId),
@@ -10875,6 +10883,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
}
const orcaInterAgentDispatcher: OrcaInterAgentDispatcher = createOrcaInterAgentDispatcher({
+ readAutoReviewHistory: sessionId => readAutoReviewHistory(sessionId),
createId,
getSessionMeta: (sessionId) => maker.getSessionMeta(sessionId).catch(() => null),
getSessionRowSnapshot,
@@ -13644,6 +13653,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
expectedTurnGeneration?: number;
readonly [MAIN_OWNED_SEND_CONTEXT]?: MainOwnedSendContext;
readonly [AUTO_REVIEW_SOURCE_CONTENT]?: string;
+ readonly [AUTO_REVIEW_DELEGATED_CONTINUATION]?: true;
readonly [AUTO_REVIEW_USER_INTENT]?: string;
};
const readCurrentSteerSession = () => {