import type { AgentPlanTaskRef } from '@n8n/api-types'; import { BaseRepository, TransactionRunner, type OperationContext } from '@n8n/db'; import { DataSource } from '@n8n/typeorm'; import type { JsonObject } from 'n8n-workflow'; import { UserError } from '@n8n/errors'; import { AgentBackgroundJob } from '../entities/agent-background-job.entity'; import { AgentPlanHistory } from '../entities/agent-plan-history.entity'; import { AgentPlan } from '../entities/agent-plan.entity'; import { AgentExecutionThreadRepository } from './agent-execution-thread.repository'; export type AgentPlanRecord = Pick; export type AgentPlanRevision = Pick; export type AgentPlanRevisionMetadata = Omit; type PlanWrite = { threadId: string; planId: string; expectedRevision: number; }; type PlanDocument = { formatVersion: number; data: JsonObject; }; export declare class AgentPlanWriteConflictError extends UserError { constructor(); } export declare class AgentPlanRepository extends BaseRepository { private readonly threadRepository; constructor(dataSource: DataSource, transactionRunner: TransactionRunner, threadRepository: AgentExecutionThreadRepository); createActivePlan(input: PlanDocument & { id: string; threadId: string; }, ctx: OperationContext): Promise; findLatestPlan(threadId: string, ctx: OperationContext): Promise; findActivePlan(threadId: string, ctx: OperationContext): Promise; findPlan(threadId: string, planId: string, ctx: OperationContext): Promise; findRevision(threadId: string, planId: string, revision: number, ctx: OperationContext): Promise; listHistory(threadId: string, planId: string, options: { afterRevision?: number; limit?: number; }, ctx: OperationContext): Promise<{ items: AgentPlanRevisionMetadata[]; nextCursor: number | null; }>; replacePlan(input: PlanWrite & PlanDocument, ctx: OperationContext): Promise; closePlan(input: PlanWrite, ctx: OperationContext): Promise; private writeRevision; private insertSnapshot; private validateVersion; private serializeData; private jobsForPlan; jobStatesForPlan(planId: string, ctx?: OperationContext): Promise; private resolvePlan; validateTask(threadId: string, ref: AgentPlanTaskRef | undefined, ctx?: OperationContext, inherited?: boolean): Promise; bindJob(threadId: string, ref: AgentPlanTaskRef, jobId: string, ctx: OperationContext): Promise; pauseManualTasks(threadId: string, planId: string, ctx: OperationContext): Promise<{ title: string; description: string; presentation?: { label: string; detail?: string | undefined; } | undefined; items: ({ id: string; title: string; description: string; status: "cancelled" | "done" | "failed" | "in_progress" | "paused" | "pending"; dependsOn: string[]; resultSummary?: string | undefined; startedAt: string | null; endedAt: string | null; kind: "task"; fallbackFor?: string | undefined; jobId?: string | undefined; } | { id: string; title: string; description: string; status: "cancelled" | "done" | "failed" | "in_progress" | "paused" | "pending"; dependsOn: string[]; resultSummary?: string | undefined; startedAt: string | null; endedAt: string | null; kind: "group"; tasks: { id: string; title: string; description: string; status: "cancelled" | "done" | "failed" | "in_progress" | "paused" | "pending"; dependsOn: string[]; resultSummary?: string | undefined; startedAt: string | null; endedAt: string | null; kind: "task"; fallbackFor?: string | undefined; jobId?: string | undefined; }[]; })[]; } | undefined>; selectStoppedTasks(threadId: string, planId: string, taskIds?: string[]): Promise<{ status: 'stopping'; planId?: undefined; stopId?: undefined; taskIds?: undefined; blocked?: undefined; jobs?: undefined; } | { status: 'selected'; planId: string; stopId: string; taskIds: string[]; blocked: { id: string; blockedBy: string[]; }[]; jobs: AgentBackgroundJob[]; }>; releaseStoppedTasks(threadId: string, planId: string, stopId: string, ids: string[]): Promise; private saveDefinition; } export {};