diff --git a/src/db.test.ts b/src/db.test.ts index 76e2a5f..85501d3 100644 --- a/src/db.test.ts +++ b/src/db.test.ts @@ -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'); }); }); diff --git a/src/db.ts b/src/db.ts index e18a92b..a42bc36 100644 --- a/src/db.ts +++ b/src/db.ts @@ -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( diff --git a/src/task-scheduler.ts b/src/task-scheduler.ts index 7cbad9a..98e93fd 100644 --- a/src/task-scheduler.ts +++ b/src/task-scheduler.ts @@ -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'); }