mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 01:21:43 +00:00
Adds our own OAuth login and token refresh flow, independent of Claude Code CLI. Mirrors the PKCE flow used by pi-ai (clawdbot) and OpenCode: - run_hermes_oauth_login(): full PKCE authorization code flow - Opens browser to claude.ai/oauth/authorize - User pastes code#state back - Exchanges for access + refresh tokens - Stores in ~/.hermes/.anthropic_oauth.json (our own file) - Also writes to ~/.claude/.credentials.json for backward compat - refresh_hermes_oauth_token(): automatic token refresh - POST to console.anthropic.com/v1/oauth/token with refresh_token - Updates both credential files on success - Credential resolution priority updated: 1. ANTHROPIC_TOKEN env var 2. CLAUDE_CODE_OAUTH_TOKEN env var 3. Hermes OAuth credentials (~/.hermes/.anthropic_oauth.json) ← NEW 4. Claude Code credentials (~/.claude/.credentials.json) 5. ANTHROPIC_API_KEY env var Uses same CLIENT_ID, endpoints, scopes, and PKCE parameters as Claude Code / OpenCode / pi-ai. Token refresh happens automatically before each API call via _try_refresh_anthropic_client_credentials. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| anthropic_adapter.py | ||
| auxiliary_client.py | ||
| context_compressor.py | ||
| display.py | ||
| insights.py | ||
| model_metadata.py | ||
| prompt_builder.py | ||
| prompt_caching.py | ||
| redact.py | ||
| skill_commands.py | ||
| smart_model_routing.py | ||
| trajectory.py | ||
| usage_pricing.py | ||