feat(worker): add OAuth usage client + poller
Adds Usage/ with ClaudeOAuthUsageClient (reads the access token Claude Code keeps fresh at ~/.claude/.credentials.json, calls the Anthropic OAuth usage endpoint, defensively parses buckets/limits), UsageState (threadsafe last-good-snapshot holder that never regresses on failure), and UsageMonitorService (BackgroundService polling on the new usage_poll_interval_seconds config, min 15s, one poll at startup, warns at most once per distinct error).
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
namespace ClaudeDo.Worker.Usage;
|
||||
|
||||
public sealed record UsageBucket(double Utilization, DateTimeOffset? ResetsAt);
|
||||
|
||||
public sealed record UsageLimitRow(
|
||||
string Kind,
|
||||
string Group,
|
||||
double Percent,
|
||||
string Severity,
|
||||
DateTimeOffset? ResetsAt,
|
||||
string? ScopeModelDisplayName,
|
||||
bool IsActive);
|
||||
|
||||
public sealed record UsageSnapshot(
|
||||
UsageBucket? FiveHour,
|
||||
UsageBucket? SevenDay,
|
||||
IReadOnlyList<UsageLimitRow> Limits,
|
||||
DateTime FetchedAtUtc);
|
||||
Reference in New Issue
Block a user