import type { InstanceAiContext, ExecutionResult, ExecutionDebugInfo, NodeOutputResult, ServiceProxyConfig, EvaluationConfigSummary, EvaluationConfigDetail, UpsertEvaluationConfigInput, ModelConfig } from '@n8n/instance-ai';
import { GlobalConfig } from '@n8n/config';
import type { User, EvaluationConfig } from '@n8n/db';
import { InstanceAiSettingsService } from './instance-ai-settings.service';
import { WorkflowTemplatesService } from './workflow-templates.service';
import { AiBuilderTemporaryWorkflowRepository, ExecutionRepository, ProjectRepository, SharedWorkflowRepository, WorkflowRepository } from '@n8n/db';
import { Logger } from '@n8n/backend-common';
import { OutboundHttp, SsrfProtectionService } from '@n8n/backend-network';
import { type ExecutionError } from 'n8n-workflow';
import { ActiveExecutions } from '../../active-executions';
import { CredentialsFinderService } from '../../credentials/credentials-finder.service';
import { CredentialsService } from '../../credentials/credentials.service';
import { EvaluationConfigService } from '../../evaluation.ee/evaluation-config.service';
import { LlmJudgeProviderRegistry } from '../../evaluation.ee/llm-judge-provider-registry';
import { EventService } from '../../events/event.service';
import { ExecutionPersistence } from '../../executions/execution-persistence';
import { License } from '../../license';
import { LoadNodesAndCredentials } from '../../load-nodes-and-credentials';
import { NodeTypes } from '../../node-types';
import { NodeCatalogService } from '../../node-catalog';
import { DataTableRepository } from '../../modules/data-table/data-table.repository';
import { DataTableService } from '../../modules/data-table/data-table.service';
import { SourceControlPreferencesService } from '../../modules/source-control.ee/source-control-preferences.service.ee';
import { AiGatewayService } from '../../services/ai-gateway.service';
import { FolderService } from '../../services/folder.service';
import { NodeResourceExplorerService } from '../../services/node-resource-explorer.service';
import { ProjectService } from '../../services/project.service.ee';
import { RoleService } from '../../services/role.service';
import { InstanceSettings } from 'n8n-core';
import { TagService } from '../../services/tag.service';
import { WorkflowFinderService } from '../../workflows/workflow-finder.service';
import { WorkflowHistoryService } from '../../workflows/workflow-history/workflow-history.service';
import { WorkflowService } from '../../workflows/workflow.service';
import { EnterpriseWorkflowService } from '../../workflows/workflow.service.ee';
import { Telemetry } from '../../telemetry';
import { WorkflowRunner } from '../../workflow-runner';
export declare class InstanceAiAdapterService {
    private readonly globalConfig;
    private readonly workflowService;
    private readonly workflowFinderService;
    private readonly workflowRepository;
    private readonly sharedWorkflowRepository;
    private readonly projectRepository;
    private readonly executionRepository;
    private readonly credentialsService;
    private readonly credentialsFinderService;
    private readonly activeExecutions;
    private readonly workflowRunner;
    private readonly loadNodesAndCredentials;
    private readonly nodeTypes;
    private readonly instanceSettings;
    private readonly dataTableService;
    private readonly dataTableRepository;
    private readonly nodeResourceExplorerService;
    private readonly folderService;
    private readonly projectService;
    private readonly tagService;
    private readonly sourceControlPreferencesService;
    private readonly settingsService;
    private readonly workflowHistoryService;
    private readonly enterpriseWorkflowService;
    private readonly license;
    private readonly executionPersistence;
    private readonly eventService;
    private readonly roleService;
    private readonly telemetry;
    private readonly aiBuilderTemporaryWorkflowRepository;
    private readonly ssrfProtectionService;
    private readonly outboundHttp;
    private readonly aiGatewayService;
    private readonly workflowTemplatesService;
    private readonly nodeCatalogService?;
    private readonly evaluationConfigService?;
    private readonly llmJudgeProviderRegistry?;
    private readonly logger;
    private readonly allowSendingParameterValues;
    private nodesCache;
    private readonly NODES_CACHE_TTL_MS;
    private templatesService;
    private getNodesFromCache;
    constructor(logger: Logger, globalConfig: GlobalConfig, workflowService: WorkflowService, workflowFinderService: WorkflowFinderService, workflowRepository: WorkflowRepository, sharedWorkflowRepository: SharedWorkflowRepository, projectRepository: ProjectRepository, executionRepository: ExecutionRepository, credentialsService: CredentialsService, credentialsFinderService: CredentialsFinderService, activeExecutions: ActiveExecutions, workflowRunner: WorkflowRunner, loadNodesAndCredentials: LoadNodesAndCredentials, nodeTypes: NodeTypes, instanceSettings: InstanceSettings, dataTableService: DataTableService, dataTableRepository: DataTableRepository, nodeResourceExplorerService: NodeResourceExplorerService, folderService: FolderService, projectService: ProjectService, tagService: TagService, sourceControlPreferencesService: SourceControlPreferencesService, settingsService: InstanceAiSettingsService, workflowHistoryService: WorkflowHistoryService, enterpriseWorkflowService: EnterpriseWorkflowService, license: License, executionPersistence: ExecutionPersistence, eventService: EventService, roleService: RoleService, telemetry: Telemetry, aiBuilderTemporaryWorkflowRepository: AiBuilderTemporaryWorkflowRepository, ssrfProtectionService: SsrfProtectionService, outboundHttp: OutboundHttp, aiGatewayService: AiGatewayService, workflowTemplatesService: WorkflowTemplatesService, nodeCatalogService?: NodeCatalogService | undefined, evaluationConfigService?: EvaluationConfigService | undefined, llmJudgeProviderRegistry?: LlmJudgeProviderRegistry | undefined);
    createContext(user: User, options?: {
        searchProxyConfig?: ServiceProxyConfig;
        pushRef?: string;
        threadId?: string;
        projectId?: string;
        credentialIdAllowlist?: string[];
        agentId?: string;
        configEvalsEnabled?: boolean;
        modelId?: ModelConfig;
    }): InstanceAiContext;
    private withBuilderCreateTelemetry;
    private getBuilderDelegateAdapter;
    private getGatewayConfigOrNull;
    isConfigEvalsEnabled(user: User): Promise<boolean>;
    private buildAiGatewayNodeMeta;
    private getTemplatesService;
    private createWorkflowTemplateAdapter;
    private buildLicenseHints;
    private trackGatewayAvailability;
    private assertInstanceNotReadOnly;
    private createProjectScopeHelpers;
    private createWorkflowAdapter;
    private createExecutionAdapter;
    private createCredentialAdapter;
    private createEvaluationConfigAdapter;
    private createDataTableAdapter;
    private readonly webResearchCache;
    private readonly searchCache;
    private createWebResearchAdapter;
    private buildSearchMethod;
    private _nodeDefinitionDirs?;
    getNodeDefinitionDirs(): string[];
    private getNodeCatalogService;
    private createNodeAdapter;
    private createWorkspaceAdapter;
}
interface DataTableRecord {
    id: string;
    name: string;
    projectId: string;
}
interface DataTableIdOrNameRepository {
    findOneBy: (where: {
        id: string;
    }) => Promise<DataTableRecord | null>;
    findBy: (where: {
        name: string;
        projectId?: string;
    }) => Promise<DataTableRecord[]>;
}
interface DataTableResolverLogger {
    warn: (message: string, meta?: Record<string, unknown>) => void;
}
export type ResolveDataTableResult = {
    kind: 'hit';
    table: DataTableRecord;
} | {
    kind: 'miss';
} | {
    kind: 'ambiguous';
    candidates: DataTableRecord[];
};
interface ResolveMetricProvidersDeps {
    user: User;
    credentialsFinderService: CredentialsFinderService;
    llmJudgeProviderRegistry?: LlmJudgeProviderRegistry;
}
export declare function resolveMetricProviders(input: UpsertEvaluationConfigInput, deps: ResolveMetricProvidersDeps): Promise<UpsertEvaluationConfigInput>;
export declare function buildEvaluationConfigDto(input: UpsertEvaluationConfigInput): {
    name: string;
    startNodeName: string;
    endNodeName: string;
    metrics: ({
        id: string;
        name: string;
        type: "expression";
        config: {
            expression: string;
            outputType: "boolean" | "numeric";
        };
    } | {
        id: string;
        name: string;
        type: "llm_judge";
        config: {
            preset: "correctness" | "helpfulness";
            prompt?: string | undefined;
            provider: string;
            credentialId: string;
            model: string;
            outputType: "boolean" | "numeric";
            inputs: {
                actualAnswer: string;
                userQuery?: string | undefined;
                expectedAnswer?: string | undefined;
            };
        };
    } | {
        id: string;
        name: string;
        type: "string_similarity";
        config: {
            inputs: {
                actualAnswer: string;
                expectedAnswer: string;
            };
        };
    } | {
        id: string;
        name: string;
        type: "categorization";
        config: {
            inputs: {
                actualAnswer: string;
                expectedAnswer: string;
            };
        };
    } | {
        id: string;
        name: string;
        type: "tools_used";
        config: {
            inputs: {
                expectedTools: string;
                intermediateSteps: string;
            };
        };
    })[];
} & ({
    datasetSource: "data_table";
    datasetRef: {
        dataTableId: string;
    };
} | {
    datasetSource: "google_sheets";
    datasetRef: {
        credentialId: string;
        spreadsheetId: string;
        sheetName: string;
        headerRow?: number | undefined;
    };
});
export declare function evaluationConfigToSummary(config: EvaluationConfig): EvaluationConfigSummary;
export declare function evaluationConfigToDetail(config: EvaluationConfig): EvaluationConfigDetail;
export declare function resolveDataTableByIdOrName(repository: DataTableIdOrNameRepository, logger: DataTableResolverLogger, idOrName: string, options?: {
    projectIdFilter?: string;
    accessFilter?: (id: string) => Promise<boolean>;
}): Promise<ResolveDataTableResult>;
export declare function truncateResultData(resultData: Record<string, unknown>): Record<string, unknown>;
export declare function extractExecutionResult(executionId: string, includeOutputData?: boolean): Promise<ExecutionResult>;
export declare function formatExecutionError(error: ExecutionError, includeUpstreamDetails: boolean): string;
export declare function truncateNodeOutput(items: unknown[]): unknown[] | unknown;
export declare function extractNodeOutput(executionId: string, nodeName: string, options?: {
    startIndex?: number;
    maxItems?: number;
}): Promise<NodeOutputResult>;
export declare function extractExecutionDebugInfo(executionId: string, includeOutputData?: boolean, nodeTypes?: NodeTypes): Promise<ExecutionDebugInfo>;
export {};
