export interface CompletionPayload { handle: string; [key: string]: unknown; } export interface CompletionView extends CompletionPayload { acknowledgement: string; delivery: { handle: string; nonce: string; state: "recorded" | "emitted" | "acknowledged"; emission_attempts: number; }; } export interface CompletionEntry { type?: string; customType?: string; data?: unknown; payload?: unknown; } export interface CompletionChannel { acknowledge(handle: string, nonce: string): | { ok: true; delivery: CompletionView } | { ok: false; error: string }; complete(payload: CompletionPayload): CompletionView | undefined; dispose(): void; get(handle: string): CompletionView | undefined; has(handle: string): boolean; launchBlocker(): CompletionView | undefined; pending(): CompletionView[]; recover(handle: string): CompletionView | undefined; restore(entries?: CompletionEntry[]): CompletionView[]; retryPending(): CompletionView[]; } export interface CompletionChannelOptions { append(customType: string, data: unknown): void; emit(payload: CompletionView): void; schedule?(callback: () => void, delayMs: number): Timer; cancel?(timer: Timer): void; nonce?(): string; maxAttempts?: number; retryDelayMs?: number; } export const COMPLETION_RECORD_ENTRY: "dirtyloops-child-record"; export const COMPLETION_EMISSION_ENTRY: "dirtyloops-child-emission"; export const COMPLETION_ACK_ENTRY: "dirtyloops-child-ack"; export function createCompletionChannel(options: CompletionChannelOptions): CompletionChannel;