/** * GoalManager:goal-driven 自主循环(对标 wave-agent GoalManager)。 * * set goal → 每轮 incrementTurnCount → checkCircuitBreakers → evaluateGoal 判定达成。 * circuit breakers:max turns / max duration / consecutive eval failures。 * * evaluateGoal 接受 callback(用户自己提供 judge 逻辑,如用 Agent.query 让 LLM 判定)。 */ export interface GoalState { condition: string; startedAt: number; turnCount: number; tokenBaseline: number; lastReason?: string; consecutiveEvalFailures: number; } export interface GoalEvalResult { isMet: boolean; reason: string; } export type GoalEvaluator = (context: { goal: GoalState; abortSignal?: AbortSignal; }) => Promise; export interface GoalManagerOptions { maxTurns?: number; maxDurationMs?: number; maxConsecutiveEvalFailures?: number; maxConditionLength?: number; } export declare class GoalManager { private state; private readonly maxTurns; private readonly maxDurationMs; private readonly maxConsecutiveEvalFailures; private readonly maxConditionLength; constructor(options?: GoalManagerOptions); setGoal(condition: string): void; clearGoal(): void; getGoal(): GoalState | null; isGoalActive(): boolean; incrementTurnCount(): void; recordEvalFailure(): void; resetEvalFailures(): void; /** * Check circuit breakers. Returns a clear reason if goal should be force-cleared, null otherwise. */ checkCircuitBreakers(): string | null; getStatusString(): string; /** * Evaluate whether the goal has been met using the provided evaluator callback. * On success, resets consecutiveEvalFailures and updates lastReason. * On failure, increments consecutiveEvalFailures. */ evaluateGoal(evaluator: GoalEvaluator, abortSignal?: AbortSignal): Promise; private formatElapsed; }