docs: remove legacy docs/ directory — all content migrated to website
Removed 10 markdown files (~4,200 lines) that have been fully migrated, restructured, and accuracy-audited on the docs site at hermes-agent.nousresearch.com/docs/ Left docs/README.md as a pointer to the website. Updated CONTRIBUTING.md file tree reference.
This commit is contained in:
@@ -170,7 +170,7 @@ hermes-agent/
|
||||
├── skills/ # Bundled skills (copied to ~/.hermes/skills/ on install)
|
||||
├── environments/ # RL training environments (Atropos integration)
|
||||
├── tests/ # Test suite
|
||||
├── docs/ # Additional documentation
|
||||
├── website/ # Documentation site (hermes-agent.nousresearch.com)
|
||||
│
|
||||
├── cli-config.yaml.example # Example configuration (copied to ~/.hermes/config.yaml)
|
||||
└── AGENTS.md # Development guide for AI coding assistants
|
||||
|
||||
7
docs/README.md
Normal file
7
docs/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Documentation
|
||||
|
||||
All documentation has moved to the website:
|
||||
|
||||
**📖 [hermes-agent.nousresearch.com/docs](https://hermes-agent.nousresearch.com/docs/)**
|
||||
|
||||
The documentation source files live in [`website/docs/`](../website/docs/).
|
||||
104
docs/agents.md
104
docs/agents.md
@@ -1,104 +0,0 @@
|
||||
# Agents
|
||||
|
||||
The agent is the core loop that orchestrates LLM calls and tool execution.
|
||||
|
||||
## AIAgent Class
|
||||
|
||||
The main agent is implemented in `run_agent.py`:
|
||||
|
||||
```python
|
||||
class AIAgent:
|
||||
def __init__(
|
||||
self,
|
||||
model: str = "anthropic/claude-sonnet-4",
|
||||
api_key: str = None,
|
||||
base_url: str = "https://openrouter.ai/api/v1",
|
||||
max_turns: int = 20,
|
||||
enabled_toolsets: list = None,
|
||||
disabled_toolsets: list = None,
|
||||
verbose_logging: bool = False,
|
||||
):
|
||||
# Initialize OpenAI client, load tools based on toolsets
|
||||
...
|
||||
|
||||
def chat(self, user_message: str, task_id: str = None) -> str:
|
||||
# Main entry point - runs the agent loop
|
||||
...
|
||||
```
|
||||
|
||||
## Agent Loop
|
||||
|
||||
The core loop in `_run_agent_loop()`:
|
||||
|
||||
```
|
||||
1. Add user message to conversation
|
||||
2. Call LLM with tools
|
||||
3. If LLM returns tool calls:
|
||||
- Execute each tool
|
||||
- Add tool results to conversation
|
||||
- Go to step 2
|
||||
4. If LLM returns text response:
|
||||
- Return response to user
|
||||
```
|
||||
|
||||
```python
|
||||
while turns < max_turns:
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
tools=tool_schemas,
|
||||
)
|
||||
|
||||
if response.tool_calls:
|
||||
for tool_call in response.tool_calls:
|
||||
result = await execute_tool(tool_call)
|
||||
messages.append(tool_result_message(result))
|
||||
turns += 1
|
||||
else:
|
||||
return response.content
|
||||
```
|
||||
|
||||
## Conversation Management
|
||||
|
||||
Messages are stored as a list of dicts following OpenAI format:
|
||||
|
||||
```python
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant..."},
|
||||
{"role": "user", "content": "Search for Python tutorials"},
|
||||
{"role": "assistant", "content": None, "tool_calls": [...]},
|
||||
{"role": "tool", "tool_call_id": "...", "content": "..."},
|
||||
{"role": "assistant", "content": "Here's what I found..."},
|
||||
]
|
||||
```
|
||||
|
||||
## Reasoning Context
|
||||
|
||||
For models that support reasoning (chain-of-thought), the agent:
|
||||
1. Extracts `reasoning_content` from API responses
|
||||
2. Stores it in `assistant_msg["reasoning"]` for trajectory export
|
||||
3. Passes it back via `reasoning_content` field on subsequent turns
|
||||
|
||||
## Trajectory Export
|
||||
|
||||
Conversations can be exported for training:
|
||||
|
||||
```python
|
||||
agent = AIAgent(save_trajectories=True)
|
||||
agent.chat("Do something")
|
||||
# Saves to trajectories/*.jsonl in ShareGPT format
|
||||
```
|
||||
|
||||
## Batch Processing
|
||||
|
||||
For processing multiple prompts, use `batch_runner.py`:
|
||||
|
||||
```bash
|
||||
python batch_runner.py \
|
||||
--dataset_file=prompts.jsonl \
|
||||
--batch_size=20 \
|
||||
--num_workers=4 \
|
||||
--run_name=my_run
|
||||
```
|
||||
|
||||
See `batch_runner.py` for parallel execution with checkpointing.
|
||||
379
docs/cli.md
379
docs/cli.md
@@ -1,379 +0,0 @@
|
||||
# CLI
|
||||
|
||||
The Hermes Agent CLI provides an interactive terminal interface for working with the agent.
|
||||
|
||||
## Running the CLI
|
||||
|
||||
```bash
|
||||
# Basic usage
|
||||
hermes
|
||||
|
||||
# With specific model
|
||||
hermes --model "anthropic/claude-sonnet-4"
|
||||
|
||||
# With specific provider
|
||||
hermes --provider nous # Use Nous Portal (requires: hermes model)
|
||||
hermes --provider openrouter # Force OpenRouter
|
||||
|
||||
# With specific toolsets
|
||||
hermes --toolsets "web,terminal,skills"
|
||||
|
||||
# Resume previous sessions
|
||||
hermes --continue # Resume the most recent CLI session (-c)
|
||||
hermes --resume <session_id> # Resume a specific session by ID (-r)
|
||||
|
||||
# Verbose mode
|
||||
hermes --verbose
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
The CLI is implemented in `cli.py` and uses:
|
||||
|
||||
- **Rich** - Welcome banner with ASCII art and styled panels
|
||||
- **prompt_toolkit** - Fixed input area with command history
|
||||
- **KawaiiSpinner** - Animated feedback during operations
|
||||
|
||||
```text
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ HERMES-AGENT ASCII Logo │
|
||||
│ ┌─────────────┐ ┌────────────────────────────┐ │
|
||||
│ │ Caduceus │ │ Model: claude-opus-4.5 │ │
|
||||
│ │ ASCII Art │ │ Terminal: local │ │
|
||||
│ │ │ │ Working Dir: /home/user │ │
|
||||
│ │ │ │ Available Tools: 19 │ │
|
||||
│ │ │ │ Available Skills: 12 │ │
|
||||
│ └─────────────┘ └────────────────────────────┘ │
|
||||
└─────────────────────────────────────────────────┘
|
||||
│ Conversation output scrolls here... │
|
||||
│ │
|
||||
│ User: Hello! │
|
||||
│ ────────────────────────────────────────────── │
|
||||
│ (◕‿◕✿) 🧠 pondering... (2.3s) │
|
||||
│ ✧٩(ˊᗜˋ*)و✧ got it! (2.3s) │
|
||||
│ │
|
||||
│ Assistant: Hello! How can I help you today? │
|
||||
├─────────────────────────────────────────────────┤
|
||||
│ ❯ [Fixed input area at bottom] │
|
||||
└─────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/help` | Show available commands |
|
||||
| `/tools` | List available tools grouped by toolset |
|
||||
| `/toolsets` | List available toolsets with descriptions |
|
||||
| `/model [name]` | Show or change the current model |
|
||||
| `/prompt [text]` | View/set/clear custom system prompt |
|
||||
| `/personality [name]` | Set a predefined personality |
|
||||
| `/clear` | Clear screen and reset conversation |
|
||||
| `/reset` | Reset conversation only (keep screen) |
|
||||
| `/history` | Show conversation history |
|
||||
| `/save` | Save current conversation to file |
|
||||
| `/config` | Show current configuration |
|
||||
| `/verbose` | Cycle tool progress display: off → new → all → verbose |
|
||||
| `/compress` | Manually compress conversation context (flush memories + summarize) |
|
||||
| `/usage` | Show token usage for the current session |
|
||||
| `/quit` | Exit the CLI (also: `/exit`, `/q`) |
|
||||
|
||||
## Configuration
|
||||
|
||||
The CLI reads `~/.hermes/config.yaml` first and falls back to `cli-config.yaml` in the project directory. Copy from `cli-config.yaml.example`:
|
||||
|
||||
```bash
|
||||
cp cli-config.yaml.example ~/.hermes/config.yaml
|
||||
```
|
||||
|
||||
### Model & Provider Configuration
|
||||
|
||||
```yaml
|
||||
model:
|
||||
default: "anthropic/claude-opus-4.6"
|
||||
base_url: "https://openrouter.ai/api/v1"
|
||||
provider: "auto" # "auto" | "openrouter" | "nous"
|
||||
```
|
||||
|
||||
**Provider selection** (`provider` field):
|
||||
- `auto` (default): Uses Nous Portal if logged in (`hermes model`), otherwise falls back to OpenRouter/env vars.
|
||||
- `openrouter`: Always uses `OPENROUTER_API_KEY` from `.env`.
|
||||
- `nous`: Always uses Nous Portal OAuth credentials from `auth.json`.
|
||||
|
||||
Can also be overridden per-session with `--provider` or via `HERMES_INFERENCE_PROVIDER` env var.
|
||||
|
||||
### Terminal Configuration
|
||||
|
||||
The CLI supports multiple terminal backends:
|
||||
|
||||
```yaml
|
||||
# Local execution (default)
|
||||
terminal:
|
||||
env_type: "local"
|
||||
cwd: "." # Current directory
|
||||
|
||||
# SSH remote execution (sandboxed - agent can't touch its own code)
|
||||
terminal:
|
||||
env_type: "ssh"
|
||||
cwd: "/home/myuser/project"
|
||||
ssh_host: "my-server.example.com"
|
||||
ssh_user: "myuser"
|
||||
ssh_key: "~/.ssh/id_rsa"
|
||||
|
||||
# Docker container
|
||||
terminal:
|
||||
env_type: "docker"
|
||||
docker_image: "python:3.11"
|
||||
|
||||
# Singularity/Apptainer (HPC)
|
||||
terminal:
|
||||
env_type: "singularity"
|
||||
singularity_image: "docker://python:3.11"
|
||||
|
||||
# Modal cloud
|
||||
terminal:
|
||||
env_type: "modal"
|
||||
modal_image: "python:3.11"
|
||||
```
|
||||
|
||||
### Sudo Support
|
||||
|
||||
The CLI supports interactive sudo prompts:
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────┐
|
||||
│ 🔐 SUDO PASSWORD REQUIRED │
|
||||
├──────────────────────────────────────────────────────────┤
|
||||
│ Enter password below (input is hidden), or: │
|
||||
│ • Press Enter to skip (command fails gracefully) │
|
||||
│ • Wait 45s to auto-skip │
|
||||
└──────────────────────────────────────────────────────────┘
|
||||
|
||||
Password (hidden):
|
||||
```
|
||||
|
||||
**Options:**
|
||||
- **Interactive**: Leave `sudo_password` unset - you'll be prompted when needed
|
||||
- **Configured**: Set `sudo_password` in `~/.hermes/config.yaml` (or `cli-config.yaml` fallback) to auto-fill
|
||||
- **Environment**: Set `SUDO_PASSWORD` in `.env` for all runs
|
||||
|
||||
Password is cached for the session once entered.
|
||||
|
||||
### Toolsets
|
||||
|
||||
Control which tools are available:
|
||||
|
||||
```yaml
|
||||
# Enable all tools
|
||||
toolsets:
|
||||
- all
|
||||
|
||||
# Or enable specific toolsets
|
||||
toolsets:
|
||||
- web
|
||||
- terminal
|
||||
- skills
|
||||
```
|
||||
|
||||
Available toolsets: `web`, `search`, `terminal`, `browser`, `vision`, `image_gen`, `skills`, `moa`, `debugging`, `safe`
|
||||
|
||||
### Personalities
|
||||
|
||||
Predefined personalities for the `/personality` command:
|
||||
|
||||
```yaml
|
||||
agent:
|
||||
personalities:
|
||||
helpful: "You are a helpful, friendly AI assistant."
|
||||
kawaii: "You are a kawaii assistant! Use cute expressions..."
|
||||
pirate: "Arrr! Ye be talkin' to Captain Hermes..."
|
||||
# Add your own!
|
||||
```
|
||||
|
||||
Built-in personalities:
|
||||
- `helpful`, `concise`, `technical`, `creative`, `teacher`
|
||||
- `kawaii`, `catgirl`, `pirate`, `shakespeare`, `surfer`
|
||||
- `noir`, `uwu`, `philosopher`, `hype`
|
||||
|
||||
## Animated Feedback
|
||||
|
||||
The CLI provides animated feedback during operations:
|
||||
|
||||
### Thinking Animation
|
||||
|
||||
During API calls, shows animated spinner with thinking verbs:
|
||||
```
|
||||
◜ (。•́︿•̀。) pondering... (1.2s)
|
||||
◠ (⊙_⊙) contemplating... (2.4s)
|
||||
✧٩(ˊᗜˋ*)و✧ got it! (3.1s)
|
||||
```
|
||||
|
||||
### Tool Execution Animation
|
||||
|
||||
Each tool type has unique animations:
|
||||
```
|
||||
⠋ (◕‿◕✿) 🔍 web_search... (0.8s)
|
||||
▅ (≧◡≦) 💻 terminal... (1.2s)
|
||||
🌓 (★ω★) 🌐 browser_navigate... (2.1s)
|
||||
✧ (✿◠‿◠) 🎨 image_generate... (4.5s)
|
||||
```
|
||||
|
||||
## Multi-line Input
|
||||
|
||||
For multi-line input, end a line with `\` to continue:
|
||||
|
||||
```
|
||||
❯ Write a function that:\
|
||||
1. Takes a list of numbers\
|
||||
2. Returns the sum
|
||||
```
|
||||
|
||||
## Environment Variable Priority
|
||||
|
||||
For terminal settings, `~/.hermes/config.yaml` takes precedence, then `cli-config.yaml` (fallback), then `.env`:
|
||||
|
||||
1. `~/.hermes/config.yaml`
|
||||
2. `cli-config.yaml` (project fallback)
|
||||
3. `.env` file
|
||||
4. System environment variables
|
||||
5. Default values
|
||||
|
||||
This allows you to have different terminal configs for CLI vs batch processing.
|
||||
|
||||
## Session Management
|
||||
|
||||
- **History**: Command history is saved to `~/.hermes_history`
|
||||
- **Conversations**: Use `/save` to export conversations
|
||||
- **Reset**: Use `/clear` for full reset, `/reset` to just clear history
|
||||
- **Session Logs**: Every session automatically logs to `logs/session_{session_id}.json`
|
||||
- **Resume**: Pick up any previous session with `--resume` or `--continue`
|
||||
|
||||
### Resuming Sessions
|
||||
|
||||
When you exit a CLI session, a resume command is printed:
|
||||
|
||||
```
|
||||
Resume this session with:
|
||||
hermes --resume 20260225_143052_a1b2c3
|
||||
|
||||
Session: 20260225_143052_a1b2c3
|
||||
Duration: 12m 34s
|
||||
Messages: 28 (5 user, 18 tool calls)
|
||||
```
|
||||
|
||||
To resume:
|
||||
|
||||
```bash
|
||||
hermes --continue # Resume the most recent CLI session
|
||||
hermes -c # Short form
|
||||
hermes --resume 20260225_143052_a1b2c3 # Resume a specific session by ID
|
||||
hermes -r 20260225_143052_a1b2c3 # Short form
|
||||
hermes chat --resume 20260225_143052_a1b2c3 # Explicit subcommand form
|
||||
```
|
||||
|
||||
Resuming restores the full conversation history from SQLite (`~/.hermes/state.db`). The agent sees all previous messages, tool calls, and responses — just as if you never left. New messages append to the same session in the database.
|
||||
|
||||
Use `hermes sessions list` to browse past sessions and find IDs.
|
||||
|
||||
### Session Logging
|
||||
|
||||
Sessions are automatically logged to the `logs/` directory:
|
||||
|
||||
```
|
||||
logs/
|
||||
├── session_20260201_143052_a1b2c3.json
|
||||
├── session_20260201_150217_d4e5f6.json
|
||||
└── ...
|
||||
```
|
||||
|
||||
The session ID is displayed in the welcome banner and follows the format: `YYYYMMDD_HHMMSS_UUID`.
|
||||
|
||||
Log files contain:
|
||||
- Full conversation history in trajectory format
|
||||
- Timestamps for session start and last update
|
||||
- Model and message count metadata
|
||||
|
||||
This is useful for:
|
||||
- Debugging agent behavior
|
||||
- Replaying conversations
|
||||
- Training data inspection
|
||||
|
||||
### Context Compression
|
||||
|
||||
Long conversations can exceed model context limits. The CLI automatically compresses context when approaching the limit:
|
||||
|
||||
```yaml
|
||||
# In ~/.hermes/config.yaml (or cli-config.yaml fallback)
|
||||
compression:
|
||||
enabled: true # Enable auto-compression
|
||||
threshold: 0.85 # Compress at 85% of context limit
|
||||
summary_model: "google/gemini-2.0-flash-001"
|
||||
```
|
||||
|
||||
**How it works:**
|
||||
1. Tracks actual token usage from each API response
|
||||
2. When tokens reach threshold, middle turns are summarized
|
||||
3. First 3 and last 4 turns are always protected
|
||||
4. Conversation continues seamlessly after compression
|
||||
|
||||
**When compression triggers:**
|
||||
```
|
||||
📦 Context compression triggered (170,000 tokens ≥ 170,000 threshold)
|
||||
📊 Model context limit: 200,000 tokens (85% = 170,000)
|
||||
🗜️ Summarizing turns 4-15 (12 turns)
|
||||
✅ Compressed: 20 → 9 messages (~45,000 tokens saved)
|
||||
```
|
||||
|
||||
To disable compression:
|
||||
```yaml
|
||||
compression:
|
||||
enabled: false
|
||||
```
|
||||
|
||||
## Quiet Mode
|
||||
|
||||
The CLI runs in "quiet mode" (`HERMES_QUIET=1`), which:
|
||||
- Suppresses verbose logging from tools
|
||||
- Enables kawaii-style animated feedback
|
||||
- Hides terminal environment warnings
|
||||
- Keeps output clean and user-friendly
|
||||
|
||||
For verbose output (debugging), use:
|
||||
```bash
|
||||
./hermes --verbose
|
||||
```
|
||||
|
||||
## Skills Hub Commands
|
||||
|
||||
The Skills Hub provides search, install, and management of skills from online registries.
|
||||
|
||||
**Terminal commands:**
|
||||
```bash
|
||||
hermes skills search <query> # Search all registries
|
||||
hermes skills search <query> --source github # Search GitHub only
|
||||
hermes skills install <identifier> # Install with security scan
|
||||
hermes skills install <id> --category devops # Install into a category
|
||||
hermes skills install <id> --force # Override caution block
|
||||
hermes skills inspect <identifier> # Preview without installing
|
||||
hermes skills list # List all installed skills
|
||||
hermes skills list --source hub # Hub-installed only
|
||||
hermes skills audit # Re-scan all hub skills
|
||||
hermes skills audit <name> # Re-scan a specific skill
|
||||
hermes skills uninstall <name> # Remove a hub skill
|
||||
hermes skills publish <path> --to github --repo owner/repo
|
||||
hermes skills snapshot export <file.json> # Export skill config
|
||||
hermes skills snapshot import <file.json> # Re-install from snapshot
|
||||
hermes skills tap list # List custom sources
|
||||
hermes skills tap add owner/repo # Add a GitHub repo source
|
||||
hermes skills tap remove owner/repo # Remove a source
|
||||
```
|
||||
|
||||
**Slash commands (inside chat):**
|
||||
|
||||
All the same commands work with `/skills` prefix:
|
||||
```
|
||||
/skills search kubernetes
|
||||
/skills install openai/skills/skill-creator
|
||||
/skills list
|
||||
/skills tap add myorg/skills
|
||||
```
|
||||
174
docs/hooks.md
174
docs/hooks.md
@@ -1,174 +0,0 @@
|
||||
# Event Hooks
|
||||
|
||||
The hooks system lets you run custom code at key points in the agent lifecycle — session creation, slash commands, each tool-calling step, and more. Hooks are discovered automatically from `~/.hermes/hooks/` and fire without blocking the main agent pipeline.
|
||||
|
||||
## Creating a Hook
|
||||
|
||||
Each hook is a directory under `~/.hermes/hooks/` containing two files:
|
||||
|
||||
```
|
||||
~/.hermes/hooks/
|
||||
└── my-hook/
|
||||
├── HOOK.yaml # Declares which events to listen for
|
||||
└── handler.py # Python handler function
|
||||
```
|
||||
|
||||
### HOOK.yaml
|
||||
|
||||
```yaml
|
||||
name: my-hook
|
||||
description: Log all agent activity to a file
|
||||
events:
|
||||
- agent:start
|
||||
- agent:end
|
||||
- agent:step
|
||||
```
|
||||
|
||||
The `events` list determines which events trigger your handler. You can subscribe to any combination of events, including wildcards like `command:*`.
|
||||
|
||||
### handler.py
|
||||
|
||||
```python
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
LOG_FILE = Path.home() / ".hermes" / "hooks" / "my-hook" / "activity.log"
|
||||
|
||||
async def handle(event_type: str, context: dict):
|
||||
"""Called for each subscribed event. Must be named 'handle'."""
|
||||
entry = {
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"event": event_type,
|
||||
**context,
|
||||
}
|
||||
with open(LOG_FILE, "a") as f:
|
||||
f.write(json.dumps(entry) + "\n")
|
||||
```
|
||||
|
||||
The handler function:
|
||||
- Must be named `handle`
|
||||
- Receives `event_type` (string) and `context` (dict)
|
||||
- Can be `async def` or regular `def` — both work
|
||||
- Errors are caught and logged, never crashing the agent
|
||||
|
||||
## Available Events
|
||||
|
||||
| Event | When it fires | Context keys |
|
||||
|-------|---------------|--------------|
|
||||
| `gateway:startup` | Gateway process starts | `platforms` (list of active platform names) |
|
||||
| `session:start` | New messaging session created | `platform`, `user_id`, `session_id`, `session_key` |
|
||||
| `session:reset` | User ran `/new` or `/reset` | `platform`, `user_id`, `session_key` |
|
||||
| `agent:start` | Agent begins processing a message | `platform`, `user_id`, `session_id`, `message` |
|
||||
| `agent:step` | Each iteration of the tool-calling loop | `platform`, `user_id`, `session_id`, `iteration`, `tool_names` |
|
||||
| `agent:end` | Agent finishes processing | `platform`, `user_id`, `session_id`, `message`, `response` |
|
||||
| `command:*` | Any slash command executed | `platform`, `user_id`, `command`, `args` |
|
||||
|
||||
### Wildcard Matching
|
||||
|
||||
Handlers registered for `command:*` fire for any `command:` event (`command:model`, `command:reset`, etc.). This lets you monitor all slash commands with a single subscription.
|
||||
|
||||
## Examples
|
||||
|
||||
### Telegram Notification on Long Tasks
|
||||
|
||||
Send yourself a Telegram message when the agent takes more than 10 tool-calling steps:
|
||||
|
||||
```yaml
|
||||
# ~/.hermes/hooks/long-task-alert/HOOK.yaml
|
||||
name: long-task-alert
|
||||
description: Alert when agent is taking many steps
|
||||
events:
|
||||
- agent:step
|
||||
```
|
||||
|
||||
```python
|
||||
# ~/.hermes/hooks/long-task-alert/handler.py
|
||||
import os
|
||||
import httpx
|
||||
|
||||
THRESHOLD = 10
|
||||
BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
||||
CHAT_ID = os.getenv("TELEGRAM_HOME_CHANNEL")
|
||||
|
||||
async def handle(event_type: str, context: dict):
|
||||
iteration = context.get("iteration", 0)
|
||||
if iteration == THRESHOLD and BOT_TOKEN and CHAT_ID:
|
||||
tools = ", ".join(context.get("tool_names", []))
|
||||
text = f"⚠️ Agent has been running for {iteration} steps. Last tools: {tools}"
|
||||
async with httpx.AsyncClient() as client:
|
||||
await client.post(
|
||||
f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
|
||||
json={"chat_id": CHAT_ID, "text": text},
|
||||
)
|
||||
```
|
||||
|
||||
### Command Usage Logger
|
||||
|
||||
Track which slash commands are used and how often:
|
||||
|
||||
```yaml
|
||||
# ~/.hermes/hooks/command-logger/HOOK.yaml
|
||||
name: command-logger
|
||||
description: Log slash command usage
|
||||
events:
|
||||
- command:*
|
||||
```
|
||||
|
||||
```python
|
||||
# ~/.hermes/hooks/command-logger/handler.py
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
LOG = Path.home() / ".hermes" / "logs" / "command_usage.jsonl"
|
||||
|
||||
def handle(event_type: str, context: dict):
|
||||
LOG.parent.mkdir(parents=True, exist_ok=True)
|
||||
entry = {
|
||||
"ts": datetime.now().isoformat(),
|
||||
"command": context.get("command"),
|
||||
"args": context.get("args"),
|
||||
"platform": context.get("platform"),
|
||||
"user": context.get("user_id"),
|
||||
}
|
||||
with open(LOG, "a") as f:
|
||||
f.write(json.dumps(entry) + "\n")
|
||||
```
|
||||
|
||||
### Session Start Webhook
|
||||
|
||||
POST to an external service whenever a new session starts:
|
||||
|
||||
```yaml
|
||||
# ~/.hermes/hooks/session-webhook/HOOK.yaml
|
||||
name: session-webhook
|
||||
description: Notify external service on new sessions
|
||||
events:
|
||||
- session:start
|
||||
- session:reset
|
||||
```
|
||||
|
||||
```python
|
||||
# ~/.hermes/hooks/session-webhook/handler.py
|
||||
import httpx
|
||||
|
||||
WEBHOOK_URL = "https://your-service.example.com/hermes-events"
|
||||
|
||||
async def handle(event_type: str, context: dict):
|
||||
async with httpx.AsyncClient() as client:
|
||||
await client.post(WEBHOOK_URL, json={
|
||||
"event": event_type,
|
||||
**context,
|
||||
}, timeout=5)
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. On gateway startup, `HookRegistry.discover_and_load()` scans `~/.hermes/hooks/`
|
||||
2. Each subdirectory with `HOOK.yaml` + `handler.py` is loaded dynamically
|
||||
3. Handlers are registered for their declared events
|
||||
4. At each lifecycle point, `hooks.emit()` fires all matching handlers
|
||||
5. Errors in any handler are caught and logged — a broken hook never crashes the agent
|
||||
|
||||
Hooks only fire in the **gateway** (Telegram, Discord, Slack, WhatsApp). The CLI does not currently load hooks. The `agent:step` event bridges from the sync agent thread to the async hook system via `asyncio.run_coroutine_threadsafe`.
|
||||
@@ -1,124 +0,0 @@
|
||||
# LLM Client
|
||||
|
||||
Hermes Agent uses the OpenAI Python SDK with OpenRouter as the backend, providing access to many models through a single API.
|
||||
|
||||
## Configuration
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(
|
||||
api_key=os.getenv("OPENROUTER_API_KEY"),
|
||||
base_url="https://openrouter.ai/api/v1"
|
||||
)
|
||||
```
|
||||
|
||||
## Supported Models
|
||||
|
||||
Any model available on [OpenRouter](https://openrouter.ai/models):
|
||||
|
||||
```python
|
||||
# Anthropic
|
||||
model = "anthropic/claude-sonnet-4"
|
||||
model = "anthropic/claude-opus-4"
|
||||
|
||||
# OpenAI
|
||||
model = "openai/gpt-4o"
|
||||
model = "openai/o1"
|
||||
|
||||
# Google
|
||||
model = "google/gemini-2.0-flash"
|
||||
|
||||
# Open models
|
||||
model = "meta-llama/llama-3.3-70b-instruct"
|
||||
model = "deepseek/deepseek-chat-v3"
|
||||
model = "moonshotai/kimi-k2.5"
|
||||
```
|
||||
|
||||
## Tool Calling
|
||||
|
||||
Standard OpenAI function calling format:
|
||||
|
||||
```python
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
tools=[
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "web_search",
|
||||
"description": "Search the web",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"query": {"type": "string"}
|
||||
},
|
||||
"required": ["query"]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
# Check for tool calls
|
||||
if response.choices[0].message.tool_calls:
|
||||
for tool_call in response.choices[0].message.tool_calls:
|
||||
name = tool_call.function.name
|
||||
args = json.loads(tool_call.function.arguments)
|
||||
# Execute tool...
|
||||
```
|
||||
|
||||
## Reasoning Models
|
||||
|
||||
Some models return reasoning/thinking content:
|
||||
|
||||
```python
|
||||
# Access reasoning if available
|
||||
message = response.choices[0].message
|
||||
if hasattr(message, 'reasoning_content') and message.reasoning_content:
|
||||
reasoning = message.reasoning_content
|
||||
# Store for trajectory export
|
||||
```
|
||||
|
||||
## Provider Selection
|
||||
|
||||
OpenRouter allows selecting specific providers:
|
||||
|
||||
```python
|
||||
response = client.chat.completions.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
extra_body={
|
||||
"provider": {
|
||||
"order": ["Anthropic", "Google"], # Preferred providers
|
||||
"ignore": ["Novita"], # Providers to skip
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
Common errors and handling:
|
||||
|
||||
```python
|
||||
try:
|
||||
response = client.chat.completions.create(...)
|
||||
except openai.RateLimitError:
|
||||
# Back off and retry
|
||||
except openai.APIError as e:
|
||||
# Check e.code for specific errors
|
||||
# 400 = bad request (often provider-specific)
|
||||
# 502 = bad gateway (retry with different provider)
|
||||
```
|
||||
|
||||
## Cost Tracking
|
||||
|
||||
OpenRouter returns usage info:
|
||||
|
||||
```python
|
||||
usage = response.usage
|
||||
print(f"Tokens: {usage.prompt_tokens} + {usage.completion_tokens}")
|
||||
print(f"Cost: ${usage.cost:.6f}") # If available
|
||||
```
|
||||
527
docs/mcp.md
527
docs/mcp.md
@@ -1,527 +0,0 @@
|
||||
# MCP (Model Context Protocol) Support
|
||||
|
||||
MCP lets Hermes Agent connect to external tool servers — giving the agent access to databases, APIs, filesystems, and more without any code changes.
|
||||
|
||||
## Overview
|
||||
|
||||
The [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) is an open standard for connecting AI agents to external tools and data sources. MCP servers expose tools over a lightweight RPC protocol, and Hermes Agent can connect to any compliant server automatically.
|
||||
|
||||
What this means for you:
|
||||
|
||||
- **Thousands of ready-made tools** — browse the [MCP server directory](https://github.com/modelcontextprotocol/servers) for servers covering GitHub, Slack, databases, file systems, web scraping, and more.
|
||||
- **No code changes needed** — add a few lines to `~/.hermes/config.yaml` and the tools appear alongside built-in ones.
|
||||
- **Mix and match** — run multiple MCP servers simultaneously, combining stdio-based and HTTP-based servers.
|
||||
- **Secure by default** — environment variables are filtered and credentials are stripped from error messages returned to the LLM.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Install MCP support as an optional dependency:
|
||||
|
||||
```bash
|
||||
pip install hermes-agent[mcp]
|
||||
```
|
||||
|
||||
Depending on which MCP servers you want to use, you may need additional runtimes:
|
||||
|
||||
| Server Type | Runtime Needed | Example |
|
||||
|-------------|---------------|---------|
|
||||
| HTTP/remote | Nothing extra | `url: "https://mcp.example.com"` |
|
||||
| npm-based (npx) | Node.js 18+ | `command: "npx"` |
|
||||
| Python-based | uv (recommended) | `command: "uvx"` |
|
||||
|
||||
Most popular MCP servers are distributed as npm packages and launched via `npx`. Python-based servers typically use `uvx` (from the [uv](https://docs.astral.sh/uv/) package manager).
|
||||
|
||||
## Configuration
|
||||
|
||||
MCP servers are configured in `~/.hermes/config.yaml` under the `mcp_servers` key. Each entry is a named server with its connection details.
|
||||
|
||||
### Stdio Servers (command + args + env)
|
||||
|
||||
Stdio servers run as local subprocesses. Communication happens over stdin/stdout.
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
filesystem:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
|
||||
env: {}
|
||||
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_xxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
| Key | Required | Description |
|
||||
|-----|----------|-------------|
|
||||
| `command` | Yes | Executable to run (e.g., `npx`, `uvx`, `python`) |
|
||||
| `args` | No | List of command-line arguments |
|
||||
| `env` | No | Environment variables to pass to the subprocess |
|
||||
|
||||
**Note:** Only explicitly listed `env` variables plus a safe baseline (PATH, HOME, USER, LANG, SHELL, TMPDIR, XDG_*) are passed to the subprocess. Your shell's API keys, tokens, and secrets are **not** leaked. See [Security](#security) for details.
|
||||
|
||||
### HTTP Servers (url + headers)
|
||||
|
||||
HTTP servers run remotely and are accessed over HTTP/StreamableHTTP.
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
remote_api:
|
||||
url: "https://my-mcp-server.example.com/mcp"
|
||||
headers:
|
||||
Authorization: "Bearer sk-xxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
| Key | Required | Description |
|
||||
|-----|----------|-------------|
|
||||
| `url` | Yes | Full URL of the MCP HTTP endpoint |
|
||||
| `headers` | No | HTTP headers to include (e.g., auth tokens) |
|
||||
|
||||
### Per-Server Timeouts
|
||||
|
||||
Each server can have custom timeouts:
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
slow_database:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-postgres"]
|
||||
env:
|
||||
DATABASE_URL: "postgres://user:pass@localhost/mydb"
|
||||
timeout: 300 # Tool call timeout in seconds (default: 120)
|
||||
connect_timeout: 90 # Initial connection timeout in seconds (default: 60)
|
||||
```
|
||||
|
||||
| Key | Default | Description |
|
||||
|-----|---------|-------------|
|
||||
| `timeout` | 120 | Maximum seconds to wait for a single tool call to complete |
|
||||
| `connect_timeout` | 60 | Maximum seconds to wait for the initial connection and tool discovery |
|
||||
|
||||
### Mixed Configuration Example
|
||||
|
||||
You can combine stdio and HTTP servers freely:
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
# Local filesystem access via stdio
|
||||
filesystem:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
||||
|
||||
# GitHub API via stdio with auth
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_xxxxxxxxxxxx"
|
||||
|
||||
# Remote database via HTTP
|
||||
company_db:
|
||||
url: "https://mcp.internal.company.com/db"
|
||||
headers:
|
||||
Authorization: "Bearer sk-xxxxxxxxxxxx"
|
||||
timeout: 180
|
||||
|
||||
# Python-based server via uvx
|
||||
memory:
|
||||
command: "uvx"
|
||||
args: ["mcp-server-memory"]
|
||||
```
|
||||
|
||||
## Config Translation (Claude/Cursor JSON → Hermes YAML)
|
||||
|
||||
Many MCP server docs show configuration in Claude Desktop JSON format. Here's how to translate:
|
||||
|
||||
**Claude Desktop JSON** (`claude_desktop_config.json`):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"filesystem": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
|
||||
"env": {}
|
||||
},
|
||||
"github": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "@modelcontextprotocol/server-github"],
|
||||
"env": {
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Hermes Agent YAML** (`~/.hermes/config.yaml`):
|
||||
|
||||
```yaml
|
||||
mcp_servers: # mcpServers → mcp_servers (snake_case)
|
||||
filesystem:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
||||
env: {}
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_xxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
Translation rules:
|
||||
|
||||
1. **Key name**: `mcpServers` → `mcp_servers` (snake_case)
|
||||
2. **Format**: JSON → YAML (remove braces/brackets, use indentation)
|
||||
3. **Arrays**: `["a", "b"]` stays the same in YAML flow style, or use block style with `- a`
|
||||
4. **Everything else**: Keys (`command`, `args`, `env`) are identical
|
||||
|
||||
## How It Works
|
||||
|
||||
### Startup & Discovery
|
||||
|
||||
When Hermes Agent starts, the tool discovery system calls `discover_mcp_tools()`:
|
||||
|
||||
1. **Config loading** — Reads `mcp_servers` from `~/.hermes/config.yaml`
|
||||
2. **Background loop** — Spins up a dedicated asyncio event loop in a daemon thread for MCP connections
|
||||
3. **Connection** — Connects to each configured server (stdio subprocess or HTTP)
|
||||
4. **Session init** — Initializes the MCP client session (protocol handshake)
|
||||
5. **Tool discovery** — Calls `list_tools()` on each server to get available tools
|
||||
6. **Registration** — Registers each MCP tool into the Hermes tool registry with a prefixed name
|
||||
|
||||
### Tool Registration
|
||||
|
||||
Each discovered MCP tool is registered with a prefixed name following this pattern:
|
||||
|
||||
```
|
||||
mcp_{server_name}_{tool_name}
|
||||
```
|
||||
|
||||
Hyphens and dots in both server and tool names are replaced with underscores for API compatibility. For example:
|
||||
|
||||
| Server Name | MCP Tool Name | Registered As |
|
||||
|-------------|--------------|---------------|
|
||||
| `filesystem` | `read_file` | `mcp_filesystem_read_file` |
|
||||
| `github` | `create-issue` | `mcp_github_create_issue` |
|
||||
| `my-api` | `query.data` | `mcp_my_api_query_data` |
|
||||
|
||||
Tools appear alongside built-in tools — the agent sees them in its tool list and can call them like any other tool.
|
||||
|
||||
### Tool Calling
|
||||
|
||||
When the agent calls an MCP tool:
|
||||
|
||||
1. The handler is invoked by the tool registry (sync interface)
|
||||
2. The handler schedules the actual MCP `call_tool()` RPC on the background event loop
|
||||
3. The call blocks (with timeout) until the MCP server responds
|
||||
4. Response content blocks are collected and returned as JSON
|
||||
5. Errors are sanitized to strip credentials before returning to the LLM
|
||||
|
||||
### Shutdown
|
||||
|
||||
On agent exit, `shutdown_mcp_servers()` is called:
|
||||
|
||||
1. All server tasks are signalled to exit via their shutdown events
|
||||
2. Each server's `async with` context manager exits, cleaning up transports
|
||||
3. The background event loop is stopped and its thread is joined
|
||||
4. All server state is cleared
|
||||
|
||||
## Security
|
||||
|
||||
### Environment Variable Filtering
|
||||
|
||||
When launching stdio MCP servers, Hermes does **not** pass your full shell environment to the subprocess. The `_build_safe_env()` function constructs a minimal environment:
|
||||
|
||||
**Always passed through** (from your current environment):
|
||||
- `PATH`, `HOME`, `USER`, `LANG`, `LC_ALL`, `TERM`, `SHELL`, `TMPDIR`
|
||||
- Any variable starting with `XDG_`
|
||||
|
||||
**Explicitly added**: Any variables you list in the server's `env` config.
|
||||
|
||||
**Everything else is excluded** — your `OPENAI_API_KEY`, `AWS_SECRET_ACCESS_KEY`, database passwords, and other secrets are never leaked to MCP server subprocesses unless you explicitly add them.
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
# Only this token is passed — nothing else from your shell
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_xxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
### Credential Stripping in Errors
|
||||
|
||||
If an MCP tool call fails, the error message is sanitized by `_sanitize_error()` before being returned to the LLM. The following patterns are replaced with `[REDACTED]`:
|
||||
|
||||
- GitHub PATs (`ghp_...`)
|
||||
- OpenAI-style keys (`sk-...`)
|
||||
- Bearer tokens (`Bearer ...`)
|
||||
- Query parameters (`token=...`, `key=...`, `API_KEY=...`, `password=...`, `secret=...`)
|
||||
|
||||
This prevents accidental credential exposure through error messages in the conversation.
|
||||
|
||||
## Transport Types
|
||||
|
||||
### Stdio Transport
|
||||
|
||||
The default transport for locally-installed MCP servers. The server runs as a subprocess and communicates over stdin/stdout.
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
my_server:
|
||||
command: "npx" # or "uvx", "python", any executable
|
||||
args: ["-y", "package"]
|
||||
env:
|
||||
MY_VAR: "value"
|
||||
```
|
||||
|
||||
**Pros:** Simple setup, no network needed, works offline.
|
||||
**Cons:** Server must be installed locally, one process per server.
|
||||
|
||||
### HTTP / StreamableHTTP Transport
|
||||
|
||||
For remote MCP servers accessible over HTTP. Uses the StreamableHTTP protocol from the MCP SDK.
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
my_remote:
|
||||
url: "https://mcp.example.com/endpoint"
|
||||
headers:
|
||||
Authorization: "Bearer token"
|
||||
```
|
||||
|
||||
**Pros:** No local installation needed, shared servers, cloud-hosted.
|
||||
**Cons:** Requires network, slightly higher latency, needs `mcp` package with HTTP support.
|
||||
|
||||
**Note:** If HTTP transport is not available in your installed `mcp` package version, Hermes will log a clear error and skip that server.
|
||||
|
||||
## Reconnection
|
||||
|
||||
If an MCP server connection drops after initial setup (e.g., process crash, network hiccup), Hermes automatically attempts to reconnect with exponential backoff:
|
||||
|
||||
| Attempt | Delay Before Retry |
|
||||
|---------|--------------------|
|
||||
| 1 | 1 second |
|
||||
| 2 | 2 seconds |
|
||||
| 3 | 4 seconds |
|
||||
| 4 | 8 seconds |
|
||||
| 5 | 16 seconds |
|
||||
|
||||
- Maximum of **5 retry attempts** before giving up
|
||||
- Backoff is capped at **60 seconds** (relevant if the formula exceeds this)
|
||||
- Reconnection only triggers for **established connections** that drop — initial connection failures are reported immediately without retries
|
||||
- If shutdown is requested during reconnection, the retry loop exits cleanly
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Errors
|
||||
|
||||
**"mcp package not installed"**
|
||||
|
||||
```
|
||||
MCP SDK not available -- skipping MCP tool discovery
|
||||
```
|
||||
|
||||
Solution: Install the MCP optional dependency:
|
||||
|
||||
```bash
|
||||
pip install hermes-agent[mcp]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**"command not found" or server fails to start**
|
||||
|
||||
The MCP server command (`npx`, `uvx`, etc.) is not on PATH.
|
||||
|
||||
Solution: Install the required runtime:
|
||||
|
||||
```bash
|
||||
# For npm-based servers
|
||||
npm install -g npx # or ensure Node.js 18+ is installed
|
||||
|
||||
# For Python-based servers
|
||||
pip install uv # then use "uvx" as the command
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**"MCP server 'X' has no 'command' in config"**
|
||||
|
||||
Your stdio server config is missing the `command` key.
|
||||
|
||||
Solution: Check your `~/.hermes/config.yaml` indentation and ensure `command` is present:
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
my_server:
|
||||
command: "npx" # <-- required for stdio servers
|
||||
args: ["-y", "package-name"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Server connects but tools fail with authentication errors**
|
||||
|
||||
Your API key or token is missing or invalid.
|
||||
|
||||
Solution: Ensure the key is in the server's `env` block (not your shell env):
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_your_actual_token" # <-- check this
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**"MCP server 'X' is not connected"**
|
||||
|
||||
The server disconnected and reconnection failed (or was never established).
|
||||
|
||||
Solution:
|
||||
1. Check the Hermes logs for connection errors (`hermes --verbose`)
|
||||
2. Verify the server works standalone (e.g., run the `npx` command manually)
|
||||
3. Increase `connect_timeout` if the server is slow to start
|
||||
|
||||
---
|
||||
|
||||
**Connection timeout during discovery**
|
||||
|
||||
```
|
||||
Failed to connect to MCP server 'X': TimeoutError
|
||||
```
|
||||
|
||||
Solution: Increase the `connect_timeout` for slow-starting servers:
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
slow_server:
|
||||
command: "npx"
|
||||
args: ["-y", "heavy-server-package"]
|
||||
connect_timeout: 120 # default is 60
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**HTTP transport not available**
|
||||
|
||||
```
|
||||
mcp.client.streamable_http is not available
|
||||
```
|
||||
|
||||
Solution: Upgrade the `mcp` package to a version that includes HTTP support:
|
||||
|
||||
```bash
|
||||
pip install --upgrade mcp
|
||||
```
|
||||
|
||||
## Popular MCP Servers
|
||||
|
||||
Here are some popular free MCP servers you can use immediately:
|
||||
|
||||
| Server | Package | Description |
|
||||
|--------|---------|-------------|
|
||||
| Filesystem | `@modelcontextprotocol/server-filesystem` | Read/write/search local files |
|
||||
| GitHub | `@modelcontextprotocol/server-github` | Issues, PRs, repos, code search |
|
||||
| Git | `@modelcontextprotocol/server-git` | Git operations on local repos |
|
||||
| Fetch | `@modelcontextprotocol/server-fetch` | HTTP fetching and web content extraction |
|
||||
| Memory | `@modelcontextprotocol/server-memory` | Persistent key-value memory |
|
||||
| SQLite | `@modelcontextprotocol/server-sqlite` | Query SQLite databases |
|
||||
| PostgreSQL | `@modelcontextprotocol/server-postgres` | Query PostgreSQL databases |
|
||||
| Brave Search | `@modelcontextprotocol/server-brave-search` | Web search via Brave API |
|
||||
| Puppeteer | `@modelcontextprotocol/server-puppeteer` | Browser automation |
|
||||
| Sequential Thinking | `@modelcontextprotocol/server-sequential-thinking` | Step-by-step reasoning |
|
||||
|
||||
### Example Configs for Popular Servers
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
# Filesystem — no API key needed
|
||||
filesystem:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
|
||||
|
||||
# Git — no API key needed
|
||||
git:
|
||||
command: "uvx"
|
||||
args: ["mcp-server-git", "--repository", "/home/user/my-repo"]
|
||||
|
||||
# GitHub — requires a personal access token
|
||||
github:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-github"]
|
||||
env:
|
||||
GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_xxxxxxxxxxxx"
|
||||
|
||||
# Fetch — no API key needed
|
||||
fetch:
|
||||
command: "uvx"
|
||||
args: ["mcp-server-fetch"]
|
||||
|
||||
# SQLite — no API key needed
|
||||
sqlite:
|
||||
command: "uvx"
|
||||
args: ["mcp-server-sqlite", "--db-path", "/home/user/data.db"]
|
||||
|
||||
# Brave Search — requires API key (free tier available)
|
||||
brave_search:
|
||||
command: "npx"
|
||||
args: ["-y", "@modelcontextprotocol/server-brave-search"]
|
||||
env:
|
||||
BRAVE_API_KEY: "BSA_xxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
### Multiple Servers
|
||||
|
||||
You can run as many MCP servers as you want simultaneously. Each server gets its own subprocess (stdio) or HTTP connection, and all tools are registered into a single unified namespace.
|
||||
|
||||
Servers are connected sequentially during startup. If one server fails to connect, the others still work — failed servers are logged as warnings and skipped.
|
||||
|
||||
### Tool Naming Convention
|
||||
|
||||
All MCP tools follow the naming pattern:
|
||||
|
||||
```
|
||||
mcp_{server_name}_{tool_name}
|
||||
```
|
||||
|
||||
Both the server name and tool name are sanitized: hyphens (`-`) and dots (`.`) are replaced with underscores (`_`). This ensures compatibility with LLM function-calling APIs that restrict tool name characters.
|
||||
|
||||
If you configure a server named `my-api` that exposes a tool called `query.users`, the agent will see it as `mcp_my_api_query_users`.
|
||||
|
||||
### Configurable Timeouts
|
||||
|
||||
Fine-tune timeouts per server based on expected response times:
|
||||
|
||||
```yaml
|
||||
mcp_servers:
|
||||
fast_cache:
|
||||
command: "npx"
|
||||
args: ["-y", "mcp-server-redis"]
|
||||
timeout: 30 # Fast lookups — short timeout
|
||||
connect_timeout: 15
|
||||
|
||||
slow_analysis:
|
||||
url: "https://analysis.example.com/mcp"
|
||||
timeout: 600 # Long-running analysis — generous timeout
|
||||
connect_timeout: 120
|
||||
```
|
||||
|
||||
### Idempotent Discovery
|
||||
|
||||
`discover_mcp_tools()` is idempotent — calling it multiple times only connects to servers that aren't already running. Already-connected servers keep their existing connections and tool registrations.
|
||||
|
||||
### Custom Toolsets
|
||||
|
||||
Each MCP server's tools are automatically grouped into a toolset named `mcp-{server_name}`. These toolsets are also injected into all `hermes-*` platform toolsets, so MCP tools are available in CLI, Telegram, Discord, and other platforms.
|
||||
|
||||
### Thread Safety
|
||||
|
||||
The MCP subsystem is fully thread-safe. A dedicated background event loop runs in a daemon thread, and all server state is protected by a lock. This works correctly even with Python 3.13+ free-threading builds.
|
||||
@@ -1,121 +0,0 @@
|
||||
# Message Format & Trajectories
|
||||
|
||||
Hermes Agent uses two message formats: the **API format** for LLM calls and the **trajectory format** for training data export.
|
||||
|
||||
## API Message Format
|
||||
|
||||
Standard OpenAI chat format used during execution:
|
||||
|
||||
```python
|
||||
messages = [
|
||||
# System prompt
|
||||
{"role": "system", "content": "You are a helpful assistant with tools..."},
|
||||
|
||||
# User query
|
||||
{"role": "user", "content": "Search for Python tutorials"},
|
||||
|
||||
# Assistant with tool call
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": None,
|
||||
"tool_calls": [{
|
||||
"id": "call_abc123",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "web_search",
|
||||
"arguments": "{\"query\": \"Python tutorials\"}"
|
||||
}
|
||||
}]
|
||||
},
|
||||
|
||||
# Tool result
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "call_abc123",
|
||||
"content": "{\"results\": [...]}"
|
||||
},
|
||||
|
||||
# Final response
|
||||
{"role": "assistant", "content": "Here's what I found..."}
|
||||
]
|
||||
```
|
||||
|
||||
## Trajectory Format (ShareGPT)
|
||||
|
||||
Exported for training in ShareGPT format:
|
||||
|
||||
```json
|
||||
{
|
||||
"conversations": [
|
||||
{"from": "system", "value": "You are a helpful assistant..."},
|
||||
{"from": "human", "value": "Search for Python tutorials"},
|
||||
{"from": "gpt", "value": "<tool_call>\n{\"name\": \"web_search\", \"arguments\": {\"query\": \"Python tutorials\"}}\n</tool_call>"},
|
||||
{"from": "tool", "value": "<tool_response>\n{\"results\": [...]}\n</tool_response>"},
|
||||
{"from": "gpt", "value": "Here's what I found..."}
|
||||
],
|
||||
"tools": "[{\"type\": \"function\", \"function\": {...}}]",
|
||||
"source": "hermes-agent"
|
||||
}
|
||||
```
|
||||
|
||||
## Reasoning Content
|
||||
|
||||
For models that output reasoning/chain-of-thought:
|
||||
|
||||
**During execution** (API format):
|
||||
```python
|
||||
# Stored internally but not sent back to model in content
|
||||
assistant_msg = {
|
||||
"role": "assistant",
|
||||
"content": "Here's what I found...",
|
||||
"reasoning": "Let me think about this step by step..." # Internal only
|
||||
}
|
||||
```
|
||||
|
||||
**In trajectory export** (reasoning wrapped in tags):
|
||||
```json
|
||||
{
|
||||
"from": "gpt",
|
||||
"value": "<think>\nLet me think about this step by step...\n</think>\nHere's what I found..."
|
||||
}
|
||||
```
|
||||
|
||||
## Conversion Flow
|
||||
|
||||
```
|
||||
API Response → Internal Storage → Trajectory Export
|
||||
↓ ↓ ↓
|
||||
tool_calls reasoning field <tool_call> tags
|
||||
reasoning_content <think> tags
|
||||
```
|
||||
|
||||
The conversion happens in `_convert_to_trajectory_format()` in `run_agent.py`.
|
||||
|
||||
## Ephemeral System Prompts
|
||||
|
||||
Batch processing supports ephemeral system prompts that guide behavior during execution but are NOT saved to trajectories:
|
||||
|
||||
```python
|
||||
# During execution: full system prompt + ephemeral guidance
|
||||
messages = [
|
||||
{"role": "system", "content": SYSTEM_PROMPT + "\n\n" + ephemeral_prompt},
|
||||
...
|
||||
]
|
||||
|
||||
# In saved trajectory: only the base system prompt
|
||||
trajectory = {
|
||||
"conversations": [
|
||||
{"from": "system", "value": SYSTEM_PROMPT}, # No ephemeral
|
||||
...
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Trajectory Compression
|
||||
|
||||
Long trajectories can be compressed for training using `trajectory_compressor.py`:
|
||||
|
||||
- Protects first/last N turns
|
||||
- Summarizes middle turns with LLM
|
||||
- Targets specific token budget
|
||||
- See `configs/trajectory_compression.yaml` for settings
|
||||
@@ -1,599 +0,0 @@
|
||||
# Messaging Platform Integrations (Gateway)
|
||||
|
||||
Hermes Agent can connect to messaging platforms like Telegram, Discord, and WhatsApp to serve as a conversational AI assistant.
|
||||
|
||||
## Quick Start
|
||||
|
||||
The easiest way to configure messaging is the interactive wizard:
|
||||
|
||||
```bash
|
||||
hermes gateway setup # Configure Telegram, Discord, Slack, WhatsApp
|
||||
```
|
||||
|
||||
This walks you through each platform with arrow-key selection, handles tokens, allowlists, and home channels, and offers to start/restart the gateway when done.
|
||||
|
||||
**Or configure manually** by editing `~/.hermes/.env`:
|
||||
|
||||
```bash
|
||||
# Set your bot token(s)
|
||||
echo 'TELEGRAM_BOT_TOKEN="your_telegram_bot_token"' >> ~/.hermes/.env
|
||||
echo 'DISCORD_BOT_TOKEN="your_discord_bot_token"' >> ~/.hermes/.env
|
||||
```
|
||||
|
||||
**Then start the gateway:**
|
||||
|
||||
```bash
|
||||
hermes gateway # Run in foreground (useful for debugging)
|
||||
hermes gateway install # Install as a system service (runs in background)
|
||||
|
||||
# Manage the service
|
||||
hermes gateway start
|
||||
hermes gateway stop
|
||||
hermes gateway restart
|
||||
hermes gateway status
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```text
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Hermes Gateway │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
||||
│ │ Telegram │ │ Discord │ │ WhatsApp │ │ Slack │ │
|
||||
│ │ Adapter │ │ Adapter │ │ Adapter │ │ Adapter │ │
|
||||
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
|
||||
│ │ │ │ │ │
|
||||
│ └─────────────┼────────────┼─────────────┘ │
|
||||
│ │ │
|
||||
│ ┌────────▼────────┐ │
|
||||
│ │ Session Store │ │
|
||||
│ │ (per-chat) │ │
|
||||
│ └────────┬────────┘ │
|
||||
│ │ │
|
||||
│ ┌────────▼────────┐ │
|
||||
│ │ AIAgent │ │
|
||||
│ │ (run_agent) │ │
|
||||
│ └─────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Session Management
|
||||
|
||||
### Session Persistence
|
||||
|
||||
Sessions persist across messages until they reset. The agent remembers your conversation context.
|
||||
|
||||
### Reset Policies
|
||||
|
||||
Sessions reset based on configurable policies:
|
||||
|
||||
| Policy | Default | Description |
|
||||
|--------|---------|-------------|
|
||||
| Daily | 4:00 AM | Reset at a specific hour each day |
|
||||
| Idle | 120 min | Reset after N minutes of inactivity |
|
||||
| Both | (combined) | Whichever triggers first |
|
||||
|
||||
### Manual Reset
|
||||
|
||||
Send `/new` or `/reset` as a message to start fresh.
|
||||
|
||||
### Context Management
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/compress` | Manually compress conversation context (saves memories, then summarizes) |
|
||||
| `/usage` | Show token usage and context window status for the current session |
|
||||
| `/update` | Update Hermes Agent to the latest version (pulls code, updates deps, restarts gateway) |
|
||||
| `/reload-mcp` | Disconnect and reconnect all MCP servers from config |
|
||||
|
||||
### Per-Platform Overrides
|
||||
|
||||
Configure different reset policies per platform:
|
||||
|
||||
```json
|
||||
{
|
||||
"reset_by_platform": {
|
||||
"telegram": { "mode": "idle", "idle_minutes": 240 },
|
||||
"discord": { "mode": "idle", "idle_minutes": 60 }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Platform Setup
|
||||
|
||||
### Telegram
|
||||
|
||||
1. **Create a bot** via [@BotFather](https://t.me/BotFather)
|
||||
2. **Get your token** (looks like `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`)
|
||||
3. **Set environment variable:**
|
||||
```bash
|
||||
export TELEGRAM_BOT_TOKEN="your_token_here"
|
||||
```
|
||||
4. **Optional: Set home channel** for cron job delivery:
|
||||
```bash
|
||||
export TELEGRAM_HOME_CHANNEL="-1001234567890"
|
||||
export TELEGRAM_HOME_CHANNEL_NAME="My Notes"
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
```bash
|
||||
pip install python-telegram-bot>=20.0
|
||||
```
|
||||
|
||||
### Discord
|
||||
|
||||
1. **Create an application** at [Discord Developer Portal](https://discord.com/developers/applications)
|
||||
2. **Create a bot** under your application
|
||||
3. **Get the bot token**
|
||||
4. **Enable required intents:**
|
||||
- Message Content Intent
|
||||
- Server Members Intent (optional)
|
||||
5. **Invite to your server** using OAuth2 URL generator (scopes: `bot`, `applications.commands`)
|
||||
6. **Set environment variable:**
|
||||
```bash
|
||||
export DISCORD_BOT_TOKEN="your_token_here"
|
||||
```
|
||||
7. **Optional: Set home channel:**
|
||||
```bash
|
||||
export DISCORD_HOME_CHANNEL="123456789012345678"
|
||||
export DISCORD_HOME_CHANNEL_NAME="#bot-updates"
|
||||
```
|
||||
|
||||
**Requirements:**
|
||||
```bash
|
||||
pip install discord.py>=2.0
|
||||
```
|
||||
|
||||
### WhatsApp
|
||||
|
||||
WhatsApp uses a built-in bridge powered by [Baileys](https://github.com/WhiskeySockets/Baileys) that connects via WhatsApp Web.
|
||||
|
||||
**Two modes:**
|
||||
|
||||
- **`bot` mode (recommended):** Use a dedicated phone number for the bot. Other people message that number directly. All `fromMe` messages are treated as bot echo-backs and ignored.
|
||||
- **`self-chat` mode:** Use your own WhatsApp account. You talk to the agent by messaging yourself (WhatsApp → "Message Yourself").
|
||||
|
||||
**Setup:**
|
||||
|
||||
```bash
|
||||
hermes whatsapp
|
||||
```
|
||||
|
||||
The wizard walks you through mode selection, allowlist configuration, dependency installation, and QR code pairing. For bot mode, you'll need a second phone number with WhatsApp installed on some device (dual-SIM with WhatsApp Business app is the easiest approach).
|
||||
|
||||
Then start the gateway:
|
||||
|
||||
```bash
|
||||
hermes gateway
|
||||
```
|
||||
|
||||
**Environment variables:**
|
||||
|
||||
```bash
|
||||
WHATSAPP_ENABLED=true
|
||||
WHATSAPP_MODE=bot # "bot" (separate number) or "self-chat" (message yourself)
|
||||
WHATSAPP_ALLOWED_USERS=15551234567 # Comma-separated phone numbers with country code
|
||||
```
|
||||
|
||||
**Getting a second number for bot mode:**
|
||||
|
||||
| Option | Cost | Notes |
|
||||
|--------|------|-------|
|
||||
| WhatsApp Business app + dual-SIM | Free (if you have dual-SIM) | Install alongside personal WhatsApp, no second phone needed |
|
||||
| Google Voice | Free (US only) | voice.google.com, verify WhatsApp via the Google Voice app |
|
||||
| Prepaid SIM | $3-10/month | Any carrier; verify once, phone can go in a drawer on WiFi |
|
||||
|
||||
Agent responses are prefixed with "⚕ **Hermes Agent**" for easy identification.
|
||||
|
||||
> **Re-pairing:** If WhatsApp Web sessions disconnect (protocol updates, phone reset), re-pair with `hermes whatsapp`.
|
||||
|
||||
## Configuration
|
||||
|
||||
There are **three ways** to configure the gateway (in order of precedence):
|
||||
|
||||
### 1. Environment Variables (`.env` file) - Recommended for Quick Setup
|
||||
|
||||
Add to your `~/.hermes/.env` file:
|
||||
|
||||
```bash
|
||||
# =============================================================================
|
||||
# MESSAGING PLATFORM TOKENS
|
||||
# =============================================================================
|
||||
|
||||
# Telegram - get from @BotFather on Telegram
|
||||
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
|
||||
TELEGRAM_ALLOWED_USERS=123456789,987654321 # Security: restrict to these user IDs
|
||||
|
||||
# Optional: Default channel for cron job delivery
|
||||
TELEGRAM_HOME_CHANNEL=-1001234567890
|
||||
TELEGRAM_HOME_CHANNEL_NAME="My Notes"
|
||||
|
||||
# Discord - get from Discord Developer Portal
|
||||
DISCORD_BOT_TOKEN=your_discord_bot_token
|
||||
DISCORD_ALLOWED_USERS=123456789012345678 # Security: restrict to these user IDs
|
||||
|
||||
# Optional: Default channel for cron job delivery
|
||||
DISCORD_HOME_CHANNEL=123456789012345678
|
||||
DISCORD_HOME_CHANNEL_NAME="#bot-updates"
|
||||
|
||||
# Slack - get from Slack API (api.slack.com/apps)
|
||||
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
|
||||
SLACK_APP_TOKEN=xapp-your-slack-app-token # Required for Socket Mode
|
||||
SLACK_ALLOWED_USERS=U01234ABCDE # Security: restrict to these user IDs
|
||||
|
||||
# Optional: Default channel for cron job delivery
|
||||
# SLACK_HOME_CHANNEL=C01234567890
|
||||
|
||||
# WhatsApp - pair via: hermes whatsapp
|
||||
WHATSAPP_ENABLED=true
|
||||
WHATSAPP_ALLOWED_USERS=15551234567 # Phone numbers with country code
|
||||
|
||||
# =============================================================================
|
||||
# AGENT SETTINGS
|
||||
# =============================================================================
|
||||
|
||||
# Max tool-calling iterations per conversation (default: 60)
|
||||
HERMES_MAX_ITERATIONS=60
|
||||
|
||||
# Working directory for terminal commands (default: home ~)
|
||||
MESSAGING_CWD=/home/myuser
|
||||
|
||||
# =============================================================================
|
||||
# TOOL PROGRESS NOTIFICATIONS
|
||||
# =============================================================================
|
||||
|
||||
# Tool progress is now configured in config.yaml:
|
||||
# display:
|
||||
# tool_progress: all # off | new | all | verbose
|
||||
|
||||
# =============================================================================
|
||||
# SESSION SETTINGS
|
||||
# =============================================================================
|
||||
|
||||
# Reset sessions after N minutes of inactivity (default: 120)
|
||||
SESSION_IDLE_MINUTES=120
|
||||
|
||||
# Daily reset hour in 24h format (default: 4 = 4am)
|
||||
SESSION_RESET_HOUR=4
|
||||
```
|
||||
|
||||
### 2. Gateway Config File (`~/.hermes/gateway.json`) - Full Control
|
||||
|
||||
For advanced configuration, create `~/.hermes/gateway.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"platforms": {
|
||||
"telegram": {
|
||||
"enabled": true,
|
||||
"token": "your_telegram_token",
|
||||
"home_channel": {
|
||||
"platform": "telegram",
|
||||
"chat_id": "-1001234567890",
|
||||
"name": "My Notes"
|
||||
}
|
||||
},
|
||||
"discord": {
|
||||
"enabled": true,
|
||||
"token": "your_discord_token",
|
||||
"home_channel": {
|
||||
"platform": "discord",
|
||||
"chat_id": "123456789012345678",
|
||||
"name": "#bot-updates"
|
||||
}
|
||||
}
|
||||
},
|
||||
"default_reset_policy": {
|
||||
"mode": "both",
|
||||
"at_hour": 4,
|
||||
"idle_minutes": 120
|
||||
},
|
||||
"reset_by_platform": {
|
||||
"discord": {
|
||||
"mode": "idle",
|
||||
"idle_minutes": 60
|
||||
}
|
||||
},
|
||||
"always_log_local": true
|
||||
}
|
||||
```
|
||||
|
||||
## Platform-Specific Toolsets
|
||||
|
||||
Each platform has its own toolset for security:
|
||||
|
||||
| Platform | Toolset | Capabilities |
|
||||
|----------|---------|--------------|
|
||||
| CLI | `hermes-cli` | Full access (terminal, browser, etc.) |
|
||||
| Telegram | `hermes-telegram` | Full tools including terminal |
|
||||
| Discord | `hermes-discord` | Full tools including terminal |
|
||||
| WhatsApp | `hermes-whatsapp` | Full tools including terminal |
|
||||
| Slack | `hermes-slack` | Full tools including terminal |
|
||||
|
||||
## User Experience Features
|
||||
|
||||
### Typing Indicator
|
||||
|
||||
The gateway keeps the "typing..." indicator active throughout processing, refreshing every 4 seconds. This lets users know the bot is working even during long tool-calling sequences.
|
||||
|
||||
### Tool Progress Notifications
|
||||
|
||||
When `tool_progress` is enabled in `config.yaml`, the bot sends status messages as it works:
|
||||
|
||||
```text
|
||||
💻 `ls -la`...
|
||||
🔍 web_search...
|
||||
📄 web_extract...
|
||||
🎨 image_generate...
|
||||
```
|
||||
|
||||
Terminal commands show the actual command (truncated to 50 chars). Other tools just show the tool name.
|
||||
|
||||
**Modes:**
|
||||
- `new`: Only sends message when switching to a different tool (less spam)
|
||||
- `all`: Sends message for every single tool call
|
||||
|
||||
### Working Directory
|
||||
|
||||
- **CLI (`hermes` command)**: Uses current directory where you run the command
|
||||
- **Messaging**: Uses `MESSAGING_CWD` (default: home directory `~`)
|
||||
|
||||
This is intentional: CLI users are in a terminal and expect the agent to work in their current directory, while messaging users need a consistent starting location.
|
||||
|
||||
### Max Iterations
|
||||
|
||||
If the agent hits the max iteration limit while working, instead of a generic error, it asks the model to summarize what it found so far. This gives you a useful response even when the task couldn't be fully completed.
|
||||
|
||||
## Voice Messages (TTS)
|
||||
|
||||
The `text_to_speech` tool generates audio that the gateway delivers as native voice messages on each platform:
|
||||
|
||||
| Platform | Delivery | Format |
|
||||
|----------|----------|--------|
|
||||
| Telegram | Voice bubble (plays inline) | Opus `.ogg` — native from OpenAI/ElevenLabs, converted via ffmpeg for Edge TTS |
|
||||
| Discord | Audio file attachment | MP3 |
|
||||
| WhatsApp | Audio file attachment | MP3 |
|
||||
| CLI | Saved to `~/voice-memos/` | MP3 |
|
||||
|
||||
**Providers:**
|
||||
- **Edge TTS** (default) — Free, no API key, 322 voices in 74 languages
|
||||
- **ElevenLabs** — Premium quality, requires `ELEVENLABS_API_KEY`
|
||||
- **OpenAI TTS** — Good quality, requires `OPENAI_API_KEY`
|
||||
|
||||
Voice and provider are configured by the user in `~/.hermes/config.yaml` under the `tts:` key. The model only sends text; it does not choose the voice.
|
||||
|
||||
The tool returns a `MEDIA:<path>` tag that the gateway sending pipeline intercepts and delivers as a native audio message. If `[[audio_as_voice]]` is present (Opus format available), Telegram sends it as a voice bubble instead of an audio file.
|
||||
|
||||
**Telegram voice bubbles & ffmpeg:**
|
||||
|
||||
Telegram requires Opus/OGG format for native voice bubbles (the round, inline-playable kind). **OpenAI and ElevenLabs** produce Opus natively when on Telegram — no extra setup needed. **Edge TTS** (the default free provider) outputs MP3 and needs `ffmpeg` to convert:
|
||||
|
||||
```bash
|
||||
sudo apt install ffmpeg # Ubuntu/Debian
|
||||
brew install ffmpeg # macOS
|
||||
sudo dnf install ffmpeg # Fedora
|
||||
```
|
||||
|
||||
Without ffmpeg, Edge TTS audio is sent as a regular audio file (still playable, but shows as a rectangular music player instead of a voice bubble).
|
||||
|
||||
## Cron Job Delivery
|
||||
|
||||
Cron jobs are executed automatically by the gateway daemon. When the gateway is running (via `hermes gateway` or `hermes gateway install`), it ticks the scheduler every 60 seconds and runs due jobs.
|
||||
|
||||
When scheduling cron jobs, you can specify where the output should be delivered:
|
||||
|
||||
```text
|
||||
User: "Remind me to check the server in 30 minutes"
|
||||
|
||||
Agent uses: schedule_cronjob(
|
||||
prompt="Check server status...",
|
||||
schedule="30m",
|
||||
deliver="origin" # Back to this chat
|
||||
)
|
||||
```
|
||||
|
||||
### Delivery Options
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `"origin"` | Back to where the job was created |
|
||||
| `"local"` | Save to local files only |
|
||||
| `"telegram"` | Telegram home channel |
|
||||
| `"discord"` | Discord home channel |
|
||||
| `"telegram:123456"` | Specific Telegram chat |
|
||||
|
||||
## Dynamic Context Injection
|
||||
|
||||
The agent knows where it is via injected context:
|
||||
|
||||
```text
|
||||
## Current Session Context
|
||||
|
||||
**Source:** Telegram (group: Dev Team, ID: -1001234567890)
|
||||
**Connected Platforms:** local, telegram, discord
|
||||
|
||||
**Home Channels:**
|
||||
- telegram: My Notes (ID: -1001234567890)
|
||||
- discord: #bot-updates (ID: 123456789012345678)
|
||||
|
||||
**Delivery options for scheduled tasks:**
|
||||
- "origin" → Back to this chat (Dev Team)
|
||||
- "local" → Save to local files only
|
||||
- "telegram" → Home channel (My Notes)
|
||||
- "discord" → Home channel (#bot-updates)
|
||||
```
|
||||
|
||||
## CLI Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/platforms` | Show gateway configuration and status |
|
||||
| `--gateway` | Start the gateway (CLI flag) |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "python-telegram-bot not installed"
|
||||
|
||||
```bash
|
||||
pip install python-telegram-bot>=20.0
|
||||
```
|
||||
|
||||
### "discord.py not installed"
|
||||
|
||||
```bash
|
||||
pip install discord.py>=2.0
|
||||
```
|
||||
|
||||
### "No platforms connected"
|
||||
|
||||
1. Check your environment variables are set
|
||||
2. Check your tokens are valid
|
||||
3. Try `/platforms` to see configuration status
|
||||
|
||||
### Session not persisting
|
||||
|
||||
1. Check `~/.hermes/sessions/` exists
|
||||
2. Check session policies aren't too aggressive
|
||||
3. Verify no errors in gateway logs
|
||||
|
||||
## Adding a New Platform
|
||||
|
||||
To add a new messaging platform:
|
||||
|
||||
### 1. Create the adapter
|
||||
|
||||
Create `gateway/platforms/your_platform.py`:
|
||||
|
||||
```python
|
||||
from gateway.platforms.base import BasePlatformAdapter, MessageEvent, SendResult
|
||||
from gateway.config import Platform, PlatformConfig
|
||||
|
||||
class YourPlatformAdapter(BasePlatformAdapter):
|
||||
def __init__(self, config: PlatformConfig):
|
||||
super().__init__(config, Platform.YOUR_PLATFORM)
|
||||
|
||||
async def connect(self) -> bool:
|
||||
# Connect to the platform
|
||||
...
|
||||
|
||||
async def disconnect(self) -> None:
|
||||
# Disconnect
|
||||
...
|
||||
|
||||
async def send(self, chat_id: str, content: str, ...) -> SendResult:
|
||||
# Send a message
|
||||
...
|
||||
|
||||
async def get_chat_info(self, chat_id: str) -> Dict[str, Any]:
|
||||
# Get chat information
|
||||
...
|
||||
```
|
||||
|
||||
### 2. Register the platform
|
||||
|
||||
Add to `gateway/config.py`:
|
||||
|
||||
```python
|
||||
class Platform(Enum):
|
||||
# ... existing ...
|
||||
YOUR_PLATFORM = "your_platform"
|
||||
```
|
||||
|
||||
### 3. Add to gateway runner
|
||||
|
||||
Update `gateway/run.py` `_create_adapter()`:
|
||||
|
||||
```python
|
||||
elif platform == Platform.YOUR_PLATFORM:
|
||||
from gateway.platforms.your_platform import YourPlatformAdapter
|
||||
return YourPlatformAdapter(config)
|
||||
```
|
||||
|
||||
### 4. Create a toolset (optional)
|
||||
|
||||
Add to `toolsets.py`:
|
||||
|
||||
```python
|
||||
"hermes-your-platform": {
|
||||
"description": "Your platform toolset",
|
||||
"tools": [...],
|
||||
"includes": []
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Configure
|
||||
|
||||
Add environment variables to `.env`:
|
||||
|
||||
```bash
|
||||
YOUR_PLATFORM_TOKEN=...
|
||||
YOUR_PLATFORM_HOME_CHANNEL=...
|
||||
```
|
||||
|
||||
## Service Management
|
||||
|
||||
### Linux (systemd)
|
||||
|
||||
```bash
|
||||
# Install as user service
|
||||
./scripts/hermes-gateway install
|
||||
|
||||
# Manage
|
||||
systemctl --user start hermes-gateway
|
||||
systemctl --user stop hermes-gateway
|
||||
systemctl --user restart hermes-gateway
|
||||
systemctl --user status hermes-gateway
|
||||
|
||||
# View logs
|
||||
journalctl --user -u hermes-gateway -f
|
||||
|
||||
# Enable lingering (keeps running after logout)
|
||||
sudo loginctl enable-linger $USER
|
||||
```
|
||||
|
||||
### macOS (launchd)
|
||||
|
||||
```bash
|
||||
# Install
|
||||
./scripts/hermes-gateway install
|
||||
|
||||
# Manage
|
||||
launchctl start ai.hermes.gateway
|
||||
launchctl stop ai.hermes.gateway
|
||||
|
||||
# View logs
|
||||
tail -f ~/.hermes/logs/gateway.log
|
||||
```
|
||||
|
||||
### Manual (any platform)
|
||||
|
||||
```bash
|
||||
# Run in foreground (for testing/debugging)
|
||||
./scripts/hermes-gateway run
|
||||
|
||||
# Or via CLI (also foreground)
|
||||
python cli.py --gateway
|
||||
```
|
||||
|
||||
## Interrupting the Agent
|
||||
|
||||
Send any message while the agent is working to interrupt it. The message becomes the next prompt after the agent stops. Key behaviors:
|
||||
|
||||
- **In-progress terminal commands are killed immediately** -- SIGTERM first, SIGKILL after 1 second if the process resists. Works on local, Docker, SSH, Singularity, and Modal backends.
|
||||
- **Tool calls are cancelled** -- if the model generated multiple tool calls in one batch, only the currently-executing one runs. The rest are skipped.
|
||||
- **Multiple messages are combined** -- if you send "Stop!" then "Do X instead" while the agent is stopping, both messages are joined into one prompt (separated by newline).
|
||||
- **`/stop` command** -- interrupts without queuing a follow-up message.
|
||||
- **Priority processing** -- interrupt signals bypass command parsing and session creation for minimal latency.
|
||||
|
||||
## Storage Locations
|
||||
|
||||
| Path | Purpose |
|
||||
|------|---------|
|
||||
| `~/.hermes/gateway.json` | Gateway configuration |
|
||||
| `~/.hermes/sessions/sessions.json` | Session index |
|
||||
| `~/.hermes/sessions/{id}.jsonl` | Conversation transcripts |
|
||||
| `~/.hermes/cron/output/` | Cron job outputs |
|
||||
| `~/.hermes/logs/gateway.log` | Gateway logs (macOS launchd) |
|
||||
@@ -1,857 +0,0 @@
|
||||
# Hermes Skills Hub — Design Plan
|
||||
|
||||
## Vision
|
||||
|
||||
Turn Hermes Agent into the first **universal skills client** — not locked to any single ecosystem, but capable of pulling skills from ClawHub, GitHub, Claude Code plugin marketplaces, the Codex skills catalog, LobeHub, AI Skill Store, Vercel skills.sh, local directories, and eventually a Nous-hosted registry. Think of it like how Homebrew taps work: multiple sources, one interface, local-first with optional remotes.
|
||||
|
||||
The key insight: there is now an **official open standard** for agent skills at [agentskills.io](https://agentskills.io/specification), jointly adopted by OpenAI (Codex), Anthropic (Claude Code), Cursor, Cline, OpenCode, Pi, and 35+ other agents. The format is essentially identical to what Hermes already uses (SKILL.md + supporting files). We should fully adopt this standard and build a **polyglot skills client** that treats all of these as valid sources, with a security-first approach that none of the existing registries have nailed.
|
||||
|
||||
---
|
||||
|
||||
## Ecosystem Landscape (Research Summary, Feb 2026)
|
||||
|
||||
### The Open Standard: agentskills.io
|
||||
|
||||
Published by OpenAI in Dec 2025, now adopted across the ecosystem. Spec lives at [agentskills.io/specification](https://agentskills.io/specification). Key points:
|
||||
|
||||
- **Required:** SKILL.md with YAML frontmatter (`name` 1-64 chars, `description` 1-1024 chars)
|
||||
- **Optional dirs:** `scripts/`, `references/`, `assets/`
|
||||
- **Optional fields:** `license`, `compatibility`, `metadata` (arbitrary key-value), `allowed-tools` (experimental)
|
||||
- **Progressive disclosure:** metadata (~100 tokens) at startup → full SKILL.md (<5000 tokens) on activation → resources on demand
|
||||
- **Validation:** `skills-ref validate ./my-skill` CLI tool
|
||||
|
||||
This is already 95% compatible with Hermes's existing `skills_tool.py`. Main gaps:
|
||||
- Hermes uses `tags` and `related_skills` fields (not in spec but harmless — spec allows `metadata` for extensions)
|
||||
- Hermes doesn't yet support `compatibility` or `allowed-tools` fields
|
||||
- Hermes doesn't support the `agents/openai.yaml` metadata file (Codex-specific, optional)
|
||||
|
||||
### Registries & Marketplaces
|
||||
|
||||
| Registry | Type | Skills | Install Method | Security | Notes |
|
||||
|----------|------|--------|---------------|----------|-------|
|
||||
| **ClawHub** (clawhub.ai) | Centralized registry | 3,000+ curated (5,700 total) | `clawhub install <slug>` (npm CLI) or HTTP API | VirusTotal + LLM scan, but had 341 malicious skills incident | OpenClaw/Moltbot ecosystem. Convex backend, vector search via OpenAI embeddings |
|
||||
| **OpenAI Skills Catalog** (github.com/openai/skills) | Official GitHub repo | .system (auto-installed), .curated, .experimental tiers | `$skill-installer` inside Codex | Curated by OpenAI | 8.8k stars. Skills auto-discovered from `$HOME/.agents/skills/`, `/etc/codex/skills/`, repo `.agents/skills/` |
|
||||
| **Anthropic Skills** (github.com/anthropics/skills) | Official GitHub repo | Document skills (docx, pdf, pptx, xlsx) + examples | `/plugin marketplace add anthropics/skills` | Curated by Anthropic | Source-available (not open source) for production doc skills |
|
||||
| **Claude Code Plugin Marketplaces** | Distributed (any GitHub repo) | 2,748+ marketplace repos indexed | `/plugin marketplace add owner/repo` | Per-marketplace. 3+ reports auto-hides | Schema: `.claude-plugin/marketplace.json`. Supports GitHub, Git URL, npm, pip sources |
|
||||
| **Vercel skills.sh** (github.com/vercel-labs/skills) | Universal CLI | Aggregator (installs from GitHub) | `npx skills add owner/repo` | Trust scores via installagentskills.com | Detects 35+ agents, auto-installs to correct paths. Symlink or copy modes |
|
||||
| **LobeHub Skills Marketplace** (lobehub.com/skills) | Web marketplace | 14,500+ skills | Browse/download | Quality checks + community feedback | Huge searchable index. Categories: Developer (10.8k), Productivity (781), Science (553), etc. |
|
||||
| **AI Skill Store** (skillstore.io) | Curated marketplace | Growing | ZIP or `$skill-installer` | Automated security analysis (eval, exec, network, secrets, obfuscation checks) + admin review | Follows agentskills.io spec. Submission at skillstore.io/submit |
|
||||
| **Cursor Directory** (cursor.directory) | Rules & skills hub | Large | Settings → Rules → Remote Rule (GitHub) | Community-curated | Cursor-specific but skills follow the standard |
|
||||
|
||||
### GitHub Awesome Lists & Collections
|
||||
|
||||
| Repo | Stars | Skills | Focus |
|
||||
|------|-------|--------|-------|
|
||||
| **VoltAgent/awesome-agent-skills** | 7.3k | 300+ | Cross-platform (Claude Code, Codex, Cursor, Gemini CLI, etc.) |
|
||||
| **VoltAgent/awesome-openclaw-skills** | 16.3k | 3,002 curated | OpenClaw/Moltbot ecosystem |
|
||||
| **jdrhyne/agent-skills** | — | 35 | Cross-platform. 34/35 AgentVerus-certified. Quality over quantity |
|
||||
| **ComposioHQ/awesome-claude-skills** | — | 107 | Claude.ai and API |
|
||||
| **claudemarketplaces.com** | — | 2,748 marketplace repos | Claude Code plugin marketplace directory |
|
||||
| **majiayu000/claude-skill-registry** | — | 1,001+ | Web search at skills-registry-web.vercel.app |
|
||||
|
||||
### Agent Codebases (Local Analysis)
|
||||
|
||||
| Agent | Skills Location | Format | Remote Install | Notes |
|
||||
|-------|----------------|--------|---------------|-------|
|
||||
| **OpenClaw** (~/agent-codebases/clawdbot) | `skills/` (52 shipped) | SKILL.md + `metadata.openclaw` (emoji, requires.bins, install instructions) | ClawHub CLI + plugin marketplace system | Full plugin system with `openclaw.plugin.json` manifests, marketplace registries, workspace/global/bundled precedence |
|
||||
| **Codex** (~/agent-codebases/codex) | `.codex/skills/`, `.agents/skills/`, `~/.agents/skills/`, `/etc/codex/skills/` | SKILL.md + `agents/openai.yaml` | `$skill-installer` (built-in skill), remote.rs for API-based "hazelnut" skills | Rust implementation. Scans 6 scope levels (REPO→USER→ADMIN→SYSTEM). `openai.yaml` adds UI interface, tool dependencies, invocation policy |
|
||||
| **Cline** (~/agent-codebases/cline) | `.cline/skills/` | SKILL.md (minimal) | — | Simple SkillMetadata interface: {name, description, path, source: "global"\|"project"} |
|
||||
| **Pi** (~/agent-codebases/pi-mono) | `.agents/skills/` | SKILL.md (agentskills.io standard) | — | Follows the standard. Tests for collision handling, validation |
|
||||
| **OpenCode** (~/agent-codebases/opencode) | `.opencode/skill/` | SKILL.md | — | Minimal implementation |
|
||||
| **Composio** (~/agent-codebases/composio) | `.claude/skills/` | SKILL.md (Claude-format) | Composio SDK for tool integrations | Different focus: SDK for integrating with external services (HackerNews, GitHub, etc.) |
|
||||
| **Cursor** | `.cursor/skills/`, `~/.cursor/skills/` | SKILL.md + `disable-model-invocation` option | Remote Rules from GitHub | Also reads `.claude/skills/` and `.codex/skills/` for compatibility |
|
||||
|
||||
### Tools & Utilities
|
||||
|
||||
| Tool | Purpose | Notes |
|
||||
|------|---------|-------|
|
||||
| **Skrills** (Rust) | MCP server + CLI for managing local SKILL.md files | Validates, syncs between Claude Code and Codex, minimal token overhead |
|
||||
| **AgentVerus** | Open source security scanner | Detects prompt injection, data exfiltration, hidden threats in skills |
|
||||
| **skills-ref** | Validation library | From the agentskills.io spec. Validates naming, frontmatter |
|
||||
| **installagentskills.com** | Trust scoring directory | Trust score (0-100), risk levels, freshness/stars/safety signals |
|
||||
|
||||
### Key Security Incidents
|
||||
|
||||
1. **ClawHavoc (Feb 2026):** 341 malicious skills found on ClawHub. 335 from a single coordinated campaign. Exfiltrated env vars, installed Atomic Stealer malware.
|
||||
2. **Cisco research:** 26% of 31,000 publicly available skills contained suspicious patterns.
|
||||
3. **Bitsight report:** Exposed OpenClaw instances with terminal access are a top security risk.
|
||||
|
||||
---
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ Hermes Agent │
|
||||
│ │
|
||||
│ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐ │
|
||||
│ │ skills_tool │ │ skills_hub │ │ skills_guard│ │
|
||||
│ │ (existing) │◄──│ (new) │──►│ (new) │ │
|
||||
│ │ list/view │ │ search/ │ │ scan/audit │ │
|
||||
│ │ local skills │ │ install/ │ │ quarantine │ │
|
||||
│ └──────┬───────┘ │ update/sync │ └─────────────┘ │
|
||||
│ │ └──────┬───────┘ │
|
||||
│ │ │ │
|
||||
│ skills/ │ │
|
||||
│ ├── mlops/ ┌────┴────────────────┐ │
|
||||
│ ├── note-taking/ │ Source Adapters │ │
|
||||
│ ├── diagramming/ │ │ │
|
||||
│ └── .hub/ │ ┌───────────────┐ │ │
|
||||
│ ├── lock.json │ │ ClawHub API │ │ │
|
||||
│ ├── quarantine/│ │ GitHub repos │ │ │
|
||||
│ └── audit.log │ │ Raw URLs │ │ │
|
||||
│ │ │ Nous Registry │ │ │
|
||||
│ │ └───────────────┘ │ │
|
||||
│ └─────────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Part 1: Source Adapters
|
||||
|
||||
Each source is a Python class implementing a simple interface:
|
||||
|
||||
```python
|
||||
class SkillSource(ABC):
|
||||
async def search(self, query: str, limit: int = 10) -> list[SkillMeta]
|
||||
async def fetch(self, slug: str, version: str = "latest") -> SkillBundle
|
||||
async def inspect(self, slug: str) -> SkillDetail # metadata without download
|
||||
def source_id(self) -> str # e.g. "clawhub", "github", "nous"
|
||||
```
|
||||
|
||||
### Source 1: ClawHub Adapter
|
||||
|
||||
ClawHub's backend is Convex with HTTP actions. Rather than depending on their npm CLI, we write a lightweight Python HTTP client.
|
||||
|
||||
- **Search:** Hit their vector search endpoint (they use `text-embedding-3-small` + Convex vector search). Fall back to their lexical search if embeddings are unavailable.
|
||||
- **Install:** Download the skill bundle (SKILL.md + supporting files) via their API. They return versioned file sets.
|
||||
- **Auth:** Optional. ClawHub allows anonymous browsing/downloading. Auth (GitHub OAuth) only needed for publishing.
|
||||
- **Rate limiting:** Respect their per-IP/day dedup. Cache search results locally for 1 hour.
|
||||
|
||||
```python
|
||||
class ClawHubSource(SkillSource):
|
||||
BASE_URL = "https://clawhub.ai/api/v1"
|
||||
|
||||
async def search(self, query, limit=10):
|
||||
resp = await httpx.get(f"{self.BASE_URL}/skills/search",
|
||||
params={"q": query, "limit": limit})
|
||||
return [SkillMeta.from_clawhub(s) for s in resp.json()["skills"]]
|
||||
|
||||
async def fetch(self, slug, version="latest"):
|
||||
resp = await httpx.get(f"{self.BASE_URL}/skills/{slug}/versions/{version}/files")
|
||||
return SkillBundle.from_clawhub(resp.json())
|
||||
```
|
||||
|
||||
### Source 2: GitHub Adapter
|
||||
|
||||
For repos like `VoltAgent/awesome-openclaw-skills`, `jdrhyne/agent-skills`, or any arbitrary GitHub repo containing skills.
|
||||
|
||||
- **Search:** Use GitHub's search API or a local index of known skill repos.
|
||||
- **Install:** Sparse checkout or download specific directories via GitHub's archive/contents API.
|
||||
- **Curated repos:** Maintain a small list of known-good repos as "taps" (borrowing Homebrew terminology).
|
||||
|
||||
```python
|
||||
DEFAULT_TAPS = [
|
||||
{"repo": "VoltAgent/awesome-openclaw-skills", "path": "skills/"},
|
||||
{"repo": "jdrhyne/agent-skills", "path": "skills/"},
|
||||
]
|
||||
```
|
||||
|
||||
### Source 3: OpenAI Skills Catalog
|
||||
|
||||
The official `openai/skills` GitHub repo has tiered skills:
|
||||
- `.system` — auto-installed in Codex (we could auto-import these too)
|
||||
- `.curated` — vetted by OpenAI, high quality
|
||||
- `.experimental` — community submissions
|
||||
|
||||
Codex has a built-in `$skill-installer` that uses `scripts/list-skills.py` and `scripts/install-skill-from-github.py`. We can either call these scripts directly or replicate the GitHub API calls in Python.
|
||||
|
||||
```python
|
||||
class OpenAISkillsSource(SkillSource):
|
||||
REPO = "openai/skills"
|
||||
TIERS = [".curated", ".experimental"]
|
||||
|
||||
async def search(self, query, limit=10):
|
||||
# Fetch skill index from GitHub API, filter by query
|
||||
...
|
||||
|
||||
async def fetch(self, slug, version="latest"):
|
||||
# Download specific skill dir from openai/skills repo
|
||||
...
|
||||
```
|
||||
|
||||
### Source 4: Claude Code Plugin Marketplaces
|
||||
|
||||
Claude Code has a distributed marketplace system. Any GitHub repo with a `.claude-plugin/marketplace.json` is a marketplace. The schema supports GitHub repos, Git URLs, npm packages, and pip packages as plugin sources.
|
||||
|
||||
This is powerful because there are already 2,748+ marketplace repos. We could:
|
||||
- Index the known marketplaces from claudemarketplaces.com
|
||||
- Parse their `marketplace.json` to discover available skills
|
||||
- Download skills from the source repos they point to
|
||||
|
||||
```python
|
||||
class ClaudeMarketplaceSource(SkillSource):
|
||||
# Known marketplace repos
|
||||
KNOWN_MARKETPLACES = [
|
||||
"anthropics/skills", # Official Anthropic
|
||||
"anthropics/claude-code", # Bundled plugins
|
||||
"aiskillstore/marketplace", # Security-audited
|
||||
]
|
||||
|
||||
async def search(self, query, limit=10):
|
||||
# Parse marketplace.json files, search plugin descriptions
|
||||
...
|
||||
```
|
||||
|
||||
### Source 5: LobeHub Marketplace
|
||||
|
||||
LobeHub has 14,500+ skills with a web interface. If they have an API, we can search it:
|
||||
|
||||
```python
|
||||
class LobeHubSource(SkillSource):
|
||||
BASE_URL = "https://lobehub.com"
|
||||
# Search their marketplace API for skills
|
||||
...
|
||||
```
|
||||
|
||||
### Source 6: Vercel skills.sh / npx skills
|
||||
|
||||
Vercel's `npx skills` CLI is already a universal installer that works across 35+ agents. Rather than competing with it, we could leverage it as a fallback source — or at minimum, ensure our install paths are compatible so `npx skills add` also works with Hermes.
|
||||
|
||||
Key insight: `npx skills add owner/repo` detects installed agents and places skills in the right directories. If we register Hermes's skill path convention, any skills.sh-compatible repo just works.
|
||||
|
||||
### Source 7: Raw URL / Local Path
|
||||
|
||||
Allow installing from any URL pointing to a git repo or tarball containing a SKILL.md:
|
||||
|
||||
```
|
||||
hermes skills install https://github.com/someone/cool-skill
|
||||
hermes skills install /path/to/local/skill-folder
|
||||
```
|
||||
|
||||
### Source 8: Nous Registry (Future)
|
||||
|
||||
A Nous Research-hosted registry with curated, security-audited skills specifically tested with Hermes. This would be the "blessed" source. Differentiation:
|
||||
|
||||
- Every skill tested against Hermes Agent specifically (not just OpenClaw)
|
||||
- Security audit by Nous team before listing
|
||||
- Skills can declare Hermes-specific features (tool dependencies, required env vars, min agent version)
|
||||
- Community submissions via PR, reviewed by maintainers
|
||||
|
||||
---
|
||||
|
||||
## Part 2: Skills Guard (Security Layer)
|
||||
|
||||
This is where we differentiate hard from ClawHub's weak security posture. Every skill goes through a pipeline before it touches the live skills/ directory.
|
||||
|
||||
### Quarantine Flow
|
||||
|
||||
```
|
||||
Download → Quarantine → Static Scan → LLM Audit → User Review → Install
|
||||
│ │ │ │
|
||||
▼ ▼ ▼ ▼
|
||||
.hub/quarantine/ Pattern Prompt the Show report,
|
||||
skill-slug/ matching agent to ask confirm
|
||||
for bad analyze the
|
||||
patterns skill files
|
||||
```
|
||||
|
||||
### Static Scanner (skills_guard.py)
|
||||
|
||||
Fast regex/AST-based scanning for known-bad patterns:
|
||||
|
||||
```python
|
||||
THREAT_PATTERNS = [
|
||||
# Data exfiltration
|
||||
(r'curl\s+.*\$\{?\w*(KEY|TOKEN|SECRET|PASSWORD)', "env_exfil", "critical"),
|
||||
(r'wget\s+.*\$\{?\w*(KEY|TOKEN|SECRET|PASSWORD)', "env_exfil", "critical"),
|
||||
(r'base64.*env', "encoded_exfil", "high"),
|
||||
|
||||
# Hidden instructions
|
||||
(r'ignore\s+(previous|all|above)\s+instructions', "prompt_injection", "critical"),
|
||||
(r'you\s+are\s+now\s+', "role_hijack", "high"),
|
||||
(r'do\s+not\s+tell\s+the\s+user', "deception", "high"),
|
||||
|
||||
# Destructive operations
|
||||
(r'rm\s+-rf\s+/', "destructive_root", "critical"),
|
||||
(r'chmod\s+777', "insecure_perms", "medium"),
|
||||
(r'>\s*/etc/', "system_overwrite", "critical"),
|
||||
|
||||
# Stealth/persistence
|
||||
(r'crontab', "persistence", "medium"),
|
||||
(r'\.bashrc|\.zshrc|\.profile', "shell_mod", "medium"),
|
||||
(r'ssh-keygen|authorized_keys', "ssh_backdoor", "critical"),
|
||||
|
||||
# Network callbacks
|
||||
(r'nc\s+-l|ncat|socat', "reverse_shell", "critical"),
|
||||
(r'ngrok|localtunnel|serveo', "tunnel", "high"),
|
||||
]
|
||||
```
|
||||
|
||||
### LLM Audit (Optional, Powerful)
|
||||
|
||||
After static scanning passes, optionally use the agent itself to analyze the skill:
|
||||
|
||||
```
|
||||
"Analyze this skill file for security risks. Look for:
|
||||
1. Instructions that could exfiltrate environment variables or files
|
||||
2. Hidden instructions that override the user's intent
|
||||
3. Commands that modify system configuration
|
||||
4. Network requests to unknown endpoints
|
||||
5. Attempts to persist across sessions
|
||||
|
||||
Skill content:
|
||||
{skill_content}
|
||||
|
||||
Respond with a risk assessment: SAFE / CAUTION / DANGEROUS and explain why."
|
||||
```
|
||||
|
||||
### Trust Levels
|
||||
|
||||
Skills get a trust level that determines what they can do:
|
||||
|
||||
| Level | Source | Scan Status | Behavior |
|
||||
|-------|--------|-------------|----------|
|
||||
| **Builtin** | Ships with Hermes | N/A | Full access, loaded by default |
|
||||
| **Trusted** | Nous Registry | Audited | Full access after install |
|
||||
| **Verified** | ClawHub + scan pass | Auto-scanned | Loaded, shown warning on first use |
|
||||
| **Community** | GitHub/URL | User-scanned | Quarantined until user approves |
|
||||
| **Unscanned** | Any | Not yet scanned | Blocked until scanned |
|
||||
|
||||
---
|
||||
|
||||
## Part 3: CLI Commands
|
||||
|
||||
### New `hermes skills` subcommand tree
|
||||
|
||||
```bash
|
||||
# Discovery
|
||||
hermes skills search "kubernetes deployment" # Search all sources
|
||||
hermes skills search "docker" --source clawhub # Search specific source
|
||||
hermes skills explore # Browse trending/popular
|
||||
hermes skills inspect <slug> # View metadata without installing
|
||||
|
||||
# Installation
|
||||
hermes skills install <slug> # Install from best source
|
||||
hermes skills install <slug> --source github # Install from specific source
|
||||
hermes skills install <github-url> # Install from URL
|
||||
hermes skills install <local-path> # Install from local directory
|
||||
hermes skills install <slug> --category devops # Install into specific category
|
||||
|
||||
# Management
|
||||
hermes skills list # List installed (local + hub)
|
||||
hermes skills list --source hub # List only hub-installed skills
|
||||
hermes skills update # Update all hub-installed skills
|
||||
hermes skills update <slug> # Update specific skill
|
||||
hermes skills uninstall <slug> # Remove hub-installed skill
|
||||
hermes skills audit <slug> # Re-run security scan
|
||||
hermes skills audit --all # Audit everything
|
||||
|
||||
# Sources
|
||||
hermes skills tap add <repo-url> # Add a GitHub repo as source
|
||||
hermes skills tap list # List configured sources
|
||||
hermes skills tap remove <name> # Remove a source
|
||||
```
|
||||
|
||||
### Implementation in hermes_cli/main.py
|
||||
|
||||
Add a `cmd_skills` function and wire it into the argparse tree:
|
||||
|
||||
```python
|
||||
def cmd_skills(args):
|
||||
"""Skills hub management."""
|
||||
from hermes_cli.skills_hub import skills_command
|
||||
skills_command(args)
|
||||
```
|
||||
|
||||
New file: `hermes_cli/skills_hub.py` handles all subcommands with Rich output for pretty tables and panels.
|
||||
|
||||
---
|
||||
|
||||
## Part 4: Agent-Side Tools
|
||||
|
||||
The agent should be able to discover and install skills mid-conversation. New tools added to `tools/skills_hub_tool.py`:
|
||||
|
||||
### skill_hub_search
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "skill_hub_search",
|
||||
"description": "Search online skill registries (ClawHub, GitHub) for capabilities to install. Returns skill metadata including name, description, source, install count, and security status.",
|
||||
"parameters": {
|
||||
"query": {"type": "string", "description": "Natural language search query"},
|
||||
"source": {"type": "string", "enum": ["all", "clawhub", "github"], "default": "all"},
|
||||
"limit": {"type": "integer", "default": 5}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### skill_hub_install
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "skill_hub_install",
|
||||
"description": "Install a skill from an online registry into the local skills directory. Runs security scanning before installation. Requires user confirmation for community-sourced skills.",
|
||||
"parameters": {
|
||||
"slug": {"type": "string", "description": "Skill slug or GitHub URL"},
|
||||
"source": {"type": "string", "default": "auto"},
|
||||
"category": {"type": "string", "description": "Category folder to install into"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Workflow Example
|
||||
|
||||
User: "I need to work with Kubernetes deployments"
|
||||
|
||||
Agent thinking:
|
||||
1. Check local skills → no k8s skill found
|
||||
2. Call skill_hub_search("kubernetes deployment management")
|
||||
3. Find "k8s-skills" on ClawHub with 2.3k installs and verified status
|
||||
4. Ask user: "I found a Kubernetes skill on ClawHub. Want me to install it?"
|
||||
5. Call skill_hub_install("k8s-skills", category="devops")
|
||||
6. Security scan runs → passes
|
||||
7. Skill available immediately via existing skills_tool
|
||||
8. Agent loads it with skill_view("k8s-skills") and proceeds
|
||||
|
||||
---
|
||||
|
||||
## Part 5: Lock File & State Management
|
||||
|
||||
### skills/.hub/lock.json
|
||||
|
||||
Track what came from where, enabling updates and rollbacks:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1,
|
||||
"installed": {
|
||||
"k8s-skills": {
|
||||
"source": "clawhub",
|
||||
"slug": "k8s-skills",
|
||||
"version": "1.3.2",
|
||||
"installed_at": "2026-02-17T17:00:00Z",
|
||||
"updated_at": "2026-02-17T17:00:00Z",
|
||||
"trust_level": "verified",
|
||||
"scan_result": "safe",
|
||||
"content_hash": "sha256:abc123...",
|
||||
"install_path": "devops/k8s-skills",
|
||||
"files": ["SKILL.md", "scripts/kubectl-helper.sh"]
|
||||
},
|
||||
"elegant-reports": {
|
||||
"source": "github",
|
||||
"repo": "jdrhyne/agent-skills",
|
||||
"path": "skills/elegant-reports",
|
||||
"commit": "a1b2c3d",
|
||||
"installed_at": "2026-02-17T17:15:00Z",
|
||||
"trust_level": "community",
|
||||
"scan_result": "caution",
|
||||
"scan_notes": "Requires NUTRIENT_API_KEY env var",
|
||||
"install_path": "productivity/elegant-reports",
|
||||
"files": ["SKILL.md", "templates/report.html"]
|
||||
}
|
||||
},
|
||||
"taps": [
|
||||
{
|
||||
"name": "clawhub",
|
||||
"type": "registry",
|
||||
"url": "https://clawhub.ai/api/v1",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "awesome-openclaw",
|
||||
"type": "github",
|
||||
"repo": "VoltAgent/awesome-openclaw-skills",
|
||||
"path": "skills/",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "agent-skills",
|
||||
"type": "github",
|
||||
"repo": "jdrhyne/agent-skills",
|
||||
"path": "skills/",
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### skills/.hub/audit.log
|
||||
|
||||
Append-only log of all security scan results:
|
||||
|
||||
```
|
||||
2026-02-17T17:00:00Z SCAN k8s-skills clawhub:1.3.2 SAFE static_pass=true patterns=0
|
||||
2026-02-17T17:15:00Z SCAN elegant-reports github:a1b2c3d CAUTION static_pass=true patterns=1 note="env:NUTRIENT_API_KEY"
|
||||
2026-02-17T18:30:00Z SCAN sus-skill clawhub:0.1.0 DANGEROUS static_pass=false patterns=3 blocked=true reason="env_exfil,prompt_injection,tunnel"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Part 6: Compatibility Layer
|
||||
|
||||
Since skills from different ecosystems have slight format variations, we need a normalization step:
|
||||
|
||||
### OpenClaw/ClawHub Format (from local codebase analysis)
|
||||
```yaml
|
||||
---
|
||||
name: github
|
||||
description: "GitHub operations via `gh` CLI..."
|
||||
homepage: https://developer.1password.com/docs/cli/get-started/
|
||||
metadata:
|
||||
openclaw:
|
||||
emoji: "🐙"
|
||||
requires:
|
||||
bins: ["gh"]
|
||||
env: ["GITHUB_TOKEN"]
|
||||
primaryEnv: GITHUB_TOKEN
|
||||
install:
|
||||
- id: brew
|
||||
kind: brew
|
||||
formula: gh
|
||||
bins: ["gh"]
|
||||
label: "Install GitHub CLI (brew)"
|
||||
---
|
||||
```
|
||||
Rich metadata including install instructions, binary requirements, and emoji. Uses JSON-in-YAML for metadata block.
|
||||
|
||||
### Codex Format (from local codebase analysis)
|
||||
```yaml
|
||||
---
|
||||
name: skill-creator
|
||||
description: Guide for creating effective skills...
|
||||
metadata:
|
||||
short-description: Create or update a skill
|
||||
---
|
||||
```
|
||||
Plus optional `agents/openai.yaml` sidecar with:
|
||||
- `interface`: display_name, icon_small, icon_large, brand_color, default_prompt
|
||||
- `dependencies.tools`: MCP servers, CLI tools
|
||||
- `policy.allow_implicit_invocation`: boolean
|
||||
|
||||
### Claude Code / Cursor Format
|
||||
```yaml
|
||||
---
|
||||
name: my-skill
|
||||
description: Does something
|
||||
disable-model-invocation: false # Cursor extension
|
||||
---
|
||||
```
|
||||
Simpler. Claude Code uses `.claude-plugin/marketplace.json` for distribution metadata.
|
||||
|
||||
### Cline Format (from local codebase analysis)
|
||||
```typescript
|
||||
// Minimal: just name, description, path, source
|
||||
interface SkillMetadata {
|
||||
name: string
|
||||
description: string
|
||||
path: string
|
||||
source: "global" | "project"
|
||||
}
|
||||
```
|
||||
|
||||
### Pi Format (from local codebase analysis)
|
||||
Follows agentskills.io standard exactly. No extensions.
|
||||
|
||||
### agentskills.io Standard (canonical)
|
||||
```yaml
|
||||
---
|
||||
name: my-skill # Required, 1-64 chars, lowercase+hyphens
|
||||
description: Does thing # Required, 1-1024 chars
|
||||
license: MIT # Optional
|
||||
compatibility: Requires git, docker # Optional, 1-500 chars
|
||||
metadata: # Optional, arbitrary key-value
|
||||
internal: false
|
||||
allowed-tools: Bash(git:*) Read # Experimental
|
||||
---
|
||||
```
|
||||
|
||||
### Hermes Format (Current)
|
||||
```yaml
|
||||
---
|
||||
name: my-skill
|
||||
description: Does something
|
||||
tags: [tag1, tag2]
|
||||
related_skills: [other-skill]
|
||||
version: 1.0.0
|
||||
---
|
||||
```
|
||||
|
||||
### Normalization Strategy
|
||||
|
||||
On install, we parse any of these formats and ensure the SKILL.md works with Hermes's existing `_parse_frontmatter()`. The normalizer:
|
||||
|
||||
1. **OpenClaw metadata extraction:**
|
||||
- `metadata.openclaw.requires.env` → adds to Hermes `compatibility` field
|
||||
- `metadata.openclaw.requires.bins` → adds to `compatibility` field
|
||||
- `metadata.openclaw.install` → logged in lock.json for reference, not used by Hermes
|
||||
- `metadata.openclaw.emoji` → preserved in metadata, could use in skills_list display
|
||||
|
||||
2. **Codex metadata extraction:**
|
||||
- `metadata.short-description` → stored as-is (Hermes can use for compact display)
|
||||
- `agents/openai.yaml` → if present, extract tool dependencies into `compatibility`
|
||||
- `policy.allow_implicit_invocation` → could map to a Hermes "auto-load" vs "on-demand" setting
|
||||
|
||||
3. **Universal handling:**
|
||||
- Preserves all frontmatter fields (Hermes ignores unknown ones gracefully)
|
||||
- Checks for agent-specific instructions (e.g., "run `clawhub update`", "use $skill-installer") and adds a note
|
||||
- Adds a `source` field to frontmatter for tracking origin
|
||||
- Validates against agentskills.io spec constraints (name length, description length)
|
||||
- `_parse_frontmatter()` in skills_tool.py already handles this — no changes needed for reading
|
||||
|
||||
4. **Important: DO NOT modify downloaded SKILL.md files.**
|
||||
Store normalization metadata in the lock file instead. This preserves the original skill for updates/diffing and avoids breaking skills that reference their own frontmatter.
|
||||
|
||||
---
|
||||
|
||||
## Part 7: File Structure (New Files)
|
||||
|
||||
```
|
||||
Hermes-Agent/
|
||||
├── tools/
|
||||
│ ├── skills_tool.py # Existing — no changes needed
|
||||
│ ├── skills_hub_tool.py # NEW — agent-facing search/install tools
|
||||
│ └── skills_guard.py # NEW — security scanner
|
||||
├── hermes_cli/
|
||||
│ └── skills_hub.py # NEW — CLI subcommands
|
||||
├── skills/
|
||||
│ └── .hub/ # NEW — hub state directory
|
||||
│ ├── lock.json
|
||||
│ ├── quarantine/
|
||||
│ ├── audit.log
|
||||
│ └── taps.json
|
||||
├── model_tools.py # ADD discovery import for new tool module
|
||||
└── toolsets.py # MODIFY — add skills_hub toolset
|
||||
```
|
||||
|
||||
### Estimated LOC
|
||||
|
||||
| File | Lines | Complexity |
|
||||
|------|-------|------------|
|
||||
| `tools/skills_hub_tool.py` | ~500 | Medium — HTTP client, source adapters (GitHub, ClawHub, marketplace.json) |
|
||||
| `tools/skills_guard.py` | ~300 | Medium — pattern matching, report generation, trust scoring |
|
||||
| `hermes_cli/skills_hub.py` | ~400 | Medium — argparse, Rich output, user prompts, tap management |
|
||||
| `tools/skills_tool.py` changes | ~50 | Low — pyyaml upgrade, `assets/` support, `compatibility` field |
|
||||
| `model_tools.py` changes | ~1 | Low — add discovery import line |
|
||||
| `toolsets.py` changes | ~10 | Low — add toolset entry |
|
||||
| **Total** | **~1,340** | |
|
||||
|
||||
---
|
||||
|
||||
## Part 8: agentskills.io Conformance
|
||||
|
||||
Before building the hub, we should ensure Hermes is a first-class citizen of the open standard. This is low-effort, high-value work.
|
||||
|
||||
### Step 1: Update skills_tool.py frontmatter parsing
|
||||
|
||||
Current `_parse_frontmatter()` uses simple regex key:value parsing. It doesn't handle nested YAML (like `metadata.openclaw.requires`). Options:
|
||||
- **Quick fix:** Add `pyyaml` dependency for proper YAML parsing (most agents already use it)
|
||||
- **Minimal fix:** Keep simple parser for Hermes's own skills, add proper YAML parsing only for hub-installed skills
|
||||
|
||||
Recommendation: Use `pyyaml`. It's already a dependency of many ML libraries we bundle.
|
||||
|
||||
### Step 2: Support standard fields
|
||||
|
||||
Add recognition for these agentskills.io fields:
|
||||
- `compatibility` — display in `skills_list` output, warn user if requirements unmet
|
||||
- `metadata` — store and pass through to agent (currently lost in simple parsing)
|
||||
- `allowed-tools` — experimental, but could map to Hermes toolset restrictions
|
||||
|
||||
### Step 3: Support standard directory conventions
|
||||
|
||||
Hermes already supports `references/` and `templates/`. Add:
|
||||
- `assets/` directory support (the standard name, equivalent to our `templates/`)
|
||||
- `scripts/` already supported
|
||||
|
||||
### Step 4: Validate Hermes's own skills
|
||||
|
||||
Run `skills-ref validate` against all 41 Hermes skills to ensure they conform:
|
||||
```bash
|
||||
for skill in skills/*/; do skills-ref validate "$skill"; done
|
||||
```
|
||||
|
||||
Fix any issues (likely just the `tags` and `related_skills` fields, which should move into `metadata`).
|
||||
|
||||
---
|
||||
|
||||
## Part 9: Rollout Phases
|
||||
|
||||
### Phase 0: Spec Conformance — 1 day
|
||||
- [ ] Upgrade `_parse_frontmatter()` to use pyyaml for proper YAML parsing
|
||||
- [ ] Add `compatibility` and `metadata` field support to skills_tool.py
|
||||
- [ ] Add `assets/` directory support alongside existing `templates/`
|
||||
- [ ] Validate all 41 existing Hermes skills against agentskills.io spec
|
||||
- [ ] Ensure Hermes skills are installable by `npx skills add` (just needs correct path convention)
|
||||
|
||||
### Phase 1: Foundation (MVP) — 2-3 days
|
||||
- [ ] `skills_guard.py` — static security scanner
|
||||
- [ ] `skills_hub_tool.py` — GitHub source adapter (covers openai/skills, anthropics/skills, awesome lists)
|
||||
- [ ] `hermes skills search` CLI command
|
||||
- [ ] `hermes skills install` from GitHub repos (with quarantine + scan)
|
||||
- [ ] Lock file management
|
||||
- [ ] Add registry.register() calls in tool file + discovery import in model_tools.py + toolset in toolsets.py
|
||||
|
||||
### Phase 2: Registry Sources — 1-2 days
|
||||
- [ ] ClawHub HTTP API adapter (search + install)
|
||||
- [ ] Claude Code marketplace.json parser
|
||||
- [ ] Tap system (add/remove/list custom repos)
|
||||
- [ ] `hermes skills explore` (trending skills)
|
||||
- [ ] `hermes skills update` and `hermes skills uninstall`
|
||||
- [ ] Raw URL/local path installation
|
||||
|
||||
### Phase 3: Intelligence — 1-2 days
|
||||
- [ ] LLM-based security audit option
|
||||
- [ ] Agent auto-discovery: when agent can't find a local skill for a task, suggest searching the hub
|
||||
- [ ] Skill compatibility scoring (rate how well an external skill maps to Hermes)
|
||||
- [ ] Automatic category assignment on install
|
||||
- [ ] Trust scoring integration (installagentskills.com API or local heuristics)
|
||||
|
||||
### Phase 4: Ecosystem Integration — 1-2 days
|
||||
- [ ] Register Hermes with Vercel skills.sh as a supported agent
|
||||
- [ ] Publish Hermes skills to ClawHub / Anthropic marketplace
|
||||
- [ ] Create a Hermes-specific marketplace.json for Claude Code compatibility
|
||||
- [ ] Build a `hermes skills publish` command for community contributions
|
||||
|
||||
### Phase 5: Nous Registry — Future
|
||||
- [ ] Design and host nous-skills registry
|
||||
- [ ] Curated, Hermes-tested skills
|
||||
- [ ] Submission pipeline (PR-based with CI testing)
|
||||
- [ ] Skill rating/review system
|
||||
- [ ] Featured skills in `hermes skills explore`
|
||||
|
||||
---
|
||||
|
||||
## Part 10: Creative Differentiators
|
||||
|
||||
### 1. "Skill Suggestions" in System Prompt
|
||||
|
||||
When the agent starts a conversation, the system prompt already lists available skills. We could add a subtle hint:
|
||||
|
||||
```
|
||||
If the user's request would benefit from a skill you don't have,
|
||||
you can search for one using skill_hub_search and offer to install it.
|
||||
```
|
||||
|
||||
This makes Hermes **self-extending** — it can grow its own capabilities during a conversation.
|
||||
|
||||
### 2. Skill Composition
|
||||
|
||||
Skills can declare `related_skills` in frontmatter. When installing a skill, offer to install its related skills too:
|
||||
|
||||
```
|
||||
Installing 'k8s-skills'...
|
||||
This skill works well with: docker-ctl, helm-charts, prometheus-monitoring
|
||||
Install related skills? [y/N]
|
||||
```
|
||||
|
||||
### 3. Skill Snapshots
|
||||
|
||||
Export your entire skills configuration (builtin + hub-installed) as a shareable snapshot:
|
||||
|
||||
```bash
|
||||
hermes skills snapshot export my-setup.json
|
||||
hermes skills snapshot import my-setup.json # On another machine
|
||||
```
|
||||
|
||||
This enables teams to share curated skill sets.
|
||||
|
||||
### 4. Skill Usage Analytics (Local Only)
|
||||
|
||||
Track which skills get loaded most often (locally, never phoned home):
|
||||
|
||||
```bash
|
||||
hermes skills stats
|
||||
# Top skills (last 30 days):
|
||||
# 1. axolotl — loaded 47 times
|
||||
# 2. vllm — loaded 31 times
|
||||
# 3. k8s-skills — loaded 12 times (hub)
|
||||
# 4. docker-ctl — loaded 8 times (hub)
|
||||
```
|
||||
|
||||
### 5. Cross-Ecosystem Publishing
|
||||
|
||||
Since our format is compatible, let Hermes users publish their skills TO ClawHub:
|
||||
|
||||
```bash
|
||||
hermes skills publish skills/my-custom-skill --to clawhub
|
||||
```
|
||||
|
||||
This makes Hermes a first-class citizen in the broader agent skills ecosystem rather than just a consumer.
|
||||
|
||||
### 6. npx skills Compatibility
|
||||
|
||||
Register Hermes as a supported agent in the Vercel skills.sh ecosystem. This means anyone running `npx skills add owner/repo` will see Hermes as an install target alongside Claude Code, Codex, Cursor, etc. The table would look like:
|
||||
|
||||
| Agent | CLI Flag | Project Path | Global Path |
|
||||
|-------|----------|-------------|-------------|
|
||||
| **Hermes** | `hermes` | `.hermes/skills/` | `~/.hermes/skills/` |
|
||||
|
||||
This is probably a PR to vercel-labs/skills — they already support 35+ agents and seem welcoming.
|
||||
|
||||
### 7. Marketplace.json for Hermes Skills
|
||||
|
||||
Create a `.claude-plugin/marketplace.json` in the Hermes Agent repo so Hermes's built-in skills (axolotl, vllm, etc.) are installable by Claude Code users too:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "hermes-mlops-skills",
|
||||
"owner": { "name": "Nous Research" },
|
||||
"plugins": [
|
||||
{"name": "axolotl", "source": "./skills/mlops/axolotl", "description": "Fine-tuning with Axolotl"},
|
||||
{"name": "vllm", "source": "./skills/mlops/vllm", "description": "vLLM deployment & serving"}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
This is zero-effort marketing — anyone who runs `/plugin marketplace add NousResearch/Hermes-Agent` in Claude Code gets access to our curated ML skills.
|
||||
|
||||
### 8. Trust-Aware Skill Loading
|
||||
|
||||
When the agent loads an external skill, prepend a trust context note:
|
||||
|
||||
```
|
||||
[This skill was installed from ClawHub (verified, scanned 2026-02-17).
|
||||
Trust level: verified. It requires env vars: GITHUB_TOKEN.]
|
||||
```
|
||||
|
||||
This lets the model make informed decisions about how much to trust the skill's instructions, especially important given the prompt injection attacks seen in the wild.
|
||||
|
||||
---
|
||||
|
||||
## Open Questions
|
||||
|
||||
1. **Node.js dependency?** ClawHub CLI is npm-based. Do we vendor it or rewrite the HTTP client in Python?
|
||||
- Recommendation: Pure Python with httpx. Avoid forcing Node on users.
|
||||
- Update: The `npx skills` CLI from Vercel is also npm-based but designed as `npx` (no global install needed). Could use it as optional enhancer.
|
||||
|
||||
2. **Default taps?** Should we ship with ClawHub and awesome-openclaw-skills enabled by default, or require explicit opt-in?
|
||||
- Recommendation: Ship with them as available but not auto-searched. First `hermes skills search` prompts to enable.
|
||||
- Update: Consider shipping with `openai/skills` and `anthropics/skills` as defaults — these are the official repos with higher trust.
|
||||
|
||||
3. **Auto-install?** Should the agent be able to install skills without user confirmation?
|
||||
- Recommendation: Never for community sources. Verified/trusted sources could have an "auto-install" config flag, default off.
|
||||
|
||||
4. **Skill conflicts?** What if a hub skill has the same name as a builtin?
|
||||
- Recommendation: Builtins always win. Hub skills get namespaced: `hub/skill-name` if conflict detected.
|
||||
- Note: Codex handles this with scope priority (REPO > USER > ADMIN > SYSTEM). We could adopt similar precedence.
|
||||
|
||||
5. **Disk space?** 3,000+ skills on ClawHub, 14,500+ on LobeHub. Users won't install all of them, but should we cache search results or skill indices?
|
||||
- Recommendation: Cache search results for 1 hour. Don't pre-download indices. Skills are small (mostly markdown), disk isn't a real concern.
|
||||
|
||||
6. **agentskills.io compliance vs Hermes extensions?** Our `tags` and `related_skills` fields aren't in the standard.
|
||||
- Recommendation: Keep them. The spec explicitly allows `metadata` for extensions. Move them under `metadata.hermes.tags` and `metadata.hermes.related_skills` for new skills, keep backward compat for existing ones.
|
||||
|
||||
7. **Which registries to prioritize?** There are now 8+ potential sources.
|
||||
- Recommendation for MVP: GitHub adapter only (covers openai/skills, anthropics/skills, awesome lists, any repo). This one adapter handles 80% of use cases. Add ClawHub API in Phase 2.
|
||||
|
||||
8. **Security scanning dependency?** Should we integrate AgentVerus, build our own, or both?
|
||||
- Recommendation: Start with our own lightweight `skills_guard.py` (regex patterns). Optionally invoke AgentVerus if installed. Don't make it a hard dependency.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
# Slash Commands Reference
|
||||
|
||||
Quick reference for all CLI slash commands in Hermes Agent.
|
||||
|
||||
## Navigation & Control
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/help` | Show available commands |
|
||||
| `/quit` | Exit the CLI (aliases: `/exit`, `/q`) |
|
||||
| `/clear` | Clear screen and reset conversation |
|
||||
| `/new` | Start a new conversation |
|
||||
| `/reset` | Reset conversation (keep screen) |
|
||||
|
||||
## Tools & Configuration
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/tools` | List all available tools |
|
||||
| `/toolsets` | List available toolsets |
|
||||
| `/model` | Show or change the current model |
|
||||
| `/model <name>` | Switch to a different model |
|
||||
| `/config` | Show current configuration |
|
||||
| `/prompt` | View/set custom system prompt |
|
||||
| `/personality` | Set a predefined personality |
|
||||
|
||||
## Conversation
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/history` | Show conversation history |
|
||||
| `/retry` | Retry the last message |
|
||||
| `/undo` | Remove the last user/assistant exchange |
|
||||
| `/save` | Save the current conversation |
|
||||
|
||||
## Advanced
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/cron` | Manage scheduled tasks |
|
||||
| `/skills` | Search, install, or manage skills |
|
||||
| `/platforms` | Show gateway/messaging platform status |
|
||||
|
||||
## Gateway Only
|
||||
|
||||
These commands are available in messaging platforms (Telegram, Discord, etc.) but not the interactive CLI:
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `/stop` | Stop the running agent |
|
||||
| `/sethome` | Set this chat as the home channel |
|
||||
| `/compress` | Manually compress conversation context |
|
||||
| `/usage` | Show token usage for the current session |
|
||||
| `/reload-mcp` | Reload MCP servers from config |
|
||||
| `/update` | Update Hermes Agent to the latest version |
|
||||
| `/status` | Show session info |
|
||||
|
||||
## Examples
|
||||
|
||||
### Changing Models
|
||||
|
||||
```
|
||||
/model anthropic/claude-sonnet-4
|
||||
```
|
||||
|
||||
### Setting a Custom Prompt
|
||||
|
||||
```
|
||||
/prompt You are a helpful coding assistant specializing in Python.
|
||||
```
|
||||
|
||||
### Managing Toolsets
|
||||
|
||||
Run with specific toolsets:
|
||||
```bash
|
||||
python cli.py --toolsets web,terminal
|
||||
```
|
||||
|
||||
Then check enabled toolsets:
|
||||
```
|
||||
/toolsets
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
- Commands are case-insensitive (`/HELP` = `/help`)
|
||||
- Use Tab for autocomplete
|
||||
- Most commands work mid-conversation
|
||||
- `/clear` is useful for starting fresh without restarting
|
||||
434
docs/tools.md
434
docs/tools.md
@@ -1,434 +0,0 @@
|
||||
# Tools
|
||||
|
||||
Tools are functions that extend the agent's capabilities. Each tool is defined with an OpenAI-compatible JSON schema and an async handler function.
|
||||
|
||||
## Tool Structure
|
||||
|
||||
Each tool module in `tools/` exports:
|
||||
1. **Schema definitions** - OpenAI function-calling format
|
||||
2. **Handler functions** - Async functions that execute the tool
|
||||
|
||||
```python
|
||||
# Example: tools/web_tools.py
|
||||
|
||||
# Schema definition
|
||||
WEB_SEARCH_SCHEMA = {
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "web_search",
|
||||
"description": "Search the web for information",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"query": {"type": "string", "description": "Search query"}
|
||||
},
|
||||
"required": ["query"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Handler function
|
||||
async def web_search(query: str) -> dict:
|
||||
"""Execute web search and return results."""
|
||||
# Implementation...
|
||||
return {"results": [...]}
|
||||
```
|
||||
|
||||
## Tool Categories
|
||||
|
||||
| Category | Module | Tools |
|
||||
|----------|--------|-------|
|
||||
| **Web** | `web_tools.py` | `web_search`, `web_extract`, `web_crawl` |
|
||||
| **Terminal** | `terminal_tool.py` | `terminal` (local/docker/singularity/modal/ssh backends) |
|
||||
| **File** | `file_tools.py` | `read_file`, `write_file`, `patch`, `search` |
|
||||
| **Browser** | `browser_tool.py` | `browser_navigate`, `browser_click`, `browser_type`, etc. |
|
||||
| **Vision** | `vision_tools.py` | `vision_analyze` |
|
||||
| **Image Gen** | `image_generation_tool.py` | `image_generate` |
|
||||
| **TTS** | `tts_tool.py` | `text_to_speech` (Edge TTS free / ElevenLabs / OpenAI) |
|
||||
| **Reasoning** | `mixture_of_agents_tool.py` | `mixture_of_agents` |
|
||||
| **Skills** | `skills_tool.py`, `skill_manager_tool.py` | `skills_list`, `skill_view`, `skill_manage` |
|
||||
| **Todo** | `todo_tool.py` | `todo` (read/write task list for multi-step planning) |
|
||||
| **Memory** | `memory_tool.py` | `memory` (persistent notes + user profile across sessions) |
|
||||
| **Session Search** | `session_search_tool.py` | `session_search` (search + summarize past conversations) |
|
||||
| **Cronjob** | `cronjob_tools.py` | `schedule_cronjob`, `list_cronjobs`, `remove_cronjob` |
|
||||
| **RL Training** | `rl_training_tool.py` | `rl_list_environments`, `rl_start_training`, `rl_check_status`, etc. |
|
||||
| **Clarify** | `clarify_tool.py` | `clarify` (interactive multiple-choice / open-ended questions, CLI-only) |
|
||||
| **Code Execution** | `code_execution_tool.py` | `execute_code` (run Python scripts that call tools via RPC sandbox) |
|
||||
| **Delegation** | `delegate_tool.py` | `delegate_task` (spawn subagents with isolated context, single + parallel batch) |
|
||||
| **MCP (External)** | `tools/mcp_tool.py` | Auto-discovered from configured MCP servers |
|
||||
|
||||
## Tool Registration
|
||||
|
||||
Each tool file self-registers via `tools/registry.py`:
|
||||
|
||||
```python
|
||||
# tools/example_tool.py
|
||||
from tools.registry import registry
|
||||
|
||||
EXAMPLE_SCHEMA = {
|
||||
"name": "example_tool",
|
||||
"description": "Does something useful.",
|
||||
"parameters": { ... }
|
||||
}
|
||||
|
||||
registry.register(
|
||||
name="example_tool",
|
||||
toolset="example",
|
||||
schema=EXAMPLE_SCHEMA,
|
||||
handler=lambda args, **kw: example_tool(args.get("param", "")),
|
||||
check_fn=check_example_requirements,
|
||||
requires_env=["EXAMPLE_API_KEY"],
|
||||
)
|
||||
```
|
||||
|
||||
`model_tools.py` is a thin orchestration layer that imports all tool modules (triggering registration), then delegates to the registry for schema collection and dispatch.
|
||||
|
||||
## Toolsets
|
||||
|
||||
Tools are grouped into **toolsets** for logical organization (see `toolsets.py`). All platforms share a `_HERMES_CORE_TOOLS` list; messaging platforms add `send_message`.
|
||||
|
||||
## Adding a New Tool
|
||||
|
||||
### Overview
|
||||
|
||||
Adding a tool touches 3 files:
|
||||
|
||||
1. **`tools/your_tool.py`** -- handler, schema, check function, `registry.register()` call
|
||||
2. **`toolsets.py`** -- add tool name to `_HERMES_CORE_TOOLS` (or a specific toolset)
|
||||
3. **`model_tools.py`** -- add `"tools.your_tool"` to the `_discover_tools()` list
|
||||
|
||||
### Step 1: Create the tool file
|
||||
|
||||
Every tool file follows the same structure: handler function, availability check, schema constant, and registry registration.
|
||||
|
||||
```python
|
||||
# tools/weather_tool.py
|
||||
"""Weather Tool -- look up current weather for a location."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# --- Availability check ---
|
||||
|
||||
def check_weather_requirements() -> bool:
|
||||
"""Return True if the tool's dependencies are available."""
|
||||
return bool(os.getenv("WEATHER_API_KEY"))
|
||||
|
||||
|
||||
# --- Handler ---
|
||||
|
||||
def weather_tool(location: str, units: str = "metric") -> str:
|
||||
"""Fetch weather for a location. Returns JSON string."""
|
||||
api_key = os.getenv("WEATHER_API_KEY")
|
||||
if not api_key:
|
||||
return json.dumps({"error": "WEATHER_API_KEY not configured"})
|
||||
try:
|
||||
# ... call weather API ...
|
||||
return json.dumps({"location": location, "temp": 22, "units": units})
|
||||
except Exception as e:
|
||||
return json.dumps({"error": str(e)})
|
||||
|
||||
|
||||
# --- Schema ---
|
||||
|
||||
WEATHER_SCHEMA = {
|
||||
"name": "weather",
|
||||
"description": "Get current weather for a location.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "City name or coordinates (e.g. 'London' or '51.5,-0.1')"
|
||||
},
|
||||
"units": {
|
||||
"type": "string",
|
||||
"enum": ["metric", "imperial"],
|
||||
"description": "Temperature units (default: metric)",
|
||||
"default": "metric"
|
||||
}
|
||||
},
|
||||
"required": ["location"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# --- Registration ---
|
||||
|
||||
from tools.registry import registry
|
||||
|
||||
registry.register(
|
||||
name="weather",
|
||||
toolset="weather",
|
||||
schema=WEATHER_SCHEMA,
|
||||
handler=lambda args, **kw: weather_tool(
|
||||
location=args.get("location", ""),
|
||||
units=args.get("units", "metric")),
|
||||
check_fn=check_weather_requirements,
|
||||
requires_env=["WEATHER_API_KEY"],
|
||||
)
|
||||
```
|
||||
|
||||
**Key rules:**
|
||||
|
||||
- Handlers MUST return a JSON string (via `json.dumps()`), never raw dicts.
|
||||
- Errors MUST be returned as `{"error": "message"}`, never raised as exceptions. The registry's `dispatch()` also wraps unexpected exceptions automatically.
|
||||
- The `check_fn` is called when building tool definitions -- if it returns `False`, the tool is silently excluded from the schema sent to the LLM.
|
||||
- The `handler` receives `(args: dict, **kwargs)` where `args` is the LLM's tool call arguments and `kwargs` may include `task_id`, `user_task`, `store`, etc. depending on what the caller passes.
|
||||
|
||||
### Step 2: Add to a toolset
|
||||
|
||||
In `toolsets.py`, add the tool name to the appropriate place:
|
||||
|
||||
```python
|
||||
# If it should be available on all platforms (CLI + messaging):
|
||||
_HERMES_CORE_TOOLS = [
|
||||
...
|
||||
"weather", # <-- add here
|
||||
]
|
||||
|
||||
# Or create a new standalone toolset:
|
||||
"weather": {
|
||||
"description": "Weather lookup tools",
|
||||
"tools": ["weather"],
|
||||
"includes": []
|
||||
},
|
||||
```
|
||||
|
||||
### Step 3: Add discovery import
|
||||
|
||||
In `model_tools.py`, add the module to the `_discover_tools()` list:
|
||||
|
||||
```python
|
||||
def _discover_tools():
|
||||
_modules = [
|
||||
...
|
||||
"tools.weather_tool", # <-- add here
|
||||
]
|
||||
```
|
||||
|
||||
This import triggers the `registry.register()` call at the bottom of the tool file.
|
||||
|
||||
### Async handlers
|
||||
|
||||
If your handler needs to call async code (e.g., `aiohttp`, async SDK), mark it with `is_async=True`:
|
||||
|
||||
```python
|
||||
async def weather_tool_async(location: str) -> str:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
...
|
||||
return json.dumps(result)
|
||||
|
||||
registry.register(
|
||||
name="weather",
|
||||
toolset="weather",
|
||||
schema=WEATHER_SCHEMA,
|
||||
handler=lambda args, **kw: weather_tool_async(args.get("location", "")),
|
||||
check_fn=check_weather_requirements,
|
||||
is_async=True, # <-- registry calls _run_async() automatically
|
||||
)
|
||||
```
|
||||
|
||||
The registry handles async bridging transparently via `_run_async()` -- you never call `asyncio.run()` yourself. This works correctly in CLI mode (no event loop), the gateway (running async loop), and RL environments (Atropos event loop + thread pool wrapping).
|
||||
|
||||
### Handlers that need task_id
|
||||
|
||||
Tools that manage per-session state (terminal, browser, file ops) receive `task_id` via `**kwargs`:
|
||||
|
||||
```python
|
||||
def _handle_weather(args, **kw):
|
||||
task_id = kw.get("task_id") # may be None in CLI mode
|
||||
return weather_tool(args.get("location", ""), task_id=task_id)
|
||||
|
||||
registry.register(
|
||||
name="weather",
|
||||
...
|
||||
handler=_handle_weather,
|
||||
)
|
||||
```
|
||||
|
||||
Use a named function instead of a lambda when the arg unpacking is complex.
|
||||
|
||||
### Agent-loop intercepted tools
|
||||
|
||||
Some tools (todo, memory, session_search, delegate_task) need access to per-session agent state (TodoStore, MemoryStore, etc.) that doesn't flow through `handle_function_call`. These are intercepted by `run_agent.py` before reaching the registry. The registry still holds their schemas (so they appear in the tool list), but `dispatch()` returns a fallback error if the intercept is bypassed. See `todo_tool.py` for the pattern.
|
||||
|
||||
### Optional: setup wizard integration
|
||||
|
||||
If your tool requires an API key, add it to `hermes_cli/config.py`'s `OPTIONAL_ENV_VARS` dict so the setup wizard can prompt for it:
|
||||
|
||||
```python
|
||||
OPTIONAL_ENV_VARS = {
|
||||
...
|
||||
"WEATHER_API_KEY": {
|
||||
"description": "Weather API key for weather lookup",
|
||||
"prompt": "Weather API key",
|
||||
"url": "https://weatherapi.com/",
|
||||
"tools": ["weather"],
|
||||
"password": True,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Optional: batch processing
|
||||
|
||||
Add to `toolset_distributions.py` if the tool should be available in specific batch processing distributions.
|
||||
|
||||
## Stateful Tools
|
||||
|
||||
Some tools maintain state across calls within a session:
|
||||
|
||||
- **Terminal**: Keeps container/sandbox running between commands
|
||||
- **Browser**: Maintains browser session for multi-step navigation
|
||||
|
||||
State is managed per `task_id` and cleaned up automatically.
|
||||
|
||||
## Terminal Backends
|
||||
|
||||
The terminal tool supports multiple execution backends:
|
||||
|
||||
| Backend | Description | Use Case |
|
||||
|---------|-------------|----------|
|
||||
| `local` | Direct execution on host | Development, simple tasks |
|
||||
| `ssh` | Remote execution via SSH | Sandboxing (agent can't modify its own code) |
|
||||
| `docker` | Docker container | Isolation, reproducibility |
|
||||
| `singularity` | Singularity/Apptainer | HPC clusters, rootless containers |
|
||||
| `modal` | Modal cloud | Scalable cloud compute, GPUs |
|
||||
|
||||
Configure via environment variables or `cli-config.yaml`:
|
||||
|
||||
```yaml
|
||||
# SSH backend example (in cli-config.yaml)
|
||||
terminal:
|
||||
env_type: "ssh"
|
||||
ssh_host: "my-server.example.com"
|
||||
ssh_user: "myuser"
|
||||
ssh_key: "~/.ssh/id_rsa"
|
||||
cwd: "/home/myuser/project"
|
||||
```
|
||||
|
||||
The SSH backend uses ControlMaster for connection persistence, making subsequent commands fast.
|
||||
|
||||
## Skills Tools (Progressive Disclosure)
|
||||
|
||||
Skills are on-demand knowledge documents. They use **progressive disclosure** to minimize tokens:
|
||||
|
||||
```
|
||||
Level 0: skills_categories() → ["mlops", "devops"] (~50 tokens)
|
||||
Level 1: skills_list(category) → [{name, description}, ...] (~3k tokens)
|
||||
Level 2: skill_view(name) → Full content + metadata (varies)
|
||||
Level 3: skill_view(name, path) → Specific reference file (varies)
|
||||
```
|
||||
|
||||
All skills live in `~/.hermes/skills/` — a single directory that serves as the source of truth. On fresh install, bundled skills are seeded from the repo's `skills/` directory. Hub-installed and agent-created skills also go here. The agent can modify or delete any skill.
|
||||
|
||||
Skill directory structure:
|
||||
```
|
||||
~/.hermes/skills/
|
||||
├── mlops/
|
||||
│ └── axolotl/
|
||||
│ ├── SKILL.md # Main instructions (required)
|
||||
│ ├── references/ # Additional docs
|
||||
│ ├── templates/ # Output formats, configs
|
||||
│ └── assets/ # Supplementary files (agentskills.io)
|
||||
├── devops/
|
||||
│ └── deploy-k8s/
|
||||
│ └── SKILL.md
|
||||
├── .hub/ # Skills Hub state
|
||||
└── .bundled_manifest # Tracks seeded bundled skills
|
||||
```
|
||||
|
||||
SKILL.md uses YAML frontmatter (agentskills.io compatible):
|
||||
```yaml
|
||||
---
|
||||
name: axolotl
|
||||
description: Fine-tuning LLMs with Axolotl
|
||||
metadata:
|
||||
hermes:
|
||||
tags: [Fine-Tuning, LoRA, DPO]
|
||||
category: mlops
|
||||
---
|
||||
```
|
||||
|
||||
## Skill Management (skill_manage)
|
||||
|
||||
The `skill_manage` tool lets the agent create, update, and delete its own skills -- turning successful approaches into reusable procedural knowledge.
|
||||
|
||||
**Module:** `tools/skill_manager_tool.py`
|
||||
|
||||
**Actions:**
|
||||
| Action | Description | Required params |
|
||||
|--------|-------------|-----------------|
|
||||
| `create` | Create new skill (SKILL.md + directory) | `name`, `content`, optional `category` |
|
||||
| `patch` | Targeted find-and-replace in SKILL.md or supporting file | `name`, `old_string`, `new_string`, optional `file_path`, `replace_all` |
|
||||
| `edit` | Full replacement of SKILL.md (major rewrites only) | `name`, `content` |
|
||||
| `delete` | Remove a user skill entirely | `name` |
|
||||
| `write_file` | Add/overwrite a supporting file | `name`, `file_path`, `file_content` |
|
||||
| `remove_file` | Remove a supporting file | `name`, `file_path` |
|
||||
|
||||
### Patch vs Edit
|
||||
|
||||
`patch` and `edit` both modify skill files, but serve different purposes:
|
||||
|
||||
**`patch`** (preferred for most updates):
|
||||
- Targeted `old_string` → `new_string` replacement, same interface as the `patch` file tool
|
||||
- Token-efficient: only the changed text appears in the tool call, not the full file
|
||||
- Requires unique match by default; set `replace_all=true` for global replacements
|
||||
- Returns match count on ambiguous matches so the model can add more context
|
||||
- When targeting SKILL.md, validates that frontmatter remains intact after the patch
|
||||
- Also works on supporting files via `file_path` parameter (e.g., `references/api.md`)
|
||||
- Returns a file preview on not-found errors for self-correction without extra reads
|
||||
|
||||
**`edit`** (for major rewrites):
|
||||
- Full replacement of SKILL.md content
|
||||
- Use when the skill's structure needs to change (reorganizing sections, rewriting from scratch)
|
||||
- The model should `skill_view()` first, then provide the complete updated text
|
||||
|
||||
**Constraints:**
|
||||
- All skills live in `~/.hermes/skills/` and can be modified or deleted
|
||||
- Skill names must be lowercase, filesystem-safe (`[a-z0-9._-]+`), max 64 chars
|
||||
- SKILL.md must have valid YAML frontmatter with `name` and `description` fields
|
||||
- Supporting files must be under `references/`, `templates/`, `scripts/`, or `assets/`
|
||||
- Path traversal (`..`) in file paths is blocked
|
||||
|
||||
**Availability:** Enabled by default in CLI, Telegram, Discord, WhatsApp, and Slack. Not included in batch_runner or RL training environments.
|
||||
|
||||
**Behavioral guidance:** The tool description teaches the model when to create skills (after difficult tasks), when to update them (stale/broken instructions), to prefer `patch` over `edit` for targeted fixes, and the feedback loop pattern (ask user after difficult tasks, offer to save as a skill).
|
||||
|
||||
## Skills Hub
|
||||
|
||||
The Skills Hub enables searching, installing, and managing skills from online registries. It is **user-driven only** — the model cannot search for or install skills.
|
||||
|
||||
**Sources:** GitHub repos (openai/skills, anthropics/skills, custom taps), ClawHub, Claude Code marketplaces, LobeHub.
|
||||
|
||||
**Security:** Every downloaded skill is scanned by `tools/skills_guard.py` (regex patterns + optional LLM audit) before installation. Trust levels: `builtin` (ships with Hermes), `trusted` (openai/skills, anthropics/skills), `community` (everything else — any findings = blocked unless `--force`).
|
||||
|
||||
**Architecture:**
|
||||
- `tools/skills_guard.py` — Static scanner + LLM audit, trust-aware install policy
|
||||
- `tools/skills_hub.py` — SkillSource ABC, GitHubAuth (PAT + App), 4 source adapters, lock file, hub state
|
||||
- `tools/skill_manager_tool.py` — Agent-managed skill CRUD (`skill_manage` tool)
|
||||
- `hermes_cli/skills_hub.py` — Shared `do_*` functions, CLI subcommands, `/skills` slash command handler
|
||||
|
||||
**CLI:** `hermes skills search|install|inspect|list|audit|uninstall|publish|snapshot|tap`
|
||||
**Slash:** `/skills search|install|inspect|list|audit|uninstall|publish|snapshot|tap`
|
||||
|
||||
## MCP Tools
|
||||
|
||||
MCP (Model Context Protocol) tools are **dynamically registered** from external MCP servers configured in `cli-config.yaml`. Unlike built-in tools which are defined in Python source files, MCP tools are discovered at startup by connecting to each configured server and querying its available tools.
|
||||
|
||||
Each MCP tool is automatically wrapped with an OpenAI-compatible schema and registered in the tool registry under the `mcp` toolset. Tool names are prefixed with the server name (e.g., `time__get_current_time`) to avoid collisions.
|
||||
|
||||
**Key characteristics:**
|
||||
- Tools are discovered and registered at agent startup — no code changes needed
|
||||
- Supports both stdio (subprocess) and HTTP (streamable HTTP) transports
|
||||
- Auto-reconnects on connection failures with exponential backoff
|
||||
- Environment variables passed to stdio servers are filtered for security
|
||||
- Each server can have independent timeout settings
|
||||
|
||||
**Configuration:** Add servers to `mcp_servers` in `cli-config.yaml`. See [docs/mcp.md](mcp.md) for full documentation.
|
||||
|
||||
**Installation:** MCP support requires the optional `mcp` extra: `pip install hermes-agent[mcp]`
|
||||
Reference in New Issue
Block a user