somratpro commited on
Commit
0f02e7f
Β·
1 Parent(s): e69d277

feat: overhaul README documentation and add .env.example configuration template

Browse files
Files changed (2) hide show
  1. .env.example +50 -0
  2. README.md +102 -145
.env.example ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ============================================================================
2
+ # HuggingMess - Hermes Agent on Hugging Face Spaces
3
+ # Configuration Reference
4
+ # ============================================================================
5
+
6
+ # ── REQUIRED: Core Configuration ──
7
+ # Your LLM provider API key
8
+ LLM_API_KEY=your_api_key_here
9
+
10
+ # LLM model to use (e.g. google/gemini-2.0-flash, openai/gpt-4o)
11
+ LLM_MODEL=google/gemini-2.0-flash
12
+
13
+ # Bearer token for the proxied Hermes API routes and Dashboard
14
+ # Generate: openssl rand -hex 32
15
+ GATEWAY_TOKEN=your_gateway_token_here
16
+
17
+ # ── OPTIONAL: Chat Integrations ──
18
+ # Get bot token from: https://t.me/BotFather
19
+ # TELEGRAM_BOT_TOKEN=your_bot_token_here
20
+
21
+ # Allowed Telegram User IDs (comma-separated numeric IDs)
22
+ # TELEGRAM_ALLOWED_USERS=123456789,987654321
23
+
24
+ # ── OPTIONAL: Cloudflare Proxy & Keep-Alive ──
25
+ # Cloudflare API token for automatic Worker proxy and KeepAlive setup
26
+ # CLOUDFLARE_WORKERS_TOKEN=your_cloudflare_token_here
27
+
28
+ # Alternatively, manual proxy config:
29
+ # CLOUDFLARE_PROXY_URL=https://your-proxy.workers.dev
30
+ # CLOUDFLARE_PROXY_SECRET=your_proxy_secret_here
31
+
32
+ # Extra domains to proxy, comma-separated. Set to "*" to proxy all.
33
+ # CLOUDFLARE_PROXY_DOMAINS=api.sendgrid.com,slack.com
34
+
35
+ # ── OPTIONAL: Workspace Backup to HF Dataset ──
36
+ # HF token with write access for private Dataset backup
37
+ HF_TOKEN=hf_your_token_here
38
+
39
+ # Dataset name (default: huggingmess-backup)
40
+ # BACKUP_DATASET_NAME=huggingmess-backup
41
+
42
+ # Backup interval in seconds (default: 180)
43
+ SYNC_INTERVAL=180
44
+
45
+ # ── OPTIONAL: Advanced ──
46
+ # Telegram mode (webhook/polling)
47
+ TELEGRAM_MODE=webhook
48
+
49
+ # Include .env in backups (default: false)
50
+ # SYNC_INCLUDE_ENV=false
README.md CHANGED
@@ -9,204 +9,161 @@ pinned: true
9
  license: mit
10
  secrets:
11
  - name: LLM_API_KEY
12
- description: "Your LLM provider API key. HuggingMess maps it to the right Hermes provider env var."
13
  - name: LLM_MODEL
14
- description: "Optional model ID override, e.g. openrouter/anthropic/claude-sonnet-4 or anthropic/claude-opus-4.6."
 
 
15
  - name: TELEGRAM_BOT_TOKEN
16
  description: "Telegram bot token from @BotFather."
17
  - name: TELEGRAM_ALLOWED_USERS
18
- description: "Comma-separated numeric Telegram user IDs allowed to use the bot."
19
- - name: GATEWAY_TOKEN
20
- description: "Bearer token for the proxied Hermes API routes."
21
  - name: HF_TOKEN
22
- description: "Hugging Face token with write access for private Dataset backup."
23
  - name: CLOUDFLARE_WORKERS_TOKEN
24
- description: "Cloudflare API token for automatic Telegram proxy and keep-awake Worker setup."
25
  ---
26
 
