[NIGHT] Остальные задачи: alert digest+analysis, memory/USER.md, onboarding, redaction watcher, fallback notice, task backlog, deep audit v2
This commit is contained in:
1 parent
4804dc6a75
commit
eed9381b2e
7 files changed
+859
-137
No files matched your search
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fallback-уведомление: если OpenClaw лёг — сказать семье, что секретарь недоступен."""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
ROOM = "!puEdcZCc87kKoCm3mX5bbjrTS-Skv2XCZg7JJBKOMw0"
|
||||
HS = "http://192.168.1.155:8008"
|
||||
STATE = "/var/lib/openclaw-fallback.state"
|
||||
|
||||
|
||||
def send(text):
|
||||
tok = open("/root/.matrix-admin-token").read().strip()
|
||||
txn = "fb-%d" % int(time.time() * 1000)
|
||||
body = json.dumps({"msgtype": "m.text", "body": text}).encode()
|
||||
url = "%s/_matrix/client/v3/rooms/%s/send/m.room.message/%s?access_token=%s" % (HS, ROOM, txn, tok)
|
||||
r = urllib.request.Request(url, data=body, headers={"Content-Type": "application/json"}, method="PUT")
|
||||
with urllib.request.urlopen(r, timeout=20) as resp:
|
||||
return resp.status
|
||||
|
||||
|
||||
def healthy():
|
||||
try:
|
||||
r = subprocess.run(["pct", "exec", "115", "--", "docker", "exec", "openclaw",
|
||||
"node", "openclaw.mjs", "health"], capture_output=True, text=True, timeout=20)
|
||||
out = (r.stdout or "") + (r.stderr or "")
|
||||
return "Agents:" in out
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
prev = "up"
|
||||
try:
|
||||
prev = open(STATE).read().strip()
|
||||
except Exception:
|
||||
pass
|
||||
cur = "up" if healthy() else "down"
|
||||
if cur != prev:
|
||||
if cur == "down":
|
||||
send("⚠️ **Секретарь временно недоступен.** Базовые команды hub-bots работают; "
|
||||
"если срочно — напишите @secretary.")
|
||||
else:
|
||||
send("✅ Секретарь снова на связи.")
|
||||
open(STATE, "w").write(cur)
|
||||
print("state:", cur)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user