n8n
Version:
n8n Workflow Automation Tool
59 lines (58 loc) • 2.41 kB
TypeScript
import type { StreamChunk } from '@n8n/agents';
import type { Chat } from 'chat';
import type { Logger } from 'n8n-workflow';
import type { AgentExecutionOrchestratorService } from '../agent-execution-orchestrator.service';
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;
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 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);
static create(chat: Chat, agentId: string, agentService: AgentExecutionOrchestratorService, componentMapper: ComponentMapper, logger: Logger, n8nProjectId: string, integration: AgentIntegrationConfig): AgentChatBridge;
private registerHandlers;
dispose(): void;
private canUserAccess;
private resolvePlatformThreadId;
private toAgentThreadId;
getShortenCallback(): ShortenCallback | undefined;
private executeAndStream;
private resolveBridgeExecutionContext;
private handleSuspension;
private handleMessage;
private getPlatformAgentContext;
private prepareInboundText;
private postErrorToThread;
}
export {};