n8n
Version:
n8n Workflow Automation Tool
115 lines (114 loc) • 6.77 kB
TypeScript
import { InstanceAiFeedbackRequestDto, InstanceAiGatewayCapabilitiesDto, InstanceAiFilesystemResponseDto, InstanceAiRenameThreadRequestDto, InstanceAiSendMessageRequest, InstanceAiEventsQuery, InstanceAiCorrectTaskRequest, InstanceAiEnsureThreadRequest, InstanceAiThreadMessagesQuery, InstanceAiAdminSettingsUpdateRequest, InstanceAiUserPreferencesUpdateRequest, InstanceAiEvalExecutionRequest, InstanceAiEvalSubAgentRequest } from '@n8n/api-types';
import { ModuleRegistry } from '@n8n/backend-common';
import { GlobalConfig } from '@n8n/config';
import { AuthenticatedRequest } from '@n8n/db';
import type { NextFunction, Request, Response } from 'express';
import { EvalExecutionService } from './eval/execution.service';
import { SubAgentEvalService } from './eval/sub-agent-eval.service';
import { InProcessEventBus } from './event-bus/in-process-event-bus';
import { InstanceAiMemoryService } from './instance-ai-memory.service';
import { InstanceAiSettingsService } from './instance-ai-settings.service';
import { InstanceAiService } from './instance-ai.service';
import { Push } from '../../push';
import { UrlService } from '../../services/url.service';
type FlushableResponse = Response & {
flush?: () => void;
};
export declare class InstanceAiController {
private readonly instanceAiService;
private readonly memoryService;
private readonly settingsService;
private readonly evalExecutionService;
private readonly subAgentEvalService;
private readonly eventBus;
private readonly moduleRegistry;
private readonly push;
private readonly urlService;
private readonly gatewayApiKey;
private static getTreeRichnessScore;
private static selectBootstrapTree;
constructor(instanceAiService: InstanceAiService, memoryService: InstanceAiMemoryService, settingsService: InstanceAiSettingsService, evalExecutionService: EvalExecutionService, subAgentEvalService: SubAgentEvalService, eventBus: InProcessEventBus, moduleRegistry: ModuleRegistry, push: Push, urlService: UrlService, globalConfig: GlobalConfig);
private requireInstanceAiEnabled;
stripBrotli(req: Request, _res: Response, next: NextFunction): void;
chat(req: AuthenticatedRequest, _res: Response, threadId: string, payload: InstanceAiSendMessageRequest): Promise<{
runId: string;
}>;
events(req: AuthenticatedRequest, res: FlushableResponse, threadId: string, query: InstanceAiEventsQuery): Promise<void>;
confirm(req: AuthenticatedRequest, _res: Response, requestId: string): Promise<{
ok: boolean;
}>;
cancel(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<{
ok: boolean;
}>;
feedback(req: AuthenticatedRequest, _res: Response, threadId: string, responseId: string, payload: InstanceAiFeedbackRequestDto): Promise<{
ok: boolean;
}>;
cancelTask(req: AuthenticatedRequest, _res: Response, threadId: string, taskId: string): Promise<{
ok: boolean;
}>;
correctTask(req: AuthenticatedRequest, _res: Response, threadId: string, taskId: string, payload: InstanceAiCorrectTaskRequest): Promise<{
ok: boolean;
}>;
getCredits(req: AuthenticatedRequest): Promise<{
creditsQuota: number;
creditsClaimed: number;
}>;
getAdminSettings(_req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiAdminSettingsResponse>;
updateAdminSettings(_req: AuthenticatedRequest, _res: Response, payload: InstanceAiAdminSettingsUpdateRequest): Promise<import("@n8n/api-types").InstanceAiAdminSettingsResponse>;
getUserPreferences(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiUserPreferencesResponse>;
updateUserPreferences(req: AuthenticatedRequest, _res: Response, payload: InstanceAiUserPreferencesUpdateRequest): Promise<import("@n8n/api-types").InstanceAiUserPreferencesResponse>;
listModelCredentials(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiModelCredential[]>;
listServiceCredentials(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiModelCredential[]>;
listThreads(req: AuthenticatedRequest): Promise<import("@n8n/api-types").InstanceAiThreadListResponse>;
ensureThread(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEnsureThreadRequest): Promise<import("@n8n/api-types").InstanceAiEnsureThreadResponse>;
deleteThread(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<{
ok: boolean;
}>;
renameThread(req: AuthenticatedRequest, _res: Response, threadId: string, payload: InstanceAiRenameThreadRequestDto): Promise<{
thread: import("@n8n/api-types").InstanceAiThreadInfo;
}>;
getThreadMessages(req: AuthenticatedRequest, _res: Response, threadId: string, query: InstanceAiThreadMessagesQuery): Promise<import("@n8n/api-types").InstanceAiThreadMessagesResponse | {
nextEventId: number;
messages: import("@n8n/api-types").InstanceAiMessage[];
threadId: string;
}>;
getThreadStatus(req: AuthenticatedRequest, _res: Response, threadId: string): Promise<import("@n8n/api-types").InstanceAiThreadStatusResponse>;
executeWithLlmMock(req: AuthenticatedRequest, _res: Response, workflowId: string, payload: InstanceAiEvalExecutionRequest): Promise<import("@n8n/api-types").InstanceAiEvalExecutionResult>;
runSubAgentEval(req: AuthenticatedRequest, _res: Response, payload: InstanceAiEvalSubAgentRequest): Promise<import("@n8n/api-types").InstanceAiEvalSubAgentResponse>;
createGatewayLink(req: AuthenticatedRequest): Promise<{
token: string;
command: string;
expiresAt: string | null;
ttlSeconds: number | null;
}>;
gatewayEvents(req: Request, res: FlushableResponse): Promise<void>;
gatewayInit(req: Request, _res: Response, payload: InstanceAiGatewayCapabilitiesDto): Promise<{
ok: boolean;
sessionKey: string;
} | {
ok: boolean;
sessionKey?: undefined;
}>;
gatewayDisconnect(req: Request): {
ok: boolean;
};
gatewayResponse(req: Request, _res: Response, requestId: string, payload: InstanceAiFilesystemResponseDto): {
ok: boolean;
};
gatewayStatus(req: AuthenticatedRequest): Promise<{
connected: boolean;
connectedAt: string | null;
directory: string | null;
hostIdentifier: string | null;
toolCategories: import("@n8n/api-types").ToolCategory[];
}>;
gatewayDisconnectSession(req: AuthenticatedRequest): Promise<{
ok: boolean;
}>;
private assertThreadAccess;
private assertGatewayEnabled;
private getGatewayKeyHeader;
private validateGatewayApiKey;
private writeSseEvent;
}
export {};