From 7a6fb103cb4c3bf25c630ab6b9dfe315b5973e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Wed, 24 Jun 2026 21:50:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=A7=E8=A1=8C=E5=99=A8=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E9=80=9A=E8=BF=87zhiwei=E7=9A=84XMPP=E5=8F=91?= =?UTF-8?q?=E7=BB=99Dad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 send_xmpp() 用hermes send经zhiwei发XMPP给hmo - 每条TODO完成/失败/升级都调用send_xmpp - Dad通过XMPP收到所有TODO流转结果 --- scripts/self_todo_executor.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/self_todo_executor.py b/scripts/self_todo_executor.py index a403b03..639b947 100644 --- a/scripts/self_todo_executor.py +++ b/scripts/self_todo_executor.py @@ -15,6 +15,17 @@ GATEWAY_URL = "http://localhost:8643/v1/chat/completions" GATEWAY_KEY = "hermes123" +def send_xmpp(msg): + """通过zhiwei发XMPP消息给Dad""" + try: + subprocess.run( + ["hermes", "send", "--to", "xmpp:hmo@yoin.fun", msg], + capture_output=True, text=True, timeout=15 + ) + except: + pass + + def main(): start = time.time() conn = sqlite3.connect(str(DB_PATH)) @@ -43,6 +54,7 @@ def main(): if not fix: # 无修复方案 → 带完整描述调gateway context = f"[自愈执行器] 系统体检发现以下问题,无自动修复方案,需分析处理。\n\n问题: {title}\n\n详情:\n{desc}".strip() + send_xmpp(f"📋 TODO已创建(无自动修复): {title[:80]}") else: # 执行修复命令 try: @@ -51,6 +63,7 @@ def main(): conn.execute("UPDATE todos SET status='completed', note=? WHERE id=?", (f"已修复: {r.stdout.strip()[:200]}", tid)) conn.commit() + send_xmpp(f"✅ TODO修复成功: {title[:80]}") print(f" ✅ {title}: 已修复") continue output = r.stderr.strip()[:500] or r.stdout.strip()[:500] @@ -83,11 +96,13 @@ def main(): result = reply["choices"][0]["message"]["content"][:500] conn.execute("UPDATE todos SET status='completed', note=? WHERE id=?", (f"知微已处理: {result[:200]}", tid)) + send_xmpp(f"🔶 TODO需知微处理: {title[:60]}\n{result[:200]}") print(f" 🔶 {title}") print(f" {result[:300]}") except Exception as e: conn.execute("UPDATE todos SET status='pending', note=? WHERE id=?", (f"调用知微失败: {str(e)[:100]},下次再试", tid)) + send_xmpp(f"⚠️ TODO处理失败(将重试): {title[:60]}\n{str(e)[:100]}") print(f" ⚠️ {title}: gateway API调用失败,下次再试") conn.commit()