/**
 * Fires due scheduled prompts for `senpi schedule run`. The clock, the delivery, and the "is the
 * session busy" probe are injected, so every rule here is testable without real waiting or processes.
 *
 * One pass: recover occurrences whose runner died mid-delivery (they move to `failed/`, never
 * re-delivered: at-most-once), then claim and deliver due jobs - concurrently across sessions up to
 * `concurrency`, strictly one at a time within a session.
 */
import { type LiveRunner } from "../core/extensions/builtin/schedule/runner-lease.ts";
import { type InvalidJobFile, type RunnerIdentity } from "../core/extensions/builtin/schedule/store.ts";
import { type DeferProbe, type Delivery } from "./schedule-delivery.ts";
export type RunnerEvent = {
    readonly event: "fired";
    readonly id: string;
    readonly sessionId: string;
    readonly occurrence: number;
    readonly outcome: "delivered" | "failed";
    readonly error?: string;
    readonly firedAt: number;
    readonly dueAt: number;
    readonly nextDueAt?: number;
} | {
    readonly event: "deferred";
    readonly id: string;
    readonly sessionId: string;
    readonly reason: string;
} | {
    readonly event: "abandoned";
    readonly id: string;
    readonly sessionId: string;
    readonly occurrence: number;
    readonly error: string;
} | ({
    readonly event: "invalid";
} & InvalidJobFile) | {
    readonly event: "error";
    /** The job being handled, when the error belongs to one; absent for a failed pass. */
    readonly id?: string;
    readonly sessionId?: string;
    readonly error: string;
};
export interface RunDueResult {
    readonly events: readonly RunnerEvent[];
    /** Earliest due time among jobs still pending after this pass. */
    readonly nextDueAt: number | undefined;
}
/** How long a deferred job waits before the next attempt (a shorter poll interval still wins). */
export declare const DEFERRED_RETRY_MS = 15000;
export declare const ABANDONED_OCCURRENCE_ERROR = "the runner exited while delivering this occurrence; outcome unknown, not retried";
export interface RunDueOptions {
    readonly dir: string;
    readonly now: () => number;
    readonly deliver: Delivery;
    readonly owner: RunnerIdentity;
    readonly concurrency?: number;
    /** Delivery time limit, recorded in the session lock for ungated (Windows) deliveries. */
    readonly deliveryTimeoutMs?: number;
    readonly shouldDefer?: DeferProbe;
    /** Only this session's jobs: the pass a live session runs for itself. */
    readonly sessionId?: string;
    /** Live runners, for recovering occurrences of dead ones; defaults to reading the leases. */
    readonly runners?: () => Promise<readonly LiveRunner[]>;
}
export declare function runDueJobs(options: RunDueOptions): Promise<RunDueResult>;
//# sourceMappingURL=schedule-runner.d.ts.map