/**
 * Sub-agent Token Budget EnforcerCC-aligned budget limits.
 *
 * Prevents sub-agents from consuming infinite tokens by:
 *   1. Per-task token budget (from TaskStateBase.tokenBudget)
 *   2. Session-level aggregate budget (all tasks combined)
 *   3. Budget continuation messages (CC tokenBudget.ts pattern)
 *   4. Graceful degradation (warn -> force-stop, never hard-crash)
 *
 * CC reference: utils/tokenBudget.ts, main.tsxmax-budget-usd /task-budget
 *
 * Key difference from CC: We track prompt + completion tokens (not USD).
 * CC has no explicit per-sub-agent budget; they rely on session-level maxBudgetUsd.
 * We add per-task enforcement to prevent a single sub-agent from exhausting the budget.
 */
import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
export interface BudgetConfig {
    /** Per-task token budget (prompt + completion). 0 = unlimited. */
    taskBudgetTokens: number;
    /** Session-level token budget across all tasks. 0 = unlimited. */
    sessionBudgetTokens: number;
    /** Warning threshold as percentage (0-100). Default: 80. */
    warningThresholdPct: number;
}
export interface TaskBudgetState {
    taskId: string;
    /** Token budget for this task. 0 = unlimited. */
    budgetTokens: number;
    /** Accumulated token usage for this task. */
    usage: TokenUsage;
    /** Whether a warning has been issued for this task. */
    warned: boolean;
    /** Whether this task has been force-stopped due to budget. */
    stopped: boolean;
}
export interface SessionBudgetState {
    /** Session-level budget. 0 = unlimited. */
    budgetTokens: number;
    /** Aggregate usage across ALL tasks in this session. */
    totalUsage: TokenUsage;
    /** Per-task states keyed by taskId. */
    tasks: Map<string, TaskBudgetState>;
}
export type BudgetCheckResult = {
    status: "ok";
} | {
    status: "warning";
    message: string;
    usagePct: number;
} | {
    status: "exceeded";
    message: string;
    usagePct: number;
};
/**
 * Parse a token budget from user text input.
 * CC reference: parseTokenBudget()
 *
 * Supports:
 *   - Shorthand start: "+500k", "+1.5m"
 *   - Shorthand end:   "keep working +1m."
 *   - Verbose:         "use 500k tokens", "spend 1.5M tokens"
 */
export declare function parseTokenBudget(text: string): number | null;
/**
 * Generate a budget continuation message (CC getBudgetContinuationMessage pattern).
 * Appended to the assistant context when approaching budget limits.
 */
export declare function getBudgetContinuationMessage(usagePct: number, currentTokens: number, budgetTokens: number): string;
export declare function createSessionBudgetState(config?: Partial<BudgetConfig>): SessionBudgetState;
export declare function registerTaskBudget(session: SessionBudgetState, taskId: string, budgetTokens: number): TaskBudgetState;
/**
 * Record token usage for a task and aggregate into session.
 */
export declare function recordTaskUsage(session: SessionBudgetState, taskId: string, usage: TokenUsage): void;
/**
 * Check whether a task is within its token budget.
 */
export declare function checkTaskBudget(session: SessionBudgetState, taskId: string, config?: Partial<BudgetConfig>): BudgetCheckResult;
/**
 * Get a summary of all task budgets in a session.
 */
export declare function getSessionBudgetSummary(session: SessionBudgetState): {
    sessionUsed: number;
    sessionBudget: number;
    tasks: Array<{
        taskId: string;
        used: number;
        budget: number;
        stopped: boolean;
    }>;
};
