Skip to content

akrypel/anthropic-cloaked-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anthropic Cloaked Proxy for Hermes

Bypass Anthropic's "extra usage" subscription gate on Max/Pro plans by running Hermes Agent through a Claude Code OAuth fingerprint. Uses a two-proxy chain so personality, skills, and tools all work natively.

Hermes → Soul Proxy (:8319) → Cloaked Proxy (:8318) → Anthropic API
         injects SOUL.md          tool mapping (28→14)
         + skills list            CC fingerprint cloak
         + memory context         OAuth auth

Why two proxies

  • Anthropic fingerprints the system prompt — must stay under ~150 chars
  • Personality injection has to happen in the first user message
  • Soul proxy handles persona + context injection
  • Cloaked proxy handles tool mapping + fingerprint cloaking + OAuth headers

Install Claude Code

⚠️ Use the official install script, not npm:

curl -fsSL https://claude.ai/install.sh | bash

Then log in (browser flow):

claude login

Deploy proxies

Copy the three files to your Hermes host:

scp cloaked-proxy.py soul-proxy.py start_both.sh nick@your-host:/home/nick/

Start both:

bash ~/start_both.sh

Point Hermes at the soul proxy:

hermes config set model.provider anthropic
hermes config set model.default claude-opus-4-7
hermes config set model.base_url "http://127.0.0.1:8319"
hermes config set model.api_key "sk-dummy"

Test

# Personality check
hermes chat -q "Without using any tools or skills, what can you see are available from your system prompt."

# Tool execution check
hermes chat -q "ls /home/nick/ | head -3"

Files

File Purpose
cloaked-proxy.py Tool mapping + Anthropic fingerprint cloak + OAuth headers
soul-proxy.py SOUL.md injection + skills list + gateway dynamic context
start_both.sh Restart script (kill old, start cloaked, start soul, verify)

Architecture

Soul Proxy (port 8319)

Reads ~/.hermes/SOUL.md from disk on startup. On each request:

  1. Captures gateway's system prompt (contains MEMORY + USER PROFILE)
  2. Finds the SOUL.md boundary ("You live by this soul.") and extracts everything after it as dynamic context
  3. Strips verbose <available_skills> from gateway context (replaces with compact list)
  4. Injects <hermes_persona> (fresh SOUL.md) + dynamic context + compact skills list into first user message
  5. Appends behavioral directive: You are Hermes. Follow the persona above. Be caveman.
  6. Strips system prompt (cloaked proxy sets the CC one-liner)
  7. Forwards to cloaked proxy on :8318

Cloaked Proxy (port 8318)

Pure cloak — zero personality injection (soul proxy handles that).

Model context awareness

Context limits from Anthropic docs:

Model Context Max Output
claude-opus-4-7 1M 128k
claude-opus-4-6 200k 64k
claude-sonnet-4-6 1M 64k
claude-sonnet-4-20250514 200k 64k
claude-haiku-4-5-20251001 200k 64k

Unknown models default to 200k. The proxy injects _model_context and _hermes_note into API responses.

Beta Headers (required)

anthropic-beta: oauth-2025-04-20,interleaved-thinking-2025-05-14,token-counting-2024-11-01

Missing any of these breaks OAuth routing or returns incorrect usage counts.

Tool Mapping (28 Hermes → 14 CC aliases)

CC Alias Hermes Tools
Bash terminal, execute_code
Read read_file
Write write_file
Edit patch
Grep search_files
Task delegate_task
TodoWrite todo, viking_browse, viking_remember
NotebookEdit clarify
WebFetch web_extract, viking_read, viking_add_resource
WebSearch web_search, viking_search
Glob browser_* (5), vision_analyze, image_generate, text_to_speech
BashOutput process
KillShell cronjob
Skill skill_view, skill_manage, skills_list, memory, session_search, send_message, mcp_*

Reverse mapping stores TOOL_MAP = {cc_name: real_hermes_name} — tool names are swapped back in responses so the gateway executes the right tool.

Fingerprint vectors covered

  1. System prompt — exactly You are Claude Code, Anthropic's official CLI for Claude. (150 chars max)
  2. Tool count — hard cap at 14 aliases
  3. Tool descriptions — pure functional text, no brackets or qualifiers
  4. Headers — CC User-Agent, x-app: cli, anthropic-version: 2023-06-01, betas
  5. Banned output fields — thinking, temperature, top_p/k, output_config, metadata, stop_sequences, tool_choice (all stripped)
  6. Max tokens — capped at 64k (CC limit, Hermes may send 128k)
  7. Message structure — flatten arrays to plain strings
  8. Assistant prefill — drop empty assistant messages
  9. Tool result passthrough — preserve tool_result blocks in message history for multi-turn loops

What NOT to do

  • NO directive in system prompt ("Tool names are aliases" triggers editorialization)
  • NO directive in first user message ("Do not comment on tool names" gets quoted verbatim)
  • NO brackets in descriptions ([browser_navigate] draws attention)
  • NO "despite the name" qualifiers

The model may naturally note the CC/Hermes name mismatch — accept it. Routing is correct.

Systemd units (optional)

# /etc/systemd/system/hermes-cloaked-proxy.service
[Unit]
Description=Hermes Cloaked Proxy (:8318)
After=network-online.target

[Service]
Type=simple
User=nick
ExecStart=/usr/bin/python3 /home/nick/cloaked-proxy.py --port 8318
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
# /etc/systemd/system/hermes-soul-proxy.service
[Unit]
Description=Hermes Soul Proxy (:8319)
After=hermes-cloaked-proxy.service
Requires=hermes-cloaked-proxy.service

[Service]
Type=simple
User=nick
ExecStart=/usr/bin/python3 /home/nick/soul-proxy.py --port 8319
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Troubleshooting

"extra usage" or 429 errors

  • Verify both proxies: ss -tlnp | grep -E '831[89]'
  • Check Hermes base_url points to 8319 (soul): hermes config | grep base_url
  • System prompt must be exactly the CC one-liner
  • Clear rate limit after ~10-15 min of zero requests

Proxy dies after disconnect

  • Use bash ~/start_both.sh from within the VM (uses nohup)
  • Never inline SSH with & — Terminal tool blocks backgrounding

Current deployment

  • Dev: hermes-dev (10.0.30.103, PVE VM 109) — both proxies active, tested
  • Prod target: this production Hermes VM (10.0.30.149)

License

MIT — use at your own risk. Anthropic ToS may frown on this.

About

Two-proxy chain (soul + cloaked) to run Hermes Agent on Anthropic Max/Pro subscription via Claude Code OAuth

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors