import { type ScheduleKind } from "./schedule.ts";
export type CronJobStatus = "pending" | "running" | "success" | "failed" | "silent" | "paused" | "completed";
export interface CronJobModelRef {
    provider?: string;
    id?: string;
}
export interface CronJob {
    id: string;
    name: string;
    prompt: string;
    schedule: string;
    scheduleDisplay: string;
    kind: ScheduleKind;
    repeat: boolean;
    /** Stop after this many runs (repeating jobs only). */
    repeatTimes?: number;
    /** How many times this job has run so far. */
    completedRuns?: number;
    intervalMs?: number;
    cronExpression?: string;
    enabled: boolean;
    state: CronJobStatus;
    createdAt: string;
    updatedAt: string;
    nextRunAt?: string;
    lastRunAt?: string;
    lastStatus?: CronJobStatus;
    lastError?: string;
    lastDeliveryError?: string;
    lastOutputPath?: string;
    deliver: string;
    origin?: string;
    script?: string;
    noAgent?: boolean;
    contextFrom?: string[];
    /** Skills loaded into the job prompt at fire time. */
    skills?: string[];
    tools?: string[];
    workdir?: string;
    model?: CronJobModelRef;
    timezone?: string;
}
export interface CreateCronJobInput {
    name: string;
    prompt: string;
    schedule: string;
    repeat?: boolean;
    repeatTimes?: number;
    deliver?: string;
    origin?: string;
    script?: string;
    noAgent?: boolean;
    contextFrom?: string[];
    skills?: string[];
    tools?: string[];
    workdir?: string;
    model?: CronJobModelRef;
    timezone?: string;
}
export interface UpdateCronJobInput {
    name?: string;
    prompt?: string;
    schedule?: string;
    repeat?: boolean;
    repeatTimes?: number | null;
    deliver?: string;
    origin?: string;
    script?: string | null;
    noAgent?: boolean;
    contextFrom?: string[] | null;
    skills?: string[] | null;
    tools?: string[] | null;
    workdir?: string | null;
    model?: CronJobModelRef | null;
    enabled?: boolean;
    timezone?: string | null;
}
export interface CronJobStoreOptions {
    agentDir: string;
    cwd?: string;
}
export declare class CronJobStore {
    readonly cronDir: string;
    readonly jobsFile: string;
    readonly outputDir: string;
    readonly scriptsDir: string;
    private readonly cwd?;
    constructor(options: CronJobStoreOptions);
    ensure(): Promise<void>;
    list(): Promise<CronJob[]>;
    get(idOrName: string): Promise<CronJob | undefined>;
    create(input: CreateCronJobInput): Promise<CronJob>;
    update(idOrName: string, input: UpdateCronJobInput): Promise<CronJob>;
    pause(idOrName: string): Promise<CronJob>;
    resume(idOrName: string): Promise<CronJob>;
    remove(idOrName: string): Promise<CronJob>;
    trigger(idOrName: string, now?: Date): Promise<CronJob>;
    getDueJobs(now?: Date): Promise<CronJob[]>;
    claimDueJob(id: string, now?: Date): Promise<CronJob | undefined>;
    markRun(id: string, result: {
        status: CronJobStatus;
        outputPath?: string;
        error?: string;
        ranAt?: Date;
    }): Promise<CronJob>;
    markDelivery(id: string, deliveryError?: string): Promise<CronJob>;
    /**
     * Reset jobs stuck in "running" state whose `updatedAt` is older than `timeoutMs`.
     * Called at scheduler startup to recover from crashed runs.
     */
    resetStaleRunning(timeoutMs: number, now?: Date): Promise<number>;
    saveOutput(jobId: string, output: string, now?: Date): Promise<string>;
    latestOutput(jobId: string): Promise<string | undefined>;
    resolveScriptPath(script: string): Promise<string>;
    private withLock;
    private ensureUnlocked;
    private readJobsFile;
    private ensureFileOnly;
    private writeJobsFile;
    private resolveJob;
    private resolveJobIndex;
    private createJobId;
}
//# sourceMappingURL=job-store.d.ts.map