import { type CredentialProvider, type StreamChunk } from '@n8n/agents'; import { type ApprovalSuspendPayload } from '@n8n/agents/tool'; import type { User } from '@n8n/db'; import { UserError } from 'n8n-workflow'; import { z } from 'zod'; import { AgentExecutionOrchestratorService, type ExecuteForChatConfig, type ResumeForChatConfig } from './agent-execution-orchestrator.service'; import { AgentExecutionService } from './agent-execution.service'; import { AgentValidationService } from './agent-validation.service'; import { N8NCheckpointStorage } from './integrations/n8n-checkpoint-storage'; interface PrepareDraftRunInput { agentId: string; projectId: string; sessionId?: string; credentialProvider: CredentialProvider; } export type PrepareDraftRunResult = { status: 'ready'; sessionId: string; } | { status: 'session_not_found'; } | { status: 'agent_misconfigured'; missing: string[]; }; interface DraftRunConsumptionOptions { errorMode?: 'throw' | 'forward'; onChunk?: (chunk: StreamChunk) => void; } export interface ExecutePreparedDraftRunInput extends Omit, DraftRunConsumptionOptions { sessionId: string; } export interface ResumePreparedDraftRunInput extends Omit, DraftRunConsumptionOptions { user: User; initialResponse?: string; } type ExecuteDraftRunInput = PrepareDraftRunInput & Pick; interface ResumeDraftRunInput extends Omit { sessionId: string; user: User; response: string; } export declare const agentTestRunContinuationSchema: z.ZodObject<{ runId: z.ZodString; toolCallId: z.ZodString; sessionId: z.ZodString; response: z.ZodString; }, "strict", z.ZodTypeAny, { runId: string; toolCallId: string; sessionId: string; response: string; }, { runId: string; toolCallId: string; sessionId: string; response: string; }>; export type AgentTestRunContinuation = z.infer; export interface AgentTestRunSuspension { runId: string; toolCallId: string; toolName: string; input?: unknown; suspendPayload?: unknown; resumeSchema?: unknown; } export interface AgentTestRunApproval extends ApprovalSuspendPayload { continuation: AgentTestRunContinuation; } export type PreparedDraftRunResult = { response: string; executionId: string; } & ({ status: 'completed'; } | { status: 'suspended'; suspensions: AgentTestRunSuspension[]; }); export type AgentTestRunResult = (PreparedDraftRunResult & { sessionId: string; }) | Exclude; export declare class InvalidAgentTestRunCheckpointError extends UserError { readonly code = "invalid_checkpoint"; constructor(); } export declare function parseStandardApprovalSuspension(suspension: AgentTestRunSuspension): ApprovalSuspendPayload | undefined; export declare function collectStandardApprovals(result: Extract): AgentTestRunApproval[] | undefined; export declare class AgentTestRunService { private readonly agentExecutionService; private readonly agentValidationService; private readonly agentExecutionOrchestratorService; private readonly n8nCheckpointStorage; constructor(agentExecutionService: AgentExecutionService, agentValidationService: AgentValidationService, agentExecutionOrchestratorService: AgentExecutionOrchestratorService, n8nCheckpointStorage: N8NCheckpointStorage); prepareDraftRun({ agentId, projectId, sessionId, credentialProvider, }: PrepareDraftRunInput): Promise; executePreparedDraftRun({ sessionId, errorMode, onChunk, onExecutionRecorded, ...execution }: ExecutePreparedDraftRunInput): Promise; resumePreparedDraftRun({ initialResponse, errorMode, onChunk, onExecutionRecorded, ...execution }: ResumePreparedDraftRunInput): Promise; executeDraftRun({ credentialProvider, ...input }: ExecuteDraftRunInput): Promise; resumeDraftRun({ sessionId, response, ...input }: ResumeDraftRunInput): Promise; resumeDraftApproval(input: { agentId: string; projectId: string; continuation: unknown; approved: boolean; user: User; source?: string; abortSignal?: AbortSignal; }): Promise; cancelSuspendedRuns({ agentId, suspensions, userId, }: { agentId: string; suspensions: Array>; userId: string; }): Promise; private collectDraftRun; } export {};