$ show kristianvast/hermes-claude-auth
hermes-claude-auth is a runtime patching tool that enables hermes-agent to use Claude Code subscription credentials by bypassing Anthropic's server-side OAuth validation. It works through a Python import hook that monkey-patches hermes-agent's anthropic adapter to modify outgoing API requests with proper billing headers, system prompt restructuring, and Claude Code fingerprint matching. The tool consists of three main components: the core bypass logic (anthropic_billing_bypass.py) that implements complex request transformation, an import hook mechanism (sitecustomize_hook.py) for runtime patching, and installation/uninstallation scripts. The bypass handles billing header signing, system prompt relocation, tool name namespacing, Stainless header spoofing, tool pair repair, effort stripping for haiku models, temperature fixing for Opus 4.6, and account metadata mapping. It's designed to be idempotent and tracks upstream changes from the opencode-claude-auth project.
The LLM identified 2 files worth highlighting for reuse:
The core bypass implementation that transforms hermes-agent's API requests to match Claude Code's fingerprint. It implements billing header signing using SHA-256 with Anthropic's salt, system prompt relocation moving non-identity entries to first user message, tool name rewriting to match MCP namespacing expectations, Stainless SDK header spoofing, orphaned tool pair repair, effort stripping for haiku models, temperature fixing for Opus 4.6 adaptive thinking, and account metadata mapping. Each feature is isolated, well-documented, and demonstrates deep understanding of Anthropic's API validation mechanisms. The module is highly reusable for similar API request modification tasks with minimal adaptation.
A clean, reusable import hook mechanism that uses Python's MetaPathFinder to intercept specific module imports and apply patches at runtime. It safely patches the target module's loader to apply modifications after the module loads but before it's used, ensuring the bypass is active for all subsequent requests. The implementation handles recursion avoidance, proper error handling, and follows Python's import system best practices. This pattern is broadly applicable to any runtime patching scenario and could be extracted with minimal changes to target different modules or apply different patches.