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',
|
||||
});
|
||||
|
||||
expect(getDueTasks('claude-code').map((task) => task.id)).toEqual([
|
||||
'task-claude',
|
||||
]);
|
||||
expect(getDueTasks('codex').map((task) => task.id)).toEqual(['task-codex']);
|
||||
const dueIds = getDueTasks().map((task) => task.id);
|
||||
expect(dueIds).toContain('task-claude');
|
||||
expect(dueIds).toContain('task-codex');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1411,20 +1411,18 @@ export function deleteTask(id: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function getDueTasks(
|
||||
agentType: AgentType = SERVICE_AGENT_TYPE,
|
||||
): ScheduledTask[] {
|
||||
export function getDueTasks(): ScheduledTask[] {
|
||||
const now = new Date().toISOString();
|
||||
return db
|
||||
.prepare(
|
||||
`
|
||||
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 <= ?)
|
||||
ORDER BY next_run
|
||||
`,
|
||||
)
|
||||
.all(agentType, now, now) as ScheduledTask[];
|
||||
.all(now, now) as ScheduledTask[];
|
||||
}
|
||||
|
||||
export function updateTaskAfterRun(
|
||||
|
||||
@@ -899,9 +899,9 @@ export function startSchedulerLoop(deps: SchedulerDependencies): void {
|
||||
schedulerTickInFlight = true;
|
||||
|
||||
try {
|
||||
const agentType = deps.serviceAgentType || SERVICE_AGENT_TYPE;
|
||||
// Unified service: process all agent types, not just the service default.
|
||||
const nowMs = Date.now();
|
||||
const activeTasks = getAllTasks(agentType).filter(
|
||||
const activeTasks = getAllTasks().filter(
|
||||
(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) {
|
||||
logger.info({ count: dueTasks.length }, 'Found due tasks');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user