Skip to content

Implement Hermes Relay Windows reverse-connection worker with secure local ops and MCP orchestration#1

Merged
zhangchaoeu merged 5 commits into
mainfrom
copilot/implement-windows-worker
May 26, 2026
Merged

Implement Hermes Relay Windows reverse-connection worker with secure local ops and MCP orchestration#1
zhangchaoeu merged 5 commits into
mainfrom
copilot/implement-windows-worker

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

  • Explore existing repo structure and worker protocol
  • Create hermes_gateway/ package (config, state, server, gateway core, tools, entrypoint)
  • Write focused tests for gateway (auth, call_worker timeout, offline worker)
  • Add gateway_config.example.json
  • Update README with gateway setup docs
  • Run parallel validation and address review feedback
Original prompt

实现一个运行在 Windows 上的项目 Hermes Relay,它不是主聊天 Agent,而是 33 号服务器上 Hermes 的远程 worker。由于 33 可能无法主动访问 32,所以请采用 反向连接架构:32 上的 Hermes Relay 主动通过 WebSocket 连接到 33,建立长连接后接收任务、执行任务并返回结果。

目标
实现一个可运行的 Windows worker,包含以下能力:

WebSocket Worker

启动后主动连接配置中的 ws_server_url
发送 register 消息
定期发送 heartbeat
接收 task 消息
执行任务后返回 task_result
支持自动重连
本地能力

fs.list
fs.read
fs.write
powershell.safe
MCP 管理能力

mcp.install
mcp.register
mcp.start
mcp.stop
mcp.restart
mcp.status
mcp.logs
mcp.tools
mcp.invoke
注意

不要内置网页抓取或浏览器自动化
网页能力由专门的 MCP server 提供
Hermes Relay 的职责是:本地系统能力 + MCP 管理/调用 + WebSocket worker
技术栈
优先使用:

Python 3.11+
asyncio
websockets
pydantic
psutil
subprocess
必做要求
设计清晰的项目结构
使用配置文件保存:
ws_server_url
agent_id
agent_name
worker_token
heartbeat_interval_seconds
reconnect_interval_seconds
allowed_file_roots
powershell_allowlist
allowed_npm_packages
allowed_pip_packages
registry_file
log_dir
文件访问必须限制在允许目录内,防止目录穿越
PowerShell 只允许白名单命令或预定义动作,禁止任意命令透传
MCP server 使用 servers.json 持久化配置,支持:
name
command
args
cwd
env
auto_start
使用子进程托管 MCP server,并采集 stdout/stderr 日志
实现最小可用的 MCP client/host 层,至少打通一个 stdio MCP server 的工具发现和调用流程
提供 README,说明安装、配置、启动、消息协议、任务 action、MCP 使用示例
消息协议
至少实现这些 JSON 消息:

register
32 -> 33

JSON
{
"type": "register",
"agent_id": "windows-32",
"agent_name": "Hermes Relay",
"token": "worker-auth-token",
"capabilities": [
"fs.list",
"fs.read",
"fs.write",
"powershell.safe",
"mcp.install",
"mcp.register",
"mcp.start",
"mcp.stop",
"mcp.restart",
"mcp.status",
"mcp.logs",
"mcp.tools",
"mcp.invoke"
]
}
heartbeat
JSON
{
"type": "heartbeat",
"agent_id": "windows-32",
"timestamp": "2026-05-26T12:00:00Z"
}
task
33 -> 32

JSON
{
"type": "task",
"task_id": "task-123",
"action": "fs.read",
"payload": {
"path": "D:\agent_workspace\test.txt"
}
}
task_result
32 -> 33

JSON
{
"type": "task_result",
"task_id": "task-123",
"ok": true,
"data": {
"content": "hello"
},
"error": null
}
开发顺序
WebSocket client + register/heartbeat/reconnect
task dispatcher
fs.list/read/write
powershell.safe
MCP registry + process manager
mcp.install/register/start/stop/restart/status/logs
mcp.tools/invoke
README + 示例配置 + 示例 servers.json
验收标准
Windows 上能启动 Hermes Relay
启动后会主动连接 33
能发送 register/heartbeat
能处理 fs.list/read/write 和 powershell.safe
能注册并托管至少一个 MCP server
能发现并调用至少一个 MCP 工具
README 完整
请直接生成:

完整项目代码
配置文件示例
servers.json 示例
README
可选:本地 mock WebSocket server 方便联调

Copilot AI and others added 2 commits May 26, 2026 03:04
Copilot AI changed the title [WIP] Implement Windows worker for Hermes Relay using WebSocket Implement Hermes Relay Windows reverse-connection worker with secure local ops and MCP orchestration May 26, 2026
Copilot AI requested a review from zhangchaoeu May 26, 2026 03:09
Copilot AI and others added 2 commits May 26, 2026 05:27
Agent-Logs-Url: https://github.com/zhangchaoeu/relay-tool/sessions/97cf14a2-1176-49a5-ba0c-57b7dd7093c3

Co-authored-by: zhangchaoeu <64073423+zhangchaoeu@users.noreply.github.com>
@zhangchaoeu zhangchaoeu marked this pull request as ready for review May 26, 2026 06:22
@zhangchaoeu zhangchaoeu merged commit 1b263ef into main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants