The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(local_runtime): catalog.entry_for_model replaces 2 hit-unpack sites; tighten _host_os_arch
Teknium7c7d967b4cc4
diff --git a/hermes_cli/local_runtime/binaries.py b/hermes_cli/local_runtime/binaries.pyindex ce83ef39952..b35e835399e 100644--- a/hermes_cli/local_runtime/binaries.py+++ b/hermes_cli/local_runtime/binaries.py@@ -5,6 +5,7 @@ from __future__ import annotationsimport hashlibimport jsonimport logging+import osimport platformimport shutilimport subprocess@@ -87,19 +88,14 @@ def installed_tags() -> list[str]:def _host_os_arch() -> tuple[str, str]:- """(os, arch) normalized to release-asset vocabulary.-- PITFALL: PROCESSOR_ARCHITECTURE lies under x64 emulation on ARM64 Windows, and- platform.machine() reads the same env on some Pythons — so on Windows prefer- PROCESSOR_IDENTIFIER's text when present.- """+ """(os, arch) normalized to release-asset vocabulary. PITFALL: PROCESSOR_ARCHITECTURE lies+ under x64 emulation on ARM64 Windows, and platform.machine() reads the same env on some+ Pythons — so on Windows prefer PROCESSOR_IDENTIFIER's text when present."""system = platform.system().lower()os_name = {"windows": "win", "darwin": "macos", "linux": "ubuntu"}.get(system, system)- machine = platform.machine().lower()- arch = "arm64" if machine in ("arm64", "aarch64") else "x64"+ arch = "arm64" if platform.machine().lower() in ("arm64", "aarch64") else "x64"if os_name == "win":- import os as _os- ident = _os.environ.get("PROCESSOR_IDENTIFIER", "").lower()+ ident = os.environ.get("PROCESSOR_IDENTIFIER", "").lower()if "armv8" in ident or "arm " in ident:arch = "arm64"return os_name, arch@@ -257,12 +253,10 @@ def prune_old_tags(keep: list[str]) -> None:def ensure_runtime_installed(tag: str, backend: str,expected_sha256: dict[str, str] | None = None,progress: "Callable[[str, int, int, str], None] | None" = None) -> Path:- """Idempotent: resolve, download, verify, extract, version-check. Returns the install dir.-+ """Idempotent: resolve, download, verify, extract, version-check; returns the install dir.``expected_sha256`` pins hashes per asset; without pins the computed hash is recorded in themanifest (trust on first download, verified on every reinstall). ``progress(stage, done,- total, label)`` ticks through download/extract/verify.- """+ total, label)`` ticks through download/extract/verify."""plan = resolve_assets(tag, backend)install_dir = plan.install_dirmanifest_path = install_dir / "manifest.json"diff --git a/hermes_cli/local_runtime/capabilities.py b/hermes_cli/local_runtime/capabilities.pyindex 349f922d917..f85a8b3253f 100644--- a/hermes_cli/local_runtime/capabilities.py+++ b/hermes_cli/local_runtime/capabilities.py@@ -60,7 +60,7 @@ def managed_model_supports_vision(model_id: str) -> "bool | None":with suppress(Exception):from hermes_cli.local_runtime.bootstrap import assets_dir, staged_model_ids- from hermes_cli.local_runtime.catalog import find_entry_for_model+ from hermes_cli.local_runtime.catalog import entry_for_model# Only answer for models actually staged with us.if model_id not in staged_model_ids():@@ -71,11 +71,9 @@ def managed_model_supports_vision(model_id: str) -> "bool | None":# Staged but not loaded (or an older server build): the catalog knows whether this model# ships a vision projector. Capability requires the projector to actually be on disk — a# model downloaded before its mmproj (partial delete, old layout) genuinely cannot see.- hit = find_entry_for_model(model_id)- if hit is None:+ entry = entry_for_model(model_id)+ if entry is None:return None- entry = hit[0]- if entry.mmproj is None:- return False- return (assets_dir() / entry.mmproj.local_name).exists()+ return (entry.mmproj is not None+ and (assets_dir() / entry.mmproj.local_name).exists())return Nonediff --git a/hermes_cli/local_runtime/catalog.py b/hermes_cli/local_runtime/catalog.pyindex ae47fa58ae0..0e8d33d76ab 100644--- a/hermes_cli/local_runtime/catalog.py+++ b/hermes_cli/local_runtime/catalog.py@@ -345,3 +345,8 @@ def find_entry_for_model(model_id: str) -> "tuple[CatalogEntry, QuantVariant] |if variant.model_id == model_id:return entry, variantreturn None+++def entry_for_model(model_id: str) -> "CatalogEntry | None":+ hit = find_entry_for_model(model_id)+ return hit[0] if hit is not None else Nonediff --git a/hermes_cli/local_runtime/hardware.py b/hermes_cli/local_runtime/hardware.pyindex a5fdfc65abe..ae1c62f05c5 100644--- a/hermes_cli/local_runtime/hardware.py+++ b/hermes_cli/local_runtime/hardware.py@@ -71,9 +71,8 @@ def _ram_bytes() -> tuple[int, int]:class MEMORYSTATUSEX(ctypes.Structure):_fields_ = ([("dwLength", ctypes.c_ulong), ("dwMemoryLoad", ctypes.c_ulong)]+ [(name, ctypes.c_ulonglong) for name in (- "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile",- "ullAvailPageFile", "ullTotalVirtual", "ullAvailVirtual",- "ullAvailExtendedVirtual")])+ "ullTotalPhys", "ullAvailPhys", "ullTotalPageFile", "ullAvailPageFile",+ "ullTotalVirtual", "ullAvailVirtual", "ullAvailExtendedVirtual")])stat = MEMORYSTATUSEX()stat.dwLength = ctypes.sizeof(MEMORYSTATUSEX)diff --git a/hermes_cli/local_runtime/presets.py b/hermes_cli/local_runtime/presets.pyindex 876de8d844e..90fce70ac2e 100644--- a/hermes_cli/local_runtime/presets.py+++ b/hermes_cli/local_runtime/presets.py@@ -112,7 +112,7 @@ def _restore_grown_window(model_id: str, profile: ModelProfile, budget: Hardwaredef _preset_for(gguf: Path, budget: HardwareBudget,mtp_capable: set[str]) -> PresetEntry | None:"""The launch decision for one staged model, or None when its header is unreadable."""- from hermes_cli.local_runtime.catalog import find_entry_for_model+ from hermes_cli.local_runtime.catalog import entry_for_modelmodel_id = model_id_from_stem(gguf.stem)try:@@ -121,8 +121,7 @@ def _preset_for(gguf: Path, budget: HardwareBudget,except (ValueError, OSError) as exc:logger.warning("preset skip %s: %s", gguf.name, exc)return None- hit = find_entry_for_model(model_id)- entry = hit[0] if hit is not None else None+ entry = entry_for_model(model_id)is_mtp = entry.mtp if entry is not None else model_id in mtp_capableif is_mtp and profile.kv_scale == 1.0:# Header-derived profiles don't know about MTP's draft context; apply the calibrated KV