import type { CloudEventType, CommandResult, EventEnvelope, IngressAck } from "./protocol.js"; export declare function cloudStateDir(jobsDir: string): string; /** Durable events waiting for the cloud's acknowledgement, in order; the oldest are dropped past `maxEvents`. */ export declare class Outbox { private readonly options; readonly dir: string; private readonly file; private readonly stateFile; private state; private entries; private sinceCompaction; private loaded; constructor(jobsDir: string, options: () => { maxEvents: number; }); /** Reads the files once; a torn last line (a crash mid-write) is ignored. */ load(): void; private persistState; private enforceLimit; append(machineId: string, type: CloudEventType, data: unknown): EventEnvelope; /** The oldest pending events, at most `limit` and (after the first) at most `maxBytes` of JSON. */ pending(limit: number, maxBytes?: number): EventEnvelope[]; /** Every event with `seq` at most `throughSeq` is durable on the cloud. */ ack(throughSeq: number): number; depth(): number; /** Gives up on one event (the cloud refused it even on its own); it counts as dropped. */ drop(seq: number): boolean; droppedTotal(): number; seq(): number; private maybeCompact; /** Rewrites the file with only the pending events (temp file + rename). */ compact(): void; /** Forgets everything (disconnect). */ purge(): void; } /** Which commands ran (so a re-sent one is not run twice), results waiting for the cloud's ack, and a few results kept for retries. */ export declare class CommandLedger { private readonly file; private state; private loaded; constructor(jobsDir: string); private load; private save; seen(id: string): boolean; /** A result kept for a command the cloud sent again (never a sensitive one). */ cachedResult(id: string): CommandResult | undefined; /** Records that the command ran, its result for the next sync, and a copy for retries unless sensitive. */ complete(result: CommandResult): void; pendingResults(limit: number): CommandResult[]; ackResults(ids: string[]): void; purge(): void; } export declare class IngressLedger { private readonly file; private state; private loaded; constructor(jobsDir: string); private load; private save; known(id: string): IngressAck | undefined; record(ack: IngressAck): void; pendingAcks(limit: number): IngressAck[]; /** The cloud answered a sync that carried these acks: it has them. */ acksSent(ids: string[]): void; purge(): void; }