fix: remove agent_type filter from getDueTasks for unified service
This commit is contained in:
@@ -531,10 +531,9 @@ Check the run.
|
|||||||
created_at: '2024-01-01T00:00:01.000Z',
|
created_at: '2024-01-01T00:00:01.000Z',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(getDueTasks('claude-code').map((task) => task.id)).toEqual([
|
const dueIds = getDueTasks().map((task) => task.id);
|
||||||
'task-claude',
|
expect(dueIds).toContain('task-claude');
|
||||||
]);
|
expect(dueIds).toContain('task-codex');
|
||||||
expect(getDueTasks('codex').map((task) => task.id)).toEqual(['task-codex']);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1411,20 +1411,18 @@ export function deleteTask(id: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDueTasks(
|
export function getDueTasks(): ScheduledTask[] {
|
||||||
agentType: AgentType = SERVICE_AGENT_TYPE,
|
|
||||||
): ScheduledTask[] {
|
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
return db
|
return db
|
||||||
.prepare(
|
.prepare(
|
||||||
`
|
`
|
||||||
SELECT * FROM scheduled_tasks
|
SELECT * FROM scheduled_tasks
|
||||||
WHERE status = 'active' AND agent_type = ? AND next_run IS NOT NULL AND next_run <= ?
|
WHERE status = 'active' AND next_run IS NOT NULL AND next_run <= ?
|
||||||
AND (suspended_until IS NULL OR suspended_until <= ?)
|
AND (suspended_until IS NULL OR suspended_until <= ?)
|
||||||
ORDER BY next_run
|
ORDER BY next_run
|
||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
.all(agentType, now, now) as ScheduledTask[];
|
.all(now, now) as ScheduledTask[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateTaskAfterRun(
|
export function updateTaskAfterRun(
|
||||||
|
|||||||
@@ -899,9 +899,9 @@ export function startSchedulerLoop(deps: SchedulerDependencies): void {
|
|||||||
schedulerTickInFlight = true;
|
schedulerTickInFlight = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const agentType = deps.serviceAgentType || SERVICE_AGENT_TYPE;
|
// Unified service: process all agent types, not just the service default.
|
||||||
const nowMs = Date.now();
|
const nowMs = Date.now();
|
||||||
const activeTasks = getAllTasks(agentType).filter(
|
const activeTasks = getAllTasks().filter(
|
||||||
(task) => task.status === 'active',
|
(task) => task.status === 'active',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -927,7 +927,7 @@ export function startSchedulerLoop(deps: SchedulerDependencies): void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dueTasks = getDueTasks(agentType);
|
const dueTasks = getDueTasks();
|
||||||
if (dueTasks.length > 0) {
|
if (dueTasks.length > 0) {
|
||||||
logger.info({ count: dueTasks.length }, 'Found due tasks');
|
logger.info({ count: dueTasks.length }, 'Found due tasks');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user