/** * AutonomousPlanner — AI 自主决策引擎 * * 让 Agent 从「被动执行单条指令」升级为「自主规划多步任务」: * 1. 任务分解:将复杂目标拆解为执行步骤 * 2. 工具选择:自动匹配最佳工具组合 * 3. 执行循环:Plan → Act → Observe → Reflect → Re-plan * 4. 反思纠错:执行失败时自动调整策略 * 5. 记忆整合:利用向量记忆辅助决策 * * 参考: OpenClaw + AutoGPT + ReAct 模式 */ export interface TaskGoal { id: string; /** 用户原始目标 */ goal: string; /** 优先级 */ priority: "high" | "medium" | "low"; /** 约束条件 */ constraints?: string[]; /** 最大步骤数 */ maxSteps?: number; /** 超时(ms) */ timeout?: number; } export interface PlanStep { stepId: number; action: string; tool?: string; params?: Record; reasoning: string; status: "pending" | "running" | "success" | "failed" | "skipped"; result?: unknown; error?: string; durationMs?: number; } export interface ExecutionTrace { taskId: string; goal: string; startedAt: string; completedAt?: string; status: "planning" | "executing" | "reflecting" | "completed" | "failed" | "timeout"; plan: PlanStep[]; reflections: Reflection[]; finalResult?: string; totalSteps: number; successSteps: number; failedSteps: number; } export interface Reflection { afterStep: number; observation: string; analysis: string; decision: "continue" | "replan" | "abort"; newPlan?: PlanStep[]; } export interface PlannerConfig { /** 最大步骤数 */ maxSteps: number; /** 最大反思次数 */ maxReflections: number; /** 连续失败阈值 */ failureThreshold: number; /** 步骤超时 ms */ stepTimeout: number; } export declare class AutonomousPlanner { private config; /** 工具执行回调(由 AgentCore 提供) */ private executeTool?; /** LLM 调用回调(用于规划和反思) */ private callLLM?; /** 可用工具列表 */ private availableTools; /** 执行历史 */ private traces; constructor(config?: Partial); /** 设置工具执行器 */ setToolExecutor(fn: typeof this.executeTool): void; /** 设置 LLM 回调 */ setLLM(fn: typeof this.callLLM): void; /** 注册可用工具 */ registerTools(tools: Array<{ name: string; description: string; }>): void; /** * 自主执行任务 * Plan → Act → Observe → Reflect → Re-plan */ execute(goal: TaskGoal): Promise; /** * 将目标分解为执行步骤 */ planSteps(goal: TaskGoal): Promise; private planWithLLM; private planWithRules; private reflect; private summarizeResult; /** 获取执行历史 */ getTraces(limit?: number): ExecutionTrace[]; /** 获取状态 */ getStatus(): { totalTasks: number; completed: number; failed: number; avgSteps: number; }; } //# sourceMappingURL=planner.d.ts.map