import { InstanceAiFeedbackRequestDto, InstanceAiGatewayCapabilitiesDto, InstanceAiGatewayCreateCredentialDto, InstanceAiFilesystemResponseDto, InstanceAiRenameThreadRequestDto, InstanceAiSendMessageRequest, InstanceAiEventsQuery, InstanceAiCorrectTaskRequest, InstanceAiEnsureThreadRequest, InstanceAiThreadMessagesQuery, InstanceAiAdminSettingsUpdateRequest, InstanceAiUserPreferencesUpdateRequest, InstanceAiEvalExecutionRequest, InstanceAiEvalAgentExecutionRequest, InstanceAiEvalCredentialAllowlistRequest, InstanceAiEvalRestoreThreadRequest, InstanceAiEvalSeedDataTableRowsRequest } from '@n8n/api-types';
import type { InstanceAiAdminSettingsResponse } from '@n8n/api-types';
import { ModuleRegistry } from '@n8n/backend-common';
import { GlobalConfig } from '@n8n/config';
import { AuthenticatedRequest, UserRepository } from '@n8n/db';
import type { NextFunction, Request, Response } from 'express';
import { InstanceAiBrowserSessionService } from './browser/instance-ai-browser-session.service';
import { EvalAgentExecutionService } from './eval/agent-execution.service';
import { EvalExecutionService } from './eval/execution.service';
import { EvalThreadCredentialAllowlistService } from './eval/thread-credential-allowlist.service';
import { EvalThreadRestoreService } from './eval/thread-restore.service';
import { DurableEventLog } from './event-bus/durable-event-log';
import { DurableLogMetrics } from './event-bus/durable-log-metrics';
import { InProcessEventBus } from './event-bus/in-process-event-bus';
import { InstanceAiErrorReporterService } from './instance-ai-error-reporter.service';
import { InstanceAiGatewayService } from './instance-ai-gateway.service';
import { InstanceAiMemoryService } from './instance-ai-memory.service';
import { InstanceAiSettingsService } from './instance-ai-settings.service';
import { InstanceAiService } from './instance-ai.service';
import { CredentialsService } from '../../credentials/credentials.service';
import { Push } from '../../push';
import { Publisher } from '../../scaling/pubsub/publisher.service';
import { ProjectService } from '../../services/project.service.ee';
import { UrlService } from '../../services/url.service';
type FlushableResponse = Response & {
    flush?: () => void;
};
export declare class InstanceAiController {
    private readonly instanceAiService;
    private readonly gatewayService;
    private readonly browserSessionService;
    private readonly memoryService;
    private readonly settingsService;
    private readonly evalExecutionService;
    private readonly evalAgentExecutionService;
    private readonly evalCredentialAllowlists;
    private readonly evalThreadRestore;
    private readonly eventBus;
    private readonly eventLog;
    private readonly durableLogMetrics;
    private readonly moduleRegistry;
    private readonly push;
    private readonly urlService;
    private readonly userRepository;
    private readonly credentialsService;
    private readonly projectService;
    private readonly instanceAiErrorReporter;
    private readonly publisher;
    private readonly gatewayApiKey;
    private readonly durableLogEnabled;
    private static getTreeRichnessScore;
    private static selectBootstrapTree;
    constructor(instanceAiService: InstanceAiService, gatewayService: InstanceAiGatewayService, browserSessionService: InstanceAiBrowserSessionService, memoryService: InstanceAiMemoryService, settingsService: InstanceAiSettingsService, evalExecutionService: EvalExecutionService, evalAgentExecutionService: EvalAgentExecutionService, evalCredentialAllowlists: EvalThreadCredentialAllowlistService, evalThreadRestore: EvalThreadRestoreService, eventBus: InProcessEventBus, eventLog: DurableEventLog, durableLogMetrics: DurableLogMetrics, moduleRegistry: ModuleRegistry, push: Push, urlService: UrlService, userRepository: UserRepository, credentialsService: CredentialsService, projectService: ProjectService, instanceAiErrorReporter: InstanceAiErrorReporterService, publisher: Publisher, globalConfig: GlobalConfig);
    private requireInstanceAiEnabled;
    private requireRunDebugEnabled;
    stripBrotli(req: Request, _res: Response, next: NextFunction): void;
    chat(req: AuthenticatedRequest, _res: Response, threadId: string, payload: InstanceAiSendMessageRequest): Promise<{
        runId: string;
    }>;
    events(req: AuthenticatedRequest, res: FlushableResponse, threadId: string, query: InstanceAiEventsQuery): Promise<void>;
    confirm(req: AuthenticatedRequest, _res: Response, requestId: string): Promise<import("@n8n/api-types").InstanceAiConfirmResponse>;
    cancel(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<{
        ok: boolean;
    }>;
    feedback(req: AuthenticatedRequest, _res: Response, threadId: string, responseId: string, payload: InstanceAiFeedbackRequestDto): Promise<{
        ok: boolean;
    }>;
    cancelTask(req: AuthenticatedRequest, _res: Response, threadId: string, taskId: string): Promise<{
        ok: boolean;
    }>;
    correctTask(req: AuthenticatedRequest, _res: Response, threadId: string, taskId: string, payload: InstanceAiCorrectTaskRequest): Promise<{
        ok: boolean;
    }>;
    getCredits(req: AuthenticatedRequest): Promise<{
        creditsQuota: number;
        creditsClaimed: number;
    }>;
    getAdminSettings(_req: AuthenticatedRequest): Promise<InstanceAiAdminSettingsResponse>;
    updateAdminSettings(req: AuthenticatedRequest, _res: Response, payload: InstanceAiAdminSettingsUpdateRequest): Promise<InstanceAiAdminSettingsResponse>;
    reloadAdminSettings(): Promise<void>;
    private applyAdminSettingsSideEffects;
    getUserPreferences(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiUserPreferencesResponse>;
    updateUserPreferences(req: AuthenticatedRequest, _res: Response, payload: InstanceAiUserPreferencesUpdateRequest): Promise<import("@n8n/api-types").InstanceAiUserPreferencesResponse>;
    listServiceCredentials(_req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiProviderConnection[]>;
    listInstanceModelCredentials(_req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiProviderConnection[]>;
    listThreads(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiThreadListResponse>;
    ensureThread(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEnsureThreadRequest): Promise<import("@n8n/api-types").InstanceAiEnsureThreadResponse>;
    deleteThread(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<{
        ok: boolean;
    }>;
    renameThread(req: AuthenticatedRequest, _res: Response, threadId: string, payload: InstanceAiRenameThreadRequestDto): Promise<{
        thread: import("@n8n/api-types").InstanceAiThreadInfo;
    }>;
    getThreadMessages(req: AuthenticatedRequest, _res: Response, threadId: string, query: InstanceAiThreadMessagesQuery): Promise<import("@n8n/api-types").InstanceAiThreadMessagesResponse | {
        threadId: string;
        projectId?: string;
        messages: import("@n8n/api-types").InstanceAiMessage[];
        nextEventId: number;
    }>;
    getThreadStatus(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<import("@n8n/api-types").InstanceAiThreadStatusResponse>;
    getRunDebug(req: AuthenticatedRequest, _res: Response, runId: string): Promise<import("@n8n/instance-ai").RunDebugRecord>;
    listThreadDebugRuns(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<{
        threadId: string;
        runs: {
            runId: string;
            threadId: string;
            startedAt: number;
            stepCount: number;
            workflowCodeCount: number;
            label: string | undefined;
        }[];
    }>;
    executeWithLlmMock(req: AuthenticatedRequest, _res: Response, workflowId: string, payload: InstanceAiEvalExecutionRequest): Promise<import("@n8n/api-types").InstanceAiEvalExecutionResult>;
    executeAgentWithLlmMock(req: AuthenticatedRequest, _res: Response, agentId: string, payload: InstanceAiEvalAgentExecutionRequest): Promise<import("@n8n/api-types").InstanceAiEvalAgentExecutionResult>;
    setThreadCredentialAllowlist(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEvalCredentialAllowlistRequest): Promise<{
        ok: boolean;
    }>;
    restoreEvalThread(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEvalRestoreThreadRequest): Promise<{
        ok: boolean;
        threadId: string;
        restored: number;
        workflowIds: string[];
        dataTableIds: string[];
    }>;
    seedEvalDataTableRows(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEvalSeedDataTableRowsRequest): Promise<{
        ok: boolean;
        tableId: string;
        rowCount: number;
    }>;
    createGatewayLink(req: AuthenticatedRequest): Promise<{
        token: string;
        command: string;
        expiresAt: string | null;
        ttlSeconds: number | null;
    }>;
    gatewayEvents(req: Request, res: FlushableResponse): Promise<void>;
    gatewayInit(req: Request, _res: Response, payload: InstanceAiGatewayCapabilitiesDto): Promise<{
        ok: boolean;
        sessionKey: string;
    } | {
        sessionKey?: undefined;
        ok: boolean;
    }>;
    gatewayDisconnect(req: Request): {
        ok: boolean;
    };
    gatewayResponse(req: Request, _res: Response, requestId: string, payload: InstanceAiFilesystemResponseDto): {
        ok: boolean;
    };
    gatewayCreateCredential(req: Request, _res: Response, payload: InstanceAiGatewayCreateCredentialDto): Promise<{
        credentialId: string;
    }>;
    gatewayStatus(req: AuthenticatedRequest): Promise<{
        connected: boolean;
        connectedAt: string | null;
        directory: string | null;
        hostIdentifier: string | null;
        toolCategories: import("@n8n/api-types").ToolCategory[];
    }>;
    gatewayDisconnectSession(req: AuthenticatedRequest): Promise<{
        ok: boolean;
    }>;
    createBrowserLink(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiBrowserCreateLinkResponse>;
    browserStatus(req: AuthenticatedRequest): import("@n8n/api-types").InstanceAiBrowserStatusResponse;
    browserDisconnectSession(req: AuthenticatedRequest): Promise<{
        ok: boolean;
    }>;
    private assertBrowserChannelEnabled;
    private assertThreadAccess;
    private assertGatewayEnabled;
    private getGatewayKeyHeader;
    private validateGatewayApiKey;
    private resolveGatewayUser;
    private writeSseEvent;
}
export {};
