claude-usage-widget/src/types.ts

71 lines
1.6 KiB
TypeScript

// Mirrors the Rust serde structs in src-tauri/src/{usage,settings,paths}.rs.
// Keep in lockstep — if you rename a field on one side, rename it here too.
export type ModelFamily = "opus" | "sonnet" | "haiku" | "other";
export interface ModelBreakdown {
opus: number;
sonnet: number;
haiku: number;
other: number;
}
export interface BlockSummary {
block_start: string; // ISO 8601
block_end: string;
now: string;
seconds_remaining: number;
total_tokens: number;
by_family: ModelBreakdown;
message_count: number;
}
export interface DayBucket {
date_local: string; // YYYY-MM-DD
total_tokens: number;
}
export interface WeeklySummary {
window_start: string;
window_end: string;
total_tokens: number;
by_day: DayBucket[]; // length 7, oldest-first
by_family: ModelBreakdown;
}
export interface Caps {
block_tokens: number;
weekly_tokens: number;
}
export interface UsageSnapshot {
block: BlockSummary | null;
weekly: WeeklySummary;
caps: Caps;
generated_at: string;
}
export interface Settings {
caps: Caps;
wsl_distro_override: string | null;
include_native: boolean;
window_pos: [number, number] | null;
autostart: boolean;
}
export interface ResolvedRoots {
roots: string[];
wsl_distro: string | null;
native_present: boolean;
}
// Mirrors PlanTier in src-tauri/src/tier.rs. The Rust enum is serde-tagged
// externally, so the wire shape is `"Max5x"` for unit variants and
// `{ MaxOther: "raw-string" }` for tuple variants — we just keep it as
// `unknown` here and rely on `label` for display.
export interface TierInfo {
tier: unknown;
label: string;
recommended_caps: Caps;
searched: string[];
}