n8n
Version:
n8n Workflow Automation Tool
51 lines (50 loc) • 3.14 kB
TypeScript
import { type AgentConfigValidationResponse, type AgentVersionListItemDto } from '@n8n/api-types';
import { Logger } from '@n8n/backend-common';
import type { User } from '@n8n/db';
import { CredentialsService } from '../../credentials/credentials.service';
import { Telemetry } from '../../telemetry';
import { AgentCustomToolsService } from './agent-custom-tools.service';
import { AgentRuntimeCacheService } from './agent-runtime-cache.service';
import { AgentValidationService } from './agent-validation.service';
import type { Agent } from './entities/agent.entity';
import { AgentHistoryRepository } from './repositories/agent-history.repository';
import { AgentTaskSnapshotRepository } from './repositories/agent-task-snapshot.repository';
import { AgentTaskRepository } from './repositories/agent-task.repository';
import { AgentRepository } from './repositories/agent.repository';
import { SubAgentCleanupService } from './sub-agents/sub-agent-cleanup.service';
export type AgentPublishSource = 'editor' | 'builder' | 'channel_connect' | 'slack_setup';
export interface PublishAgentOptions {
syncIntegrations?: boolean;
ignoreDraftIntegrations?: boolean;
}
export type ValidAgentConfigValidationResponse = AgentConfigValidationResponse & {
status: 'valid';
};
export interface PublishAgentResult {
agent: Agent;
draftValidation?: ValidAgentConfigValidationResponse;
}
export declare class AgentPublishService {
private readonly logger;
private readonly agentRepository;
private readonly agentHistoryRepository;
private readonly agentTaskSnapshotRepository;
private readonly agentTaskRepository;
private readonly customToolsService;
private readonly runtimeCacheService;
private readonly subAgentCleanupService;
private readonly agentValidationService;
private readonly credentialsService;
private readonly telemetry;
constructor(logger: Logger, agentRepository: AgentRepository, agentHistoryRepository: AgentHistoryRepository, agentTaskSnapshotRepository: AgentTaskSnapshotRepository, agentTaskRepository: AgentTaskRepository, customToolsService: AgentCustomToolsService, runtimeCacheService: AgentRuntimeCacheService, subAgentCleanupService: SubAgentCleanupService, agentValidationService: AgentValidationService, credentialsService: CredentialsService, telemetry: Telemetry);
publishAgent(agentId: string, projectId: string, user: User, source: AgentPublishSource, versionId?: string, options?: PublishAgentOptions): Promise<PublishAgentResult>;
private assertPublishable;
unpublishAgent(agentId: string, projectId: string, user: User, source: 'editor' | 'builder'): Promise<Agent>;
revertToPublishedAgent(agentId: string, projectId: string): Promise<Agent>;
revertToVersion(agentId: string, projectId: string, versionId: string): Promise<Agent>;
hasPublishHistory(agentId: string): Promise<boolean>;
listPublishHistory(agentId: string, projectId: string, take: number, skip: number): Promise<AgentVersionListItemDto[]>;
private snapshotConfiguredTasks;
private pickConfiguredSkillBodies;
private restoreTasksFromSnapshot;
}