import { Logger } from '@n8n/backend-common'; import { AgentsConfig } from '@n8n/config'; import type { IRunData, TerminalExecutionStatus } from 'n8n-workflow'; import { ExecutionPersistence } from '../../../executions/execution-persistence'; import { Publisher } from '../../../scaling/pubsub/publisher.service'; import { AgentExecutionUpdateBroadcaster } from '../agent-execution-update-broadcaster'; import type { AgentBackgroundJob } from '../entities/agent-background-job.entity'; import { AgentBackgroundJobRepository, type AgentBackgroundJobSettlement, type BackgroundJobGroupItem, type NewSubAgentJob, type NewWorkflowJob } from '../repositories/agent-background-job.repository'; import { AgentExecutionRepository } from '../repositories/agent-execution.repository'; export declare const MAX_RUNNING_JOBS_PER_THREAD = 5; export declare const SUB_AGENT_BACKGROUND_TIMEOUT_MS: number; export declare const SETTLED_JOB_RETENTION_MS: number; export type BackgroundJobReceipt = { status: 'started'; jobId: string; } | { status: 'limit-reached'; }; export type BackgroundJobView = Pick; export declare const WORKFLOW_JOB_RESULT_MAX_CHARS = 8000; export declare const EXECUTION_OUTCOME_UNKNOWN_ERROR = "The workflow execution was not retained (check the workflow\u2019s save settings), so its outcome is unknown \u2014 it may have completed. Do not run the workflow again without checking for its effects."; export declare function settlementStatusForExecution(status: TerminalExecutionStatus): 'completed' | 'failed' | 'cancelled'; export declare function collectResultData(runData: IRunData, allOutputs: boolean): Record; export declare function serializeWorkflowJobResult(resultData: Record | undefined): string | null; export declare class AgentBackgroundJobService { private readonly jobRepository; private readonly executionRepository; private readonly executionPersistence; private readonly publisher; private readonly logger; private readonly agentsConfig; private readonly updateBroadcaster; private readonly abortControllers; constructor(jobRepository: AgentBackgroundJobRepository, executionRepository: AgentExecutionRepository, executionPersistence: ExecutionPersistence, publisher: Publisher, logger: Logger, agentsConfig: AgentsConfig, updateBroadcaster: AgentExecutionUpdateBroadcaster); registerSubAgentJob(params: Omit): Promise; registerWorkflowJob(params: Omit & { executionId: string; }): Promise; settleWorkflowJobByExecutionId(executionId: string, settlement: AgentBackgroundJobSettlement): Promise; settle(jobId: string, settlement: AgentBackgroundJobSettlement): Promise; markMailConsumed(parentThreadId: string, jobIds: string[]): Promise; private consumeMail; registerAbortController(jobId: string, controller: AbortController): void; listForThread(parentThreadId: string, ids?: string[]): Promise; private toJobView; listCurrentGroupForThread(parentAgentId: string, parentThreadId: string): Promise; cancel(parentThreadId: string, jobId: string): Promise<'cancelled' | 'not-found' | 'already-settled'>; private findJob; private notifyJobUpdate; private notifyJobUpdateById; private requestWakeSafely; handleCancelRelay({ jobId }: { jobId: string; }): void; reconcile(): Promise; reconcileWorkflowJobs(): Promise; private cancelWorkflowJob; private consumeCancelledMail; private settleFinishedWorkflowJobs; private loadExecutionResult; private failJobsPastTimeout; private failOrphanedSubAgentJobs; }