import { type AgentExecutionCounter, type BuiltTelemetry, type CredentialProvider, type DelegateSubAgentCancelRequest, type DelegateSubAgentResumeRequest, type GenerateResult, type EpisodicScopeDecision, type JSONValue, type StreamChunk, type SubAgentTaskDifficulty, type SubAgentTaskPath } from '@n8n/agents'; import type { AgentBudgetNotice, AgentPlanTaskRef, AgentToolOutputFile, SubAgentSpawnRequest } from '@n8n/api-types'; import { Logger } from '@n8n/backend-common'; import { AiConfig } from '@n8n/config'; import type { User } from '@n8n/db'; import type { AgentRunTelemetryType } from '../../../interfaces'; import { AgentChatAttachmentService } from '../agent-chat-attachment.service'; import { AgentSandboxFilesService } from '../agent-sandbox-files.service'; import { AgentExecutionRepository } from '../repositories/agent-execution.repository'; import type { IntegrationMessageContext } from '../integrations/integration-tool-types'; import { AgentTurnExecutionService } from '../agent-turn-execution.service'; import { AgentToolApprovalService } from '../agent-tool-approval.service'; import type { AgentRuntimeInstrumentation } from '../evaluation/agent-evaluation.contracts'; import type { AgentSandboxRuntime } from '../agent-sandbox-runtime.service'; import { N8NCheckpointStorage } from '../integrations/n8n-checkpoint-storage'; import type { WorkflowToolExecutionMode } from '../tools/workflow-tool-factory'; import { SubAgentSourceResolver } from './sub-agent-source-resolver'; import { SystemAgentUsageRelay } from '../system-agents/system-agent-usage-relay'; export interface SubAgentRunContext { parentEpisodicScope?: EpisodicScopeDecision; projectId: string; parentAgentId: string; credentialProvider: CredentialProvider; runType: AgentRunTelemetryType; workflowToolExecutionMode?: WorkflowToolExecutionMode; executionCounter?: AgentExecutionCounter; abortSignal?: AbortSignal; telemetry?: BuiltTelemetry; user?: User; instrumentation?: AgentRuntimeInstrumentation; parentWorkspaceHandle?: AgentSandboxRuntime; onChunk?: (chunk: StreamChunk) => void; rootSessionId?: string; rootSessionCapUsd?: number; budgetForwarded?: boolean; selfDelegationDifficulty?: SubAgentTaskDifficulty; backgroundJobId?: string; planTask?: AgentPlanTaskRef; parentMessageContext?: IntegrationMessageContext | null; onResumeClaimed?: () => Promise; beforeResume?: () => Promise; shouldPause?: () => Promise; runtimeSnapshot?: string; onBudgetNotice?: (notice: AgentBudgetNotice) => void; } export interface SubAgentRunResult { taskPath: SubAgentTaskPath; threadId: string; status: 'completed' | 'failed' | 'suspended' | 'paused'; result: GenerateResult; resumeContext?: JSONValue; files?: AgentToolOutputFile[]; filesError?: string; } type SubAgentResumeRequest = Pick; export declare class SubAgentRunner { private readonly sourceResolver; private readonly turnExecutionService; private readonly checkpointStorage; private readonly logger; private readonly aiConfig; private readonly toolApprovalService; private readonly executionRepository; private readonly usageRelay; private readonly attachmentService; private readonly sandboxFiles; constructor(sourceResolver: SubAgentSourceResolver, turnExecutionService: AgentTurnExecutionService, checkpointStorage: N8NCheckpointStorage, logger: Logger, aiConfig: AiConfig, toolApprovalService: AgentToolApprovalService, executionRepository: AgentExecutionRepository, usageRelay: SystemAgentUsageRelay, attachmentService: AgentChatAttachmentService, sandboxFiles: AgentSandboxFilesService); run(request: SubAgentSpawnRequest, context: SubAgentRunContext): Promise; resumeForeground(request: SubAgentResumeRequest, context: SubAgentRunContext, expectedSourceAgentId?: string): Promise; resumePaused(request: Omit, context: SubAgentRunContext): Promise; cancelForeground(request: DelegateSubAgentCancelRequest, expectedSourceAgentId?: string): Promise; private executeForeground; private returnFilesToParent; private syncChildOutputs; private reportDelegatedRunUsage; private resolveExecutionLinks; private resolveSandboxPrincipalHash; } export {};