import { Agent } from '../core/agent'; import { Tool } from '../core/types'; /** * Different types of goals an agent might have */ export declare enum GoalType { INFORMATION = "information",// Goals about finding or learning information ACTION = "action",// Goals that require taking specific actions DECISION = "decision",// Goals that require making a decision MONITORING = "monitoring",// Goals about continuously checking for conditions CREATION = "creation",// Goals about creating content or artifacts COMMUNICATION = "communication" } /** * Status of a goal's execution */ export declare enum GoalStatus { PENDING = "pending",// Not yet started IN_PROGRESS = "in_progress",// Currently being worked on COMPLETED = "completed",// Successfully completed FAILED = "failed",// Failed to achieve BLOCKED = "blocked",// Waiting on dependencies CANCELLED = "cancelled" } /** * Structure representing a goal or sub-goal */ export interface Goal { id: string; description: string; type: GoalType; status: GoalStatus; parentId?: string; successCriteria: string[]; dependencies?: string[]; priority: number; deadline?: Date; recurrence?: string; metadata?: Record; createdAt: Date; updatedAt: Date; } /** * Task derived from a goal */ export interface GoalTask { id: string; goalId: string; description: string; status: GoalStatus; toolsRequired?: string[]; estimatedDuration?: number; result?: any; error?: string; createdAt: Date; updatedAt: Date; } /** * Result of a goal execution */ export interface GoalResult { goalId: string; success: boolean; subgoalResults?: GoalResult[]; tasks: GoalTask[]; insights: string[]; nextSteps?: string[]; } /** * Configuration for the goal planner */ export interface GoalPlannerConfig { maxSubgoals?: number; maxTasksPerGoal?: number; reflectionFrequency?: number; adaptivePlanning?: boolean; defaultPriority?: number; defaultDeadlineDays?: number; } /** * A powerful system for breaking down high-level goals into manageable sub-goals * and tasks, with support for dependencies, priorities, and continuous monitoring. */ export declare class GoalPlanner { private goals; private tasks; private config; private logger; private agent?; private provider?; /** * Creates a new goal planner * * @param config - Configuration options */ constructor(config?: GoalPlannerConfig); /** * Connects the goal planner to an agent * * @param agent - The agent to connect * @returns The goal planner instance for chaining */ connectAgent(agent: Agent): GoalPlanner; /** * Creates a new main goal * * @param description - Description of the goal * @param options - Additional goal options * @returns The created goal */ createMainGoal(description: string, options?: { type?: GoalType; successCriteria?: string[]; priority?: number; deadline?: Date; recurrence?: string; metadata?: Record; }): Promise; /** * Decomposes a goal into sub-goals using LLM * * @param goalId - ID of the goal to decompose * @param availableTools - Tools available to the agent * @returns The updated goal with sub-goals */ decomposeGoal(goalId: string, availableTools?: Tool[]): Promise; /** * Parse sub-goals from LLM response * * @param response - The LLM response text * @param parentGoalId - The parent goal ID * @returns Array of created sub-goals */ private parseSubGoalsFromLLMResponse; /** * Resolve dependencies between sub-goals based on descriptions * * @param subGoals - The array of sub-goals to process */ private resolveDependenciesByDescription; /** * Generates specific tasks for a goal using LLM * * @param goalId - ID of the goal * @param availableTools - Tools available to the agent * @returns Array of tasks */ generateTasks(goalId: string, availableTools?: Tool[]): Promise; /** * Parse tasks from LLM response * * @param response - The LLM response text * @param goalId - The goal ID * @returns Array of created tasks */ private parseTasksFromLLMResponse; /** * Executes a task using the connected agent * * @param taskId - ID of the task to execute * @param availableTools - Tools that can be used * @returns The updated task with results */ executeTask(taskId: string, availableTools?: Tool[]): Promise; /** * Evaluates whether a goal has been achieved based on success criteria * * @param goalId - ID of the goal to evaluate * @returns Evaluation result */ evaluateGoalSuccess(goalId: string): Promise<{ success: boolean; reasons: string[]; }>; /** * Parse evaluation results from LLM response * * @param response - The LLM response text * @returns Parsed evaluation result */ private parseEvaluationFromLLMResponse; /** * Reflect on goal progress and adapt the plan if needed * * @param goalId - ID of the goal to reflect on * @param availableTools - Tools available to the agent * @returns Updated plan information */ reflectAndAdapt(goalId: string, availableTools?: Tool[]): Promise<{ insights: string[]; adaptations: string[]; newTasks?: GoalTask[]; }>; /** * Parse reflection results from LLM response * * @param response - The LLM response text * @param goalId - The goal ID for new tasks * @returns Parsed reflection result */ private parseReflectionFromLLMResponse; /** * Create a task object from a description * * @param description - Task description * @param goalId - Goal ID * @returns Created task object */ private createTaskFromDescription; /** * Execute a goal completely, including decomposition, task generation, execution, * and evaluation, with optional adaptation * * @param goalId - ID of the goal to execute * @param availableTools - Tools available to the agent * @param options - Execution options * @returns Complete goal execution result */ executeGoal(goalId: string, availableTools?: Tool[], options?: { maxReflections?: number; reflectAfterTaskCount?: number; stopOnFailure?: boolean; }): Promise; /** * Sort goals by dependencies and priority * * @param goals - Array of goals to sort * @returns Sorted goals */ private sortGoalsByDependenciesAndPriority; /** * Gets all goals * * @returns Array of all goals */ getGoals(): Goal[]; /** * Gets all tasks * * @returns Array of all tasks */ getTasks(): GoalTask[]; /** * Gets a goal by ID * * @param goalId - ID of the goal * @returns The goal or undefined if not found */ getGoal(goalId: string): Goal | undefined; /** * Gets a task by ID * * @param taskId - ID of the task * @returns The task or undefined if not found */ getTask(taskId: string): GoalTask | undefined; /** * Gets tasks for a goal * * @param goalId - ID of the goal * @returns Array of tasks for the goal */ getTasksForGoal(goalId: string): GoalTask[]; /** * Gets sub-goals for a goal * * @param goalId - ID of the parent goal * @returns Array of sub-goals */ getSubGoals(goalId: string): Goal[]; /** * Clears all goals and tasks */ clear(): void; }