import type { InstanceAiConfirmResponse } from '@n8n/api-types'; import type { Logger } from '@n8n/backend-common'; import type { User } from '@n8n/db'; import { type ConfirmationData, type RunStateRegistry, type SuspendedRunState } from '@n8n/instance-ai'; import type { InstanceAiPendingConfirmation } from './entities/instance-ai-pending-confirmation.entity'; import type { InProcessEventBus } from './event-bus/in-process-event-bus'; import type { InstanceAiPendingConfirmationRepository } from './repositories/instance-ai-pending-confirmation.repository'; import type { DbSnapshotStorage } from './storage/db-snapshot-storage'; type ClaimedOrphan = InstanceAiPendingConfirmation; export type ResumableOrphan = ClaimedOrphan & { toolCallId: string; checkpointKey: string; }; export type RebuildSuspendedRunOutcome = { kind: 'ready'; state: SuspendedRunState; } | { kind: 'no-user'; } | { kind: 'no-checkpoint'; error?: unknown; } | { kind: 'env-failure'; error: unknown; } | { kind: 'agent-failure'; error: unknown; }; export interface SuspendedRunRebuilder { rebuildSuspendedRun(orphan: ResumableOrphan): Promise; resumeSuspendedRun(requestingUserId: string, requestId: string, data: ConfirmationData): Promise; } export type OrphanConfirmationStore = Pick; export type SuspendedRunStateRegistry = Pick, 'suspendRun'>; export type RunSnapshotCanceller = Pick; export type RunFinishEventPublisher = Pick; export interface SuspendedRunRestorerOptions { logger: Logger; pendingConfirmationRepo: OrphanConfirmationStore; runState: SuspendedRunStateRegistry; dbSnapshotStorage: RunSnapshotCanceller; eventBus: RunFinishEventPublisher; rebuilder: SuspendedRunRebuilder; } export declare class SuspendedRunRestorer { private readonly logger; private readonly pendingConfirmationRepo; private readonly runState; private readonly dbSnapshotStorage; private readonly eventBus; private readonly rebuilder; constructor(options: SuspendedRunRestorerOptions); resolveOrphanedConfirmation(userId: string, requestId: string, data: ConfirmationData): Promise; private canResumeOrphan; private finalizeUnresumableOrphan; private publishRunFinish; private tryResumeFromOrphan; } export {};