n8n
Version:
n8n Workflow Automation Tool
407 lines (406 loc) • 16.1 kB
TypeScript
import { AgentBuildResumeDto, AgentChatMessageDto, type AgentBuilderMessagesResponse, type AgentIntegrationStatusResponse, type AgentPersistedMessageDto, type AgentSkill, type AgentVersionListItemDto, type ChatIntegrationDescriptor, CreateSlackAgentAppDto, type CreateSlackAgentAppResponse, type SlackAgentAppManifestResponse, CreateAgentDto, CreateAgentSkillDto, PaginationDto, UpdateAgentConfigDto, UpdateAgentDto, UpdateAgentSkillDto, AgentDisconnectIntegrationDto, PublishAgentDto, CreateAgentTaskDto, UpdateAgentTaskDto, type AgentTaskDto, RevertAgentToVersionDto } from '@n8n/api-types';
import type { AuthenticatedRequest } from '@n8n/db';
import type { Request, Response } from 'express';
import { CredentialsService } from '../../credentials/credentials.service';
import { AgentExecutionService } from './agent-execution.service';
import { AgentKnowledgeService } from './agent-knowledge.service';
import { type FlushableResponse } from './agent-sse-stream';
import { AgentTaskService } from './agent-task.service';
import { AgentsService } from './agents.service';
import { AgentsBuilderService } from './builder/agents-builder.service';
import { ChatIntegrationRegistry } from './integrations/agent-chat-integration';
import { ChatIntegrationService } from './integrations/chat-integration.service';
import { SlackAppSetupService } from './integrations/slack-app-setup.service';
import { AgentRepository } from './repositories/agent.repository';
import type { Agent } from './entities/agent.entity';
export declare class AgentsController {
private readonly agentsService;
private readonly agentsBuilderService;
private readonly credentialsService;
private readonly chatIntegrationService;
private readonly agentRepository;
private readonly agentExecutionService;
private readonly chatIntegrationRegistry;
private readonly slackAppSetupService;
private readonly agentTaskService;
private readonly agentKnowledgeService;
constructor(agentsService: AgentsService, agentsBuilderService: AgentsBuilderService, credentialsService: CredentialsService, chatIntegrationService: ChatIntegrationService, agentRepository: AgentRepository, agentExecutionService: AgentExecutionService, chatIntegrationRegistry: ChatIntegrationRegistry, slackAppSetupService: SlackAppSetupService, agentTaskService: AgentTaskService, agentKnowledgeService: AgentKnowledgeService);
private validateIntegration;
private withRunnableState;
create(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, payload: CreateAgentDto): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
list(req: AuthenticatedRequest<{
projectId: string;
}, unknown, unknown, {
all?: string;
}>): Promise<Agent[]>;
getConfig(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<{
model: string;
name: string;
instructions: string;
description?: string | undefined;
credential?: string | undefined;
tools?: ({
type: "custom";
id: string;
requireApproval?: boolean | undefined;
} | {
type: "workflow";
workflow: string;
description?: string | undefined;
name?: string | undefined;
requireApproval?: boolean | undefined;
allOutputs?: boolean | undefined;
} | {
type: "node";
name: string;
node: {
nodeType: string;
nodeTypeVersion: number;
nodeParameters: Record<string, unknown>;
credentials?: Record<string, {
id: string;
name: string;
}> | undefined;
};
description?: string | undefined;
requireApproval?: boolean | undefined;
})[] | undefined;
memory?: {
enabled: boolean;
storage: "n8n";
semanticRecall?: {
topK: number;
scope?: "thread" | "resource" | undefined;
messageRange?: {
before: number;
after: number;
} | undefined;
embedder?: string | undefined;
} | undefined;
observationalMemory?: {
enabled?: boolean | undefined;
observerModel?: {
model: string;
credential: string;
} | undefined;
reflectorModel?: {
model: string;
credential: string;
} | undefined;
observerThresholdTokens?: number | undefined;
reflectorThresholdTokens?: number | undefined;
renderTokenBudget?: number | undefined;
observationLogTailLimit?: number | undefined;
lockTtlMs?: number | undefined;
} | undefined;
episodicMemory?: {
enabled: false;
} | {
credential: string;
enabled: true;
topK?: number | undefined;
reflectorModel?: {
model: string;
credential: string;
} | undefined;
extractorModel?: {
model: string;
credential: string;
} | undefined;
maxEntriesPerRun?: number | undefined;
} | undefined;
} | undefined;
skills?: {
type: "skill";
id: string;
}[] | undefined;
tasks?: {
type: "task";
enabled: boolean;
id: string;
}[] | undefined;
providerTools?: Record<string, Record<string, unknown>> | undefined;
integrations?: ({
type: "telegram";
credentialId: string;
settings?: {
accessMode: "private" | "public";
allowedUsers: string[];
} | undefined;
} | {
type: "slack";
credentialId: string;
} | {
type: "linear";
credentialId: string;
})[] | undefined;
mcpServers?: {
name: string;
url: string;
transport: "sse" | "streamableHttp";
authentication: string;
description?: string | undefined;
credential?: string | undefined;
metadata?: {
nodeTypeName?: string | undefined;
} | undefined;
toolFilter?: {
mode: "allow";
tools: string[];
} | {
mode: "exclude";
tools: string[];
} | undefined;
approval?: {
mode: "global";
} | {
mode: "selected";
tools: string[];
} | undefined;
connectionTimeoutMs?: number | undefined;
}[] | undefined;
config?: {
thinking?: {
provider: "anthropic" | "openai";
budgetTokens?: number | undefined;
reasoningEffort?: string | undefined;
} | undefined;
webSearch?: {
enabled: boolean;
provider?: "auto" | "native" | "brave" | "searxng" | undefined;
credential?: string | undefined;
} | undefined;
toolCallConcurrency?: number | undefined;
maxIterations?: number | undefined;
nodeTools?: {
enabled: boolean;
} | undefined;
} | undefined;
}>;
putConfig(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>, _res: Response, agentId: string, payload: UpdateAgentConfigDto): Promise<{
config: import("@n8n/api-types").AgentJsonConfig;
updatedAt: string;
versionId: string | null;
}>;
deleteTool(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
toolId: string;
}>, _res: Response, agentId: string, toolId: string): Promise<{
ok: boolean;
}>;
listSkills(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<Record<string, AgentSkill>>;
getSkill(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
skillId: string;
}>, _res: Response, agentId: string, skillId: string): Promise<AgentSkill>;
createSkill(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>, _res: Response, agentId: string, payload: CreateAgentSkillDto): Promise<import("@n8n/api-types").AgentSkillMutationResponse>;
updateSkill(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
skillId: string;
}>, _res: Response, agentId: string, skillId: string, payload: UpdateAgentSkillDto): Promise<import("@n8n/api-types").AgentSkillMutationResponse>;
deleteSkill(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
skillId: string;
}>, _res: Response, agentId: string, skillId: string): Promise<{
ok: boolean;
}>;
getModelCatalog(): Promise<import("@n8n/agents").ProviderCatalog>;
listIntegrations(): ChatIntegrationDescriptor[];
listThreads(req: AuthenticatedRequest<{
projectId: string;
}, {}, {}, {
cursor?: string;
limit?: string;
agentId?: string;
}>): Promise<{
threads: import("./agent-execution.service").ThreadListItem[];
nextCursor: string | null;
}>;
getThread(req: AuthenticatedRequest<{
projectId: string;
threadId: string;
}, {}, {}, {
agentId?: string;
}>): Promise<import("./agent-execution.service").ThreadDetail>;
deleteThread(req: AuthenticatedRequest<{
projectId: string;
threadId: string;
}>): Promise<{
success: boolean;
}>;
get(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
update(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: UpdateAgentDto): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
private assertKnowledgeBaseEnabled;
listFiles(_req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, projectId: string, agentId: string): Promise<import("@n8n/api-types").AgentFileDto[]>;
uploadFiles(req: AuthenticatedRequest<{
projectId: string;
}> & {
files?: Express.Multer.File[];
fileUploadError?: Error;
}, _res: Response, projectId: string, agentId: string): Promise<import("@n8n/api-types").AgentFileDto[]>;
deleteFile(_req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, projectId: string, agentId: string, fileId: string): Promise<{
success: boolean;
}>;
delete(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<{
success: boolean;
}>;
publish(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: PublishAgentDto): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
unpublish(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
revertToPublished(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
revertToVersion(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: RevertAgentToVersionDto): Promise<Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
}>;
listVersions(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>, _res: Response, agentId: string, query: PaginationDto): Promise<AgentVersionListItemDto[]>;
chat(req: AuthenticatedRequest<{
projectId: string;
}>, res: FlushableResponse, agentId: string, payload: AgentChatMessageDto): Promise<void>;
getChatMessages(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
threadId: string;
}>): Promise<AgentPersistedMessageDto[]>;
getBuilderMessages(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<AgentBuilderMessagesResponse>;
clearBuilderMessages(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<{
ok: boolean;
}>;
getTestChatMessages(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<AgentPersistedMessageDto[]>;
clearTestChatMessages(req: AuthenticatedRequest<{
projectId: string;
agentId: string;
}>): Promise<{
ok: boolean;
}>;
build(req: AuthenticatedRequest<{
projectId: string;
}>, res: FlushableResponse, agentId: string, payload: AgentChatMessageDto): Promise<void>;
buildResume(req: AuthenticatedRequest<{
projectId: string;
}>, res: FlushableResponse, agentId: string, payload: AgentBuildResumeDto): Promise<void>;
connectIntegration(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<{
status: string;
agent: Agent & {
isRunnable: boolean;
hasPublishHistory: boolean;
};
} | {
status: string;
agent?: undefined;
}>;
createSlackApp(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: CreateSlackAgentAppDto): Promise<CreateSlackAgentAppResponse>;
getSlackAppManifest(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<SlackAgentAppManifestResponse>;
handleSlackAppOAuthCallback(req: Request<{
projectId: string;
agentId: string;
}, unknown, unknown, {
code?: string;
state?: string;
error?: string;
error_description?: string;
}>, res: Response, agentId: string): Promise<void>;
disconnectIntegration(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: AgentDisconnectIntegrationDto): Promise<{
status: string;
}>;
private getAgentOrThrow;
listTasks(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<AgentTaskDto[]>;
createTask(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, payload: CreateAgentTaskDto): Promise<AgentTaskDto>;
updateTask(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, taskId: string, payload: UpdateAgentTaskDto): Promise<AgentTaskDto>;
deleteTask(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, taskId: string): Promise<{
success: true;
}>;
runTaskNow(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string, taskId: string): Promise<{
success: true;
}>;
integrationStatus(req: AuthenticatedRequest<{
projectId: string;
}>, _res: Response, agentId: string): Promise<AgentIntegrationStatusResponse>;
handleWebhook(req: Request<{
projectId: string;
agentId: string;
platform: string;
}>, res: Response): Promise<void>;
}