import type { Session } from "../shared/types.js"; /** * A restart can strand any number of conversational sessions at once. Waking * them all in the same tick spawns that many engine processes simultaneously, * which is exactly the moment a rate-limited primary engine starts refusing — * so the tail is capped and the rest are spaced far enough apart that later * nudges land on the fallback chain instead of failing together. */ export declare const MAX_RESTART_RESUMES = 10; export declare const RESTART_RESUME_STAGGER_MS = 15000; export interface RestartResume { sessionId: string; dueAt: number; } export interface RestartResumePlan { resumes: RestartResume[]; /** Candidates over the cap. Reported so a busy restart is visible in the log * rather than silently losing the oldest sessions. */ deferred: number; } /** Preserve running conversational Sessions for resume. Exported as a shutdown test seam. */ export declare function interruptRunningSessionsForShutdown(): void; /** * Take the sessions this gateway's own restart interrupted, exactly once. * Selecting the marks and clearing them share one transaction, so a second boot * can never re-fire the first restart's nudges. * * Every mark is cleared, including the ones this returns nothing for: a session * whose turn `resumePendingWebQueueItems` already re-dispatched is resumed, just * not by us, and leaving its mark behind would turn it into a nudge on some * later restart it had nothing to do with. */ export declare function consumeRestartResumeCandidates(): Session[]; /** Order the sessions a restart interrupted, newest conversation first, and * spread their wake-ups over the stagger window. */ export declare function planRestartResumes(input: { candidates: Session[]; now: number; }): RestartResumePlan; /** The wake-up itself. Both halves matter: the session must know the break was * the gateway's doing and not the operator's, and it must re-check anything * that was mid-flight rather than assume it ran or blindly run it again. */ export declare function restartResumeMessage(gatewayVersion: string): string; /** * Wake one interrupted session through the durable delivery outbox, which * retries on its own and collapses a repeat claim onto the same row. Returns * whether this call is the one that claimed the nudge. */ export declare function notifyGatewayRestartResume(session: Session, gatewayVersion: string): boolean; /** * Boot step: tell every session this restart interrupted to carry on. Runs after * the pending web queue replay, so a session already back on the engine through * its own queue item is skipped rather than resumed twice. */ export declare function resumeRestartInterruptedSessions(gatewayVersion: string): void; //# sourceMappingURL=restart-resume.d.ts.map