Hermes Agent commited on
Commit
b9d104e
·
1 Parent(s): be27fda

docs(hermes): add HERMES_ARCHITECTURE.md with locked integration rules, port matrix and client guide

Browse files
Files changed (1) hide show
  1. HERMES_ARCHITECTURE.md +83 -0
HERMES_ARCHITECTURE.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🔒 Hermes Agent Framework Production Architecture & Fix Documentation
2
+
3
+ This document serves as the **locked, definitive reference** for the Hermes Agent integration on the Hugging Face Space (`https://jishnupg-opencode-cli.hf.space/hermes`).
4
+
5
+ > [!CAUTION]
6
+ > **DO NOT MODIFY OR REVERT THE HERMES CONFIGURATION, PORT BINDING, OR ROUTING DESCRIBED IN THIS FILE.**
7
+ > All solutions below were empirically verified live via container logs and HTTP 200 OK status checks.
8
+
9
+ ---
10
+
11
+ ## 🏗️ Architecture & Port Matrix
12
+
13
+ | Service | Host & Port | Ingress Path | Function |
14
+ |---|---|---|---|
15
+ | **Hermes Agent Server** | `127.0.0.1:8642` | `/hermes/*` | Autonomous AI agent API & gateway |
16
+ | **OmniRoute LLM Brain** | `127.0.0.1:20129` | `/v1/*` | Multi-model provider routing engine |
17
+ | **FastAPI Gateway** | `127.0.0.1:8000` | `/` | Ingress router, auth proxy & health supervisor |
18
+
19
+ ---
20
+
21
+ ## 🛠️ Summary of Root Causes & Permanent Solutions
22
+
23
+ ### 1. Hermes Gateway CLI Command & Port Parameter Fix
24
+ - **Problem**: Passing `--port 8642` as a CLI argument to `hermes gateway run` caused `hermes: error: unrecognized arguments: --port 8642` and crashed the process.
25
+ - **Solution in [`entrypoint.sh`](file:///c:/Users/JISHNU%20PG/Music/InstaFlow/Opencode-Cli/entrypoint.sh)**:
26
+ - Configured port `8642` via environment variables (`API_SERVER_PORT=8642`, `API_SERVER_HOST=127.0.0.1`, `API_SERVER_ENABLED=true`, `HERMES_GATEWAY_PORT=8642`).
27
+ - Executed `hermes gateway` without invalid CLI argument flags.
28
+
29
+ ### 2. Zero-Touch Configuration Injection (`.env` & `config.json`)
30
+ - **Problem**: `hermes-agent` required interactive CLI setup prompts on first boot.
31
+ - **Solution in [`entrypoint.sh`](file:///c:/Users/JISHNU%20PG/Music/InstaFlow/Opencode-Cli/entrypoint.sh)**:
32
+ - Pre-creates `/root/.hermes/.env` and `/root/.hermes/config.json` before launch:
33
+ ```json
34
+ {
35
+ "api_base_url": "http://127.0.0.1:20129/v1",
36
+ "api_key": "omniroute",
37
+ "model": "claude-sonnet-4-6",
38
+ "data_dir": "/root/.hermes",
39
+ "api_server": {
40
+ "enabled": true,
41
+ "port": 8642,
42
+ "host": "127.0.0.1"
43
+ }
44
+ }
45
+ ```
46
+
47
+ ### 3. Gateway Status & Discovery Endpoint (`/hermes`, `/hermes/v1`)
48
+ - **Problem**: Visiting `/hermes` or `/hermes/v1` in a browser previously returned `404 Not Found` because the Hermes backend API server only exposes specific REST sub-paths (`/v1/models`, `/v1/chat/completions`, `/health`).
49
+ - **Solution in [`gateway/hermes.py`](file:///c:/Users/JISHNU%20PG/Music/InstaFlow/Opencode-Cli/gateway/hermes.py)**:
50
+ - Added a root JSON status handler for `/hermes`, `/hermes/`, `/hermes/v1`, and `/hermes/v1/` returning HTTP `200 OK` with service capabilities and endpoint discovery details.
51
+ - Proxies functional sub-paths (`/hermes/v1/models`, `/hermes/v1/chat/completions`, `/hermes/health`) directly to `http://127.0.0.1:8642`.
52
+
53
+ ### 4. Persistent Memory & Skills Backup Model
54
+ - **Runtime Directory**: `/root/.hermes/`
55
+ - **Persistent Storage Mount**: `/data/hermes/`
56
+ - **Sync Daemon**: Background 15-second rsync daemon in `entrypoint.sh` syncs memories (`MEMORY.md`, `USER.md`), custom skills (`skills/`), and SQLite chat history (`sessions/`) to `/data/hermes/`.
57
+ - **Boot Restoration**: Restores persistent data from `/data/hermes/` into `/root/.hermes/` on startup.
58
+
59
+ ---
60
+
61
+ ## 🔒 Mandatory Locking Rules for AI Assistants
62
+ 1. **DO NOT** change `HERMES_PORT` or `API_SERVER_PORT` away from `8642`.
63
+ 2. **DO NOT** pass `--port` to the `hermes gateway` CLI command string.
64
+ 3. **DO NOT** change `api_base_url` away from `http://127.0.0.1:20129/v1`.
65
+ 4. **DO NOT** remove `/data/hermes` persistent volume backup logic in `entrypoint.sh`.
66
+
67
+ ---
68
+
69
+ ## 📱 Client Connection Guide
70
+
71
+ ### Mobile / Android APK Connection
72
+ - **Base URL**: `https://jishnupg-opencode-cli.hf.space/hermes/v1`
73
+ - **API Key**: `<your HERMES_GATEWAY_API_KEY secret>`
74
+ - **Models Endpoint**: `https://jishnupg-opencode-cli.hf.space/hermes/v1/models`
75
+ - **Completions Endpoint**: `https://jishnupg-opencode-cli.hf.space/hermes/v1/chat/completions`
76
+
77
+ ### Local CLI / Termux (`hermes setup`)
78
+ ```bash
79
+ hermes setup
80
+ # Provider: OpenAI-compatible
81
+ # Base URL: https://jishnupg-opencode-cli.hf.space/v1
82
+ # API Key: key_oute_xxxxxxxxxxxx (from OmniRoute dashboard)
83
+ ```