/** * Budget guard: enforces turn count and cost limits during the agentic loop. * * Monitors turn_end events for turn counting and cost accumulation. * On breach, calls the provided abort function to stop the loop. * Defaults to Infinity for both limits (no enforcement unless configured). * * Counters reset on agent_start (beginning of each agentic loop). * * Reference: cortex-architecture.md (Budget Guards section) */ import type { BudgetGuardConfig, CortexLogger } from './types.js'; import type { EventBridge } from './event-bridge.js'; export declare class BudgetGuard { private readonly maxTurns; private readonly maxCost; private readonly abortFn; private readonly logger; private turnCount; private totalCost; private breached; private unsubscribers; /** * Create a BudgetGuard. * * @param config - Budget limits (maxTurns, maxCost). Both default to Infinity. * @param abortFn - Function to call when a limit is breached (typically agent.abort()) * @param logger - Optional logger for diagnostics (defaults to silent no-op) */ constructor(config: Partial, abortFn: () => void, logger?: CortexLogger); /** * Wire the guard to an event bridge. * Subscribes to turn_end (for turn counting and cost) and loop_start (for reset). * * @param bridge - The EventBridge to subscribe to */ wire(bridge: EventBridge): void; /** * Disconnect from the event bridge. */ unwire(): void; /** * Get the current turn count. */ getTurnCount(): number; /** * Get the accumulated cost. */ getTotalCost(): number; /** * Get the maximum turn limit. */ getMaxTurns(): number; /** * Get the maximum cost limit. */ getMaxCost(): number; /** * Whether any limit has been breached. */ isBreached(): boolean; /** * Reset counters. Called automatically on loop_start. */ reset(): void; /** * Clean up all subscriptions. */ destroy(): void; /** * Check if any limits have been exceeded and abort if so. */ private checkLimits; } //# sourceMappingURL=budget-guard.d.ts.map