import { Agent } from '../core/agent'; import { RunOptions, RunResult } from '../core/types'; import { Plan, PlanTask, PlannerInterface, PlanOptions } from './planner-interface'; /** * Enhanced planner implementation that supports hierarchical planning, * parallel execution, and adaptive replanning */ export declare class EnhancedPlanner implements PlannerInterface { private logger; constructor(); /** * Creates a plan based on the selected strategy * * @param task - The complex task to plan for * @param agent - The agent creating the plan * @param options - Planning options * @returns Promise resolving to the created plan */ createPlan(task: string, agent: Agent, options?: PlanOptions): Promise; /** * Creates a sequential plan (tasks executed one after another) * * @param task - The complex task to plan for * @param agent - The agent creating the plan * @param planOptions - Planning options * @returns Promise resolving to the created plan */ private createSequentialPlan; /** * Creates a parallel plan (independent tasks can run concurrently) * * @param task - The complex task to plan for * @param agent - The agent creating the plan * @param planOptions - Planning options * @returns Promise resolving to the created plan */ private createParallelPlan; /** * Creates a hierarchical plan (tasks can have subtasks) * * @param task - The complex task to plan for * @param agent - The agent creating the plan * @param planOptions - Planning options * @returns Promise resolving to the created plan */ private createHierarchicalPlan; /** * Creates an adaptive plan (replan on failures) * * @param task - The complex task to plan for * @param agent - The agent creating the plan * @param planOptions - Planning options * @returns Promise resolving to the created plan */ private createAdaptivePlan; /** * Executes a plan using an agent * * @param plan - The plan to execute * @param agent - The agent executing the plan * @param options - The original run options * @returns Promise resolving to the execution result */ executePlan(plan: Plan, agent: Agent, options: RunOptions): Promise; /** * Executes a sequential plan * * @param plan - The plan to execute * @param agent - The agent executing the plan * @param options - The original run options * @returns Promise resolving to the execution result */ private executeSequentialPlan; /** * Executes a parallel plan * * @param plan - The plan to execute * @param agent - The agent executing the plan * @param options - The original run options * @returns Promise resolving to the execution result */ private executeParallelPlan; /** * Executes a hierarchical plan * * @param plan - The plan to execute * @param agent - The agent executing the plan * @param options - The original run options * @returns Promise resolving to the execution result */ private executeHierarchicalPlan; /** * Executes an adaptive plan with replanning on failures * * @param plan - The plan to execute * @param agent - The agent executing the plan * @param options - The original run options * @returns Promise resolving to the execution result */ private executeAdaptivePlan; /** * Executes a single task and returns its result * * @param task - The task to execute * @param agent - The agent executing the task * @param options - The run options * @returns Promise resolving to the task result */ private executeTask; /** * Updates a task's status and result * * @param plan - The plan containing the task * @param taskId - ID of the task to update * @param status - New status * @param result - Optional result from the task * @param error - Optional error message * @returns The updated plan */ updateTaskStatus(plan: Plan, taskId: string, status: PlanTask['status'], result?: string, error?: string): Plan; /** * Checks if a plan needs to be revised based on execution results * * @param plan - The current plan * @param agent - The agent executing the plan * @returns Promise resolving to a boolean indicating if replanning is needed */ shouldReplan(plan: Plan, agent: Agent): Promise; /** * Creates a revised plan based on execution results so far * * @param originalPlan - The original plan that needs revision * @param agent - The agent creating the revised plan * @returns Promise resolving to the revised plan */ replan(originalPlan: Plan, agent: Agent): Promise; /** * Generates a summary of the plan execution * * @param plan - The executed plan * @param agent - The agent that executed the plan * @param options - The original run options * @returns Promise resolving to the summary result */ private generateSummary; /** * Simple parser to extract tasks from the LLM's planning response * * @param response - The LLM's response to the planning prompt * @returns Array of task descriptions */ private parseTasksFromResponse; /** * Parses dependencies from LLM response with advanced inference * * @param response - The LLM's response about dependencies * @param tasks - The tasks to update with dependencies */ private parseDependencies; /** * Basic dependency parsing as a fallback * * @param response - The LLM's response about dependencies * @param tasks - The tasks to update with dependencies */ private parseDependenciesBasic; /** * Parses a hierarchical plan from LLM response * * @param response - The LLM's response to the hierarchical planning prompt * @returns Array of top-level tasks with subtasks */ private parseHierarchicalPlan; /** * Parses tasks from a phase's content * * @param phaseContent - The content of a phase * @param phaseId - ID of the parent phase * @param phaseNumber - Number of the phase (for task numbering) * @returns Array of tasks */ private parseTasksFromPhase; /** * Parses subtasks from a task's content * * @param taskContent - The content of a task * @param taskId - ID of the parent task * @param taskHeader - Header of the task (for subtask pattern matching) * @returns Array of subtasks */ private parseSubtasksFromTask; /** * Counts the total number of tasks in a plan (including subtasks) * * @param tasks - Array of tasks * @returns Total number of tasks */ private countTotalTasks; /** * Counts the number of completed tasks in a plan (including subtasks) * * @param tasks - Array of tasks * @returns Number of completed tasks */ private countCompletedTasks; /** * Counts the number of failed tasks in a plan (including subtasks) * * @param tasks - Array of tasks * @returns Number of failed tasks */ private countFailedTasks; /** * Estimates the completion time for a plan based on task durations * * @param tasks - Array of tasks * @param maxParallel - Maximum number of tasks to run in parallel * @returns Estimated completion time in milliseconds from now */ private estimateCompletionTime; /** * Sums the durations of all tasks (including subtasks) * * @param tasks - Array of tasks * @returns Total duration in milliseconds */ private sumTaskDurations; /** * Converts effort level to milliseconds * * @param effort - Effort level (Low/Medium/High) * @returns Duration in milliseconds */ private parseEffortToMilliseconds; /** * Formats a plan for inclusion in a prompt * * @param plan - The plan to format * @returns Formatted plan string */ private formatPlanForPrompt; /** * Formats completed tasks for inclusion in a prompt * * @param plan - The plan containing completed tasks * @returns Formatted completed tasks string */ private formatCompletedTasksForPrompt; /** * Formats failed tasks for inclusion in a prompt * * @param plan - The plan containing failed tasks * @returns Formatted failed tasks string */ private formatFailedTasksForPrompt; /** * Formats plan results for summary * * @param plan - The executed plan * @returns Formatted plan results string */ private formatPlanResultsForSummary; }