import { CredentialProvider, StreamChunk, ToolDescriptor } from '@n8n/agents'; import { type AgentIntegrationConfig, type AgentJsonConfig, type AgentSkill, type AgentSkillMutationResponse, type AgentVersionListItemDto, type ChatIntegrationDescriptor, AgentPersistedMessageDto } from '@n8n/api-types'; import { Logger } from '@n8n/backend-common'; import { AgentsConfig, GlobalConfig } from '@n8n/config'; import { ProjectRelationRepository, User } from '@n8n/db'; import type { JSONSchema7 } from 'json-schema'; import { type ExecuteAgentData } from 'n8n-workflow'; import type { PubSubCommandMap } from '../../scaling/pubsub/pubsub.event-map'; import { Publisher } from '../../scaling/pubsub/publisher.service'; import { Telemetry } from '../../telemetry'; import { AgentExecutionService } from './agent-execution.service'; import { AgentSkillsService } from './agent-skills.service'; import { Agent } from './entities/agent.entity'; import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage'; import { N8nMemory } from './integrations/n8n-memory'; import { AgentRuntimeReconstructionService } from './agent-runtime-reconstruction.service'; import { AgentHistoryRepository } from './repositories/agent-history.repository'; import { AgentTaskSnapshotRepository } from './repositories/agent-task-snapshot.repository'; import { AgentTaskRepository } from './repositories/agent-task.repository'; import { AgentRepository } from './repositories/agent.repository'; import { ChatIntegrationService } from './integrations/chat-integration.service'; import { AgentKnowledgeService } from './agent-knowledge.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; userId?: string; usePublishedVersion?: boolean; integrationType?: string; } export interface ExecuteForTaskPublishedConfig { agentId: string; projectId: string; message: string; memory: AgentMemoryScope; taskId: string; taskVersionId: string; } export interface ExecuteForTaskNowConfig { agentId: string; projectId: string; userId: string; message: string; memory: AgentMemoryScope; taskId: string; } interface PublishAgentOptions { syncIntegrations?: boolean; } interface SaveCredentialIntegrationOptions { broadcast?: boolean; } export declare class AgentsService { private readonly logger; private readonly agentRepository; private readonly projectRelationRepository; private readonly n8nCheckpointStorage; private readonly n8nMemory; private readonly agentExecutionService; private readonly agentHistoryRepository; private readonly agentSkillsService; private readonly agentTaskRepository; private readonly agentTaskSnapshotRepository; private readonly publisher; private readonly agentsConfig; private readonly globalConfig; private readonly telemetry; private readonly chatIntegrationService; private readonly agentKnowledgeService; private readonly agentRuntimeReconstructionService; private readonly runtimes; private computeRuntimeCacheKey; private clearRuntimes; handleAgentConfigChanged(payload: PubSubCommandMap['agent-config-changed']): void; constructor(logger: Logger, agentRepository: AgentRepository, projectRelationRepository: ProjectRelationRepository, n8nCheckpointStorage: N8NCheckpointStorage, n8nMemory: N8nMemory, agentExecutionService: AgentExecutionService, agentHistoryRepository: AgentHistoryRepository, agentSkillsService: AgentSkillsService, agentTaskRepository: AgentTaskRepository, agentTaskSnapshotRepository: AgentTaskSnapshotRepository, publisher: Publisher, agentsConfig: AgentsConfig, globalConfig: GlobalConfig, telemetry: Telemetry, chatIntegrationService: ChatIntegrationService, agentKnowledgeService: AgentKnowledgeService, agentRuntimeReconstructionService: AgentRuntimeReconstructionService); private isNodeToolsModuleEnabled; isKnowledgeBaseModuleEnabled(): boolean; private closeAgentResources; private createAgentExecutionCounter; 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, options?: PublishAgentOptions): Promise; unpublishAgent(agentId: string, projectId: string): Promise; revertToPublishedAgent(agentId: string, projectId: string): Promise; revertToVersion(agentId: string, projectId: string, versionId: string): Promise; hasPublishHistory(agentId: string): Promise; listPublishHistory(agentId: string, projectId: string, take: number, skip: number): Promise; delete(agentId: string, projectId: string): Promise; getConversationHistory(params: { threadId: string; projectId: string; agentId: string; }): Promise; private createCredentialProvider; private getRuntime; resumeForChat(config: ResumeForChatConfig): AsyncGenerator; validateAgentIsRunnable(agentId: string, projectId: string, credentialProvider: CredentialProvider): Promise<{ missing: string[]; }>; private validateMemoryWorkerModel; private workerCredentialSupportsModel; executeForChat(config: ExecuteForChatConfig): AsyncGenerator; getTestChatMessages(agentId: string, userId: string): Promise; clearTestChatMessages(agentId: string, userId: string): Promise; clearAllTestChatMessages(agentId: string): Promise; executeForChatPublished(config: ExecuteForChatPublishedConfig): AsyncGenerator; executeForTaskPublished(config: ExecuteForTaskPublishedConfig): AsyncGenerator; executeForTaskNow(config: ExecuteForTaskNowConfig): AsyncGenerator; private streamChatResponse; private compileIsolated; private getPublishedAgent; executeForWorkflow(agentId: string, message: string, executionId: string, threadId: string, userId: string, projectId: string, telemetryUserId?: string, useDraftVersion?: boolean, outputSchema?: JSONSchema7): 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: AgentIntegrationConfig, options?: SaveCredentialIntegrationOptions): Promise; removeCredentialIntegration(agent: Agent, type: string, credentialId: string): Promise; 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 removeMissingConfigRefs; private fetchUniqueSubAgents; private validateSubAgentRefs; private getMissingCustomToolIds; private snapshotConfiguredTools; private snapshotConfiguredTasks; private restoreTasksFromSnapshot; private reconstructFromConfig; } export {};