/** * ContextBudget tracks token consumption within a single Claude turn. * * Each Claude invocation starts fresh with the full context window available. * This class tracks accumulated token usage and decides when content should * be externalized to prevent context overflow. */ /** * Estimate token count from content using whitespace-based approximation. * Multiplies word count by 1.3 to account for subword tokenization. */ export declare function estimateTokens(content: string): number; /** * Configuration options for ContextBudget. */ export interface ContextBudgetConfig { /** Total context limit in tokens (default: 300,000) */ contextLimit?: number; /** Threshold fraction for externalization (default: 0.75) */ threshold?: number; /** Tokens reserved for response (default: 10,000) */ reservedForResponse?: number; } /** * ContextBudget manages token allocation within a single turn. * * Usage: * ``` * const budget = new ContextBudget(); * budget.consume(estimateTokens(userMessage)); * * // For each tool result: * const tokens = estimateTokens(toolResult); * if (budget.wouldExceed(tokens)) { * // Externalize the content * } else { * budget.consume(tokens); * } * * // After turn completes: * budget.reset(); * ``` */ export declare class ContextBudget { private consumed; private readonly limit; private readonly contextLimit; private readonly threshold; constructor(config?: ContextBudgetConfig); /** * Check if adding new content would exceed the budget. * @param tokens - Token count of the new content * @returns true if content should be externalized */ wouldExceed(tokens: number): boolean; /** * Record token consumption. Call after content passes through to context. * @param tokens - Token count consumed */ consume(tokens: number): void; /** * Reset budget for a new turn. Call after Claude responds. */ reset(): void; /** * Get current consumption stats. */ getStats(): { consumed: number; limit: number; remaining: number; utilizationPercent: number; }; /** * Get the effective token limit for this budget. */ getLimit(): number; /** * Get current consumed tokens. */ getConsumed(): number; } //# sourceMappingURL=context-budget.d.ts.map