你在地铁上用 Telegram 下达「批量生成 HTML Landing Page」的任务,然后锁屏、切 App 或进出隧道——若是网页聊天,运行会断、上下文会丢。这是 2026 年独立开发者常见痛点:用手机遥控 Agent,却需要任务在永不断线的常开主机上继续执行。
Hermes Agent(Nous Research)用单一 Gateway 统一网关进程解决:在 Mac 或 VPS 上长期驻留,经平台适配器与 Webhook 同时接通 Telegram、Discord、Slack、WhatsApp、Signal、Email 等。Agent 循环在服务器端运行,而非手机浏览器。会话保存在 per-chat 存储中,直到你 /reset 或触发空闲超时——上游默认空闲重置为 1440 分钟(24 小时),可在 ~/.hermes/gateway.json 按平台调整。
本指南聚焦 Hermes Agent Gateway 配置下的跨设备工作流:在 Telegram 发起长任务,进办公室打开 Discord,从同一 Gateway 接续文件、后台任务结果与命名会话。安装前置见 Hermes macOS 安装配置指南;并行 worker 见 Hermes 多智能体委派指南。少推销 NodeMac,以官方文档为准。
为何浏览器标签页会失败,而 Gateway 能持续运行
| 失败模式 | 网页聊天 / 本地脚本 | 常开主机上的 Hermes Gateway |
|---|---|---|
| Phone app backgrounded | SSE/WebSocket often drops | Gateway process keeps running |
| Laptop lid closed | Process suspended | launchd/systemd keeps gateway alive |
| Long tool run (30+ min) | Tab timeout, lost context | Agent loop on server; optional /background |
| Switch Telegram → Discord | N/A (different products) | Same gateway, shared workspace + memory |
| Cron / scheduled jobs | Requires separate scheduler | Built-in cron ticks every 60 seconds inside gateway |
可引用: Hermes Gateway is one background process that connects all configured platforms, routes each message through a per-chat session store, dispatches to AIAgent, and runs the cron scheduler—upstream architecture docs, June 2026.
Gateway 架构:适配器、会话与 Webhook
┌─────────────────────────────────────┐
Telegram webhook ──►│ Hermes Gateway (single process) │
Discord gateway ──►│ ├─ Platform adapters │
Slack events ──►│ ├─ Per-chat session store │
│ ├─ AIAgent tool loop (server-side) │
│ ├─ Cron scheduler (60s tick) │
│ └─ ~/.hermes/ state + workspace │
└─────────────────────────────────────┘
│
Files, memory, skills on disk
│
Phone (Telegram) Desktop (Discord)
same user, different reads outputs / /resume
chat sessions named session
Each platform adapter receives inbound messages (Telegram bot API, Discord gateway events, Slack webhooks), maps them to a session key (platform + chat ID), and enqueues agent turns. Tool progress can stream back to the chat (display.tool_progress: all in ~/.hermes/config.yaml).
跨设备体验的诚实说明: Telegram DM and Discord DM are 独立会话 by default—they do not magically mirror every message. Continuity comes from three mechanisms working together:
/background— Fire-and-forget tasks; results deliver to the chat where you started the command, while your main session stays responsive.- Shared workspace — Generated HTML, logs, and artifacts land on the gateway host filesystem; any platform can ask the agent to read them.
/title+/resume— Name a session on Telegram, resume the named session from Discord (same gateway user).
Configure longer idle resets so a commute does not wipe context:
{
"reset_by_platform": {
"telegram": { "mode": "idle", "idle_minutes": 480 },
"discord": { "mode": "idle", "idle_minutes": 240 }
}
}
Path: ~/.hermes/gateway.json per session management docs.
场景:地铁 Telegram → 办公室 Discord
目标: From Telegram mobile, assign "Generate 5 HTML landing page variants in ~/projects/landing-batch/". At the desk, Discord shows progress and file previews.
推荐路径:
| 步骤 | 位置 | 操作 |
|---|---|---|
| 1 | 服务器(一次性) | Gateway running 24/7 via hermes gateway install + launchd |
| 2 | Telegram | /background Build 5 HTML landing variants in ~/projects/landing-batch/ using brand colors from MEMORY.md |
| 3 | Telegram | Gateway ack: Task ID: bg_HHMMSS_xxxx — phone can lock |
| 4 | Discord | /resume landing-batch if you /title landing-batch first, OR ask: List files in ~/projects/landing-batch and summarize |
| 5 | Discord | Enable display.tool_progress: all to see tool status during active turns |
| 6 | 任意端 | /status shows session info; /platform list shows adapter health |
For live streaming in Discord while the task runs, start the job in Discord with display.busy_input_mode: queue so follow-ups queue instead of interrupting—or run the heavy work via /background on Telegram and poll from Discord using filesystem tools.
Pair with Hermes 多智能体委派一人企业指南 when one landing page needs parallel research + codegen subagents; Gateway delivers human messages, delegation handles fan-out.
Gateway 配置分步手册
1. 安装 Hermes
If missing: curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash, then hermes doctor. Details: Hermes macOS 安装配置指南.
2. 运行网关向导
hermes gateway setup
Walk through Telegram bot token (from @BotFather), Discord bot token + intents, allowlists. Upstream recommends DM pairing or TELEGRAM_ALLOWED_USERS / DISCORD_ALLOWED_USERS—never GATEWAY_ALLOW_ALL_USERS=true on bots with terminal access.
3. 批准手机 Telegram 用户
hermes pairing approve telegram XKGH5N7P
4. 安装持久化网关服务
hermes gateway install
hermes gateway start
hermes gateway status
Equivalent to launchd plist under ~/Library/LaunchAgents/ per upstream; logs in ~/.hermes/logs/.
5. 配置显示与会话策略
display:
tool_progress: all
busy_input_mode: queue
busy_ack_enabled: true
Edit ~/.hermes/gateway.json for idle timeouts (JSON block in architecture section).
6. 设置 Discord 主频道
/sethome
Circuit-breaker trip notifications and gateway restart messages route to configured home_chat_id per platform.
7. 测试跨设备交接
Telegram: /title commute-test then start a 2-minute task. Discord: /resume commute-test. If empty, verify same allowed user ID on both platforms.
8. 生产环境加固
gateway:
platforms:
discord:
extra:
allow_from: ["YOUR_DISCORD_USER_ID"]
allow_admin_from: ["YOUR_DISCORD_USER_ID"]
telegram:
extra:
allow_from: ["YOUR_TELEGRAM_USER_ID"]
Restart: hermes gateway stop && hermes gateway start or launchctl kickstart -k gui/$(id -u)/com.hermes.gateway.
硬件说明: Apple Mac mini specifications list 16 GB base RAM—enough for gateway + one active agent; 24 GB if you add subagents or MCP servers concurrently.
故障排查
Gateway 在跑但 Telegram 机器人无响应
现象: hermes gateway status shows running; DMs never reply.
处理: Complete DM pairing (hermes pairing list). Confirm bot token in env survived launchd—launchctl print gui/$(id -u)/com.hermes.gateway | grep -i telegram. Restart gateway after token changes.
Discord 已连接但无流式进度
现象: Final answers appear; no tool progress lines.
处理: Set display.tool_progress: all in ~/.hermes/config.yaml. Enable Message Content Intent in Discord Developer Portal.
/platform list shows adapter paused-by-breaker
现象: One platform stops after repeated API errors.
处理: Check ~/.hermes/logs/gateway.log. Wait for upstream recovery, then /platform resume telegram. Breakers do not auto-resume by design.
后台任务完成但 Discord 看不到
现象: Telegram received background complete; Discord empty.
预期行为: Background results deliver to the originating chat. From Discord, run /status or ask the agent to read output paths.
Gateway 与 CLI:何时用哪个
| 用 CLI(hermes) | 用 Gateway |
|---|---|
| Local debugging, slash command dev | Mobile + multi-platform access |
| Ephemeral experiments | 24/7 cron + messaging delivery |
| No bot tokens needed | Telegram/Discord/Slack integration |
Both share ~/.hermes/ memory, skills, and model config—/model works on either surface per CLI vs Messaging quick reference.
延伸阅读
- Hermes macOS 安装配置指南 — install, first tokens, launchd on macOS
- Hermes 多智能体委派一人企业指南 — parallel subagents via
delegate_task - Hermes Mac mini M4 教程 — always-on Mac mini / headless hosting patterns
常见问题
Hermes Gateway 会自动把 Telegram 与 Discord 的对话同步成一条吗?
不会自动镜像为同一线程。每个平台+聊天有独立会话存储。连续性来自共享磁盘工作区、记忆文件、/background 任务 ID,以及同一网关上的 /title + /resume 命名会话——不是靠把每条消息复制到两个 App。
手机锁屏时任务会怎样?
网关在主机上继续执行,进行中的工具调用在服务端运行。长任务用 /background,或设 busy_input_mode: queue 避免误触中断。手机断线不会杀死 gateway 进程。
一个 Gateway 能接多少平台?
上游单进程支持 20+ 适配器。一人团队常用 2–3 个。用 /platform list 监控。
必须用云 Mac 或 VPS 吗?
需要某种常开主机——桌面 Mac mini、家用服务器或租用 macOS/Linux VM。休眠笔记本会暂停网关投递。
与 macOS 安装指南有何不同?
安装指南讲 install、首次 token、launchd。本文讲多设备工作流架构、会话交接、/background,以及 Telegram + Discord 通勤场景。