Skip to content

Hermes 完整调用链

总览

Hermes 支持六种以上调用入口,但最终都汇入同一个 AIAgent

六条调用链

1. CLI 模式

hermes chat

hermes_cli/main.py → cli.py::HermesCLI

HermesCLI.chat(user_input)

AIAgent(...)

agent.conversation_loop.run_conversation(...)

response → print to terminal

2. Gateway 模式

Telegram message

gateway/platforms/telegram.py

MessageEvent

GatewayRunner.route(event)

session_key cache lookup

AIAgent(...)

run_conversation(...)

response → platform.send(chat_id, ...)

3. Cron 模式

Ticker → load_jobs()

spawn thread

AIAgent(...)

run_conversation(job.prompt)

response → deliver("telegram")

save to ~/.hermes/cron/output/

4. ACP 模式

IDE (Zed/VSCode/...)

ACP Agent Client Protocol

acp_adapter/server.py

ThreadPoolExecutor

AIAgent(...)

run_conversation(...)

ACP events → back to IDE

5. TUI 模式

hermes tui

TypeScript Ink app

IPC / subprocess → AIAgent

run_conversation(...)

streaming → TUI components

6. Desktop 模式

Electron app

HTTP / WebSocket → Gateway API

GatewayRunner

AIAgent

response → desktop UI

统一抽象

所有 surface 共享:

AIAgent
  ├─ provider / base_url / api_key
  ├─ toolsets + tool schemas
  ├─ SessionDB
  ├─ memory manager
  ├─ context compressor
  ├─ system prompt (cached)
  └─ callbacks

没有 surface 走特殊路径——这是 Hermes 架构最核心的约束和优势。

对比

SurfacePiOpenCodeHermes
CLI
TUI✅ (自研)✅ (Solid)✅ (Ink)
Gateway❌ (无消息平台)
Cron
ACP
Desktop
API ServerRPCHTTP REST
MCP

Powered by VitePress