chore: sync

This commit is contained in:
知微
2026-07-20 21:43:03 +08:00
parent c01c6cd266
commit 3eb214f3a6
3 changed files with 696 additions and 648 deletions
@@ -50,6 +50,9 @@ REGISTRY = [
{"module": "gateway_llm", "function": "LLM调用链可用(gateway agent.log)",
"check": {"type": "agent_log", "max_age_min": 30, "when": "always"},
"repair": {"action": "llm_diagnose"}},
{"module": "sense_ocr", "function": "识图服务(SenseNova OCR配置+API可达)",
"check": {"type": "ocr_health", "when": "always"},
"repair": {"action": "llm_diagnose"}},
{"module": "xmpp_bot", "function": "XMPP消息收发(bot journal)",
"check": {"type": "bot_activity", "when": "always"},
"repair": {"action": "llm_diagnose"}},
@@ -127,6 +130,31 @@ def check_bot_activity(chk, now):
return "fail", f"检查失败: {e}"
def check_ocr_health(chk, now):
"""识图服务健康:OCR 配置存在 + SenseNova API 可达(TCP 443)。
不发真实 OCR 请求(省钱),真实端到端验证走 K 测试。"""
import json as _json, socket
# 1. OCR 配置存在且含 key
cfg_path = '/home/hmo/.config/mofin/ocr_config.json'
if not os.path.exists(cfg_path):
return "fail", "OCR 配置文件不存在: /home/hmo/.config/mofin/ocr_config.json"
try:
cfg = _json.load(open(cfg_path))
if not cfg.get('key') or not cfg.get('base_url'):
return "fail", "OCR 配置缺 key 或 base_url"
except Exception as e:
return "fail", f"OCR 配置解析失败: {str(e)[:60]}"
# 2. SenseNova API TCP 可达
try:
host = cfg['base_url'].split('//')[1].split('/')[0].split(':')[0]
port = int(cfg['base_url'].split('//')[1].split('/')[0].split(':')[1]) if ':' in cfg['base_url'].split('//')[1].split('/')[0] else 443
s = socket.create_connection((host, port), timeout=5)
s.close()
except Exception as e:
return "fail", f"SenseNova API 不可达 ({host}): {str(e)[:60]}"
return "ok", f"配置 OK + {host}:{port} 可达"
def check_cron_engine(chk, now):
"""cron 引擎:最近 max_age_min 内是否有任何 job 运行过"""
try:
@@ -180,6 +208,8 @@ def main():
status, reason = check_agent_log(chk, now)
elif t == "bot_activity":
status, reason = check_bot_activity(chk, now)
elif t == "ocr_health":
status, reason = check_ocr_health(chk, now)
elif t == "cron_engine":
status, reason = check_cron_engine(chk, now)
else: