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 type { StoredAttachmentRef } from './agent-chat-attachment.service';
import { AgentExecutionOrchestratorService } 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 StreamDraftRunInput {
    agentId: string;
    projectId: string;
    message: string;
    user: User;
    sessionId: string;
    attachments?: StoredAttachmentRef[];
    source?: string;
    onExecutionRecorded?: (executionId: string) => void;
    abortSignal?: AbortSignal;
}
interface ExecuteDraftRunInput extends PrepareDraftRunInput {
    message: string;
    user: User;
    source?: string;
    abortSignal?: AbortSignal;
}
interface ResumeDraftRunInput {
    agentId: string;
    projectId: string;
    sessionId: string;
    runId: string;
    toolCallId: string;
    resumeData: unknown;
    user: User;
    source?: string;
    response: string;
    abortSignal?: AbortSignal;
}
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<typeof agentTestRunContinuationSchema>;
export interface AgentTestRunSuspension {
    runId: string;
    toolCallId: string;
    toolName: string;
    input?: unknown;
    suspendPayload?: unknown;
    resumeSchema?: unknown;
}
export interface AgentTestRunApproval extends ApprovalSuspendPayload {
    continuation: AgentTestRunContinuation;
}
export type AgentTestRunResult = {
    status: 'completed';
    response: string;
    sessionId: string;
    executionId?: string;
} | {
    status: 'suspended';
    response: string;
    sessionId: string;
    executionId?: string;
    suspensions: AgentTestRunSuspension[];
} | {
    status: 'session_not_found';
} | {
    status: 'agent_misconfigured';
    missing: string[];
};
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<AgentTestRunResult, {
    status: 'suspended';
}>): 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<PrepareDraftRunResult>;
    streamDraftRun({ agentId, projectId, message, user, sessionId, attachments, source, onExecutionRecorded, abortSignal, }: StreamDraftRunInput): AsyncGenerator<StreamChunk>;
    executeDraftRun(input: ExecuteDraftRunInput): Promise<AgentTestRunResult>;
    resumeDraftRun(input: ResumeDraftRunInput): Promise<AgentTestRunResult>;
    resumeDraftApproval(input: {
        agentId: string;
        projectId: string;
        continuation: unknown;
        approved: boolean;
        user: User;
        source?: string;
        abortSignal?: AbortSignal;
    }): Promise<AgentTestRunResult>;
    cancelSuspendedRuns({ agentId, suspensions, userId, }: {
        agentId: string;
        suspensions: Array<Pick<AgentTestRunSuspension, 'runId'>>;
        userId: string;
    }): Promise<boolean>;
    private collectDraftRun;
}
export {};
