/** * Request Limiter - Controls agent request rate per turn * * Prevents agent from making too many LLM calls in a single turn by: * - Counting requests per session/turn * - Enforcing configurable limits * - Providing graceful degradation when limits are reached */ export interface RequestLimiterConfig { maxRequestsPerTurn: number; warnThreshold: number; softLimit: boolean; } export interface RequestLimitResult { allowed: boolean; count: number; remaining: number; limit: number; isWarning: boolean; shouldStop: boolean; } export declare class RequestLimiter { private requestCount; private config; private turnStartTime; /** Avoid spamming logs: `recordRequest` runs every LLM round while above the warn threshold. */ private approachWarningLogged; private limitReachedLogged; constructor(config?: Partial); /** * Record a request and check if it's allowed */ recordRequest(): RequestLimitResult; /** * Check current request status without recording */ getStatus(): RequestLimitResult; /** * Get current request count */ getCount(): number; /** * Get remaining requests */ getRemaining(): number; /** * Check if limit is reached */ isLimitReached(): boolean; /** * Check if approaching limit (warning threshold) */ isApproachingLimit(): boolean; /** * Get usage percentage */ getUsagePercent(): number; /** * Get warning message for agent */ getWarningMessage(): string | null; /** * Reset counter (called at end of turn) */ reset(): void; /** * Manually adjust count (for testing or special cases) */ setCount(count: number): void; /** * Get turn duration in milliseconds */ getTurnDuration(): number; /** * Get stats for reporting */ getStats(): { count: number; limit: number; remaining: number; usagePercent: number; turnDurationMs: number; isWarning: boolean; isLimitReached: boolean; }; }