Initial: multi-agent XMPP communication system with dashboard
- Platform-based architecture (Windows/Linux/Mac) - Agent instance registry (agents.yaml) - Management dashboard with cross-platform monitoring - xmpp_bot with HTTP bridge + health endpoints - wechat_agent with WeChat-Hermes bridging - Platform services: ProcessGuardian, HealthProbe, APIRouter, ChannelBridge - Deployment: systemd (Linux) + PowerShell (Windows) - Monitoring: SSH+ejabberdctl for cross-platform presence
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# Linux 部署步骤(给 mohe 参考)
|
||||
|
||||
## 1. hermes-gateway@.service
|
||||
|
||||
```bash
|
||||
# 复制模板
|
||||
sudo cp /path/to/deploy/linux/hermes-gateway@.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# 启用默认 gateway(8642端口)
|
||||
sudo systemctl enable --now hermes-gateway@default
|
||||
|
||||
# 验证
|
||||
systemctl status hermes-gateway@default
|
||||
```
|
||||
|
||||
## 2. state.db 清理
|
||||
|
||||
```bash
|
||||
cd ~/.hermes/profiles/main
|
||||
|
||||
# 方案A:CLI 清理(推荐)
|
||||
hermes session prune --older-than 30d
|
||||
|
||||
# 方案B:手动清理
|
||||
sqlite3 state.db "DELETE FROM sessions WHERE time_created < strftime('%s','now','-30 days'); VACUUM;"
|
||||
```
|
||||
|
||||
## 3. Provider key 迁移
|
||||
|
||||
```yaml
|
||||
# config.yaml 中用环境变量替换
|
||||
providers:
|
||||
volcengine:
|
||||
api_key: ${VOLCENGINE_KEY} # 从 .env 读取
|
||||
ocg-new:
|
||||
api_key: ${OCG_NEW_KEY}
|
||||
ocg-old:
|
||||
api_key: ${OCG_OLD_KEY}
|
||||
```
|
||||
|
||||
```bash
|
||||
# .env 文件
|
||||
echo "VOLCENGINE_KEY=xxx" >> ~/.hermes/.env
|
||||
echo "OCG_NEW_KEY=xxx" >> ~/.hermes/.env
|
||||
echo "OCG_OLD_KEY=xxx" >> ~/.hermes/.env
|
||||
```
|
||||
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Hermes Gateway — %i profile
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=hmo
|
||||
WorkingDirectory=/home/hmo/hermes-agent
|
||||
Environment="PATH=/home/hmo/.local/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
ExecStart=/home/hmo/hermes-agent/.venv/bin/python -m hermes_cli.main -p %i gateway run --replace
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=hermes-gateway-%i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
# AgentsMeeting — Linux 安装脚本
|
||||
# 以 hmo 用户身份运行
|
||||
|
||||
echo "=== AgentsMeeting Linux Installation ==="
|
||||
|
||||
# 1. Install systemd units
|
||||
echo "[1/4] Installing systemd units..."
|
||||
sudo cp deploy/linux/hermes-gateway@.service /etc/systemd/system/
|
||||
sudo cp deploy/linux/xmpp-bot@.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
# 2. Create bot directories
|
||||
echo "[2/4] Creating bot directories..."
|
||||
for bot in mohe xiaoguo zhiwei; do
|
||||
mkdir -p /home/hmo/bots/${bot}
|
||||
done
|
||||
|
||||
# 3. Copy bot scripts
|
||||
echo "[3/4] Copying bot scripts..."
|
||||
cp src/bots/mohe/bot.py /home/hmo/bots/mohe/
|
||||
cp src/bots/xiaoguo/bot.py /home/hmo/bots/xiaoguo/
|
||||
cp src/bots/zhiwei/bot.py /home/hmo/bots/zhiwei/
|
||||
|
||||
# 4. Enable services
|
||||
echo "[4/4] Enabling services..."
|
||||
for profile in main mohe position-analyst xiaoguo; do
|
||||
if [ -f "/home/hmo/.hermes/profiles/${profile}/config.yaml" ]; then
|
||||
sudo systemctl enable --now hermes-gateway@${profile}
|
||||
echo " hermes-gateway@${profile} enabled"
|
||||
else
|
||||
echo " hermes-gateway@${profile}: SKIP (no config)"
|
||||
fi
|
||||
done
|
||||
|
||||
for bot in mohe xiaoguo zhiwei; do
|
||||
if [ -f "/home/hmo/bots/${bot}/bot.py" ]; then
|
||||
sudo systemctl enable --now xmpp-bot@${bot}
|
||||
echo " xmpp-bot@${bot} enabled"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "=== Done ==="
|
||||
echo "Check: systemctl status hermes-gateway@main xmpp-bot@mohe"
|
||||
@@ -0,0 +1,20 @@
|
||||
[Unit]
|
||||
Description=XMPP Bot — %i
|
||||
After=network-online.target ejabberd.service
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=hmo
|
||||
WorkingDirectory=/home/hmo/bots
|
||||
Environment="PYTHONUNBUFFERED=1"
|
||||
Environment="BOT_NAME=%i"
|
||||
ExecStart=/home/hmo/.local/bin/uv run python /home/hmo/bots/%i/bot.py
|
||||
Restart=always
|
||||
RestartSec=15
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=xmpp-bot-%i
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,48 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
AgentsMeeting �?状态检�?#>
|
||||
Write-Host "=== AgentsMeeting Status ===" -ForegroundColor Cyan
|
||||
|
||||
# Bot
|
||||
$bot = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "xmpp_bot" -and $_.CommandLine -notmatch "watchdog|health" }
|
||||
if ($bot) { Write-Host "xmpp_bot: RUNNING (PID $($bot.ProcessId))" -ForegroundColor Green }
|
||||
else { Write-Host "xmpp_bot: STOPPED" -ForegroundColor Red }
|
||||
|
||||
# HTTP bridge test
|
||||
try { $r = Invoke-RestMethod "http://127.0.0.1:5802/messages" -TimeoutSec 3 -ErrorAction Stop; Write-Host "http_bridge: OK ($($r.count) msgs)" -ForegroundColor Green }
|
||||
catch { Write-Host "http_bridge: ERROR" -ForegroundColor Yellow }
|
||||
|
||||
# WeChat
|
||||
$agent = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "wechat_agent" }
|
||||
if ($agent) { Write-Host "wechat_agent: RUNNING (PID $($agent.ProcessId))" -ForegroundColor Green }
|
||||
else { Write-Host "wechat_agent: STOPPED" -ForegroundColor Yellow }
|
||||
|
||||
# Watchdog
|
||||
$wd = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "watchdog" }
|
||||
if ($wd) { Write-Host "watchdog: RUNNING (PID $($wd.ProcessId))" -ForegroundColor Green }
|
||||
else { Write-Host "watchdog: STOPPED" -ForegroundColor Yellow }
|
||||
|
||||
# Proxy
|
||||
$proxy = netstat -ano 2>$null | Select-String ":8787"
|
||||
if ($proxy) { Write-Host "api_proxy: RUNNING (:8787)" -ForegroundColor Green }
|
||||
else { Write-Host "api_proxy: stopped" -ForegroundColor Yellow }
|
||||
|
||||
# Health last run
|
||||
$log = "D:\F\NewI\opencode\daily-workspace\projects\AgentsMeeting\gateway\logs\health_check.log"
|
||||
if (Test-Path $log) {
|
||||
$last = Get-Content $log -Tail 3
|
||||
Write-Host "health_check: LAST 3 LINES:" -ForegroundColor Gray
|
||||
$last | ForEach-Object { Write-Host " $_" -ForegroundColor Gray }
|
||||
}
|
||||
|
||||
# Mohe inbox
|
||||
$inbox = "D:\F\NewI\opencode\daily-workspace\projects\AgentsMeeting\gateway\logs\mohe_inbox.log"
|
||||
if (Test-Path $inbox) {
|
||||
$moheLines = Get-Content $inbox -Tail 3
|
||||
Write-Host "mohe_watcher: LAST 3 LINES:" -ForegroundColor Gray
|
||||
$moheLines | ForEach-Object { Write-Host " $_" -ForegroundColor Cyan }
|
||||
}
|
||||
|
||||
# Dashboard
|
||||
try { $d = Invoke-RestMethod "http://127.0.0.1:5803/api/health" -TimeoutSec 3 -ErrorAction Stop; Write-Host "dashboard: OK (:5803)" -ForegroundColor Green }
|
||||
catch { Write-Host "dashboard: stopped" -ForegroundColor Yellow }
|
||||
@@ -0,0 +1,36 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
AgentsMeeting �回滚到上一个稳定版�.DESCRIPTION
|
||||
ä¿�å˜å½“å‰�版本å�Žï¼Œä»?Git 拉å�–上一ä¸?tag æˆ?commitã€?#>
|
||||
|
||||
param([string]$Target = "")
|
||||
|
||||
$root = "D:\F\NewI\opencode\daily-workspace"
|
||||
$gateway = "$root\projects\AgentsMeeting\\gateway"
|
||||
|
||||
Write-Host "=== AgentsMeeting Rollback ===" -ForegroundColor Cyan
|
||||
|
||||
# Stop services
|
||||
Write-Host "[1/3] Stopping services..." -ForegroundColor Yellow
|
||||
& "$root\projects\AgentsMeeting\deploy\windows\stop.ps1"
|
||||
Start-Sleep 2
|
||||
|
||||
# Backup current
|
||||
$backupDir = "$gateway\backups\$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||
New-Item -ItemType Directory -Path $backupDir -Force | Out-Null
|
||||
Copy-Item "$gateway\scripts\*.py" $backupDir
|
||||
Write-Host "[2/3] Backup saved to $backupDir" -ForegroundColor Green
|
||||
|
||||
# Restore target
|
||||
if ($Target) {
|
||||
# Could restore from specific backup
|
||||
$restoreDir = "$gateway\backups\$Target"
|
||||
if (Test-Path $restoreDir) {
|
||||
Copy-Item "$restoreDir\*" "$gateway\scripts\" -Force
|
||||
Write-Host "[3/3] Restored from $Target" -ForegroundColor Green
|
||||
}
|
||||
else { Write-Host "[3/3] Target not found: $Target" -ForegroundColor Red; exit 1 }
|
||||
}
|
||||
else { Write-Host "[3/3] No rollback target specified. Skipped." -ForegroundColor Yellow }
|
||||
|
||||
Write-Host "`nRun start.ps1 to restart services" -ForegroundColor Cyan
|
||||
@@ -0,0 +1,96 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
AgentsMeeting Windows Services �?一键启动所有组�?.DESCRIPTION
|
||||
按依赖顺序启�? api_proxy �?wechat_agent �?xmpp_bot �?watchdog �?health_check
|
||||
每个服务启动后等待确认,失败则终止�?#>
|
||||
|
||||
param([switch]$Force)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Python = "C:\Users\hmo\AppData\Local\Programs\Python\Python310\python.exe"
|
||||
$GatewayRoot = "D:\F\NewI\opencode\daily-workspace\projects\AgentsMeeting\gateway"
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " AgentsMeeting Windows Services" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
|
||||
# Stop all existing services first
|
||||
Write-Host "`n[0] Stopping existing services..." -ForegroundColor Yellow
|
||||
Get-Process -Name "python*" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$cmd = (Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine
|
||||
if ($cmd -match "xmpp_bot|wechat_agent|api_proxy|watchdog|health_check") {
|
||||
Write-Host " Killing PID $($_.Id): $($_.ProcessName)" -ForegroundColor Gray
|
||||
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
# 1. API Proxy (port 8787)
|
||||
Write-Host "`n[1/5] Starting API Proxy..." -ForegroundColor Green
|
||||
$proxyScript = Join-Path $GatewayRoot "scripts\api_proxy.py"
|
||||
Start-Process -WindowStyle Hidden -FilePath $Python -ArgumentList $proxyScript
|
||||
Start-Sleep -Seconds 2
|
||||
$proxyCheck = netstat -ano 2>$null | Select-String ":8787"
|
||||
if ($proxyCheck) {
|
||||
Write-Host " API Proxy: OK (:8787)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " API Proxy: STARTED (port check skipped)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# 2. WeChat Agent (port 5801 + 19088 via wxhelper)
|
||||
Write-Host "`n[2/5] Starting WeChat Agent..." -ForegroundColor Green
|
||||
$agentScript = Join-Path $GatewayRoot "scripts\wechat_agent.py"
|
||||
Start-Process -WindowStyle Hidden -FilePath $Python -ArgumentList $agentScript
|
||||
Start-Sleep -Seconds 3
|
||||
Write-Host " WeChat Agent: STARTED" -ForegroundColor Green
|
||||
|
||||
# 3. XMPP Bot (xxm)
|
||||
Write-Host "`n[3/5] Starting XMPP Bot (xxm)..." -ForegroundColor Green
|
||||
$botScript = Join-Path $GatewayRoot "scripts\xmpp_bot.py"
|
||||
Start-Process -WindowStyle Hidden -FilePath $Python -ArgumentList $botScript
|
||||
Start-Sleep -Seconds 5
|
||||
$botCheck = Get-CimInstance Win32_Process -Filter "Name='python.exe'" | Where-Object { $_.CommandLine -match "xmpp_bot" -and $_.CommandLine -notmatch "watchdog" }
|
||||
if ($botCheck) {
|
||||
Write-Host " XMPP Bot: OK (PID $($botCheck.ProcessId))" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " XMPP Bot: FAILED TO START" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 4. Watchdog
|
||||
Write-Host "`n[4/5] Starting Watchdog..." -ForegroundColor Green
|
||||
$wdScript = Join-Path $GatewayRoot "scripts\xmpp_watchdog.py"
|
||||
Start-Process -WindowStyle Hidden -FilePath $Python -ArgumentList $wdScript
|
||||
Start-Sleep -Seconds 2
|
||||
Write-Host " Watchdog: STARTED" -ForegroundColor Green
|
||||
|
||||
# 5. Mohe watcher �?auto-log mohe replies
|
||||
Write-Host "`n[5/6] Starting Mohe Watcher..." -ForegroundColor Green
|
||||
$moheWatcher = Join-Path $GatewayRoot "scripts\mohe_watcher.py"
|
||||
Start-Process -WindowStyle Hidden -FilePath $Python -ArgumentList $moheWatcher
|
||||
Start-Sleep -Seconds 1
|
||||
Write-Host " Mohe Watcher: STARTED (�?logs/mohe_inbox.log)" -ForegroundColor Green
|
||||
|
||||
# 6. Health check (scheduled task)
|
||||
Write-Host "`n[6/6] Registering health check..." -ForegroundColor Green
|
||||
$taskName = "xxm-health-check"
|
||||
$checkScript = Join-Path $GatewayRoot "scripts\health_check_xxm.py"
|
||||
try {
|
||||
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
||||
$action = New-ScheduledTaskAction -Execute $Python -Argument "`"$checkScript`""
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) `
|
||||
-RepetitionInterval (New-TimeSpan -Minutes 5) `
|
||||
-RepetitionDuration (New-TimeSpan -Days 365)
|
||||
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType S4U -RunLevel Limited
|
||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null
|
||||
Write-Host " Health Check: OK (every 5 min)" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " Health Check: WARNING - $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host "`n========================================" -ForegroundColor Cyan
|
||||
Write-Host " ALL SERVICES STARTED" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " Dashboard: http://192.168.1.246:5803 (Linux)" -ForegroundColor Green
|
||||
Write-Host " Logs: $GatewayRoot\logs\" -ForegroundColor Gray
|
||||
Write-Host " Status: powershell -File deploy\windows\check.ps1" -ForegroundColor Gray
|
||||
@@ -0,0 +1,17 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
AgentsMeeting Windows Services â€?å�œæ¢æ‰€æœ‰æœ�åŠ?#>
|
||||
|
||||
Write-Host "Stopping all AgentsMeeting services..." -ForegroundColor Yellow
|
||||
|
||||
$count = 0
|
||||
Get-Process -Name "python*" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$cmd = (Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine
|
||||
if ($cmd -match "xmpp_bot|wechat_agent|api_proxy|watchdog|health_check") {
|
||||
Write-Host " Killing PID $($_.Id)" -ForegroundColor Gray
|
||||
Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue
|
||||
$count++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Stopped $count processes." -ForegroundColor Green
|
||||
Reference in New Issue
Block a user