/**
 * Tool Dependency Graph Module
 *
 * Manages tool dependencies and execution ordering for smart parallelization.
 * Enables safe parallel execution of tools by analyzing:
 * - Tool output/input dependencies
 * - Resource conflicts (files, directories)
 * - Side effects and state modifications
 *
 * @module agent/execution
 */
import { CodeBuddyToolCall } from "../../codebuddy/client.js";
/**
 * Resource type that a tool can access
 */
export type ResourceType = "file" | "directory" | "network" | "process" | "state";
/**
 * Access mode for a resource
 */
export type AccessMode = "read" | "write" | "execute";
/**
 * Resource access declaration
 */
export interface ResourceAccess {
    /** Type of resource being accessed */
    type: ResourceType;
    /** Resource identifier (file path, URL, etc.) */
    identifier: string;
    /** Access mode */
    mode: AccessMode;
}
/**
 * Tool metadata for dependency analysis
 */
export interface ToolMetadata {
    /** Tool name */
    name: string;
    /** Resources this tool reads */
    reads: ResourceType[];
    /** Resources this tool writes */
    writes: ResourceType[];
    /** Whether the tool has side effects */
    hasSideEffects: boolean;
    /** Tools that must run before this one */
    dependsOn: string[];
    /** Whether the tool is safe for parallel execution */
    parallelSafe: boolean;
    /** Priority for execution ordering (higher = earlier) */
    priority: number;
}
/**
 * Default tool metadata definitions
 */
export declare const TOOL_METADATA: Record<string, Partial<ToolMetadata>>;
/**
 * Node in the dependency graph
 */
export interface GraphNode {
    /** Tool call ID */
    id: string;
    /** Tool name */
    toolName: string;
    /** Tool call data */
    toolCall: CodeBuddyToolCall;
    /** Resources accessed by this tool */
    resources: ResourceAccess[];
    /** Dependencies (must execute before this) */
    dependencies: Set<string>;
    /** Dependents (execute after this) */
    dependents: Set<string>;
    /** Execution level (for parallel scheduling) */
    level: number;
}
/**
 * Execution plan with parallel batches
 */
export interface ExecutionPlan {
    /** Batches of tool calls that can run in parallel */
    batches: CodeBuddyToolCall[][];
    /** Total number of levels */
    levels: number;
    /** Whether any parallelization was possible */
    parallelized: boolean;
    /** Explanation of the plan */
    explanation: string;
}
/**
 * ToolDependencyGraph - Analyzes and manages tool execution dependencies
 *
 * @example
 * ```typescript
 * const graph = new ToolDependencyGraph();
 * const plan = graph.buildExecutionPlan(toolCalls);
 *
 * for (const batch of plan.batches) {
 *   // Execute tools in batch in parallel
 *   await Promise.all(batch.map(tc => executeTool(tc)));
 * }
 * ```
 */
export declare class ToolDependencyGraph {
    private nodes;
    private customMetadata;
    /**
     * Register custom tool metadata
     */
    registerToolMetadata(toolName: string, metadata: Partial<ToolMetadata>): void;
    /**
     * Get metadata for a tool
     */
    getToolMetadata(toolName: string): ToolMetadata;
    /**
     * Extract resources accessed by a tool call
     */
    extractResources(toolCall: CodeBuddyToolCall): ResourceAccess[];
    /**
     * Extract resources from a bash command (best effort)
     */
    private extractBashResources;
    /**
     * Check if two tool calls have a resource conflict
     */
    hasResourceConflict(resources1: ResourceAccess[], resources2: ResourceAccess[]): boolean;
    /**
     * Build dependency graph from tool calls
     */
    buildGraph(toolCalls: CodeBuddyToolCall[]): Map<string, GraphNode>;
    /**
     * Calculate execution levels using topological sort
     */
    private calculateLevels;
    /**
     * Build an execution plan with parallel batches
     */
    buildExecutionPlan(toolCalls: CodeBuddyToolCall[]): ExecutionPlan;
    /**
     * Check if a specific pair of tools can run in parallel
     */
    canRunInParallel(toolCall1: CodeBuddyToolCall, toolCall2: CodeBuddyToolCall): boolean;
    /**
     * Get a visualization of the dependency graph
     */
    visualize(): string;
    /**
     * Clear the graph
     */
    clear(): void;
}
/**
 * Create a new ToolDependencyGraph instance
 */
export declare function createToolDependencyGraph(): ToolDependencyGraph;
/**
 * Get global ToolDependencyGraph instance
 */
export declare function getToolDependencyGraph(): ToolDependencyGraph;
/**
 * Reset global ToolDependencyGraph
 */
export declare function resetToolDependencyGraph(): void;
