UNPKG

n8n

Version:

n8n Workflow Automation Tool

100 lines (99 loc) 3.93 kB
import type { Agent as RuntimeAgent, StreamChunk } from '@n8n/agents'; import type { AgentPersistedMessageDto } from '@n8n/api-types'; import { Logger } from '@n8n/backend-common'; import type { User } from '@n8n/db'; import { ExternalHooks } from '../../external-hooks'; import type { AgentRunTelemetryType, IAgentConfigurationTelemetryProperties } from '../../interfaces'; import { Telemetry } from '../../telemetry'; import { AgentExecutionService } from './agent-execution.service'; import { AgentRunTracingService } from './agent-run-tracing.service'; import { AgentRuntimeCacheService } from './agent-runtime-cache.service'; import { IntegrationMessageContextService } from './integrations/integration-message-context.service'; import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage'; import type { ToolRegistry } from './tool-registry'; export interface AgentMemoryScope { threadId: string; resourceId: string; } export interface ExecuteForChatConfig { agentId: string; projectId: string; message: string; user: User; memory: AgentMemoryScope; onExecutionRecorded?: (executionId: string) => void; } 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; user?: User; usePublishedVersion?: boolean; integrationType?: string; onExecutionRecorded?: (executionId: string) => void; } export interface ExecuteForTaskPublishedConfig { agentId: string; projectId: string; message: string; memory: AgentMemoryScope; taskId: string; taskVersionId: string; } export interface ExecuteForTaskNowConfig { agentId: string; projectId: string; user: User; message: string; memory: AgentMemoryScope; taskId: string; } export interface StreamChatResponseConfig { agentInstance: RuntimeAgent; toolRegistry: ToolRegistry; agentId: string; userId?: string; message: string; memory: AgentMemoryScope; projectId: string; source?: string; taskId?: string; taskVersionId?: string; telemetry?: { runType: AgentRunTelemetryType; configuration: IAgentConfigurationTelemetryProperties; }; onExecutionRecorded?: (executionId: string) => void; } export declare class AgentExecutionOrchestratorService { private readonly logger; private readonly n8nCheckpointStorage; private readonly agentExecutionService; private readonly telemetry; private readonly runtimeCacheService; private readonly integrationMessageContextService; private readonly agentRunTracingService; private readonly externalHooks; constructor(logger: Logger, n8nCheckpointStorage: N8NCheckpointStorage, agentExecutionService: AgentExecutionService, telemetry: Telemetry, runtimeCacheService: AgentRuntimeCacheService, integrationMessageContextService: IntegrationMessageContextService, agentRunTracingService: AgentRunTracingService, externalHooks: ExternalHooks); getConversationHistory(params: { threadId: string; projectId: string; agentId: string; }): Promise<AgentPersistedMessageDto[] | null>; resumeForChat(config: ResumeForChatConfig): AsyncGenerator<StreamChunk>; executeForChat(config: ExecuteForChatConfig): AsyncGenerator<StreamChunk>; executeForChatPublished(config: ExecuteForChatPublishedConfig): AsyncGenerator<StreamChunk>; executeForTaskPublished(config: ExecuteForTaskPublishedConfig): AsyncGenerator<StreamChunk>; executeForTaskNow(config: ExecuteForTaskNowConfig): AsyncGenerator<StreamChunk>; streamChatResponse(config: StreamChatResponseConfig): AsyncGenerator<StreamChunk>; private persistRecordedExecution; }