/**
 * Parallel Tool Executor
 *
 * Research-based implementation of parallel tool execution.
 * Identifies and executes independent tool calls in parallel.
 *
 * Expected Impact:
 * - 2.5-4.6x cost reduction
 * - 1.6-5.4x latency reduction
 *
 * Reference: LLMCompiler, AsyncLM (arXiv 2024)
 */
import { EventEmitter } from "events";
/**
 * Tool call definition
 */
export interface ToolCall {
    id: string;
    name: string;
    arguments: Record<string, unknown>;
    dependencies?: string[];
}
/**
 * Tool execution result
 */
export interface ToolResult {
    id: string;
    name: string;
    success: boolean;
    output?: unknown;
    error?: string;
    duration: number;
    startTime: number;
    endTime: number;
}
/**
 * Execution group - tools that can run in parallel
 */
export interface ExecutionGroup {
    level: number;
    calls: ToolCall[];
}
/**
 * Tool executor function type
 */
export type ToolExecutor = (call: ToolCall) => Promise<unknown>;
/**
 * Execution options
 */
export interface ExecutionOptions {
    /** Maximum concurrent executions */
    maxConcurrency: number;
    /** Timeout per tool call in ms */
    timeoutMs: number;
    /** Whether to continue on errors */
    continueOnError: boolean;
    /** Retry count for failed calls */
    retryCount: number;
    /** Delay between retries in ms */
    retryDelayMs: number;
}
/**
 * Default execution options
 */
export declare const DEFAULT_EXECUTION_OPTIONS: ExecutionOptions;
/**
 * Analyze tool calls to identify dependencies
 */
export declare function analyzeDependencies(calls: ToolCall[]): Map<string, string[]>;
/**
 * Group tool calls into execution levels based on dependencies
 */
export declare function groupByDependency(calls: ToolCall[]): ExecutionGroup[];
/**
 * Parallel executor class
 */
export declare class ParallelExecutor extends EventEmitter {
    private options;
    private executor;
    private activeCount;
    private results;
    constructor(executor: ToolExecutor, options?: Partial<ExecutionOptions>);
    /**
     * Execute tool calls with optimal parallelism
     */
    execute(calls: ToolCall[]): Promise<ToolResult[]>;
    /**
     * Execute a group of independent calls in parallel
     */
    private executeGroup;
    /**
     * Execute a single tool call with retry and timeout
     */
    private executeCall;
    /**
     * Execute with timeout
     */
    private executeWithTimeout;
    /**
     * Delay helper
     */
    private delay;
    /**
     * Get execution statistics
     */
    getStats(): {
        totalDuration: number;
        parallelSavings: number;
        successRate: number;
    };
    /**
     * Update options
     */
    updateOptions(options: Partial<ExecutionOptions>): void;
}
/**
 * Estimate parallel execution speedup
 */
export declare function estimateSpeedup(calls: ToolCall[]): {
    sequentialEstimate: number;
    parallelEstimate: number;
    speedupFactor: number;
};
/**
 * Create a simple parallel executor for common use cases
 */
export declare function createParallelExecutor(executor: ToolExecutor, options?: Partial<ExecutionOptions>): ParallelExecutor;
declare const _default: {
    ParallelExecutor: typeof ParallelExecutor;
    groupByDependency: typeof groupByDependency;
    analyzeDependencies: typeof analyzeDependencies;
    estimateSpeedup: typeof estimateSpeedup;
    createParallelExecutor: typeof createParallelExecutor;
    DEFAULT_EXECUTION_OPTIONS: ExecutionOptions;
};
export default _default;
