wartung: Groesse je Quantisierung, GitHub-Antworten 15 min gemerkt, Hermes-Version auch bei haengendem Abruf

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-09-24 17:52:37 +02:00
co-authored by Claude Opus 5.5
parent 0e961f112b
commit ee2bb9d03c
3 changed files with 101 additions and 16 deletions
+25 -10
View File
@@ -50,10 +50,26 @@ _engine_cache = {"ts": 0.0, "avail": False}
_ENGINE_ASSET_RX = re.compile(r"ubuntu-vulkan-x64\.tar\.gz$", re.IGNORECASE)
# GitHub erlaubt ohne Anmeldung 60 Anfragen pro Stunde. Jeder Blick auf die Update-Details fragte
# bisher neu; jetzt gilt eine Antwort 15 Minuten. Fehler (auch das Anfragelimit) werden nicht gemerkt.
GITHUB_CACHE_S = int(os.environ.get("MC_GITHUB_CACHE_S", "900"))
_github_cache: dict[str, tuple[float, object]] = {}
def _github_json(pfad: str, timeout: float = 8) -> object:
jetzt = time.time()
if (eintrag := _github_cache.get(pfad)) and jetzt - eintrag[0] < GITHUB_CACHE_S:
return eintrag[1]
r = httpx.get(f"https://api.github.com/{pfad}", timeout=timeout, headers={"User-Agent": "MissionControl2"})
r.raise_for_status()
daten = r.json()
_github_cache[pfad] = (jetzt, daten)
return daten
def _latest_engine_asset_release() -> dict | None:
try:
rels = httpx.get(f"https://api.github.com/repos/{ENGINE_REPO}/releases?per_page=15",
timeout=8, headers={"User-Agent": "MissionControl2"}).json()
rels = _github_json(f"repos/{ENGINE_REPO}/releases?per_page=15")
for rel in (rels if isinstance(rels, list) else []):
if any(_ENGINE_ASSET_RX.search(a.get("name", "")) for a in (rel.get("assets") or [])):
return rel
@@ -160,9 +176,8 @@ def _swap_update_available() -> bool:
avail = False
fehler = None
try:
rel = httpx.get(f"https://api.github.com/repos/{SWAP_REPO}/releases/latest",
timeout=6, headers={"User-Agent": "MissionControl2"}).json()
tag = str(rel.get("tag_name", ""))
rel = _github_json(f"repos/{SWAP_REPO}/releases/latest", timeout=6)
tag = str(rel.get("tag_name", "")) if isinstance(rel, dict) else ""
latest = int(m.group(1)) if (m := re.search(r"(\d{2,})", tag)) else None
installed = _installed_swap_version()
if latest is not None and installed is not None:
@@ -346,8 +361,7 @@ def swap_update_details() -> dict:
"latest_build": None, "latest_tag": None, "name": None,
"url": None, "body": None}
try:
rel = httpx.get(f"https://api.github.com/repos/{SWAP_REPO}/releases/latest",
timeout=8, headers={"User-Agent": "MissionControl2"}).json()
rel = _github_json(f"repos/{SWAP_REPO}/releases/latest")
tag = str(rel.get("tag_name", ""))
info["latest_tag"] = tag
info["latest_build"] = int(m.group(1)) if (m := re.search(r"(\d{2,})", tag)) else None
@@ -446,8 +460,8 @@ def _summarize_release(kind: str, key: str, context: str, changes: str) -> dict:
def _summarize_hermes_commits(commits: list[dict]) -> dict:
subjects = "\n".join(f"- {c['subject']}" for c in commits[:100])
context = ("Es geht um ein Update des Hermes-Agenten (das Gehirn/Werkzeug-System der Box auf "
"Strix Halo; genutzt werden: api_server/Gateway, memory-provider-Plugin 'mc2-memory', "
"terminal-/web-Tools, approvals, cron).")
"Strix Halo; genutzt werden: api_server/Gateway, Telegram, eigenes Gedächtnis, "
"terminal-/web-Tools, Plugins, cron).")
return _summarize_release("hermes", commits[0]["hash"] if commits else "", context, subjects)
@@ -469,6 +483,8 @@ def hermes_update_details() -> dict:
info["error"] = "Hermes-Agent-Repo nicht gefunden."
return info
path = git["path"]
# Vor dem Abruf: scheitert der (Zeitlimit, Netz), zeigt die Seite trotzdem die laufende Version.
info["installed_version"] = _hermes_version(path)
try:
branch = (subprocess.run(["git", "-C", path, "rev-parse", "--abbrev-ref", "HEAD"],
capture_output=True, text=True, timeout=8).stdout.strip() or "main")
@@ -484,7 +500,6 @@ def hermes_update_details() -> dict:
commits.append({"hash": parts[0], "subject": parts[1], "when": parts[2]})
info["commits"] = commits
info["behind"] = len(commits)
info["installed_version"] = _hermes_version(path)
if commits:
info.update(_summarize_hermes_commits(commits))
except Exception as exc: