Scheduled job configuration

interface ScheduledJob {
    id: string;
    cron?: string;
    intervalMs?: number;
    runner: EnhancedRunner<any, any>;
    userId: string;
    sessionId?: string;
    input: string | Content;
    enabled?: boolean;
    maxExecutions?: number;
    onTrigger?: ((jobId: string) => void);
    onComplete?: ((jobId: string, events: Event[]) => void);
    onError?: ((jobId: string, error: Error) => void);
    onEvent?: ((jobId: string, event: Event) => void);
}

Properties

id: string

Unique identifier for this job

cron?: string

Cron expression (e.g., "0 9 * * *" for daily at 9 AM)

intervalMs?: number

Interval in milliseconds (alternative to cron)

runner: EnhancedRunner<any, any>

The runner to execute

userId: string

User ID for the session

sessionId?: string

Session ID (optional - creates new session each run if not provided)

input: string | Content

Input message to send on each scheduled run

enabled?: boolean

Whether the job is enabled (default: true)

maxExecutions?: number

Maximum number of executions (undefined = unlimited)

onTrigger?: ((jobId: string) => void)

Callback when job triggers

onComplete?: ((jobId: string, events: Event[]) => void)

Callback when execution completes

onError?: ((jobId: string, error: Error) => void)

Callback on execution error

onEvent?: ((jobId: string, event: Event) => void)

Callback for each event as it streams in during execution