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 { AgentsConfig } from '@n8n/config'; import { UserRepository, WorkflowRepository } from '@n8n/db'; import { ActiveExecutions } from '../../active-executions'; import { EphemeralNodeExecutor } from '../../node-execution'; import { OauthService } from '../../oauth/oauth.service'; import { UrlService } from '../../services/url.service'; import { WorkflowRunner } from '../../workflow-runner'; import { WorkflowFinderService } from '../../workflows/workflow-finder.service'; import { Agent } from './entities/agent.entity'; import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage'; import { N8nMemory } from './integrations/n8n-memory'; import { AgentRepository } from './repositories/agent.repository'; import { AgentSecureRuntime } from './runtime/agent-secure-runtime'; import { type ToolRegistry } from './tool-registry'; import { AgentKnowledgeCommandService } from './agent-knowledge-command.service'; import { AgentKnowledgeService } from './agent-knowledge.service'; import { AgentsToolsService } from './agents-tools.service'; export type AgentRuntimeProfile = 'top-level' | 'sub-agent'; export interface SubAgentDelegationConfig { sourcesById: Record; availableSubAgents: Array<{ id: string; name: string; description?: string; }>; } export interface ReconstructAgentRuntimeParams { config: AgentJsonConfig; memoryOwnerAgentId: string; projectId: string; credentialProvider: CredentialProvider; toolDescriptors: Record; toolCodeByName: Record; skills: Record; userId: string; runtimeProfile: AgentRuntimeProfile; parentAgentIdForDelegation?: string; integrationType?: string; credentialIntegrations?: AgentIntegrationConfig[]; } export declare class AgentRuntimeReconstructionService { private readonly logger; private readonly agentRepository; private readonly workflowRunner; private readonly activeExecutions; private readonly workflowRepository; private readonly userRepository; private readonly workflowFinderService; private readonly urlService; private readonly n8nCheckpointStorage; private readonly secureRuntime; private readonly ephemeralNodeExecutor; private readonly agentsToolsService; private readonly n8nMemory; private readonly oauthService; private readonly agentsConfig; private readonly agentKnowledgeService; private readonly agentKnowledgeCommandService; constructor(logger: Logger, agentRepository: AgentRepository, workflowRunner: WorkflowRunner, activeExecutions: ActiveExecutions, workflowRepository: WorkflowRepository, userRepository: UserRepository, workflowFinderService: WorkflowFinderService, urlService: UrlService, n8nCheckpointStorage: N8NCheckpointStorage, secureRuntime: AgentSecureRuntime, ephemeralNodeExecutor: EphemeralNodeExecutor, agentsToolsService: AgentsToolsService, n8nMemory: N8nMemory, oauthService: OauthService, agentsConfig: AgentsConfig, agentKnowledgeService: AgentKnowledgeService, agentKnowledgeCommandService: AgentKnowledgeCommandService); reconstructFromAgentEntity(agentEntity: Agent, credentialProvider: CredentialProvider, userId: string, integrationType?: string): Promise<{ agent: RuntimeAgent; toolRegistry: ToolRegistry; }>; reconstructFromResolvedSource(params: ReconstructAgentRuntimeParams): Promise<{ agent: RuntimeAgent; toolRegistry: ToolRegistry; }>; private reconstructRuntime; createSubAgentDelegationConfig(config: AgentJsonConfig, projectId: string): Promise; private fetchUniqueSubAgents; private getMemoryFactory; private shouldAttachNodeTools; private isNodeToolsModuleEnabled; private isKnowledgeBaseModuleEnabled; private makeToolResolver; private injectRuntimeDependencies; private attachSubAgentDelegationTool; private resolveInlineSubAgentModelsByDifficulty; private attachWriteTodosTool; private buildSubAgentPolicy; }