import type { CredentialProvider, StreamChunk, ToolDescriptor } from '@n8n/agents'; import { type AgentCredentialIntegrationConfig, type AgentJsonConfig, type AgentSkill, type AgentSkillMutationResponse, type ChatIntegrationDescriptor, AgentPersistedMessageDto } from '@n8n/api-types'; import { Logger } from '@n8n/backend-common'; import { AgentsConfig, GlobalConfig } from '@n8n/config'; import { ExecutionRepository, ProjectRelationRepository, User, UserRepository, WorkflowRepository } from '@n8n/db'; import { type ExecuteAgentData } from 'n8n-workflow'; import { ActiveExecutions } from '../../active-executions'; import { EphemeralNodeExecutor } from '../../node-execution'; import type { PubSubCommandMap } from '../../scaling/pubsub/pubsub.event-map'; import { Publisher } from '../../scaling/pubsub/publisher.service'; import { UrlService } from '../../services/url.service'; import { Telemetry } from '../../telemetry'; import { WorkflowRunner } from '../../workflow-runner'; import { WorkflowFinderService } from '../../workflows/workflow-finder.service'; import { AgentExecutionService } from './agent-execution.service'; import { AgentSkillsService } from './agent-skills.service'; import { AgentsToolsService } from './agents-tools.service'; import { Agent } from './entities/agent.entity'; import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage'; import { N8nMemory } from './integrations/n8n-memory'; import { AgentHistoryRepository } from './repositories/agent-history.repository'; import { AgentRepository } from './repositories/agent.repository'; import { AgentSecureRuntime } from './runtime/agent-secure-runtime'; import { ChatIntegrationService } from './integrations/chat-integration.service'; export declare function chatThreadId(agentId: string, userId?: string): string; export interface AgentMemoryScope { threadId: string; resourceId: string; } export interface ExecuteForChatConfig { agentId: string; projectId: string; message: string; userId: string; memory: AgentMemoryScope; } export interface ExecuteForChatPublishedConfig { agentId: string; projectId: string; message: string; memory: AgentMemoryScope; integrationType?: string; } export interface ResumeForChatConfig { agentId: string; projectId: string; runId: string; toolCallId: string; resumeData: unknown; integrationType?: string; } export interface ExecuteForSchedulePublishedConfig { agentId: string; projectId: string; message: string; memory: AgentMemoryScope; } export declare class AgentsService { private readonly logger; private readonly agentRepository; private readonly projectRelationRepository; private readonly workflowRunner; private readonly activeExecutions; private readonly executionRepository; 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 agentExecutionService; private readonly agentHistoryRepository; private readonly agentSkillsService; private readonly publisher; private readonly agentsConfig; private readonly globalConfig; private readonly telemetry; private readonly chatIntegrationService; private readonly runtimes; private computeRuntimeCacheKey; private clearRuntimes; handleAgentConfigChanged(payload: PubSubCommandMap['agent-config-changed']): void; constructor(logger: Logger, agentRepository: AgentRepository, projectRelationRepository: ProjectRelationRepository, workflowRunner: WorkflowRunner, activeExecutions: ActiveExecutions, executionRepository: ExecutionRepository, workflowRepository: WorkflowRepository, userRepository: UserRepository, workflowFinderService: WorkflowFinderService, urlService: UrlService, n8nCheckpointStorage: N8NCheckpointStorage, secureRuntime: AgentSecureRuntime, ephemeralNodeExecutor: EphemeralNodeExecutor, agentsToolsService: AgentsToolsService, n8nMemory: N8nMemory, agentExecutionService: AgentExecutionService, agentHistoryRepository: AgentHistoryRepository, agentSkillsService: AgentSkillsService, publisher: Publisher, agentsConfig: AgentsConfig, globalConfig: GlobalConfig, telemetry: Telemetry, chatIntegrationService: ChatIntegrationService); private isNodeToolsModuleEnabled; private createAgentExecutionCounter; private shouldAttachNodeTools; listChatIntegrations(): ChatIntegrationDescriptor[]; create(projectId: string, name: string): Promise; findByProjectId(projectId: string): Promise; findById(agentId: string, projectId: string): Promise; updateName(agentId: string, projectId: string, name: string): Promise; updateDescription(agentId: string, projectId: string, description: string, updatedAt?: string): Promise; findByUser(userId: string): Promise; findPublishedByUser(userId: string): Promise; publishAgent(agentId: string, projectId: string, user: User, versionId?: string): Promise; unpublishAgent(agentId: string, projectId: string): Promise; revertToPublishedAgent(agentId: string, projectId: string): Promise; delete(agentId: string, projectId: string): Promise; getConversationHistory(params: { threadId: string; projectId: string; agentId: string; }): Promise; private getMemoryFactory; private createCredentialProvider; private getRuntime; private makeToolResolver; private injectRuntimeDependencies; private attachNodeToolChain; resumeForChat(config: ResumeForChatConfig): AsyncGenerator; validateAgentIsRunnable(agentId: string, projectId: string, credentialProvider: CredentialProvider): Promise<{ missing: string[]; }>; executeForChat(config: ExecuteForChatConfig): AsyncGenerator; getTestChatMessages(agentId: string, userId: string): Promise; clearTestChatMessages(agentId: string, userId: string): Promise; clearAllTestChatMessages(agentId: string): Promise; executeForChatPublished(config: ExecuteForChatPublishedConfig): AsyncGenerator; executeForSchedulePublished(config: ExecuteForSchedulePublishedConfig): AsyncGenerator; private streamChatResponse; private compileIsolated; executeForWorkflow(agentId: string, message: string, executionId: string, threadId: string, userId: string, projectId: string, telemetryUserId?: string): Promise; getConfig(agentId: string, projectId: string): Promise; validateConfig(raw: unknown): Promise<{ valid: true; config: AgentJsonConfig; } | { valid: false; error: string; }>; private validateNodeToolExpressions; updateConfig(agentId: string, projectId: string, config: unknown): Promise<{ config: AgentJsonConfig; updatedAt: string; versionId: string | null; }>; saveCredentialIntegration(agent: Agent, integration: AgentCredentialIntegrationConfig): Promise; removeCredentialIntegration(agent: Agent, type: string, credentialId: string): Promise; private validateIntegrationRefs; buildCustomTool(agentId: string, projectId: string, code: string, descriptor: ToolDescriptor): Promise<{ ok: boolean; id: string; descriptor: ToolDescriptor; }>; listSkills(agentId: string, projectId: string): Promise>; getSkill(agentId: string, projectId: string, skillId: string): Promise; createSkill(agentId: string, projectId: string, skill: AgentSkill): Promise; createAndAttachSkill(agentId: string, projectId: string, skill: AgentSkill): Promise; updateSkill(agentId: string, projectId: string, skillId: string, updates: Partial): Promise; deleteCustomTool(agentId: string, projectId: string, toolId: string): Promise; deleteSkill(agentId: string, projectId: string, skillId: string): Promise; private validateNodeToolConfigs; private validateConfigRefs; private getMissingCustomToolIds; private snapshotConfiguredTools; private reconstructFromConfig; }