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()