27
- # HuggingMess
28
-
29
- HuggingMess runs [Nous Research Hermes Agent](https://github.com/NousResearch/hermes-agent) as a Hugging Face Docker Space. It follows the same practical shape as HuggingClaw: one public Space port, Telegram gateway support, Cloudflare Worker proxy setup, Cloudflare cron keep-awake, and private HF Dataset backup for Hermes state.
30
-
31
- ## Quick Start
32
 
33
- 1. Duplicate this Space or push this folder to a new Docker Space.
34
- 2. Add these secrets in Space Settings:
35
 
36
- | Secret | Required | Notes |
37
- | :--- | :--- | :--- |
38
- | `LLM_MODEL` | Optional | Model override. If unset, HuggingMess leaves Hermes default/restored config alone. |
39
- | `LLM_API_KEY` | Usually | Used to populate the provider-specific env var automatically |
40
- | `TELEGRAM_BOT_TOKEN` | For Telegram | Bot token from BotFather |
41
- | `TELEGRAM_ALLOWED_USERS` | Recommended | Comma-separated numeric Telegram user IDs |
42
- | `GATEWAY_TOKEN` | Recommended | Bearer token for `/v1/*` API routes |
43
- | `HF_TOKEN` | Optional | Enables private Dataset backup named `huggingmess-backup` |
44
- | `CLOUDFLARE_WORKERS_TOKEN` | Optional | Auto-creates Workers for Telegram proxy and `/health` keep-awake |
45
-
46
- ## Access Control
47
 
48
- Hermes' built-in dashboard is local-first and does not provide its own public auth layer. HuggingMess adds wrapper-level auth for the exposed Space routes.
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- Set this Space secret:
51
-
52
- ```text
53
- GATEWAY_TOKEN=your-strong-password-or-token
54
- ```
55
 
56
- Then:
 
 
 
 
 
 
57
 
58
- - Opening `/app/` shows a HuggingMess login page with one field.
59
- - Paste `GATEWAY_TOKEN` into that field.
60
- - HuggingMess stores an HTTP-only session cookie for the dashboard routes.
61
- - API routes under `/v1/*` accept `Authorization: Bearer <GATEWAY_TOKEN>`.
62
 
63
- ## LLM Providers
64
 
65
- HuggingMess supports two configuration styles:
66
 
67
- 1. **Simple wrapper style:** set `LLM_MODEL` and `LLM_API_KEY`; HuggingMess maps them into Hermes config and provider-specific API key variables.
68
- 2. **Native Hermes style:** set Hermes variables directly, such as `HERMES_MODEL`, `HERMES_INFERENCE_PROVIDER`, and the provider API key.
69
 
70
- ### Gemini
71
 
72
- For Google Gemini, add these Space secrets:
 
 
73
 
74
- | Secret | Value |
75
- | :--- | :--- |
76
- | `LLM_MODEL` | `google/gemini-2.5-flash` |
77
- | `LLM_API_KEY` | Your Google AI Studio API key |
78
 
79
- HuggingMess will convert that into Hermes config:
80
 
81
- ```yaml
82
- model:
83
- default: gemini-2.5-flash
84
- provider: gemini
85
- ```
86
 
87
- And it exports both `GOOGLE_API_KEY` and `GEMINI_API_KEY` for Hermes. You can also use `gemini/gemini-2.5-flash`; the prefix is stripped the same way.
88
 
89
- Native Hermes equivalent:
 
90
 
91
- | Secret | Value |
92
- | :--- | :--- |
93
- | `HERMES_MODEL` | `gemini-2.5-flash` |
94
- | `HERMES_INFERENCE_PROVIDER` | `gemini` |
95
- | `GOOGLE_API_KEY` or `GEMINI_API_KEY` | Your Google AI Studio API key |
96
 
97
- ### Common Examples
98
 
99
- | Provider | Simple `LLM_MODEL` | API key secret |
100
  | :--- | :--- | :--- |
101
- | Gemini | `google/gemini-2.5-flash` | `LLM_API_KEY` |
102
- | OpenRouter | `openrouter/anthropic/claude-sonnet-4` | `LLM_API_KEY` |
103
- | Anthropic | `anthropic/claude-opus-4.6` | `LLM_API_KEY` |
104
- | OpenAI | `openai/gpt-4o` | `LLM_API_KEY` |
105
- | Hugging Face Router | `huggingface/meta-llama/Llama-3.3-70B-Instruct` | `LLM_API_KEY` |
106
-
107
- ## Telegram on HF Spaces
108
-
109
- When `TELEGRAM_BOT_TOKEN` and `SPACE_HOST` are present, HuggingMess defaults Telegram to webhook mode:
110
-
111
- ```bash
112
- TELEGRAM_WEBHOOK_URL=https://your-space.hf.space/telegram
113
- TELEGRAM_WEBHOOK_PORT=8765
114
- ```
115
-
116
- If you need polling instead, set:
117
-
118
- ```bash
119
- TELEGRAM_MODE=polling
120
- ```
121
-
122
- Hermes requires numeric Telegram IDs for allowlists. You can use either Hermes-native `TELEGRAM_ALLOWED_USERS` or the HuggingClaw-style aliases `TELEGRAM_USER_ID` / `TELEGRAM_USER_IDS`.
123
-
124
- ## Cloudflare Workers
125
 
126
- Hugging Face Spaces can be restrictive for outbound bot API traffic. Add `CLOUDFLARE_WORKERS_TOKEN`, and HuggingMess will:
127
 
128
- 1. create a Telegram proxy Worker,
129
- 2. generate a shared proxy secret,
130
- 3. set Hermes Telegram `base_url` to `https://worker.example.workers.dev/bot`,
131
- 4. set `base_file_url` to `https://worker.example.workers.dev/file/bot`,
132
- 5. create a second scheduled keep-awake Worker that pings your Space `/health` route.
133
-
134
- Manual mode is also supported:
135
-
136
- ```bash
137
- CLOUDFLARE_PROXY_URL=https://your-worker.workers.dev
138
- CLOUDFLARE_PROXY_SECRET=optional-shared-secret
139
- ```
140
 
141
- The manual Worker source is included in `cloudflare-worker.js`.
 
 
142
 
143
- ### Keep Awake
144
 
145
- When `CLOUDFLARE_WORKERS_TOKEN` is present, HuggingMess creates a scheduled Worker that pings your Space's `/health` route. It automatically detects your Space hostname:
146
 
147
- ```text
148
- https://your-space.hf.space/health
149
- ```
150
 
151
- Default schedule:
152
 
153
- ```text
154
- */10 * * * *
155
- ```
156
 
157
- Optional variables:
158
 
159
- | Variable | Default | Description |
160
- | :--- | :--- | :--- |
161
- | `CLOUDFLARE_KEEPALIVE_ENABLED` | `true` | Set `false` to skip keep-awake Worker setup |
162
- | `CLOUDFLARE_KEEPALIVE_CRON` | `*/10 * * * *` | Cloudflare cron expression |
163
- | `CLOUDFLARE_KEEPALIVE_URL` | `https://<auto-detected-space-host>/health` | URL to ping |
164
- | `CLOUDFLARE_KEEPALIVE_WORKER_NAME` | derived from space host | Custom Worker name |
165
 
166
- ## Backup
167
 
168
- Set `HF_TOKEN` with write access to enable backup. HuggingMess syncs `/opt/data` to a private Dataset named `huggingmess-backup` every 180 seconds by default.
169
 
170
  | Variable | Default | Description |
171
  | :--- | :--- | :--- |
172
- | `BACKUP_DATASET_NAME` | `huggingmess-backup` | Dataset name under your HF account |
173
- | `SYNC_INTERVAL` | `180` | Backup interval in seconds |
174
- | `SYNC_INCLUDE_ENV` | `false` | Include `/opt/data/.env` in backup |
 
 
 
175
 
176
- By default `.env` is excluded from backups because HF Space secrets are already injected at runtime.
177
-
178
- ## Local Development
179
 
180
  ```bash
181
  docker compose up --build
 
 
182
  ```
183
 
184
- Then open:
185
 
186
- ```text
187
- http://localhost:7861
188
- ```
 
 
189
 
190
- ## Useful Routes
191
 
192
- | Route | Purpose |
193
- | :--- | :--- |
194
- | `/` | HuggingMess dashboard |
195
- | `/health` | Health check for HF and Cloudflare keep-awake |
196
- | `/status` | JSON status |
197
- | `/app/` | Proxied Hermes dashboard/app |
198
- | `/v1/*` | Proxied Hermes OpenAI-compatible API routes |
199
- | `/telegram` | Telegram webhook endpoint |
200
 
201
- The `/v1/*` routes require:
202
 
203
- ```text
204
- Authorization: Bearer <GATEWAY_TOKEN>
205
- ```
206
 
207
- ## Links
 
 
 
 
 
208
 
209
- - [Hermes Agent GitHub](https://github.com/NousResearch/hermes-agent)
210
- - [Hermes Agent Docs](https://hermes-agent.nousresearch.com/docs)
211
- - [Hermes Docker Docs](https://hermes-agent.nousresearch.com/docs/user-guide/docker/)
212
- - [Hermes Telegram Docs](https://hermes-agent.nousresearch.com/docs/user-guide/messaging/telegram)
 
9
  license: mit
10
  secrets:
11
  - name: LLM_API_KEY
12
+ description: "Your LLM provider API key (e.g. Anthropic, OpenAI, Google, OpenRouter)."
13
  - name: LLM_MODEL
14
+ description: "Model ID to use, e.g. google/gemini-2.0-flash or openai/gpt-4o."
15
+ - name: GATEWAY_TOKEN
16
+ description: "Strong token to secure your dashboard and API (generate: openssl rand -hex 32)."
17
  - name: TELEGRAM_BOT_TOKEN
18
  description: "Telegram bot token from @BotFather."
19
  - name: TELEGRAM_ALLOWED_USERS
20
+ description: "Comma-separated list of numeric user IDs allowed to use the bot."
 
 
21
  - name: HF_TOKEN
22
+ description: "Hugging Face token with write access. Used for automatic workspace backup."
23
  - name: CLOUDFLARE_WORKERS_TOKEN
24
+ description: "Cloudflare API token for automatic Worker proxy and KeepAlive setup."
25
  ---
26
 
27
+ <!-- Badges -->
28
+ [![GitHub Stars](https://img.shields.io/github/stars/NousResearch/hermes-agent?style=flat-square)](https://github.com/NousResearch/hermes-agent)
29
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
30
+ [![HF Space](https://img.shields.io/badge/πŸ€—%20HuggingFace-Space-blue?style=flat-square)](https://huggingface.co/spaces)
31
+ [![Hermes](https://img.shields.io/badge/Hermes-Agent-indigo?style=flat-square)](https://github.com/NousResearch/hermes-agent)
32
 
33
+ **Self-hosted Hermes AI agent gateway β€” free, no server needed.** HuggingMess runs [Nous Research Hermes Agent](https://github.com/NousResearch/hermes-agent) on HuggingFace Spaces, providing a 24/7 personal AI assistant. It includes a premium management dashboard, automatic persistent backup to HF Datasets, and built-in connectivity fixes to bypass platform restrictions. Deploy in minutes on the free HF Spaces tier with full data persistence.
 
34
 
35
+ ## Table of Contents
 
 
 
 
 
 
 
 
 
 
36
 
37
+ - [✨ Features](#-features)
38
+ - [πŸš€ Quick Start](#-quick-start)
39
+ - [πŸ” Access Control](#-access-control)
40
+ - [πŸ€– LLM Providers](#-llm-providers)
41
+ - [πŸ“± Telegram Setup](#-telegram-setup)
42
+ - [🌐 Cloudflare Proxy](#-cloudflare-proxy)
43
+ - [πŸ’Ύ Backup & Persistence](#-backup--persistence)
44
+ - [πŸ’“ Staying Alive](#-staying-alive)
45
+ - [πŸ” Security & Advanced](#-security--advanced)
46
+ - [πŸ’» Local Development](#-local-development)
47
+ - [πŸ—οΈ Architecture](#️-architecture)
48
+ - [πŸ› Troubleshooting](#-troubleshooting)
49
+ - [🌟 More Projects](#-more-projects)
50
 
51
+ ## ✨ Features
 
 
 
 
52
 
53
+ - 🧠 **Hermes Core:** Runs the powerful Hermes agent framework for multi-modal chat and tool use.
54
+ - πŸ” **Secure by Default:** Adds a custom auth layer to protect the Hermes dashboard and API routes.
55
+ - 🌐 **Built-in Connectivity:** Includes transparent outbound proxying via Cloudflare Workers for Telegram, Google APIs, and more.
56
+ - πŸ“Š **Premium Dashboard:** Beautiful Web UI at `/` for real-time monitoring of uptime, sync health, and agent status.
57
+ - πŸ’Ύ **Persistent Backup:** Automatically syncs agent state, chats, and config to a private HF Dataset.
58
+ - ⏰ **Easy Keep-Alive:** Uses `CLOUDFLARE_WORKERS_TOKEN` to automatically set up a cron-triggered keep-awake worker at boot.
59
+ - 🐳 **Optimized Infrastructure:** Minimal resource usage with clean startup logs and production-ready proxying.
60
 
61
+ ## πŸš€ Quick Start
 
 
 
62
 
63
+ ### Step 1: Duplicate this Space
64
 
65
+ [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-xl.svg)](https://huggingface.co/spaces/somratpro/HuggingMess?duplicate=true)
66
 
67
+ ### Step 2: Add Your Secrets
 
68
 
69
+ Navigate to your new Space's **Settings β†’ Variables and secrets**, and add the following three under **Secrets**:
70
 
71
+ - `LLM_API_KEY` – Your provider API key (e.g., Anthropic, OpenAI, OpenRouter).
72
+ - `LLM_MODEL` – The model ID string (e.g., `google/gemini-2.0-flash` or `openai/gpt-4o`).
73
+ - `GATEWAY_TOKEN` – A custom password to secure your dashboard.
74
 
75
+ ### Step 3: Access Your Dashboard
 
 
 
76
 
77
+ Once the build is complete, visit your Space's public URL. You will see the HuggingMess management dashboard. Click **Open Hermes UI** and enter your `GATEWAY_TOKEN` to access the agent interface.
78
 
79
+ ## πŸ” Access Control
 
 
 
 
80
 
81
+ Hermes' built-in dashboard is local-first. HuggingMess adds a secure wrapper:
82
 
83
+ - **Dashboard:** Opening `/app/` requires your `GATEWAY_TOKEN`.
84
+ - **API:** Routes under `/v1/*` (OpenAI-compatible) require `Authorization: Bearer <GATEWAY_TOKEN>`.
85
 
86
+ ## πŸ€– LLM Providers
 
 
 
 
87
 
88
+ HuggingMess automatically maps your `LLM_MODEL` and `LLM_API_KEY` to the correct Hermes configuration.
89
 
90
+ | Provider | Prefix | Example `LLM_MODEL` |
91
  | :--- | :--- | :--- |
92
+ | **Google** | `google/` | `google/gemini-2.0-flash` |
93
+ | **OpenRouter** | `openrouter/` | `openrouter/anthropic/claude-3.5-sonnet` |
94
+ | **Anthropic** | `anthropic/` | `anthropic/claude-3-opus-latest` |
95
+ | **OpenAI** | `openai/` | `openai/gpt-4o` |
96
+ | **HuggingFace** | `huggingface/` | `huggingface/meta-llama/Llama-3.3-70B-Instruct` |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ ## πŸ“± Telegram Setup *(Optional)*
99
 
100
+ To use Hermes via Telegram:
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ 1. Add `TELEGRAM_BOT_TOKEN` from [@BotFather](https://t.me/BotFather).
103
+ 2. Add `TELEGRAM_ALLOWED_USERS` (comma-separated numeric IDs) to restrict access.
104
+ 3. Add `CLOUDFLARE_WORKERS_TOKEN` to bypass HF network restrictions automatically.
105
 
106
+ ## 🌐 Cloudflare Proxy
107
 
108
+ HuggingFace Spaces often block outbound connections to external APIs. HuggingMess handles this automatically:
109
 
110
+ 1. Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret.
111
+ 2. Restart the Space.
 
112
 
113
+ HuggingMess will auto-provision a Worker proxy for Telegram and other restricted traffic, and set up a keep-awake cron.
114
 
115
+ ## πŸ’Ύ Backup & Persistence
 
 
116
 
117
+ Set `HF_TOKEN` with **Write** access to enable backup. HuggingMess syncs all agent data to a private Dataset named `huggingmess-backup` every 180 seconds.
118
 
119
+ ## πŸ’“ Staying Alive *(Recommended on Free HF Spaces)*
 
 
 
 
 
120
 
121
+ Your Space will automatically be kept awake by a background Cloudflare Worker when you configure the `CLOUDFLARE_WORKERS_TOKEN` secret. The worker uses a cron trigger to regularly ping your Space's `/health` endpoint. The dashboard displays the current keep-alive worker status.
122
 
123
+ ## πŸ” Security & Advanced
124
 
125
  | Variable | Default | Description |
126
  | :--- | :--- | :--- |
127
+ | `GATEWAY_TOKEN` | β€” | Token for dashboard and API auth |
128
+ | `HF_TOKEN` | β€” | HF token with write access for backups |
129
+ | `CLOUDFLARE_WORKERS_TOKEN` | β€” | Cloudflare API token for proxy & keep-awake |
130
+ | `SYNC_INTERVAL` | `180` | Backup frequency in seconds |
131
+ | `CLOUDFLARE_KEEPALIVE_ENABLED` | `true` | Set `false` to disable keep-awake worker |
132
+ | `TELEGRAM_MODE` | `webhook` | `webhook` or `polling` |
133
 
134
+ ## πŸ’» Local Development
 
 
135
 
136
  ```bash
137
  docker compose up --build
138
+ # Dashboard: http://localhost:7861
139
+ # Hermes App: http://localhost:7861/app/
140
  ```
141
 
142
+ ## πŸ—οΈ Architecture
143
 
144
+ - **Dashboard (`/`)**: Real-time management and monitoring.
145
+ - **Hermes App (`/app/`)**: Secure proxied access to the Hermes UI.
146
+ - **API (`/v1/*`)**: Proxied OpenAI-compatible agent API.
147
+ - **Health Check (`/health`)**: Readiness probe for HF and Keep-Alive.
148
+ - **Sync Engine**: Python background task for HF Dataset persistence.
149
 
150
+ ## πŸ› Troubleshooting
151
 
152
+ - **Telegram bot not responding:** Ensure `CLOUDFLARE_WORKERS_TOKEN` is set. Check logs for "Setting up Cloudflare proxy".
153
+ - **Authentication failed:** Clear your browser cookies or use an incognito window if your `GATEWAY_TOKEN` has changed.
154
+ - **Data not persisting:** Ensure `HF_TOKEN` has **Write** permissions.
155
+ - **Space keeps sleeping:** Add `CLOUDFLARE_WORKERS_TOKEN` as a Space secret to enable automatic keep-awake monitoring via Cloudflare Workers.
 
 
 
 
156
 
157
+ ## 🌟 More Projects
158
 
159
+ Similar projects by [@somratpro](https://github.com/somratpro) β€” all free, one-click deploy on HF Spaces:
 
 
160
 
161
+ | Project | What it runs | HF Space | GitHub |
162
+ | :--- | :--- | :--- | :--- |
163
+ | **Hugging8n** | n8n β€” workflow & automation platform | [Space](https://huggingface.co/spaces/somratpro/Hugging8n) | [Repo](https://github.com/somratpro/hugging8n) |
164
+ | **HuggingClaw** | OpenClaw β€” Claude Code in the browser | [Space](https://huggingface.co/spaces/somratpro/HuggingClaw) | [Repo](https://github.com/somratpro/huggingclaw) |
165
+ | **HuggingClip** | Paperclip β€” AI agent orchestration platform | [Space](https://huggingface.co/spaces/somratpro/HuggingClip) | [Repo](https://github.com/somratpro/huggingclip) |
166
+ | **HuggingPost** | Postiz β€” social-media scheduler | [Space](https://huggingface.co/spaces/somratpro/HuggingPost) | [Repo](https://github.com/somratpro/huggingpost) |
167
 
168
+ ---
169
+ *Made with ❀️ by [@somratpro](https://github.com/somratpro)*