/** * Noah — Fleet Cron Manager * * BB Spec §6: Noah is the temporal authority for scheduled fleet operations. * Manages the cron schedule, enforces constitutional boundaries, * triggers jobs via fleet-bus, and records execution history with hash chains. * * Amendment 4 (D-05): Mighty Mark is autonomous — cannot be scheduled by Noah. */ import type { SqliteTemporalStore } from '../store/sqlite-store.js'; import type { CronJobRow, CronRunRow } from '../store/sqlite-types.js'; import type { FleetCronJobDefinition, CronExecutionResult } from './cron-types.js'; import type { FleetBusClient, FleetAlertBus } from '../cortex/null-implementations.js'; export type CallGatewayFn = (opts: { method: string; params?: unknown; timeoutMs?: number; }) => Promise; export interface CronManagerConfig { store: SqliteTemporalStore; fleetBus: FleetBusClient; fleetAlerting: FleetAlertBus; callGateway?: CallGatewayFn; dataDir?: string; defaultMaxRuntimeMs?: number; } /** * Compute the next occurrence of a cron expression after a given date. * Uses `cron-parser` — the standard npm package for cron expression parsing. */ export declare function computeNextRun(cronExpr: string, after?: Date): string; export declare class CronManager { private readonly store; private readonly fleetBus; private readonly fleetAlerting; private readonly callGateway; private tickInterval; private readonly runningJobs; private readonly runningJobsFile; private readonly defaultMaxRuntimeMs; constructor(config: CronManagerConfig); /** * Seed the default schedule into SQLite if not already present. * Constitutional jobs are always ensured. */ seedDefaultSchedule(): void; /** * Get all cron jobs with their current state. */ getAllJobs(): CronJobRow[]; /** * Get a specific cron job. */ getJob(id: string): CronJobRow | null; /** * Create a new cron job, enforcing constitutional boundaries. */ createJob(definition: FleetCronJobDefinition): { success: boolean; reason?: string; }; /** * Enable or disable a job, enforcing constitutional boundaries. */ setJobEnabled(jobId: string, enabled: boolean): { success: boolean; reason?: string; }; /** * Delete a job, enforcing constitutional boundaries. */ deleteJob(jobId: string): { success: boolean; reason?: string; }; /** * Execute a single cron job. Sends via fleet-bus for agentTurn payloads, * handles internal payloads directly. Records execution with hash chain. */ executeJob(jobId: string, maxRuntimeMs?: number): Promise; /** * Check which jobs are due now and execute them. */ tickDueJobs(): Promise; /** * Get execution history for a specific job. */ getJobHistory(jobId: string, limit?: number): CronRunRow[]; /** * Get a summary suitable for FleetTemporalSummary. */ getCronSummary(): { activeJobCount: number; nextScheduledJobs: Array<{ id: string; name: string; agentId: string; nextRun: string | null; constitutional: boolean; }>; }; /** * Start the tick loop. Checks for due jobs at the specified interval. */ start(intervalMs?: number): void; /** * Stop the tick loop. */ stop(): void; /** * Recompute next_run for all enabled cron jobs. * Handles server restarts where next_run may be in the past. */ private recomputeAllNextRuns; /** * Execute an agentTurn job by injecting a synthetic SYSTEM message * into the target agent's existing session via callGateway(deliver: true). * * This bypasses fleet-bus transport entirely — agentTurn jobs need the * agent's LLM to reason and call tools, which requires deliver: true * (routing to the persistent session). Fleet-bus deliver: false creates * ephemeral sessions where plugin hooks don't fire. * * Falls back to fleet-bus send() if callGateway is unavailable. */ private executeAgentTurn; /** * Execute a Noah-internal job (no fleet-bus involved). * These run directly within Noah's process. */ private executeInternalJob; private isJobDue; private getLastCronRunHash; private persistRunningJobs; private clearOrphanedJobs; private definitionToRow; } //# sourceMappingURL=cron-manager.d.ts.map