Files
AgentsMeeting/HANDFOFF.md
T

125 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AgentsMeeting — Session Handoff
> 创建时间: 2026-06-12 04:00
> 源会话: hermes session (ses_1d95d15c4ffehQaZ6hrbIbak5k)
## 🔴 关键操作手册(必读)
### 如何发送消息到 coregroup(核心群聊)
> **任何时候要向 coregroup 发消息,不要从 246 操作。用本地 HTTP bridge。**
```powershell
# ✅ 正确方式(UTF-8 编码,中文不会乱码)
$json = '{"message":"你好大家,开发完成,请 git pull 测试"}'
$bytes = [System.Text.Encoding]::UTF8.GetBytes($json)
Invoke-WebRequest -Uri "http://127.0.0.1:5802/send" -Method POST -Body $bytes -ContentType "application/json; charset=utf-8" -UseBasicParsing
# ❌ 错误 — Invoke-WebRequest -Body "字符串" 会走系统 GBK 编码,中文变问号
# ❌ 错误 — 不要从 246 发
# ❌ 错误 — 不要用 send_xmpp_groupmsg.py(没有 join MUC 被丢弃)
```
**原理:**
- 我的 XMPP bot JID: `xxm@yoin.fun`(运行在这个 Windows 机器上)
- bot 启动时已自动 join MUC rooms(含 `coregroup@conference.yoin.fun`
- HTTP bridge`xmpp_bot.py` 内置)绑定 `127.0.0.1:5802`
- 只有这个方式发的消息会出现在 coregroup 里
### 如何查看是否有新消息
```powershell
# 查看 mohe 发给我的消息
curl "http://127.0.0.1:5802/messages?from=mohe"
# 查看全部消息
curl "http://127.0.0.1:5802/messages"
```
### 状态检查
```powershell
# 检查 bot 是否在运行
Get-Process -Name python* | Where-Object { $_.CommandLine -match "xmpp_bot" }
# 检查 HTTP bridge 是否在监听
netstat -ano | findstr :5802
## 已完成
### 系统修复
- `part_` 前缀 bug (chat_bridge.py:335): `part_` → `prt_`
- 工具调用 XML 泄漏: final force 用干净上下文 + `_strip_toolcall_xml()`
- 静默模式误杀: `_SHUTUP_PATTERNS` 缩紧到仅 "闭嘴"/"住口"/"shut up"
- self-message 回声静默: on_group_message 中 self-msg 检查提前到 shutup 之前
- MAX_TOOL_LOOPS: 15 → 30,超限后走 clean final force
- watchdog 进程唯一: `start_bot()` 先 `kill_all_bots()` 再启动
- 健康检查: 检测 "alive 但无消息接收" 状态,自动重启
- 日志轮转: watchdog 每 15 分钟检查 >5MB 自动轮转
### 架构设计
- docs/ARCHITECTURE.md (17.5 KB): 系统总览/拓扑/数据流/模块/监控
- docs/AUDIT.md (4.2 KB): 稳定性审计报告
- docs/DEPLOY.md (2.8 KB): 部署指南 (Windows + Linux)
- docs/OPS.md (3.2 KB): 运维手册/常见故障/日志轮转
- docs/QUICKSTART.md: 快速操作手册
- README.md (4.4 KB): 项目概览
### 部署脚本
- deploy/windows/{start,stop,check,rollback}.ps1
- deploy/linux/{install.sh,hermes-gateway@.service,xmpp-bot@.service}
### 源码
- src/shared/config.py: 集中配置管理 (env var + YAML)
- src/shared/bot_base.py: Bot 基类 (BotConfig/BaseBot/extract_response)
- src/ops/watch_group.py: 消息监控脚本
- src/channels/qq/bridge.py: QQ 通道骨架
- config/.env.example: 环境变量模板
### HTTP 桥 (:5802)
- POST /send: 发送群消息
- GET /messages: 读取最近 200 条消息 (支持 ?from=mohe 过滤)
- 集成到 xmpp_bot.pybot 重启自动恢复
### 测试
- tests/test_core.py: 单元测试
- tests/verify_deploy.py: 部署验证 (12 项全部通过)
- HTTP bridge 验证: send+receive 均正常
### 运行状态
- xmpp_bot: RUNNING (watchdog 守护)
- wechat_agent: RUNNING (uptime 35h+)
- watchdog: RUNNING (30s 检查 + 日志轮转)
- api_proxy: RUNNING
- health_check: 5 分钟定时任务
## 待完成
### 需 mohe 在 Linux 侧
- 部署 systemd services (hermes-gateway@.service, xmpp-bot@.service)
- 配置 provider 环境变量 (替换 configs/*/config.yaml 中的占位符)
- 排查 ejabberd MUC conference.yoin.fun 响应问题
- state.db 829MB 归档清理
### 需 mohe 配合
- 架构文档最终审核
- 部署验证
- hermes-gateway@.service 使用实际 systemd 模板
## 关键文件
- projects/wechat-hermes-gateway/scripts/xmpp_bot.py (HTTP bridge)
- projects/wechat-hermes-gateway/scripts/chat_bridge.py (final force 修复)
- projects/wechat-hermes-gateway/scripts/xmpp_watchdog.py (log rotation)
- projects/wechat-hermes-gateway/scripts/health_check_xxm.py
- projects/AgentsMeeting/src/shared/config.py
- projects/AgentsMeeting/src/shared/bot_base.py
- projects/AgentsMeeting/deploy/windows/start.ps1
- projects/AgentsMeeting/deploy/windows/check.ps1
- projects/AgentsMeeting/docs/ARCHITECTURE.md
- projects/AgentsMeeting/tests/verify_deploy.py
## 注意事项
- HTTP bridge (:5802) 绑定 127.0.0.1,不对外暴露
- bot 重启后消息 buffer 会清空,新消息到达后自动重建
- 健康检查 lastMsg=999min 是 MAM 恢复期间正常现象
- MUC join 一直超时,bot 通过 MAM 订阅工作