/** * Scheduler Service - Main orchestrator for scheduled tasks with timing groups * Uses timing groups to reduce OS scheduler entries and enable parallel execution */ import { ExecutionRecorder } from './execution-recorder.js'; import { ScheduledTask, TaskExecutionSummary, TimingGroup } from '../../types/scheduler.js'; export interface CreateTaskOptions { name: string; schedule: string; timezone?: string; tool: string; parameters: Record; description?: string; fireOnce?: boolean; maxExecutions?: number; endDate?: string; catchupMissed?: boolean; skipValidation?: boolean; testRun?: boolean; } export type CreateJobOptions = CreateTaskOptions; export declare class Scheduler { private taskManager; executionRecorder: ExecutionRecorder; private scheduleManager?; private timingExecutor; private toolValidator; private settingsManager; private cleanupTimingId?; constructor(orchestrator?: any); /** * Check if scheduler is available on this platform */ isAvailable(): boolean; /** * Set up automatic cleanup timing (internal system timing) */ private setupAutomaticCleanup; /** * Get the path to ncp executable */ private getNCPExecutablePath; /** * Create a new scheduled task */ createTask(options: CreateTaskOptions): Promise; /** * Create a new scheduled job (backward compatibility wrapper for createTask) * @deprecated Use createTask() instead */ createJob(options: CreateJobOptions): Promise; /** * Check if string is a valid cron expression */ private isCronExpression; /** * Check if string is an RFC 3339 datetime */ private isRFC3339DateTime; /** * Get a task by ID */ getTask(taskId: string): ScheduledTask | null; /** * Get a task by name */ getTaskByName(name: string): ScheduledTask | null; /** * List all tasks */ listTasks(statusFilter?: ScheduledTask['status']): ScheduledTask[]; /** * List all timing groups */ listTimingGroups(): TimingGroup[]; /** * Get tasks for a timing group */ getTasksForTiming(timingId: string): ScheduledTask[]; /** * Update a task */ updateTask(taskId: string, updates: Partial): Promise; /** * Pause a task (marks it as paused, but timing group remains active if other tasks use it) */ pauseTask(taskId: string): void; /** * Resume a paused task */ resumeTask(taskId: string): void; /** * Delete a task (removes from timing group, deletes timing if it was the last task) */ deleteTask(taskId: string): void; /** * Run a task immediately (manual trigger) */ runTaskNow(taskId: string): Promise; /** * Get executions for a task */ getExecutions(taskId: string): TaskExecutionSummary[]; /** * Query executions */ queryExecutions(filters?: { taskId?: string; jobId?: string; status?: string; startDate?: string; endDate?: string; }): TaskExecutionSummary[]; /** * Get execution statistics */ getExecutionStatistics(taskId?: string): { total: number; success: number; failure: number; timeout: number; avgDuration: number | null; }; /** * Get task statistics */ getTaskStatistics(): { totalTasks: number; activeTasks: number; pausedTasks: number; completedTasks: number; errorTasks: number; totalTimings: number; }; /** * Clean up old executions */ cleanupOldExecutions(maxAgeDays?: number, maxExecutionsPerTask?: number): Promise; /** * Sync timings with OS scheduler (repair/reconcile) */ syncWithScheduler(): { added: number; removed: number; errors: string[]; }; /** * Get a job by ID (backward compatibility wrapper) * @deprecated Use getTask() instead */ getJob(taskId: string): ScheduledTask | null; /** * Get a job by name (backward compatibility wrapper) * @deprecated Use getTaskByName() instead */ getJobByName(name: string): ScheduledTask | null; /** * List all jobs (backward compatibility wrapper) * @deprecated Use listTasks() instead */ listJobs(statusFilter?: ScheduledTask['status']): ScheduledTask[]; /** * Update a job (backward compatibility wrapper) * @deprecated Use updateTask() instead */ updateJob(taskId: string, updates: Partial): Promise; /** * Pause a job (backward compatibility wrapper) * @deprecated Use pauseTask() instead */ pauseJob(taskId: string): void; /** * Resume a job (backward compatibility wrapper) * @deprecated Use resumeTask() instead */ resumeJob(taskId: string): void; /** * Delete a job (backward compatibility wrapper) * @deprecated Use deleteTask() instead */ deleteJob(taskId: string): void; /** * Get job statistics (backward compatibility wrapper) * @deprecated Use getTaskStatistics() instead */ getJobStatistics(): { total: number; active: number; paused: number; completed: number; error: number; }; /** * Sync jobs with OS scheduler (backward compatibility wrapper) * @deprecated Use syncWithScheduler() instead */ syncWithCrontab(): { added: number; removed: number; errors: string[]; }; /** * Catch up on missed task executions * Executes tasks with catchupMissed=true that should have run while system was off */ catchupMissedExecutions(): Promise<{ executed: number; skipped: number; failed: number; errors: string[]; }>; /** * Determine if a task should be caught up * Returns true if the task should have run at least once since lastRun */ private shouldCatchupTask; /** * Set up automatic catchup agent (macOS only) * Creates a launchd agent that runs catchup at login and every hour */ setupAutoCatchup(): void; /** * Remove automatic catchup agent (macOS only) */ removeAutoCatchup(): void; } //# sourceMappingURL=scheduler.d.ts.map