import type { Automation, AutomationDeps, AutomationEvent, AutomationMetrics, AutomationProductEventRun, AutomationRun, AutomationRunEvent } from '../domain/types.js'; import { type CreateAutomationInput, type UpdateAutomationInput } from '../domain/validation.js'; export declare class AutomationAlreadyRunningError extends Error { readonly automationId: string; readonly runningRunId?: string; constructor(automationId: string, runningRunId?: string); } export declare class AutomationAlreadyExistsError extends Error { readonly automationId: string; constructor(automationId: string); } export declare class AutomationService { private readonly executor; private readonly eventDispatcher; private readonly deliveryRouter; private timer; private stopped; private runningScheduler; private deps; private maxConcurrentRuns; private readonly activeRuns; private readonly activeRunTasks; private readonly heartbeatTimers; private readonly leaseOwner; setDeps(deps: AutomationDeps): void; initialize(options?: { maxConcurrentRuns?: number; }): Promise; stop(): Promise; create(input: CreateAutomationInput): Promise; /** SQLite-only creation; scheduling starts after the caller commits. */ createAtomically(input: CreateAutomationInput): Automation; private applyCreate; list(options?: { projectId?: string; }): Promise; get(id: string): Promise; update(id: string, patch: UpdateAutomationInput): Promise; /** SQLite-only mutation; callers must refresh scheduling after their outer transaction commits. */ updateAtomically(id: string, patch: UpdateAutomationInput): Automation | null; refreshSchedule(): void; private applyUpdate; remove(id: string): Promise; /** Persist deletion and cancellation intent together; never abort within a transaction. */ removeAtomically(id: string): { removed: boolean; automation?: Automation; cancelRunId?: string; }; finishRemoval(cancelRunId?: string): void; pause(id: string): Promise; resume(id: string): Promise; runNow(id: string): Promise; rerunFromRun(runId: string): Promise; ingestEvent(event: AutomationEvent, targetAutomationIds?: string[]): import("../index.js").AutomationEventIngestResult; dispatchEvents(): Promise; replayEventAtomically(eventId: string): boolean; retryResultDeliveryAtomically(runId: string, destinationKey: string): boolean; dispatchRecoveryWork(): void; listEventRecords(input?: { type?: string; source?: string; limit?: number; }): import("../index.js").AutomationEventRecord[]; listResultDeliveries(input?: { runId?: string; status?: 'pending' | 'delivering' | 'retrying' | 'delivered' | 'dead_letter'; limit?: number; }): import("../index.js").AutomationResultDeliveryRecord[]; private ingestTargetedTrigger; queueTriggerAtomically(automationId: string, input: AutomationEvent, executionEvent?: AutomationEvent): AutomationRun; queueRunAtomically(id: string, opts?: { manual: boolean; event?: AutomationEvent; }): AutomationRun; /** Claim before invoking external work; replays never restart running or completed runs. */ dispatchQueuedRun(runId: string): void; availableRunSlots(): number; listRuns(options?: { automationId?: string; projectId?: string; limit?: number; }): Promise; listRunsForProductEvent(options: { eventType: string; source?: string; payloadKey?: string; payloadValue?: string; limit?: number; }): Promise; getRun(runId: string): Promise; listRunEvents(runId: string): Promise; markRunRead(runId: string): Promise; markAllRunsRead(options?: { projectId?: string; }): Promise; cancelRun(runId: string): Promise; dispatchCancellation(runId: string): void; cancelRunAtomically(runId: string): { cancelled: boolean; confirmed: boolean; }; getMetrics(): Promise; private recomputeNextRuns; private armTimer; private onTimer; private persistQueuedRun; private executeRun; private recoverInterruptedRuns; private waitForRetry; private appendRunEvent; private finishAutomationRun; }