[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2218":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":14,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":15,"starSnapshotCount":15,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},2218,"hermes-claude-auth","kristianvast\u002Fhermes-claude-auth","kristianvast","Claude Code OAuth bypass for hermes-agent",null,"Python",253,49,13,8,0,42,121,24,91.1,"MIT License",false,"main",true,[],"2026-06-12 04:00:13","# hermes-claude-auth\nClaude Code OAuth bypass for hermes-agent, use your Claude Code subscription (Max\u002FPro) with Hermes.\n\n## What this does\nPatches hermes-agent at runtime to pass Anthropic's server-side OAuth content validation. It does not modify hermes-agent source files. Installation happens through a Python import hook that monkey-patches `build_anthropic_kwargs` on startup.\n\n## Why this exists\nOn 2026-04-04, Anthropic added server-side validation that rejects OAuth requests from third-party tools. This patch adds the billing header signature and system prompt structure the API expects.\n\n## Prerequisites\n- hermes-agent installed (`~\u002F.hermes\u002Fhermes-agent\u002F`)\n- Claude Code CLI authenticated (valid credentials at `~\u002F.claude\u002F.credentials.json`)\n- hermes-agent configured for OAuth (`credential_pool` has a `claude_code` entry in `~\u002F.hermes\u002Fauth.json`)\n- Python 3.11+\n\n## Install\n```bash\ncurl -fsSL https:\u002F\u002Fraw.githubusercontent.com\u002Fkristianvast\u002Fhermes-claude-auth\u002Fmain\u002Finstall-remote.sh | bash\n```\n\nOr clone manually:\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fkristianvast\u002Fhermes-claude-auth.git\ncd hermes-claude-auth\n.\u002Finstall.sh\n```\n\nWhat `install.sh` does:\n- Copies `anthropic_billing_bypass.py` to `~\u002F.hermes\u002Fpatches\u002F`\n- Installs the import hook as `sitecustomize.py` in the hermes venv's site-packages\n- Restarts `hermes-gateway.service` if running\n\n## Uninstall\n```bash\n.\u002Funinstall.sh          # remove hook only\n.\u002Funinstall.sh --purge  # remove hook + patch file\n```\n\n## How it works\n1. **Billing header**: SHA-256 signed `x-anthropic-billing-header` injected as `system[0]`\n2. **System prompt relocation**: Non-identity system entries moved to the first user message as `\u003Csystem-reminder>` blocks\n3. **Beta flags**: Adds `prompt-caching-scope-2026-01-05` and `advisor-tool-2026-03-01`\n4. **Stainless SDK spoof**: Lowercase `x-stainless-*` headers + `anthropic-dangerous-direct-browser-access` + `?beta=true` query param matching real Claude Code 2.1.112\n5. **Tool name namespacing**: Hermes's `mcp_bash` is rewritten to `mcp__hermes__Bash` outbound; the response normalizer unwraps it back to `bash` so hermes's tool dispatcher resolves the registered name without auto-repair noise\n6. **Tool pair repair**: Orphaned `tool_use` \u002F `tool_result` blocks (left by long conversations or partial summaries) are stripped before signing — prevents HTTP 400 (upstream PR #136)\n7. **Haiku effort stripping**: `effort` parameter is removed for haiku models that reject it with HTTP 400 (upstream PR #126)\n8. **Temperature fix**: Strips non-default `temperature` on Opus 4.6 adaptive thinking, which otherwise rejects with HTTP 400\n9. **Account metadata**: Maps `~\u002F.claude.json::oauthAccount.accountUuid` to `metadata.user_id` (Anthropic rejected the older `account_uuid` key with HTTP 400 on 2026-04-29)\n\nInstalled through a `sitecustomize.py` MetaPathFinder hook, so it runs at interpreter startup with no source modifications.\n\n## What gets modified\n| File | Action |\n|------|--------|\n| `~\u002F.hermes\u002Fpatches\u002Fanthropic_billing_bypass.py` | Created |\n| `\u003Cvenv>\u002Flib\u002FpythonX.Y\u002Fsite-packages\u002Fsitecustomize.py` | Created or replaced |\n| hermes-agent source files | NOT modified |\n\n## Compatibility\n- Tested with hermes-agent on Python 3.11+\n- Linux and macOS\n- Depends on `build_anthropic_kwargs(is_oauth=...)` in `agent.anthropic_adapter`, so it may need updating if hermes-agent changes that interface\n\n## Troubleshooting\n\n### Install issues\n- **\"hermes-agent not found\"**: Make sure Hermes is installed at `~\u002F.hermes\u002Fhermes-agent\u002F`\n- **\"No virtualenv found\"**: Set `HERMES_VENV` to point to your venv\n- **Patch not loading**: Check `journalctl --user -u hermes-gateway -n 50` for `[anthropic_billing_bypass]` or `[hermes-claude-auth]` messages\n\n### Auth issues\n\n- **`Anthropic 401 authentication failed`** or **`No Anthropic credentials found`**: Hermes reads Claude subscription credentials from `~\u002F.claude\u002F.credentials.json`. If Claude Code is authenticated (e.g. in macOS Keychain) but that file is missing or stale, Hermes fails even when Claude Code itself works.\n\n  On macOS, `install.sh` v1.1.1+ auto-mirrors the `Claude Code-credentials` Keychain entry into `~\u002F.claude\u002F.credentials.json` on every run, so re-running the installer is usually enough. Full fix:\n\n  1. Refresh Claude subscription login:\n     ```bash\n     claude auth login --claudeai\n     ```\n  2. Re-run the installer to re-mirror credentials (macOS) and reload the patch:\n     ```bash\n     .\u002Finstall.sh\n     ```\n  3. Remove stale `ANTHROPIC_TOKEN` \u002F `ANTHROPIC_API_KEY` values from `~\u002F.hermes\u002F.env` — they can override subscription auth.\n  4. Reset cached credentials:\n     ```bash\n     hermes auth reset anthropic\n     ```\n  5. Retry with a smoke test:\n     ```bash\n     hermes chat -q 'Reply with exactly: AUTH TEST OK' --provider anthropic -m claude-sonnet-4-6 -Q\n     ```\n\n  If the auto-mirror doesn't work (e.g. your Keychain entry is under a different service name), mirror it manually:\n  ```bash\n  python3 - \u003C\u003C'PY'\n  import subprocess\n  from pathlib import Path\n\n  secret = subprocess.check_output(\n      ['security', 'find-generic-password', '-s', 'Claude Code-credentials', '-w'],\n      text=True,\n  ).strip()\n\n  cred_path = Path.home() \u002F '.claude' \u002F '.credentials.json'\n  cred_path.parent.mkdir(parents=True, exist_ok=True)\n  cred_path.write_text(secret)\n  cred_path.chmod(0o600)\n  print(f'wrote {cred_path}')\n  PY\n  ```\n\n  Credit: the macOS Keychain mirror approach was written up by [@DrQbz](https:\u002F\u002Fgithub.com\u002FDrQbz) in [issue #5](https:\u002F\u002Fgithub.com\u002Fkristianvast\u002Fhermes-claude-auth\u002Fissues\u002F5) and is now automated in `install.sh`.\n\n### Billing \u002F routing issues\n\n- **HTTP 400: \"Third-party apps now draw from your extra usage, not your plan limits\"**: Anthropic's server-side validation has classified your requests as third-party and routed them to pay-per-token credits instead of your Max\u002FPro plan. Make sure you're on the latest version of this patch (it tracks the upstream [opencode-claude-auth](https:\u002F\u002Fgithub.com\u002Fgriffinmartin\u002Fopencode-claude-auth) fingerprint changes). Reinstall with `.\u002Finstall.sh` and restart `hermes-gateway`. If the error persists after update, the bypass is currently broken upstream too — track [issue #6](https:\u002F\u002Fgithub.com\u002Fkristianvast\u002Fhermes-claude-auth\u002Fissues\u002F6) for status.\n- **HTTP 400 persists after update**: The billing salt or signature format may have been rotated by Anthropic again. Check for newer commits to this repo.\n\n## Credits\n- [griffinmartin\u002Fopencode-claude-auth](https:\u002F\u002Fgithub.com\u002Fgriffinmartin\u002Fopencode-claude-auth), the original TypeScript implementation for opencode (MIT)\n- [NousResearch\u002Fhermes-agent](https:\u002F\u002Fgithub.com\u002FNousResearch\u002Fhermes-agent), the AI agent this patches (MIT)\n\n## Disclaimer\nThis uses Claude Code subscription credentials outside the official Claude Code CLI. It works with Anthropic's current OAuth implementation but may break if Anthropic changes their validation. Use at your own risk.\n\n## License\nMIT, see [LICENSE](LICENSE).\n","hermes-claude-auth 是一个用于绕过 Anthropic 服务器端 OAuth 验证的工具，使得 hermes-agent 可以与 Claude Code 订阅（Max\u002FPro）一起使用。项目通过在运行时动态修补 hermes-agent 来实现功能，不会修改源文件，而是通过 Python 的导入钩子在启动时对 `build_anthropic_kwargs` 进行猴子补丁处理。该工具适用于需要将第三方工具与 Claude Code 服务集成但因 Anthropic 新增的安全措施而受限的情况。其核心功能包括添加必要的计费头签名、系统提示结构调整等，确保请求符合 API 期望。此外，它还支持一些高级特性如 Beta 标志添加、工具名称命名空间转换等，从而提升兼容性和稳定性。",2,"2026-06-11 02:48:55","CREATED_QUERY"]