Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Accept absent optional automation associations

CloudTianTian2ce636dce99f
diff --git a/src/main/features/auto_tasks.ts b/src/main/features/auto_tasks.ts
index c4b67a3b..3de18110 100644
--- a/src/main/features/auto_tasks.ts
+++ b/src/main/features/auto_tasks.ts
@@ -587,12 +587,12 @@ function _normaliseDraft(d: TaskDraft): { ok: true; fields: NormalisedFields } |
recipient = d.recipient;
}
let skill: TaskSkillRef | undefined;
- if (d.skill !== undefined) {
+ if (d.skill !== undefined && d.skill !== null) {
if (!_isValidRef(d.skill)) return { ok: false, error: 'invalid_skill' };
skill = { id: d.skill.id, name: d.skill.name };
}
let connector: TaskConnectorRef | undefined;
- if (d.connector !== undefined) {
+ if (d.connector !== undefined && d.connector !== null) {
if (!_isValidRef(d.connector)) return { ok: false, error: 'invalid_connector' };
connector = { id: d.connector.id, name: d.connector.name };
}
diff --git a/test/main/features/auto_tasks_tool.test.ts b/test/main/features/auto_tasks_tool.test.ts
index 08f5d9ca..44f39fe3 100644
--- a/test/main/features/auto_tasks_tool.test.ts
+++ b/test/main/features/auto_tasks_tool.test.ts
@@ -80,6 +80,28 @@ describe('auto_tasks shared tool', () => {
expect((await run(tool, { action: 'get', task_id: result.taskId })).task.schedule).toEqual(schedule);
});
+ it.each([
+ { connector: null }, { skill: null }, { connector: null, skill: null },
+ ])('creates exactly one disabled automation with absent optional associations from %j', async references => {
+ const tool = createTool({ userId: uid, projectId: null });
+ const input = { action: 'create', ...draft, ...references };
+ const accepts = new AjvJsonSchemaValidator().getValidator(tool.inputSchema);
+ expect(accepts(input).valid).toBe(true);
+ const result = await run(tool, input);
+ expect(result).toMatchObject({ ok: true, isError: false, kind: 'created' });
+ tasks.stopScheduler();
+ vi.resetModules();
+ tasks = await import('../../../src/main/features/auto_tasks');
+ const persisted = await tasks.getTask(uid, result.taskId);
+ expect(persisted).toMatchObject({ content: draft.content, schedule: draft.schedule, enabled: false });
+ for (const field of ['skill', 'connector', 'last_run_at']) expect(persisted).not.toHaveProperty(field);
+ expect((await tasks.listTasks(uid)).map(task => task.id)).toEqual([result.taskId]);
+ for (const invalid of [{ connector: {} }, { skill: { id: '', name: 'Invalid' } }]) {
+ expect(await run(tool, { action: 'create', ...draft, ...invalid })).toMatchObject({ ok: false, isError: true });
+ expect((await tasks.listTasks(uid)).map(task => task.id)).toEqual([result.taskId]);
+ }
+ });
+
it('rejects conditional omissions and mixed variants without changing saved state, then clears nullable fields', async () => {
const tool = createTool({ userId: uid, projectId: pid });
const created = await run(tool, { action: 'create', ...draft, end_condition: { type: 'count', max_runs: 3 } });