Combined app used by tests and the single-port fallback mode.
Includes both proxy routes and management routes (/health, /status, /use)
sharing a single AppState so state changes are visible across all routes.
For any account with no rate-limit data yet, make a cheap request directly
to the upstream API so we populate metrics without waiting for a real user
request. Runs as a background task after startup.
Runs as a background task. Every 2 minutes, tries to refresh tokens for any
auth_failed account. If refresh succeeds the account is brought back online
without a process restart. If all accounts remain unrecoverable, fires a
macOS notification (at most once per hour).