import type { Thread, Author, Message } from 'chat'; import type { Logger } from 'n8n-workflow'; import { AgentIntegrationConfig } from '@n8n/api-types'; import type { RichCardComponentType } from '@n8n/api-types'; import type { ChatInstance } from './chat-integration.service'; import type { SuspendComponent } from './component-mapper'; import type { IntegrationAction, IntegrationActionDefinition, IntegrationActionResult, IntegrationContextQuery, IntegrationContextQueryDefinition, IntegrationMessageContext, IntegrationToolConnectionDescriptor } from './integration-tools'; export interface AgentChatIntegrationContext { agentId: string; projectId: string; credentialId: string; credential: Record; webhookUrlFor: (platform: string) => string; } export interface UnauthenticatedWebhookResponse { status: number; body: unknown; } export interface AgentChatIntegrationBuilderGuidance { capabilities: string[]; useIntegrationWhen: string[]; useNodeToolWhen: string[]; } export interface PlatformAgentContext { agentUserId?: string; } export interface BridgeStatusHandle { clearBeforeResponse(): Promise; } export declare function onceStatusHandle(handle: BridgeStatusHandle | undefined): BridgeStatusHandle | undefined; export interface BridgeExecutionContext { platformAgentContext: PlatformAgentContext; forceBuffered?: boolean; statusHandle?: BridgeStatusHandle; historyContext?: string; } export type BridgeResumeExecutionContext = Pick; export interface BridgeMessageContextParams { chat: ChatInstance; thread: Thread; message: Message; logger: Logger; agentId: string; statusRetry?: AbortController; isNewMention: boolean; } export declare abstract class AgentChatIntegration { abstract readonly type: string; abstract readonly credentialTypes: string[]; abstract readonly displayLabel: string; abstract readonly displayIcon: string; readonly builderGuidance?: AgentChatIntegrationBuilderGuidance; readonly supportedComponents?: readonly RichCardComponentType[]; readonly contextToolDefinitions: IntegrationContextQueryDefinition[]; readonly actionToolDefinitions: IntegrationActionDefinition[]; readonly contextToolGuidance?: string[]; readonly actionToolGuidance?: string[]; get contextQueries(): IntegrationContextQuery[]; get actions(): IntegrationAction[]; readonly needsShortCallbackData: boolean; readonly disableStreaming: boolean; readonly internal: boolean; readonly requiresChatInstance: boolean; requiresLeader(): boolean; abstract createAdapter(ctx: AgentChatIntegrationContext): Promise; handleUnauthenticatedWebhook?(body: unknown): UnauthenticatedWebhookResponse | undefined; onBeforeConnect?(ctx: AgentChatIntegrationContext): Promise; onAfterConnect?(ctx: AgentChatIntegrationContext): Promise; onBeforeDisconnect?(ctx: AgentChatIntegrationContext): Promise; normalizeComponents?(components: SuspendComponent[]): SuspendComponent[]; formatThreadId?: { fromSdk: (thread: Thread) => string; toSdk: (threadId: string) => string; }; isUserAllowed?(author: Author, settings: AgentIntegrationConfig | undefined): boolean; getPlatformAgentContext?(chat: ChatInstance): PlatformAgentContext; prepareInboundText?(text: string, context: PlatformAgentContext): string; createBridgeExecutionContext?(params: BridgeMessageContextParams): Promise; createResumeExecutionContext?(params: { chat: ChatInstance; thread: Thread; logger: Logger; agentId: string; }): Promise; executeContextQuery?(params: PlatformContextQueryParams): Promise; executeAction?(params: PlatformActionParams): Promise; } export interface PlatformContextQueryParams { chat: ChatInstance | undefined; descriptor: IntegrationToolConnectionDescriptor; query: IntegrationContextQuery; input: Record; } export interface PlatformActionParams { chat: ChatInstance | undefined; descriptor: IntegrationToolConnectionDescriptor; action: IntegrationAction; input: Record; currentMessageContext?: IntegrationMessageContext; } export declare class ChatIntegrationRegistry { private readonly integrations; register(integration: AgentChatIntegration): void; get(type: string): AgentChatIntegration | undefined; require(type: string): AgentChatIntegration; list(): AgentChatIntegration[]; listPublic(): AgentChatIntegration[]; }