import { type AgentExecutionCounter, type BuiltTelemetry, type CredentialProvider, type DelegateSubAgentCancelRequest, type DelegateSubAgentResumeRequest, type GenerateResult, type JSONValue, type StreamChunk, type SubAgentTaskDifficulty, type SubAgentTaskPath } from '@n8n/agents'; import type { 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 { AgentTurnExecutionService } from '../agent-turn-execution.service'; import type { AgentRuntimeInstrumentation } from '../agent-runtime-instrumentation'; 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'; export interface SubAgentRunContext { 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; selfDelegationDifficulty?: SubAgentTaskDifficulty; } export interface SubAgentRunResult { taskPath: SubAgentTaskPath; threadId: string; status: 'completed' | 'failed' | 'suspended'; result: GenerateResult; resumeContext?: JSONValue; } export declare class SubAgentRunner { private readonly sourceResolver; private readonly turnExecutionService; private readonly checkpointStorage; private readonly logger; private readonly aiConfig; constructor(sourceResolver: SubAgentSourceResolver, turnExecutionService: AgentTurnExecutionService, checkpointStorage: N8NCheckpointStorage, logger: Logger, aiConfig: AiConfig); run(request: SubAgentSpawnRequest, context: SubAgentRunContext): Promise; resumeForeground(request: DelegateSubAgentResumeRequest, context: SubAgentRunContext, expectedSourceAgentId?: string): Promise; cancelForeground(request: DelegateSubAgentCancelRequest, expectedSourceAgentId?: string): Promise; private executeForeground; private resolveSandboxPrincipalHash; }