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(plugin): 保留目标目录与运行配置校验

liugaowei5fdcc4bd2ed6
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/pluginTargetSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/pluginTargetSlot.test.ts
index 5b1fef2111..6bae64574f 100644
--- a/apps/desktop/src/main/cindy-brain/__tests__/pluginTargetSlot.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/pluginTargetSlot.test.ts
@@ -76,9 +76,9 @@ describe('plugin target queries and delivery', () => {
await expect(f.call(f.request)).rejects.toMatchObject({ code: 'TARGET_UNAVAILABLE' });
expect(f.send).not.toHaveBeenCalled();
});
- it('creates in the specified project and passes its selected route', async () => {
+ it.each([false, true, 'ultrafast'] as const)('creates in the specified project with fastMode %s', async (fastMode) => {
const f = fixture();
- const route = { agentKind: 'codex', providerId: 'provider', model: 'model', effort: '', fastMode: false };
+ const route = { agentKind: 'codex', providerId: 'provider', model: 'model', effort: '', fastMode };
const result = await f.call({ ...f.request, target: { kind: 'project', id: 'chosen' }, route, title: 'New task' });
expect(result).toMatchObject({ accepted: true, delivery: 'queue' });
expect(f.create).toHaveBeenCalledWith('plugin', 'chosen', expect.any(String), 'New task', route, expect.any(Function));
diff --git a/apps/desktop/src/main/cindy-brain/pluginTargetSlot.ts b/apps/desktop/src/main/cindy-brain/pluginTargetSlot.ts
index 2185a756ac..14c73fab84 100644
--- a/apps/desktop/src/main/cindy-brain/pluginTargetSlot.ts
+++ b/apps/desktop/src/main/cindy-brain/pluginTargetSlot.ts
@@ -142,7 +142,7 @@ export class PluginTargetSlot {
target.kind !== 'project' || !route || !['cc', 'codex', 'pi'].includes(route.agentKind) ||
!keyString(route.providerId) || typeof route.model !== 'string' || !route.model.trim() ||
route.model.length > 256 || typeof route.effort !== 'string' || route.effort.length > 32 ||
- typeof route.fastMode !== 'boolean'
+ (typeof route.fastMode !== 'boolean' && route.fastMode !== 'ultrafast')
) return fail('INVALID_PARAMS');
}
const route = request.route && {
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index ad2eb06933..da47b33d27 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -11098,6 +11098,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
inheritSourcePermissionMode?: boolean;
/** Host-owned durable inputs use the coordinator even when idle. */
forceQueue?: boolean;
+ /** Explicit target delivery preserves the recipient's current plan mode. */
+ inheritTargetPlanMode?: boolean;
/** 插件任务派发的来源(只用于标签与 `[消息来源]`,不是权限判据,也不是 origin)。 */
sourcePlugin?: AgentInputQueuedMessage['sourcePlugin'];
/**
@@ -11537,6 +11539,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
botTaskCoordination: params.botTaskCoordination,
authorizationGuard: params.authorizationGuard,
files: params.files,
+ inheritTargetPlanMode: params.inheritTargetPlanMode,
taskActionDeliveryGuard: params.taskActionDeliveryGuard,
});
return {
@@ -13078,16 +13081,17 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const currentRoute = await resolveRoute(pluginId, requestedRoute, callId);
if ((Object.keys(currentRoute) as Array<keyof PluginTaskRoute>).some(key => currentRoute[key] !== route[key]))
throw new PluginTaskError('ROUTE_UNAVAILABLE', 'Plugin task route changed');
- const workingDir = targetContext?.workingDir ?? (!isolatedWorkspace && cfg.workingDir
+ const requestedWorkingDir = targetContext?.workingDir ?? (!isolatedWorkspace ? cfg.workingDir : undefined);
+ const workingDir = requestedWorkingDir
? await resolvePluginWorkerDirectory({
- requested: cfg.workingDir, configuredDirectory: cfg.workingDir,
+ requested: requestedWorkingDir, configuredDirectory: requestedWorkingDir,
isPickedDirectory: () => false,
assertCurrent: () => {
assertPlugin(pluginId);
if (!configurationIsCurrent()) throw new PluginTaskError('PERMISSION_DENIED', 'Plugin task configuration changed');
},
})
- : undefined);
+ : undefined;
assertPlugin(pluginId);
if (!configurationIsCurrent()) throw new PluginTaskError('PERMISSION_DENIED', 'Plugin task configuration changed');
await createPluginTaskSession({
@@ -13545,6 +13549,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
if (!meta) throw new Error('TARGET_UNAVAILABLE');
const item = await buildSessionControlInputItem({ targetSessionId: taskId, clientId,
message: text, persistedContent: text, meta, sourcePlugin, files,
+ inheritTargetPlanMode: true,
autoReviewUserText: { kind: 'delegated-continuation' },
});
await validate();
@@ -13566,6 +13571,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
const result = await sendToSessionInternal({ targetSessionId: taskId, clientId, message: text, files,
autoReviewUserText: { kind: 'delegated-continuation' }, forceQueue: true,
resumeWithStoredPermissionMode: true,
+ inheritTargetPlanMode: true,
sourcePlugin,
authorizationGuard: { validate, assertCurrent },
onAccepted: validate,