AI 自動化 2026年6月2日

手機發 Telegram,電腦看 Discord:用 Hermes Agent 的統一閘道(Gateway)打造永不斷線的全裝置賽博分身

NodeMac 技術團隊

約 14 分鐘

你在地鐵上用 Telegram 下達「批量生成 HTML Landing Page」的任務,然後鎖屏、切 App 或進出隧道——若是網頁聊天,執行會斷、上下文會丟。這是 2026 年獨立開發者常見痛點:用手機遙控 Agent,卻需要任務在永不斷線的常開主機上繼續執行。

Hermes AgentNous 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,以官方文件為準。

Hermes Agent Gateway 多裝置 Telegram Discord 設定教學
披露: NodeMac 發布 Mac 自動化指南並提供 Mac 託管服務。本文依據 Messaging Gateway 官方文件 描述上游 Hermes Gateway 行為;平台列表與預設值可能隨版本變化。

为何浏览器标签页会失败,而 Gateway 能持续运行

失败模式网页聊天 / 本地脚本常开主机上的 Hermes Gateway
Phone app backgroundedSSE/WebSocket often dropsGateway process keeps running
Laptop lid closedProcess suspendedlaunchd/systemd keeps gateway alive
Long tool run (30+ min)Tab timeout, lost contextAgent loop on server; optional /background
Switch Telegram → DiscordN/A (different products)Same gateway, shared workspace + memory
Cron / scheduled jobsRequires separate schedulerBuilt-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.

来源: Hermes Messaging Gateway.

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:

  1. /background — Fire-and-forget tasks; results deliver to the chat where you started the command, while your main session stays responsive.
  2. Shared workspace — Generated HTML, logs, and artifacts land on the gateway host filesystem; any platform can ask the agent to read them.
  3. /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
2Telegram/background Build 5 HTML landing variants in ~/projects/landing-batch/ using brand colors from MEMORY.md
3TelegramGateway ack: Task ID: bg_HHMMSS_xxxx — phone can lock
4Discord/resume landing-batch if you /title landing-batch first, OR ask: List files in ~/projects/landing-batch and summarize
5DiscordEnable 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 devMobile + multi-platform access
Ephemeral experiments24/7 cron + messaging delivery
No bot tokens neededTelegram/Discord/Slack integration

Both share ~/.hermes/ memory, skills, and model config—/model works on either surface per CLI vs Messaging quick reference.

常見問題

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 通勤场景。

需要 24/7 常開 Mac 跑 Hermes Gateway?

专属 Apple Silicon Mac,SSH 访问,港日新韩美节点。

NM
NodeMac 云端 Mac
5 分钟即可部署

租用专属 Apple Silicon Mac。SSH/VNC,港日新韩美节点。

立即开始