n8n
Version:
n8n Workflow Automation Tool
40 lines (39 loc) • 1.6 kB
TypeScript
import type { Thread } from 'chat';
import type { SuspendComponent } from './component-mapper';
export interface AgentChatIntegrationContext {
agentId: string;
projectId: string;
credentialId: string;
credential: Record<string, unknown>;
webhookUrlFor: (platform: string) => string;
}
export interface UnauthenticatedWebhookResponse {
status: number;
body: unknown;
}
export declare abstract class AgentChatIntegration {
abstract readonly type: string;
abstract readonly credentialTypes: string[];
abstract readonly displayLabel: string;
abstract readonly displayIcon: string;
readonly supportedComponents?: string[];
readonly needsShortCallbackData: boolean;
readonly disableStreaming: boolean;
requiresLeader(): boolean;
abstract createAdapter(ctx: AgentChatIntegrationContext): Promise<unknown>;
handleUnauthenticatedWebhook?(body: unknown): UnauthenticatedWebhookResponse | undefined;
onBeforeConnect?(ctx: AgentChatIntegrationContext): Promise<void>;
onAfterConnect?(ctx: AgentChatIntegrationContext): Promise<void>;
normalizeComponents?(components: SuspendComponent[]): SuspendComponent[];
formatThreadId?: {
fromSdk: (thread: Thread<unknown, unknown>) => string;
toSdk: (threadId: string) => string;
};
}
export declare class ChatIntegrationRegistry {
private readonly integrations;
register(integration: AgentChatIntegration): void;
get(type: string): AgentChatIntegration | undefined;
require(type: string): AgentChatIntegration;
list(): AgentChatIntegration[];
}