import { type InstanceAiAttachment, type InstanceAiConfirmRequest, type InstanceAiThreadStatusResponse, type InstanceAiGatewayCapabilities, type McpToolCallResult, type ToolCategory } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import { GlobalConfig, SsrfProtectionConfig } from '@n8n/config';
import { ErrorReporter, InstanceSettings } from 'n8n-core';
import { SsrfProtectionService } from '../../services/ssrf/ssrf-protection.service';
import { AiBuilderTemporaryWorkflowRepository, UserRepository, type User } from '@n8n/db';
import { UrlService } from '../../services/url.service';
import { type ModelConfig } from '@n8n/instance-ai';
import { EventService } from '../../events/event.service';
import { SourceControlPreferencesService } from '../../modules/source-control.ee/source-control-preferences.service.ee';
import { AiService } from '../../services/ai.service';
import { Push } from '../../push';
import { Telemetry } from '../../telemetry';
import { InProcessEventBus } from './event-bus/in-process-event-bus';
import type { LocalGateway } from './filesystem';
import { InstanceAiSettingsService } from './instance-ai-settings.service';
import { InstanceAiAdapterService } from './instance-ai.adapter.service';
import { DbSnapshotStorage } from './storage/db-snapshot-storage';
import { DbIterationLogStorage } from './storage/db-iteration-log-storage';
import { TypeORMAgentCheckpointStore } from './storage/typeorm-agent-checkpoint-store';
import { TypeORMAgentMemory } from './storage/typeorm-agent-memory';
import { InstanceAiPendingConfirmationRepository } from './repositories/instance-ai-pending-confirmation.repository';
import { InstanceAiThreadRepository } from './repositories/instance-ai-thread.repository';
export declare class InstanceAiService {
    private readonly instanceSettings;
    private readonly adapterService;
    private readonly eventBus;
    private readonly settingsService;
    private readonly agentMemory;
    private readonly checkpointStore;
    private readonly aiService;
    private readonly push;
    private readonly threadRepo;
    private readonly pendingConfirmationRepo;
    private readonly urlService;
    private readonly dbSnapshotStorage;
    private readonly dbIterationLogStorage;
    private readonly sourceControlPreferencesService;
    private readonly telemetry;
    private readonly userRepository;
    private readonly aiBuilderTemporaryWorkflowRepository;
    private readonly errorReporter;
    private readonly eventService;
    private _mcpClientManager?;
    private readonly _ssrfProtectionConfig;
    private readonly _ssrfProtectionService;
    private get mcpClientManager();
    private readonly instanceAiConfig;
    private readonly oauth2CallbackUrl;
    private readonly webhookBaseUrl;
    private readonly formBaseUrl;
    private readonly runState;
    private readonly backgroundTasks;
    private readonly traceContextsByRunId;
    private readonly sandboxes;
    private readonly sandboxCreations;
    private readonly gatewayRegistry;
    private readonly domainAccessTrackersByThread;
    private readonly threadPushRef;
    private readonly planRequestsByThread;
    private readonly schedulerLocks;
    private readonly pendingCheckpointReentries;
    private readonly pendingTerminalOutcomes;
    private terminalOutcomeStorage?;
    private readonly liveness;
    private readonly creditedThreads;
    private readonly traceReplay;
    private readonly defaultTimeZone;
    private readonly logger;
    private checkpointPruneTimer;
    private checkpointPruningStopped;
    private readonly inFlightExecutions;
    private readonly preserveHitlOnShutdown;
    private readonly userMessagePersistenceByRun;
    constructor(logger: Logger, globalConfig: GlobalConfig, instanceSettings: InstanceSettings, adapterService: InstanceAiAdapterService, eventBus: InProcessEventBus, settingsService: InstanceAiSettingsService, agentMemory: TypeORMAgentMemory, checkpointStore: TypeORMAgentCheckpointStore, aiService: AiService, push: Push, threadRepo: InstanceAiThreadRepository, pendingConfirmationRepo: InstanceAiPendingConfirmationRepository, urlService: UrlService, dbSnapshotStorage: DbSnapshotStorage, dbIterationLogStorage: DbIterationLogStorage, sourceControlPreferencesService: SourceControlPreferencesService, telemetry: Telemetry, userRepository: UserRepository, aiBuilderTemporaryWorkflowRepository: AiBuilderTemporaryWorkflowRepository, errorReporter: ErrorReporter, ssrfProtectionConfig: SsrfProtectionConfig, ssrfProtectionService: SsrfProtectionService, eventService: EventService);
    private getSandboxConfigFromEnv;
    private resolveSandboxConfig;
    private getOrCreateWorkspaceEntry;
    private getOrCreateWorkspace;
    private ensureWorkspaceSetup;
    private createWorkspaceEntry;
    private evictSandboxEntry;
    private destroySandbox;
    private get sandboxTtlMs();
    private nextSandboxExpiry;
    private isSandboxEntryExpired;
    private touchSandboxEntry;
    private isSandboxInUse;
    private scheduleSandboxExpiry;
    private stopSandboxExpiryTimers;
    private getProxyAuth;
    resolveAgentModelConfig(user: User): Promise<ModelConfig>;
    private resolveProxyModel;
    private resolveHttpProxyModel;
    private countCreditsIfFirst;
    isProxyEnabled(): boolean;
    getCredits(user: User): Promise<{
        creditsQuota: number;
        creditsClaimed: number;
    }>;
    isEnabled(): boolean;
    hasActiveRun(threadId: string): boolean;
    getThreadStatus(threadId: string): InstanceAiThreadStatusResponse;
    private storeTraceContext;
    private getTraceContext;
    private getTraceContextForContinuation;
    private createOrchestratorResumeTraceContext;
    private configureTraceReplayMode;
    private finalizeMessageTraceRoot;
    private maybeFinalizeRunTraceRoot;
    private buildMessageTraceMetadata;
    private finalizeRemainingMessageTraceRoots;
    private deleteTraceContextsForThread;
    private finalizeDetachedTraceRun;
    private finalizeRunTracing;
    private finalizeBackgroundTaskTracing;
    submitLangsmithFeedback(user: User, threadId: string, responseId: string, payload: {
        rating: 'up' | 'down';
        comment?: string;
    }): Promise<void>;
    startRun(user: User, threadId: string, message: string, attachments?: InstanceAiAttachment[], timeZone?: string, pushRef?: string): string;
    getMessageGroupId(threadId: string): string | undefined;
    getLiveMessageGroupId(threadId: string): string | undefined;
    getRunIdsForMessageGroup(messageGroupId: string): string[];
    getActiveRunId(threadId: string): string | undefined;
    cancelRun(threadId: string, reason?: string): void;
    sendCorrectionToTask(threadId: string, taskId: string, correction: string): 'queued' | 'task-completed' | 'task-not-found';
    cancelBackgroundTask(threadId: string, taskId: string): void;
    cancelAllBackgroundTasks(): number;
    startStuckBackgroundTaskForTest(user: User, threadId: string): Promise<{
        threadId: string;
        runId: string;
        messageGroupId: string;
        taskId: string;
        agentId: string;
        timeoutAt: number;
    }>;
    runLivenessSweepForTest(now?: number): Promise<void>;
    loadTraceEvents(slug: string, events: unknown[]): void;
    getTraceEvents(slug: string): unknown[];
    activateTraceSlug(slug: string): void;
    clearTraceEvents(slug: string): void;
    getUserIdForApiKey(key: string): string | undefined;
    generatePairingToken(userId: string): string;
    getGatewayApiKeyExpiresAt(userId: string, key: string): Date | null;
    getPairingToken(userId: string): string | null;
    consumePairingToken(userId: string, token: string): string | null;
    getActiveSessionKey(userId: string): string | null;
    clearActiveSessionKey(userId: string): void;
    getLocalGateway(userId: string): LocalGateway;
    initGateway(userId: string, data: InstanceAiGatewayCapabilities): void;
    resolveGatewayRequest(userId: string, requestId: string, result?: McpToolCallResult, error?: string): boolean;
    disconnectGateway(userId: string): void;
    disconnectAllGateways(): string[];
    isLocalGatewayDisabled(): boolean;
    getGatewayStatus(userId: string): {
        connected: boolean;
        connectedAt: string | null;
        directory: string | null;
        hostIdentifier: string | null;
        toolCategories: ToolCategory[];
    };
    startDisconnectTimer(userId: string, onDisconnect: () => void): void;
    clearDisconnectTimer(userId: string): void;
    clearThreadState(threadId: string): Promise<void>;
    shutdown(): Promise<void>;
    startCheckpointPruning(): void;
    stopCheckpointPruning(): void;
    private scheduleCheckpointPrune;
    private trackInFlightExecution;
    private startExecuteRun;
    private startProcessResumedStream;
    private shouldPreserveHitlOnShutdown;
    private persistUserMessageOnFirstSuspend;
    private drainInFlightExecutions;
    private pruneStaleCheckpoints;
    private pruneStalePendingConfirmations;
    private computePendingConfirmationExpiresAt;
    private persistPendingConfirmation;
    private dropPendingConfirmation;
    private dropPendingConfirmationsForThread;
    private persistUserMessageOnSuspend;
    private persistShutdownSnapshot;
    private createAgentMemoryOptions;
    private ensureThreadExists;
    private projectPlannedTaskList;
    private buildPlannedTaskFollowUpMessage;
    private createPlannedTaskState;
    private evaluateTerminalResponse;
    private evaluateWaitingResponse;
    private getTerminalGuardEvents;
    private handleTerminalResponseDecision;
    private createTerminalOutcomeStorage;
    private finishInvalidConfirmationRun;
    private buildBackgroundTerminalOutcome;
    replayUndeliveredTerminalOutcomes(threadId: string, options?: {
        delivery?: 'snapshot' | 'event';
    }): Promise<void>;
    private persistTerminalOutcomeLineToSnapshot;
    private publishTerminalOutcomeLine;
    private recordBackgroundTerminalOutcome;
    private syncPlannedTasksToUi;
    private cancelAwaitingApprovalPlan;
    private createExecutionEnvironment;
    private dispatchPlannedTask;
    private createPlannedTaskContext;
    private getCheckpointAllowedWorkflowIds;
    private handlePlannedTaskSettlement;
    private startInternalFollowUpRun;
    private schedulePlannedTasks;
    private doSchedulePlannedTasks;
    private executeRun;
    private queuePendingCheckpointReentry;
    private drainPendingCheckpointReentries;
    private reenterCheckpointById;
    private maybeReenterParentCheckpoint;
    private finalizeCheckpointFollowUp;
    resolveConfirmation(requestingUserId: string, requestId: string, request: InstanceAiConfirmRequest): Promise<boolean>;
    private resolveOrphanedConfirmation;
    private canResumeOrphan;
    private finalizeUnresumableOrphan;
    private tryResumeFromOrphan;
    private rebuildSuspendedRunFromCheckpoint;
    private revalidateActiveUser;
    private resumeSuspendedRun;
    private processResumedStream;
    private spawnBackgroundTask;
    private buildMessageWithRunningTasks;
    private trackConfirmationRequest;
    private reapAiTemporaryFromRun;
    private archiveAiTemporaryWorkflows;
    private finalizeCancelledSuspendedRun;
    private reapAiTemporaryForThreadCleanup;
    private publishRunFinish;
    private finalizeRun;
    private refineTitleIfNeeded;
    private extractStoredMessageText;
    private saveAgentTreeSnapshot;
    private parseMcpServers;
}
