mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 17:27:37 +08:00
Broad drift audit against origin/main (b52b63396).
Reference pages (most user-visible drift):
- slash-commands: add /busy, /curator, /footer, /indicator, /redraw, /steer
that were missing; drop non-existent /terminal-setup; fix /q footnote
(resolves to /queue, not /quit); extend CLI-only list with all 24
CLI-only commands in the registry
- cli-commands: add dedicated sections for hermes curator / fallback /
hooks (new subcommands not previously documented); remove stale
hermes honcho standalone section (the plugin registers dynamically
via hermes memory); list curator/fallback/hooks in top-level table;
fix completion to include fish
- toolsets-reference: document the real 52-toolset count; split browser
vs browser-cdp; add discord / discord_admin / spotify / yuanbao;
correct hermes-cli tool count from 36 to 38; fix misleading claim
that hermes-homeassistant adds tools (it's identical to hermes-cli)
- tools-reference: bump tool count 55 -> 68; add 7 Spotify, 5 Yuanbao,
2 Discord toolsets; move browser_cdp/browser_dialog to their own
browser-cdp toolset section
- environment-variables: add 40+ user-facing HERMES_* vars that were
undocumented (--yolo, --accept-hooks, --ignore-*, inference model
override, agent/stream/checkpoint timeouts, OAuth trace, per-platform
batch tuning for Telegram/Discord/Matrix/Feishu/WeCom, cron knobs,
gateway restart/connect timeouts); dedupe the Cron Scheduler section;
replace stale QQ_SANDBOX with QQ_PORTAL_HOST
User-guide (top level):
- cli.md: compression preserves last 20 turns, not 4 (protect_last_n: 20)
- configuration.md: display.platforms is the canonical per-platform
override key; tool_progress_overrides is deprecated and auto-migrated
- profiles.md: model.default is the config key, not model.model
- sessions.md: CLI/TUI session IDs use 6-char hex, gateway uses 8
- checkpoints-and-rollback.md: destructive-command list now matches
_DESTRUCTIVE_PATTERNS (adds rmdir, cp, install, dd)
- docker.md: the container runs as non-root hermes (UID 10000) via
gosu; fix install command (uv pip); add missing --insecure on the
dashboard compose example (required for non-loopback bind)
- security.md: systemctl danger pattern also matches 'restart'
- index.md: built-in tool count 47 -> 68
- integrations/index.md: 6 STT providers, 8 memory providers
- integrations/providers.md: drop fictional dashscope/qwen aliases
Features:
- overview.md: 9 image models (not 8), 9 TTS providers (not 5),
8 memory providers (Supermemory was missing)
- tool-gateway.md: 9 image models
- tools.md: extend common-toolsets list with search / messaging /
spotify / discord / debugging / safe
- fallback-providers.md: add 6 real providers from PROVIDER_REGISTRY
(lmstudio, kimi-coding-cn, stepfun, alibaba-coding-plan,
tencent-tokenhub, azure-foundry)
- plugins.md: Available Hooks table now includes on_session_finalize,
on_session_reset, subagent_stop
- built-in-plugins.md: add the 7 bundled plugins the page didn't
mention (spotify, google_meet, three image_gen providers, two
dashboard examples)
- web-dashboard.md: add --insecure and --tui flags
- cron.md: hermes cron create takes positional schedule/prompt, not
flags
Messaging:
- telegram.md: TELEGRAM_WEBHOOK_SECRET is now REQUIRED when
TELEGRAM_WEBHOOK_URL is set (gateway refuses to start without it
per GHSA-3vpc-7q5r-276h). Biggest user-visible drift in the batch.
- discord.md: HERMES_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDS default
is 2.0, not 0.1
- dingtalk.md: document DINGTALK_REQUIRE_MENTION /
FREE_RESPONSE_CHATS / MENTION_PATTERNS / HOME_CHANNEL /
ALLOW_ALL_USERS that the adapter supports
- bluebubbles.md: drop fictional BLUEBUBBLES_SEND_READ_RECEIPTS env
var; the setting lives in platforms.bluebubbles.extra only
- qqbot.md: drop dead QQ_SANDBOX; add real QQ_PORTAL_HOST and
QQ_GROUP_ALLOWED_USERS
- wecom-callback.md: replace 'hermes gateway start' (service-only)
with 'hermes gateway' for first-time setup
Developer-guide:
- architecture.md: refresh tool/toolset counts (61/52), terminal
backend count (7), line counts for run_agent.py (~13.7k), cli.py
(~11.5k), main.py (~10.4k), setup.py (~3.5k), gateway/run.py
(~12.2k), mcp_tool.py (~3.1k); add yuanbao adapter, bump platform
adapter count 18 -> 20
- agent-loop.md: run_agent.py line count 10.7k -> 13.7k
- tools-runtime.md: add vercel_sandbox backend
- adding-tools.md: remove stale 'Discovery import added to
model_tools.py' checklist item (registry auto-discovery)
- adding-platform-adapters.md: mark send_typing / get_chat_info as
concrete base methods; only connect/disconnect/send are abstract
- acp-internals.md: ACP sessions now persist to SessionDB
(~/.hermes/state.db); acp.run_agent call uses
use_unstable_protocol=True
- cron-internals.md: gateway runs scheduler in a dedicated background
thread via _start_cron_ticker, not on a maintenance cycle; locking
is cross-process via fcntl.flock (Unix) / msvcrt.locking (Windows)
- gateway-internals.md: gateway/run.py ~12k lines
- provider-runtime.md: cron DOES support fallback (run_job reads
fallback_providers from config)
- session-storage.md: SCHEMA_VERSION = 11 (not 9); add migrations
10 and 11 (trigram FTS, inline-mode FTS5 re-index); add
api_call_count column to Sessions DDL; document messages_fts_trigram
and state_meta in the architecture tree
- context-compression-and-caching.md: remove the obsolete 'context
pressure warnings' section (warnings were removed for causing
models to give up early)
- context-engine-plugin.md: compress() signature now includes
focus_topic param
- extending-the-cli.md: _build_tui_layout_children signature now
includes model_picker_widget; add to default layout
Also fixed three pre-existing broken links/anchors the build warned
about (docker.md -> api-server.md, yuanbao.md -> cron-jobs.md and
tips#background-tasks, nix-setup.md -> #container-aware-cli).
Regenerated per-skill pages via website/scripts/generate-skill-docs.py
so catalog tables and sidebar are consistent with current SKILL.md
frontmatter.
docusaurus build: clean, no broken links or anchors.
341 lines
10 KiB
Markdown
341 lines
10 KiB
Markdown
---
|
|
sidebar_position: 16
|
|
title: "Yuanbao"
|
|
description: "Connect Hermes Agent to the Yuanbao enterprise messaging platform via WebSocket gateway"
|
|
---
|
|
|
|
# Yuanbao
|
|
|
|
Connect Hermes to [Yuanbao](https://yuanbao.tencent.com/), Tencent's enterprise messaging platform. The adapter uses a WebSocket gateway for real-time message delivery and supports both direct (C2C) and group conversations.
|
|
|
|
:::info
|
|
Yuanbao is an enterprise messaging platform primarily used within Tencent and enterprise environments. It uses WebSocket for real-time communication, HMAC-based authentication, and supports rich media including images, files, and voice messages.
|
|
:::
|
|
|
|
## Prerequisites
|
|
|
|
- A Yuanbao account with bot creation permissions
|
|
- Yuanbao APP_ID and APP_SECRET (from platform admin)
|
|
- Python packages: `websockets` and `httpx`
|
|
- For media support: `aiofiles`
|
|
|
|
Install the required dependencies:
|
|
|
|
```bash
|
|
pip install websockets httpx aiofiles
|
|
```
|
|
|
|
## Setup
|
|
|
|
### 1. Create a Bot in Yuanbao
|
|
|
|
1. Download the Yuanbao app from [https://yuanbao.tencent.com/](https://yuanbao.tencent.com/)
|
|
2. In the app, go to **PAI → My Bot** and create a new bot
|
|
3. After the bot is created, copy the **APP_ID** and **APP_SECRET**
|
|
|
|
### 2. Run the Setup Wizard
|
|
|
|
The easiest way to configure Yuanbao is through the interactive setup:
|
|
|
|
```bash
|
|
hermes gateway setup
|
|
```
|
|
|
|
Select **Yuanbao** when prompted. The wizard will:
|
|
|
|
1. Ask for your APP_ID
|
|
2. Ask for your APP_SECRET
|
|
3. Save the configuration automatically
|
|
|
|
:::tip
|
|
The WebSocket URL and API Domain have sensible defaults built in. You only need to provide APP_ID and APP_SECRET to get started.
|
|
:::
|
|
|
|
### 3. Configure Environment Variables
|
|
|
|
After initial setup, verify these variables in `~/.hermes/.env`:
|
|
|
|
```bash
|
|
# Required
|
|
YUANBAO_APP_ID=your-app-id
|
|
YUANBAO_APP_SECRET=your-app-secret
|
|
YUANBAO_WS_URL=wss://api.yuanbao.example.com/ws
|
|
YUANBAO_API_DOMAIN=https://api.yuanbao.example.com
|
|
|
|
# Optional: bot account ID (normally obtained automatically from sign-token)
|
|
# YUANBAO_BOT_ID=your-bot-id
|
|
|
|
# Optional: internal routing environment (e.g. test/staging/production)
|
|
# YUANBAO_ROUTE_ENV=production
|
|
|
|
# Optional: home channel for cron/notifications (format: direct:<account> or group:<group_code>)
|
|
YUANBAO_HOME_CHANNEL=direct:bot_account_id
|
|
YUANBAO_HOME_CHANNEL_NAME="Bot Notifications"
|
|
|
|
# Optional: restrict access (legacy, see Access Control below for fine-grained policies)
|
|
YUANBAO_ALLOWED_USERS=user_account_1,user_account_2
|
|
```
|
|
|
|
### 4. Start the Gateway
|
|
|
|
```bash
|
|
hermes gateway
|
|
```
|
|
|
|
The adapter will connect to the Yuanbao WebSocket gateway, authenticate using HMAC signatures, and begin processing messages.
|
|
|
|
## Features
|
|
|
|
- **WebSocket gateway** — real-time bidirectional communication
|
|
- **HMAC authentication** — secure request signing with APP_ID/APP_SECRET
|
|
- **C2C messaging** — direct user-to-bot conversations
|
|
- **Group messaging** — conversations in group chats
|
|
- **Media support** — images, files, and voice messages via COS (Cloud Object Storage)
|
|
- **Markdown formatting** — messages are automatically chunked for Yuanbao's size limits
|
|
- **Message deduplication** — prevents duplicate processing of the same message
|
|
- **Heartbeat/keep-alive** — maintains WebSocket connection stability
|
|
- **Typing indicators** — shows "typing…" status while the agent processes
|
|
- **Automatic reconnection** — handles WebSocket disconnections with exponential backoff
|
|
- **Group information queries** — retrieve group details and member lists
|
|
- **Sticker/Emoji support** — send TIMFaceElem stickers and emoji in conversations
|
|
- **Auto-sethome** — first user to message the bot is automatically set as the home channel owner
|
|
- **Slow-response notification** — sends a waiting message when the agent takes longer than expected
|
|
|
|
## Configuration Options
|
|
|
|
### Chat ID Formats
|
|
|
|
Yuanbao uses prefixed identifiers depending on conversation type:
|
|
|
|
| Chat Type | Format | Example |
|
|
|-----------|--------|---------|
|
|
| Direct message (C2C) | `direct:<account>` | `direct:user123` |
|
|
| Group message | `group:<group_code>` | `group:grp456` |
|
|
|
|
### Media Uploads
|
|
|
|
The Yuanbao adapter automatically handles media uploads via COS (Tencent Cloud Object Storage):
|
|
|
|
- **Images**: Supports JPEG, PNG, GIF, WebP
|
|
- **Files**: Supports all common document types
|
|
- **Voice**: Supports WAV, MP3, OGG
|
|
|
|
Media URLs are automatically validated and downloaded before upload to prevent SSRF attacks.
|
|
|
|
## Home Channel
|
|
|
|
Use the `/sethome` command in any Yuanbao chat (DM or group) to designate it as the **home channel**. Scheduled tasks (cron jobs) deliver their results to this channel.
|
|
|
|
:::tip Auto-sethome
|
|
If no home channel is configured, the first user to message the bot will be automatically set as the home channel owner. If the current home channel is a group chat, the first DM will upgrade it to a direct channel.
|
|
:::
|
|
|
|
You can also set it manually in `~/.hermes/.env`:
|
|
|
|
```bash
|
|
YUANBAO_HOME_CHANNEL=direct:user_account_id
|
|
# or for a group:
|
|
# YUANBAO_HOME_CHANNEL=group:group_code
|
|
YUANBAO_HOME_CHANNEL_NAME="My Bot Updates"
|
|
```
|
|
|
|
### Example: Set Home Channel
|
|
|
|
1. Start a conversation with the bot in Yuanbao
|
|
2. Send the command: `/sethome`
|
|
3. The bot responds: "Home channel set to [chat_name] with ID [chat_id]. Cron jobs will deliver to this location."
|
|
4. Future cron jobs and notifications will be sent to this channel
|
|
|
|
### Example: Cron Job Delivery
|
|
|
|
Create a cron job:
|
|
|
|
```bash
|
|
/cron "0 9 * * *" Check server status
|
|
```
|
|
|
|
The scheduled output will be delivered to your Yuanbao home channel every day at 9 AM.
|
|
|
|
## Usage Tips
|
|
|
|
### Starting a Conversation
|
|
|
|
Send any message to the bot in Yuanbao:
|
|
|
|
```
|
|
hello
|
|
```
|
|
|
|
The bot responds in the same conversation thread.
|
|
|
|
### Available Commands
|
|
|
|
All standard Hermes commands work on Yuanbao:
|
|
|
|
| Command | Description |
|
|
|---------|-------------|
|
|
| `/new` | Start a fresh conversation |
|
|
| `/model [provider:model]` | Show or change the model |
|
|
| `/sethome` | Set this chat as the home channel |
|
|
| `/status` | Show session info |
|
|
| `/help` | Show available commands |
|
|
|
|
### Sending Files
|
|
|
|
To send a file to the bot, simply attach it directly in the Yuanbao chat. The bot will automatically download and process the file attachment.
|
|
|
|
You can also include a message with the attachment:
|
|
|
|
```
|
|
Please analyze this document
|
|
```
|
|
|
|
### Receiving Files
|
|
|
|
When you ask the bot to create or export a file, it sends the file directly to your Yuanbao chat.
|
|
|
|
## Troubleshooting
|
|
|
|
### Bot is online but not responding to messages
|
|
|
|
**Cause**: Authentication failed during WebSocket handshake.
|
|
|
|
**Fix**:
|
|
1. Verify APP_ID and APP_SECRET are correct
|
|
2. Check that the WebSocket URL is accessible
|
|
3. Ensure the bot account has proper permissions
|
|
4. Review gateway logs: `tail -f ~/.hermes/logs/gateway.log`
|
|
|
|
### "Connection refused" error
|
|
|
|
**Cause**: WebSocket URL is unreachable or incorrect.
|
|
|
|
**Fix**:
|
|
1. Verify the WebSocket URL format (should start with `wss://`)
|
|
2. Check network connectivity to the Yuanbao API domain
|
|
3. Confirm firewall allows WebSocket connections
|
|
4. Test URL with: `curl -I https://[YUANBAO_API_DOMAIN]`
|
|
|
|
### Media uploads fail
|
|
|
|
**Cause**: COS credentials are invalid or media server is unreachable.
|
|
|
|
**Fix**:
|
|
1. Verify API_DOMAIN is correct
|
|
2. Check that media upload permissions are enabled for your bot
|
|
3. Ensure the media file is accessible and not corrupted
|
|
4. Check COS bucket configuration with platform admin
|
|
|
|
### Messages not delivered to home channel
|
|
|
|
**Cause**: Home channel ID format is incorrect or cron job hasn't triggered.
|
|
|
|
**Fix**:
|
|
1. Verify YUANBAO_HOME_CHANNEL is in correct format
|
|
2. Test with `/sethome` command to auto-detect correct format
|
|
3. Check cron job schedule with `/status`
|
|
4. Verify bot has send permissions in the target chat
|
|
|
|
### Frequent disconnections
|
|
|
|
**Cause**: WebSocket connection is unstable or network is unreliable.
|
|
|
|
**Fix**:
|
|
1. Check gateway logs for error patterns
|
|
2. Increase heartbeat timeout in connection settings
|
|
3. Ensure stable network connection to Yuanbao API
|
|
4. Consider enabling verbose logging: `HERMES_LOG_LEVEL=debug`
|
|
|
|
## Access Control
|
|
|
|
Yuanbao supports fine-grained access control for both DM and group conversations:
|
|
|
|
```bash
|
|
# DM policy: open (default) | allowlist | disabled
|
|
YUANBAO_DM_POLICY=open
|
|
# Comma-separated user IDs allowed to DM the bot (only used when DM_POLICY=allowlist)
|
|
YUANBAO_DM_ALLOW_FROM=user_id_1,user_id_2
|
|
|
|
# Group policy: open (default) | allowlist | disabled
|
|
YUANBAO_GROUP_POLICY=open
|
|
# Comma-separated group codes allowed (only used when GROUP_POLICY=allowlist)
|
|
YUANBAO_GROUP_ALLOW_FROM=group_code_1,group_code_2
|
|
```
|
|
|
|
These can also be set in `config.yaml`:
|
|
|
|
```yaml
|
|
platforms:
|
|
yuanbao:
|
|
extra:
|
|
dm_policy: allowlist
|
|
dm_allow_from: "user1,user2"
|
|
group_policy: open
|
|
group_allow_from: ""
|
|
```
|
|
|
|
## Advanced Configuration
|
|
|
|
### Message Chunking
|
|
|
|
Yuanbao has a maximum message size. Hermes automatically chunks large responses with Markdown-aware splitting (respects code fences, tables, and paragraph boundaries).
|
|
|
|
### Connection Parameters
|
|
|
|
The following connection parameters are built into the adapter with sensible defaults:
|
|
|
|
| Parameter | Default Value | Description |
|
|
|-----------|---------------|-------------|
|
|
| WebSocket connect timeout | 15 seconds | Time to wait for WS handshake |
|
|
| Heartbeat interval | 30 seconds | Ping frequency to keep connection alive |
|
|
| Max reconnect attempts | 100 | Maximum number of reconnection tries |
|
|
| Reconnect backoff | 1s → 60s (exponential) | Wait time between reconnect attempts |
|
|
| Reply heartbeat interval | 2 seconds | RUNNING status send frequency |
|
|
| Send timeout | 30 seconds | Timeout for outbound WS messages |
|
|
|
|
:::note
|
|
These values are currently not configurable via environment variables. They are optimized for typical Yuanbao deployments.
|
|
:::
|
|
|
|
### Verbose Logging
|
|
|
|
Enable debug logging to troubleshoot connection issues:
|
|
|
|
```bash
|
|
HERMES_LOG_LEVEL=debug hermes gateway
|
|
```
|
|
|
|
## Integration with Other Features
|
|
|
|
### Cron Jobs
|
|
|
|
Schedule tasks that run on Yuanbao:
|
|
|
|
```
|
|
/cron "0 */4 * * *" Report system health
|
|
```
|
|
|
|
Results are delivered to your home channel.
|
|
|
|
### Background Tasks
|
|
|
|
Run long operations without blocking the conversation:
|
|
|
|
```
|
|
/background Analyze all files in the archive
|
|
```
|
|
|
|
### Cross-Platform Messages
|
|
|
|
Send a message from CLI to Yuanbao:
|
|
|
|
```bash
|
|
hermes chat -q "Send 'Hello from CLI' to yuanbao:group:group_code"
|
|
```
|
|
|
|
## Related Documentation
|
|
|
|
- [Messaging Gateway Overview](./index.md)
|
|
- [Slash Commands Reference](/docs/reference/slash-commands.md)
|
|
- [Cron Jobs](/docs/user-guide/features/cron.md)
|
|
- [Background Sessions](/docs/user-guide/cli#background-sessions) |