Report CLI limit reset status
This commit is contained in:
31
README.md
31
README.md
@@ -4,31 +4,20 @@ Small Go service that publishes Claude Code and Codex CLI status to Home Assista
|
||||
|
||||
## What it reports
|
||||
|
||||
The CLIs do not expose a stable standalone "remaining quota" API. This service therefore performs a small real CLI probe and classifies the result:
|
||||
This publishes the limit/reset style status shown by the interactive CLIs:
|
||||
|
||||
- `ok`: CLI authenticated and a tiny probe completed.
|
||||
- `limited`: output matched rate/usage/quota-limit errors.
|
||||
- `auth_required`: login/auth is missing or invalid.
|
||||
- `timeout` / `error`: probe failed for another reason.
|
||||
- Claude Code: captures `/usage` in a PTY and parses current-session/current-week percent used and reset text.
|
||||
- Codex CLI: runs a tiny probe, captures `/status` in a PTY, and parses Codex's recorded `rate_limits` object for 5h/week percent used and reset timestamps.
|
||||
|
||||
It also publishes any usage object returned by the CLI probe:
|
||||
It reports:
|
||||
|
||||
- Claude: JSON result `usage` from `claude -p ... --output-format json`.
|
||||
- Codex: JSONL `usage` from `codex exec --json` turn completion.
|
||||
- `status`: `ok`, `limited`, `auth_required`, `timeout`, or `error`.
|
||||
- `primary`: short window limit, normally 5h/session, with `used_percent`, `window_minutes`, `resets_at`/`reset_text` where exposed.
|
||||
- `secondary`: weekly/all-model limit, with percent and reset data where exposed.
|
||||
- `raw_report`: cleaned slash-command output for debugging/comparison with the CLI.
|
||||
- `plan_type`: provider plan where exposed.
|
||||
|
||||
It now also reports rolling local token usage for each CLI:
|
||||
|
||||
- `session_5h.used_tokens` and `session_5h.percent_used`
|
||||
- `week.used_tokens` and `week.percent_used`
|
||||
|
||||
The percent fields are computed against env-configured token limits:
|
||||
|
||||
- `CLAUDE_SESSION_5H_TOKEN_LIMIT`
|
||||
- `CLAUDE_WEEK_TOKEN_LIMIT`
|
||||
- `CODEX_SESSION_5H_TOKEN_LIMIT`
|
||||
- `CODEX_WEEK_TOKEN_LIMIT`
|
||||
|
||||
Set a limit to `0` to publish raw used tokens without a percentage.
|
||||
Token usage is not the main signal. Any local token counters remain as optional attributes only for diagnostics/backward compatibility.
|
||||
|
||||
## MQTT topics
|
||||
|
||||
|
||||
Reference in New Issue
Block a user