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(scheduler): 从模板创建任务时同样校验前置检查命令

Dash0d129f6cacf0
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
index 045cc14b3b..421ae0c33f 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts
@@ -212,4 +212,17 @@ describe('scheduled model selection IPC compatibility', () => {
providerId: 'pi-source', effort: 'high', fastMode,
}));
});
+
+ it.skipIf(process.platform === 'win32')('rejects a template override whose pre-run hook has a shell syntax error', async () => {
+ const create = vi.fn(async (input: CreateScheduleInput) => input);
+ setSchedulerReady({ create } as never, {} as never);
+ registerScheduleHandlers();
+ const wire = JSON.parse(JSON.stringify({
+ templateId: BUILTIN_TEMPLATES[0]!.id,
+ overrides: { preRunHook: { command: `node '/a b/x.mjs'//'` } },
+ }));
+ await expect(handlers.get('maker:schedule:create-from-template')!(null, wire))
+ .rejects.toThrow(/shell syntax error/);
+ expect(create).not.toHaveBeenCalled();
+ });
});
diff --git a/apps/desktop/src/main/maker-ipc/schedule.ts b/apps/desktop/src/main/maker-ipc/schedule.ts
index bbd0184b14..f3363e0634 100644
--- a/apps/desktop/src/main/maker-ipc/schedule.ts
+++ b/apps/desktop/src/main/maker-ipc/schedule.ts
@@ -681,7 +681,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
body.overrides as Partial<CreateScheduleInput> & { intervalMs?: number | null },
)
: {};
- return withScheduler(({ scheduler }) => {
+ return withScheduler(async ({ scheduler }) => {
const template = findTemplate(templateId);
if (!template) throwIpcError('NOT_FOUND', `template ${templateId} not found`);
const prompt = applyTemplateParams(
@@ -689,7 +689,12 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {
paramValues,
template.parameters,
);
- return scheduler.create(buildCreateScheduleInput(template, prompt, overrides));
+ // overrides 可带 preRunHook:与普通创建走同一套路径稳定化与语法校验。
+ const normalized = await stabilizePreRunHookForCreate(
+ buildCreateScheduleInput(template, prompt, overrides),
+ hookPathDeps,
+ );
+ return scheduler.create(normalized);
});
});