/** * Cron Trigger * * Cron-based workflow scheduling with timezone support, * catch-up for missed runs, and concurrency control. */ import type { CronTriggerConfig, TriggerContext, WorkflowTrigger } from '@cogitator-ai/types'; /** * Cron trigger state */ export interface CronTriggerState { triggerId: string; workflowName: string; config: CronTriggerConfig; createdAt: number; lastRun?: number; nextRun?: number; runCount: number; errorCount: number; lastError?: string; activeRuns: number; enabled: boolean; } /** * Cron trigger handler result */ export interface CronTriggerResult { triggered: boolean; runId?: string; skipped?: boolean; reason?: string; nextRun?: number; } export declare class CronTriggerExecutor { private triggers; private timeouts; private intervals; private inFlight; private onFire?; constructor(options?: { onFire?: (trigger: WorkflowTrigger, context: TriggerContext) => Promise; }); /** * Register a cron trigger */ register(workflowName: string, config: CronTriggerConfig, externalId?: string): string; /** * Unregister a trigger */ unregister(triggerId: string): void; /** * Enable a trigger */ enable(triggerId: string): void; /** * Disable a trigger */ disable(triggerId: string): void; /** * Get trigger state */ getState(triggerId: string): CronTriggerState | undefined; /** * Get all triggers for a workflow */ getTriggersForWorkflow(workflowName: string): CronTriggerState[]; /** * Get all enabled triggers */ getEnabledTriggers(): CronTriggerState[]; /** * Manually fire a trigger. * Pass fireAt to replay a historical occurrence (catch-up). */ fire(triggerId: string, fireAt?: number): Promise; /** * Check for catch-up runs (missed scheduled runs) */ catchUp(triggerId: string, since: number, maxCatchUp?: number): Promise; /** * Get all triggers */ getAll(): CronTriggerState[]; /** * Dispose all triggers */ dispose(): void; private scheduleNext; private safeSetTimeout; private calculateNextRun; private calculateCheckInterval; private toWorkflowTrigger; } /** * Create a cron trigger executor */ export declare function createCronTrigger(options?: { onFire?: (trigger: WorkflowTrigger, context: TriggerContext) => Promise; }): CronTriggerExecutor; /** * Validate a cron trigger config */ export declare function validateCronTriggerConfig(config: CronTriggerConfig): string[]; //# sourceMappingURL=cron-trigger.d.ts.map