UNPKG

n8n

Version:

n8n Workflow Automation Tool

66 lines (65 loc) 2.95 kB
import type { StreamChunk } from '@n8n/agents'; import { type HttpRequestClient } from '@n8n/backend-network'; import type { Chat } from 'chat'; import type { Logger } from 'n8n-workflow'; import { AgentChatAttachmentService, type StoredAttachmentRef } from '../agent-chat-attachment.service'; import type { AgentExecutionOrchestratorService } from '../agent-execution-orchestrator.service'; import { type CallbackMetadata } from './callback-store'; import type { ComponentMapper, ShortenCallback } from './component-mapper'; import { IntegrationMessageContextService } from './integration-message-context.service'; import type { AgentIntegrationConfig } from '@n8n/api-types'; import { type InternalThread } from './types'; interface AgentExecutor { executeForChatPublished(config: { agentId: string; projectId: string; message: string; attachments?: StoredAttachmentRef[]; memory: { threadId: InternalThread; resourceId: string; }; integrationType?: string; }): AsyncGenerator<StreamChunk>; resumeForChat(config: { agentId: string; projectId: string; runId: string; toolCallId: string; resumeData: unknown; integrationType?: string; }): AsyncGenerator<StreamChunk>; } export declare class AgentChatBridge { private readonly chat; private readonly agentId; private readonly agentService; private readonly componentMapper; private readonly logger; private readonly n8nProjectId; private readonly integration; private readonly attachmentService?; private readonly discordHttpClient?; private readonly callbackStore?; private readonly integrationImpl; private readonly messageContextBridge; private readonly streamConsumer; private readonly hitlResumeHandler; constructor(chat: Chat, agentId: string, agentService: AgentExecutor, componentMapper: ComponentMapper, logger: Logger, n8nProjectId: string, integration: AgentIntegrationConfig, messageContextStore?: IntegrationMessageContextService, attachmentService?: AgentChatAttachmentService | undefined, discordHttpClient?: HttpRequestClient | undefined); static create(chat: Chat, agentId: string, agentService: AgentExecutionOrchestratorService, componentMapper: ComponentMapper, logger: Logger, n8nProjectId: string, integration: AgentIntegrationConfig): AgentChatBridge; private registerHandlers; private canUserAccess; private resolvePlatformThreadId; private toAgentThreadId; getShortenCallback(metadata?: CallbackMetadata): ShortenCallback | undefined; private executeAndStream; private storeInboundAttachments; private fetchAttachmentData; private resolveBridgeExecutionContext; private handleSuspension; private handleMessage; private getPlatformAgentContext; private prepareInboundText; private postErrorToThread; } export {};