import type { ListmonkClient } from "@listmonk-ops/openapi"; import { type TransactionalIdempotencyStore } from "@listmonk-ops/operations"; import type { SequenceEnrollment, SequenceRepository, SequenceTickSummary } from "./sequences.js"; export interface SequenceExecutionContext { repository: SequenceRepository; client: Pick & Partial>; idempotencyStore: TransactionalIdempotencyStore; hashPayload: (serialized: string) => string; target?: { baseUrl?: string; username?: string; }; retryJitter?: () => number; now?: () => Date; } export interface RunSequenceTickOptions { limit?: number; leaseMs?: number; now?: Date; } export interface RunSequenceWorkerOptions { intervalMs?: number; heartbeatIntervalMs?: number; limit?: number; leaseMs?: number; workerId?: string; signal?: AbortSignal; onTick?: (summary: SequenceTickSummary) => void | Promise; onError?: (error: unknown) => void | Promise; } export type SequenceAmbiguousResolution = "sent" | "not_sent"; export declare const SEQUENCE_RETRY_BASE_DELAY_MS = 5000; export declare const SEQUENCE_RETRY_MAX_DELAY_MS: number; export declare const SEQUENCE_RETRY_MAX_ATTEMPTS = 24; /** A tick that claimed enrollments but failed to complete them all. */ export declare class SequenceTickFailureError extends AggregateError { readonly claimedSteps: readonly Readonly<{ id: string; stepId: string; }>[]; constructor(failures: readonly unknown[], message: string, claimedSteps: readonly Readonly<{ id: string; stepId: string; }>[]); /** Recovery handle for adapters: the echoed claim set this failure leaves. */ toStructuredDetails(): Record; } /** * Recovery pass over an echoed claim set: claim exactly the requested * enrollment ids when they are still claimable and execute them, skipping * entries that already advanced, completed, turned ambiguous, or hold a * live lease. Retrying with the same echoed set converges — each retry * only reworks still-claimable members and never claims new due work. */ export declare function recoverSequenceTick(context: SequenceExecutionContext, options: { claims: readonly Readonly<{ id: string; stepId: string; }>[]; leaseMs?: number; now?: Date; }): Promise; export declare function runSequenceTick(context: SequenceExecutionContext, options?: RunSequenceTickOptions): Promise; export declare function reconcileAmbiguousSequenceEnrollment(context: SequenceExecutionContext, enrollmentId: string, resolution: SequenceAmbiguousResolution, now?: Date): Promise; export declare function runSequenceWorker(context: SequenceExecutionContext, options?: RunSequenceWorkerOptions): Promise;