import type { CronConfig } from "../../config/types.cron.js";
import type { CronJob, CronJobCreate, CronJobPatch, CronRunOutcome, CronRunStatus, CronRunTelemetry, CronStoreFile } from "../types.js";
export type CronEvent = {
    jobId: string;
    action: "added" | "updated" | "removed" | "started" | "finished";
    runAtMs?: number;
    durationMs?: number;
    status?: CronRunStatus;
    error?: string;
    summary?: string;
    sessionId?: string;
    sessionKey?: string;
    nextRunAtMs?: number;
} & CronRunTelemetry;
export type Logger = {
    debug: (obj: unknown, msg?: string) => void;
    info: (obj: unknown, msg?: string) => void;
    warn: (obj: unknown, msg?: string) => void;
    error: (obj: unknown, msg?: string) => void;
};
export type CronServiceDeps = {
    nowMs?: () => number;
    log: Logger;
    storePath: string;
    cronEnabled: boolean;
    /** CronConfig for session retention settings. */
    cronConfig?: CronConfig;
    /** Default agent id for jobs without an agent id. */
    defaultAgentId?: string;
    /** Resolve session store path for a given agent id. */
    resolveSessionStorePath?: (agentId?: string) => string;
    /** Path to the session store (sessions.json) for reaper use. */
    sessionStorePath?: string;
    enqueueSystemEvent: (text: string, opts?: {
        agentId?: string;
        sessionKey?: string;
        contextKey?: string;
    }) => void;
    runIsolatedAgentJob: (params: {
        job: CronJob;
        message: string;
    }) => Promise<{
        summary?: string;
        /** Last non-empty agent text output (not truncated). */
        outputText?: string;
        /**
         * `true` when the isolated run already delivered its output to the target
         * channel (including matching messaging-tool sends). See:
         * https://github.com/symi/symi/issues/15692
         */
        delivered?: boolean;
    } & CronRunOutcome & CronRunTelemetry>;
    onEvent?: (evt: CronEvent) => void;
};
export type CronServiceDepsInternal = Omit<CronServiceDeps, "nowMs"> & {
    nowMs: () => number;
};
export type CronServiceState = {
    deps: CronServiceDepsInternal;
    store: CronStoreFile | null;
    timer: NodeJS.Timeout | null;
    running: boolean;
    op: Promise<unknown>;
    warnedDisabled: boolean;
    storeLoadedAtMs: number | null;
    storeFileMtimeMs: number | null;
};
export declare function createCronServiceState(deps: CronServiceDeps): CronServiceState;
export type CronRunMode = "due" | "force";
export type CronWakeMode = "now";
export type CronStatusSummary = {
    enabled: boolean;
    storePath: string;
    jobs: number;
    nextWakeAtMs: number | null;
};
export type CronRunResult = {
    ok: true;
    ran: true;
} | {
    ok: true;
    ran: false;
    reason: "not-due";
} | {
    ok: true;
    ran: false;
    reason: "already-running";
} | {
    ok: false;
};
export type CronRemoveResult = {
    ok: true;
    removed: boolean;
} | {
    ok: false;
    removed: false;
};
export type CronAddResult = CronJob;
export type CronUpdateResult = CronJob;
export type CronListResult = CronJob[];
export type CronAddInput = CronJobCreate;
export type CronUpdateInput = CronJobPatch;
