/** * Budget Guard - Global safety limit for persistent mode hooks * * Provides a cross-mode safety net that prevents runaway token consumption * by tracking total stop-blocks per session and enforcing global limits. * * This works as a "last resort" — individual mode limits (Ralph max_iterations, * Ultrawork max_reinforcements, etc.) should normally trigger first. * The Budget Guard catches edge cases where multiple modes interact or * individual limits are misconfigured. */ export interface BudgetGuardConfig { /** Maximum number of stop-blocks per session (default: 100) */ maxStopBlocksPerSession: number; /** Minimum interval between stop-blocks in ms (default: 3000) */ minBlockIntervalMs: number; /** Maximum estimated tokens injected via hook messages per session (default: 100_000) */ maxEstimatedTokensPerSession: number; } export interface BudgetGuardState { /** Session ID this state is bound to */ session_id: string; /** Total number of stop-blocks issued this session */ total_blocks: number; /** Estimated total tokens injected via hook messages */ estimated_tokens_injected: number; /** Timestamp of last stop-block */ last_block_at: string; /** When tracking started */ started_at: string; /** Whether the budget has been exceeded (sticky flag) */ budget_exceeded: boolean; } export declare const DEFAULT_BUDGET_CONFIG: BudgetGuardConfig; export interface BudgetCheckResult { /** Whether the budget is exceeded */ exceeded: boolean; /** Human-readable reason if exceeded */ reason?: string; /** Whether to apply rate-limiting (too frequent blocks) */ rateLimited: boolean; /** Current usage stats */ stats: { totalBlocks: number; maxBlocks: number; estimatedTokens: number; maxTokens: number; }; } /** * Check if a stop-block should be allowed based on budget constraints. * Call this BEFORE executing any persistent mode's block logic. * * @param directory - Project working directory * @param sessionId - Current session ID * @param messageLength - Length of the message that would be injected (in chars) * @param config - Optional custom budget configuration */ export declare function checkBudget(directory: string, sessionId: string, messageLength?: number, config?: BudgetGuardConfig): BudgetCheckResult; /** * Reset budget guard state (called on /sk-claudecode:cancel) */ export declare function resetBudgetGuard(directory: string): void; //# sourceMappingURL=budget-guard.d.ts.map