import { type Agent as RuntimeAgent, CredentialProvider, ToolDescriptor } from '@n8n/agents';
import { type AgentIntegrationConfig, type AgentJsonConfig, type AgentSkill, type SubAgentSource } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import { OutboundHttp, SsrfProtectionService } from '@n8n/backend-network';
import { AgentsConfig, SsrfProtectionConfig } from '@n8n/config';
import type { User } from '@n8n/db';
import { WorkflowRepository } from '@n8n/db';
import { ActiveExecutions } from '../../active-executions';
import { CredentialsFinderService } from '../../credentials/credentials-finder.service';
import type { AgentRunTelemetryType } from '../../interfaces';
import { EphemeralNodeExecutor } from '../../node-execution';
import { OauthService } from '../../oauth/oauth.service';
import { AiService } from '../../services/ai.service';
import { UrlService } from '../../services/url.service';
import { WorkflowFinderService } from '../../workflows/workflow-finder.service';
import { AgentChatAttachmentService } from './agent-chat-attachment.service';
import { AgentKnowledgeSandboxService } from './agent-knowledge-sandbox.service';
import type { AgentRuntimeInstrumentation } from './agent-runtime-instrumentation';
import { Agent } from './entities/agent.entity';
import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage';
import { N8nMemory } from './integrations/n8n-memory';
import { AgentFileRepository } from './repositories/agent-file.repository';
import { AgentRepository } from './repositories/agent.repository';
import { AgentSecureRuntime } from './runtime/agent-secure-runtime';
import { type ToolRegistry } from './tool-registry';
import type { WorkflowToolExecutionMode } from './tools/workflow-tool-factory';
export type AgentRuntimeProfile = 'top-level' | 'sub-agent' | 'inline';
export interface SubAgentDelegationConfig {
    sourcesById: Record<string, SubAgentSource>;
    availableSubAgents: Array<{
        id: string;
        name: string;
        useWhen?: string;
    }>;
}
export interface ReconstructAgentRuntimeParams {
    config: AgentJsonConfig;
    memoryOwnerAgentId: string;
    projectId: string;
    credentialProvider: CredentialProvider;
    toolDescriptors: Record<string, ToolDescriptor>;
    toolCodeByName: Record<string, string>;
    skills: Record<string, AgentSkill>;
    runtimeProfile: AgentRuntimeProfile;
    runType: AgentRunTelemetryType;
    workflowToolExecutionMode?: WorkflowToolExecutionMode;
    parentAgentIdForDelegation?: string;
    integrationType?: string;
    credentialIntegrations?: AgentIntegrationConfig[];
    user?: User;
    instrumentation?: AgentRuntimeInstrumentation;
}
export declare class AgentRuntimeReconstructionService {
    private readonly logger;
    private readonly agentRepository;
    private readonly agentFileRepository;
    private readonly activeExecutions;
    private readonly workflowRepository;
    private readonly urlService;
    private readonly n8nCheckpointStorage;
    private readonly secureRuntime;
    private readonly ephemeralNodeExecutor;
    private readonly n8nMemory;
    private readonly oauthService;
    private readonly agentsConfig;
    private readonly aiService;
    private readonly outboundHttp;
    private readonly agentKnowledgeSandboxService;
    private readonly ssrfConfig;
    private readonly ssrfProtectionService;
    private readonly credentialsFinderService;
    private readonly workflowFinderService;
    private readonly agentChatAttachmentService;
    constructor(logger: Logger, agentRepository: AgentRepository, agentFileRepository: AgentFileRepository, activeExecutions: ActiveExecutions, workflowRepository: WorkflowRepository, urlService: UrlService, n8nCheckpointStorage: N8NCheckpointStorage, secureRuntime: AgentSecureRuntime, ephemeralNodeExecutor: EphemeralNodeExecutor, n8nMemory: N8nMemory, oauthService: OauthService, agentsConfig: AgentsConfig, aiService: AiService, outboundHttp: OutboundHttp, agentKnowledgeSandboxService: AgentKnowledgeSandboxService, ssrfConfig: SsrfProtectionConfig, ssrfProtectionService: SsrfProtectionService, credentialsFinderService: CredentialsFinderService, workflowFinderService: WorkflowFinderService, agentChatAttachmentService: AgentChatAttachmentService);
    reconstructFromAgentEntity(agentEntity: Agent, credentialProvider: CredentialProvider, runType: AgentRunTelemetryType, integrationType?: string, user?: User, instrumentation?: AgentRuntimeInstrumentation, workflowToolExecutionMode?: WorkflowToolExecutionMode): Promise<{
        agent: RuntimeAgent;
        toolRegistry: ToolRegistry;
    }>;
    private filterToolsForUser;
    reconstructFromResolvedSource(params: ReconstructAgentRuntimeParams): Promise<{
        agent: RuntimeAgent;
        toolRegistry: ToolRegistry;
    }>;
    private reconstructRuntime;
    createSubAgentDelegationConfig(config: AgentJsonConfig, projectId: string): Promise<SubAgentDelegationConfig>;
    private getMemoryFactory;
    private resolveManagedEmbeddingProviderOptions;
    private makeToolResolver;
    private injectRuntimeDependencies;
    private attachSubAgentDelegationTool;
    private resolveInlineSubAgentModelsByDifficulty;
    private attachWriteTodosTool;
    private buildSubAgentPolicy;
}
