n8n
Version:
n8n Workflow Automation Tool
48 lines (47 loc) • 3.37 kB
TypeScript
import { type ChatMessageId, type ChatSessionId, ChatHubConversationModel } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import { ExecutionRepository, IExecutionResponse, User } from '@n8n/db';
import { InstanceSettings } from 'n8n-core';
import { type IWorkflowBase, IRunExecutionData, IRun } from 'n8n-workflow';
import { ActiveExecutions } from '../../active-executions';
import { ChatExecutionManager } from '../../chat/chat-execution-manager';
import { ExecutionService } from '../../executions/execution.service';
import { WorkflowExecutionService } from '../../workflows/workflow-execution.service';
import { ChatHubExecutionStore } from './chat-hub-execution-store.service';
import { ChatHubWorkflowService } from './chat-hub-workflow.service';
import type { NonStreamingResponseMode, ChatTriggerResponseMode } from './chat-hub.types';
import { ChatHubMessageRepository } from './chat-message.repository';
import { ChatStreamService } from './chat-stream.service';
export declare class ChatHubExecutionService {
private readonly logger;
private readonly executionService;
private readonly workflowExecutionService;
private readonly executionRepository;
private readonly executionManager;
private readonly activeExecutions;
private readonly instanceSettings;
private readonly chatStreamService;
private readonly chatHubWorkflowService;
private readonly chatHubExecutionStore;
private readonly messageRepository;
constructor(logger: Logger, executionService: ExecutionService, workflowExecutionService: WorkflowExecutionService, executionRepository: ExecutionRepository, executionManager: ChatExecutionManager, activeExecutions: ActiveExecutions, instanceSettings: InstanceSettings, chatStreamService: ChatStreamService, chatHubWorkflowService: ChatHubWorkflowService, chatHubExecutionStore: ChatHubExecutionStore, messageRepository: ChatHubMessageRepository);
execute(user: User, workflowData: IWorkflowBase, executionData: IRunExecutionData): Promise<{
executionId: string;
}>;
stop(executionId: string, workflowId: string): Promise<import("../../executions/execution.types").StopResult>;
executeChatWorkflowWithCleanup(user: User, model: ChatHubConversationModel, workflowData: IWorkflowBase, executionData: IRunExecutionData, sessionId: ChatSessionId, previousMessageId: ChatMessageId, retryOfMessageId: ChatMessageId | null, responseMode: ChatTriggerResponseMode, pushRef?: string): Promise<void>;
private executeChatWorkflow;
private executeWithStreaming;
private executeNonStreaming;
resumeChatExecution(execution: IExecutionResponse, message: string, sessionId: ChatSessionId, _user: User, previousMessageId: ChatMessageId, model: ChatHubConversationModel, _responseMode: 'responseNodes'): Promise<void>;
waitForExecutionCompletion(executionId: string): Promise<void>;
private waitForExecutionPoller;
private waitForExecutionPromise;
private waitForErrorDetails;
private createStreamAdapter;
ensureWasSuccessfulOrThrow(executionId: string, errorMessage: string): Promise<void>;
extractErrorMessage(runData: IRunExecutionData): string | undefined;
extractMessage(runData: IRun, responseMode: NonStreamingResponseMode): string | undefined;
private getFirstOutputEntry;
private extractMessageFromEntry;
}