export interface CodexAuth {
  accessToken: string;
  accountId?: string;
}

export interface CodexUsageWindow {
  usedPercent: number;
  resetsAt: number;
  windowMinutes: number;
  windowSeconds: number;
}

export interface CodexCreditsSummary {
  hasCredits: boolean;
  unlimited: boolean;
  balance: number;
}

export interface CodexResetCredit {
  index: number;
  status?: string;
  grantedAt?: string | null;
  grantedAtLocal?: string | null;
  expiresAt?: string | null;
  expiresAtLocal?: string | null;
  timeUntilExpiry?: string | null;
}

export interface CodexResetCoupons {
  source: "live_api" | "local_state_fallback" | "unavailable";
  sourceDescription: string;
  availableCount?: number | null;
  totalEarnedCount?: number | null;
  credits?: CodexResetCredit[];
  nextExpiringCredit?: CodexResetCredit | null;
  dismissedAtLocal?: string | null;
  latestPossibleExpiryLocal?: string | null;
  latestPossibleExpiryNote?: string | null;
  fallbackReason?: string;
  error?: string;
}

export interface CodexDesktopSnapshot {
  sessionFile?: string;
  threadId?: string | null;
  snapshotTimestamp?: string | null;
  limitId?: string | null;
  planType?: string | null;
  rateLimitReachedType?: string | null;
  primary: CodexUsageWindow | null;
  secondary: CodexUsageWindow | null;
}

export interface CodexUsageResponse extends CodexDesktopSnapshot {
  credits: CodexCreditsSummary;
  resetCoupons?: CodexResetCoupons | null;
}
