import { type InstanceAiAttachment, type InstanceAiThreadStatusResponse, type InstanceAiGatewayCapabilities, type McpToolCallResult, type ToolCategory } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import { GlobalConfig } from '@n8n/config';
import type { User } from '@n8n/db';
import { UrlService } from '../../services/url.service';
import { type ConfirmationData } from '@n8n/instance-ai';
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 { TypeORMCompositeStore } from './storage/typeorm-composite-store';
import { DbSnapshotStorage } from './storage/db-snapshot-storage';
import { DbIterationLogStorage } from './storage/db-iteration-log-storage';
import { InstanceAiCompactionService } from './compaction.service';
import { InstanceAiThreadRepository } from './repositories/instance-ai-thread.repository';
export declare class InstanceAiService {
    private readonly adapterService;
    private readonly eventBus;
    private readonly settingsService;
    private readonly compositeStore;
    private readonly compactionService;
    private readonly aiService;
    private readonly push;
    private readonly threadRepo;
    private readonly urlService;
    private readonly dbSnapshotStorage;
    private readonly dbIterationLogStorage;
    private readonly sourceControlPreferencesService;
    private readonly telemetry;
    private readonly mcpClientManager;
    private readonly instanceAiConfig;
    private readonly oauth2CallbackUrl;
    private readonly webhookBaseUrl;
    private readonly runState;
    private readonly backgroundTasks;
    private readonly traceContextsByRunId;
    private readonly sandboxes;
    private readonly gatewayRegistry;
    private readonly domainAccessTrackersByThread;
    private readonly threadPushRef;
    private readonly schedulerLocks;
    private confirmationTimeoutInterval?;
    private readonly creditedThreads;
    private readonly defaultTimeZone;
    private readonly logger;
    constructor(logger: Logger, globalConfig: GlobalConfig, adapterService: InstanceAiAdapterService, eventBus: InProcessEventBus, settingsService: InstanceAiSettingsService, compositeStore: TypeORMCompositeStore, compactionService: InstanceAiCompactionService, aiService: AiService, push: Push, threadRepo: InstanceAiThreadRepository, urlService: UrlService, dbSnapshotStorage: DbSnapshotStorage, dbIterationLogStorage: DbIterationLogStorage, sourceControlPreferencesService: SourceControlPreferencesService, telemetry: Telemetry);
    private startConfirmationTimeoutSweep;
    private getSandboxConfigFromEnv;
    private resolveSandboxConfig;
    private createBuilderFactory;
    private getOrCreateWorkspace;
    private destroySandbox;
    private getProxyAuth;
    private resolveProxyModel;
    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 finalizeMessageTraceRoot;
    private maybeFinalizeRunTraceRoot;
    private finalizeRemainingMessageTraceRoots;
    private deleteTraceContextsForThread;
    private finalizeDetachedTraceRun;
    private finalizeRunTracing;
    private finalizeBackgroundTaskTracing;
    startRun(user: User, threadId: string, message: string, researchMode?: boolean, 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): void;
    sendCorrectionToTask(threadId: string, taskId: string, correction: string): 'queued' | 'task-completed' | 'task-not-found';
    cancelBackgroundTask(threadId: string, taskId: string): void;
    getUserIdForApiKey(key: string): string | undefined;
    generatePairingToken(userId: string): string;
    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;
    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>;
    private createMemoryConfig;
    private ensureThreadExists;
    private projectPlannedTaskList;
    private buildPlannedTaskFollowUpMessage;
    private createPlannedTaskState;
    private syncPlannedTasksToUi;
    private createExecutionEnvironment;
    private dispatchPlannedTask;
    private createPlannedTaskContext;
    private handlePlannedTaskSettlement;
    private startInternalFollowUpRun;
    private schedulePlannedTasks;
    private doSchedulePlannedTasks;
    private executeRun;
    resolveConfirmation(requestingUserId: string, requestId: string, data: ConfirmationData): Promise<boolean>;
    private resumeSuspendedRun;
    private processResumedStream;
    private spawnBackgroundTask;
    private buildMessageWithRunningTasks;
    private trackConfirmationRequest;
    private publishRunFinish;
    private finalizeRun;
    private refineTitleIfNeeded;
    private cleanupMastraSnapshots;
    private saveAgentTreeSnapshot;
    private parseMcpServers;
}
