Merge branch 'simp/r3-22' into simp/integration3

This commit is contained in:
Teknium
2026-09-02 22:39:43 -07:00
5 changed files with 8 additions and 25 deletions
+3 -13
View File
@@ -32,7 +32,6 @@ Caps = dict[str, Optional[dict[str, Any]]]
def _origin():
from hermes_cli import models
return models
@@ -56,14 +55,8 @@ def parse_openrouter_reasoning_capabilities(item: Any) -> Optional[dict[str, Any
raw_efforts = reasoning.get("supported_efforts")
efforts: Optional[list[str]] = None
if isinstance(raw_efforts, list):
efforts = list(dict.fromkeys(
str(effort).strip().lower() for effort in raw_efforts if str(effort).strip()
))
return {
"supports_reasoning": True,
"supported_efforts": efforts,
"mandatory": reasoning.get("mandatory") is True,
}
efforts = list(dict.fromkeys(str(e).strip().lower() for e in raw_efforts if str(e).strip()))
return {"supports_reasoning": True, "supported_efforts": efforts, "mandatory": reasoning.get("mandatory") is True}
# ── Disk mirror ────────────────────────────────────────────────────────
@@ -83,7 +76,6 @@ def _reasoning_caps_disk_path() -> Path:
def _read_reasoning_caps_disk() -> dict[str, Any]:
from hermes_cli.models import _read_json_cache
return _read_json_cache(_reasoning_caps_disk_path()) or {}
@@ -103,7 +95,6 @@ def _load_reasoning_caps_disk(url: str) -> tuple[Optional[Caps], float]:
def _save_reasoning_caps_disk(url: str, caps: Caps) -> None:
"""Merge *url*'s catalog into the shared disk mirror, atomically."""
from hermes_cli.models import _write_json_cache
try:
data = _origin()._read_reasoning_caps_disk()
data[url] = {"ts": time.time(), "caps": caps}
@@ -154,9 +145,8 @@ def _fetch_reasoning_caps_catalog(url: str, timeout: float) -> Optional[Caps]:
"""Fetch one OpenRouter-shaped ``/v1/models`` catalog → per-model caps; None when unreachable or
empty so callers remember the failure. Sends a User-Agent: the Portal 403s anonymous reads."""
m = _origin()
headers = {"Accept": "application/json", "User-Agent": m._HERMES_USER_AGENT}
try:
req = urllib.request.Request(url, headers=headers)
req = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": m._HERMES_USER_AGENT})
with m._urlopen_model_catalog_request(req, timeout=timeout) as resp:
payload = json.loads(resp.read().decode())
except Exception:
+1 -3
View File
@@ -523,9 +523,7 @@ def _tool_access_from_value(value: Any) -> Optional[NousToolAccessInfo]:
def _coerced_dataclass(cls, value: Any):
"""Build ``cls`` from a payload dict (field names = payload keys), coercing by declared type."""
if not isinstance(value, dict):
return None
return cls(**{f.name: _COERCERS[f.type](value.get(f.name)) for f in fields(cls)})
return cls(**{f.name: _COERCERS[f.type](value.get(f.name)) for f in fields(cls)}) if isinstance(value, dict) else None
def _subscription_from_payload(value: Any) -> Optional[NousPortalSubscriptionInfo]:
+2 -4
View File
@@ -18,8 +18,7 @@ from typing import Any, Optional
DEFAULT_PORTAL_BASE_URL = "https://portal.nousresearch.com"
# Tight so a hung portal doesn't freeze the TUI (charge/poll calls are quick).
DEFAULT_TIMEOUT = 15.0
DEFAULT_TIMEOUT = 15.0 # tight so a hung portal doesn't freeze the TUI (charge/poll calls are quick)
# --- Typed errors ---
@@ -101,8 +100,7 @@ class BillingUpgradeCapExceeded(BillingTransient):
def resolve_portal_base_url(state: Optional[dict[str, Any]] = None) -> str:
"""Resolve the portal base URL with login-time precedence: env, stored state, default."""
env = os.getenv("HERMES_PORTAL_BASE_URL") or os.getenv("NOUS_PORTAL_BASE_URL")
stored = state.get("portal_base_url") if state else None
for candidate in (env, stored):
for candidate in (env, state.get("portal_base_url") if state else None):
if isinstance(candidate, str) and candidate.strip():
return candidate.strip().rstrip("/")
return DEFAULT_PORTAL_BASE_URL
+1 -2
View File
@@ -63,8 +63,7 @@ def _cmd_approve(store, platform: str, code: str):
else:
result = store.approve_code(platform, code.upper())
if result:
uid = result["user_id"]
name = result.get("user_name") or ""
uid, name = result["user_id"], result.get("user_name") or ""
display = f"{name} ({uid})" if name else uid
print(f"\n Approved! User {display} on {platform} can now use the bot~")
print(" They'll be recognized automatically on their next message.\n")
+1 -3
View File
@@ -89,9 +89,7 @@ def spawn_env(purpose: str, *, project_root: Optional[Path] = None) -> dict[str,
def parse_spawn_tag(raw: object) -> Optional[SpawnTag]:
"""Parse a ``HERMES_SPAWN`` value; ``None`` for anything malformed."""
if not isinstance(raw, str):
return None
parts = raw.split(":")
parts = raw.split(":") if isinstance(raw, str) else []
if len(parts) != 5 or parts[0] != _TAG_VERSION:
return None
_, install, purpose, pid_s, create_s = parts