/**
 * Reads the codex CLI's `/status`-equivalent rate-limit usage from the
 * on-disk rollout JSONL stream — WITHOUT the interactive TUI.
 *
 * Codex has no public usage endpoint (the UsageMeterProvider falls back to
 * local token accounting and reports isAuthoritative()=false). But the codex
 * CLI DOES persist the authoritative account rate-limit windows it gets back
 * from OpenAI: every turn it appends a `token_count` event to the session
 * rollout whose `payload.rate_limits` carries the same primary (5h) /
 * secondary (weekly) windows the TUI's `/status` shows:
 *
 *   { "type": "event_msg",
 *     "payload": {
 *       "type": "token_count",
 *       "rate_limits": {
 *         "limit_id": "codex",
 *         "primary":   { "used_percent": 13, "window_minutes": 300,   "resets_at": 1780171524 },
 *         "secondary": { "used_percent": 93, "window_minutes": 10080, "resets_at": 1780174809 },
 *         "plan_type": "prolite",
 *         "rate_limit_reached_type": null } } }
 *
 * This reader finds the newest rollout(s), reads only the tail (rate-limit
 * events are appended per-turn, so the freshest is near the end), and returns
 * the most recent snapshot. It is read-only and never mutates any session
 * state — the same discipline as the rest of the codex observability layer.
 *
 * RULE 3.1 RATIONALE
 *   Criticality: high (cost-routing / model-swap input)
 *   Frequency:   per-poll / on-demand (route hit)
 *   Stability:   semi-stable (codex rollout layout changes occasionally —
 *                shared with sessionPaths, covered by codexSessionLayoutCanary)
 *   Fallback:    return null when no rollout / no token_count event is found
 *   Verdict:     deterministic tail-scan; canary covers the layout
 */
/** A single rate-limit window (5h primary or weekly secondary). */
export interface CodexRateWindow {
    /** Percent of the window's budget consumed (0-100). */
    usedPercent: number;
    /** Convenience: 100 - usedPercent, clamped to [0, 100]. */
    remainingPercent: number;
    /** Window length in minutes (300 = 5h, 10080 = weekly). */
    windowMinutes: number;
    /** Absolute reset time, unix epoch seconds (as codex reports it). */
    resetsAt: number;
    /** Derived ISO-8601 of `resetsAt`, or null if `resetsAt` is missing/invalid. */
    resetsAtIso: string | null;
    /** Seconds until reset relative to the provided clock, or null when no clock. */
    resetsInSeconds: number | null;
}
/** A point-in-time snapshot of codex account rate-limit usage. */
export interface CodexUsageSnapshot {
    source: 'codex-rollout';
    /** The rollout file the snapshot was read from. */
    rolloutPath: string;
    /** Thread UUID parsed from the rollout filename, or null. */
    threadId: string | null;
    /** Timestamp of the token_count event the snapshot came from (ISO), or null. */
    capturedAt: string | null;
    /** Model in effect at capture (best-effort from the latest turn_context), or null. */
    model: string | null;
    /** Plan tier codex reports (e.g. "plus", "prolite"), or null. */
    planType: string | null;
    /**
     * Which window (if any) is currently exhausted. codex sets this to e.g.
     * "primary" / "secondary" when a limit is hit; null when usage is fine.
     * This is the authoritative "we are rate-limited" signal.
     */
    rateLimitReachedType: string | null;
    /** The 5h rolling window (window_minutes 300), or null if absent. */
    primary: CodexRateWindow | null;
    /** The weekly rolling window (window_minutes 10080), or null if absent. */
    secondary: CodexRateWindow | null;
}
export interface ReadCodexUsageOptions {
    /** Override $CODEX_HOME (defaults to ~/.codex). */
    codexHome?: string;
    /** Clock for deriving `resetsInSeconds` (defaults to Date.now()). */
    nowMs?: number;
    /** How many newest rollouts to scan for a token_count event (default 8). */
    maxRolloutsScanned?: number;
    /** Tail size to read from each rollout (default 512 KiB). */
    tailBytes?: number;
}
/**
 * Read the freshest codex rate-limit snapshot from disk. Returns null when
 * there is no codex rollout with a rate-limit-bearing token_count event
 * (e.g. a pure-Claude agent, or a session that has not completed a turn yet).
 */
export declare function readLatestCodexUsage(opts?: ReadCodexUsageOptions): Promise<CodexUsageSnapshot | null>;
/**
 * Parse the freshest rate-limit snapshot out of a rollout tail. Exported for
 * unit tests so they can exercise the parser without touching disk.
 */
export declare function parseUsageFromTail(tail: string, rolloutPath: string, nowMs: number): CodexUsageSnapshot | null;
//# sourceMappingURL=codexRateLimitReader.d.ts.map