/** * Trigger scheduling math: parses 5-field cron expressions (with `N/step`, * range, list, and the Sunday-as-7 alias), computes the next matching run time * in a given timezone (honoring POSIX day-of-month/day-of-week OR-semantics and * DST fall-back dedupe), and resolves interval/once/cron/event triggers to * their next-run timing. Cron parsing returns null on malformed input; interval * values are clamped to [MIN, MAX]_TRIGGER_INTERVAL_MS. */ import type { TriggerConfig } from "../types/trigger.js"; export declare const MIN_TRIGGER_INTERVAL_MS = 60000; export declare const MAX_TRIGGER_INTERVAL_MS: number; export declare const DISABLED_TRIGGER_INTERVAL_MS: number; interface CronSchedule { minute: Set; hour: Set; dayOfMonth: Set; month: Set; dayOfWeek: Set; /** * Standard (POSIX/Vixie) cron day semantics: when BOTH day-of-month and * day-of-week are restricted (the field does not start with `*`), a * candidate matches when EITHER field matches; otherwise both must match. * `0 0 13 * 5` therefore fires on every 13th AND every Friday — not only * on Friday-the-13th. */ dayOfMonthRestricted: boolean; dayOfWeekRestricted: boolean; } export declare function normalizeTriggerIntervalMs(intervalMs: number): number; export declare function parseCronExpression(expression: string): CronSchedule | null; /** * UTC timestamp from calendar parts — uses setUTCFullYear so years 0-99 keep * their literal meaning (0000, 0005 … 0099) instead of Date.UTC's 1900-1999 * remapping. Exported for behavioral regression coverage; internal callers * should prefer this over raw Date.UTC(y,m,d) when the year is dynamic. */ export declare function utcDateMs(year: number, monthIndex: number, day: number, hour?: number, minute?: number, second?: number, ms?: number): number; export declare function computeNextCronRunAtMs(expression: string, fromMs: number, timezone?: string): number | null; /** * Pin an ISO date-time that carries no `Z` or UTC offset to an absolute * instant by reading its wall-clock time in `timezone`. `Date.parse` reads * such a value in the host process zone, which is not the user's zone on a * cloud or container host. Values that already carry an offset, date-only * values and anything else are returned unchanged for `parseScheduledAtIso`. */ export declare function resolveScheduledAtIsoInTimeZone(scheduledAtIso: string, timezone: string): string; export declare function parseScheduledAtIso(scheduledAtIso: string): number | null; export interface TriggerTiming { updatedAt: number; updateIntervalMs: number; nextRunAtMs: number; } export declare function resolveTriggerTiming(trigger: TriggerConfig, nowMs: number): TriggerTiming | null; /** * Powered-on scheduling. A host whose agent runs only while its device is * powered on (a phone-resident agent) sets this setting to `record`. A * scheduled occurrence that passed while the agent was not running is then * recorded once as missed and never run late, and the next occurrence is * armed as usual. A delay while the agent was running (device doze, a busy * scheduler) is not a missed occurrence: that occurrence still runs. Hosts * without the setting keep running a late occurrence. */ export declare const MISSED_SCHEDULED_OCCURRENCES_SETTING = "ELIZA_MISSED_SCHEDULED_OCCURRENCES"; /** * Lateness tolerated before an occurrence can be missed: thirty minutes, the * same window as phone typed schedules and resident digests * (`PHONE_SCHEDULE_ADMISSION_WINDOW_MS` in @elizaos/contracts). */ export declare const SCHEDULED_OCCURRENCE_WINDOW_MS: number; export declare const MISSED_SCHEDULED_OCCURRENCE_TEXT = "The scheduled time passed while the agent was not running. This occurrence did not run, and no backlog is executed."; /** * Whether this host selected the powered-on policy: the runtime setting wins, * then the process environment (the native runtime profile sets it there). */ export declare function recordsMissedScheduledOccurrences(runtime?: { getSetting?(key: string): unknown; } | null): boolean; /** Wall-clock instant at which this agent process started. */ export declare function agentProcessStartedAtMs(nowMs?: number): number; /** * True when a scheduled occurrence is reached outside its window and its * scheduled instant precedes the start of the agent process, so the agent was * not running when it came due. */ export declare function isMissedScheduledOccurrence(scheduledAtMs: number, nowMs: number, agentStartedAtMs?: number): boolean; export {};