refactor(hermes_cli): collapse banner comments to one-liners across slice E
This commit is contained in:
@@ -22,9 +22,7 @@ DEFAULT_PORTAL_BASE_URL = "https://portal.nousresearch.com"
|
||||
DEFAULT_TIMEOUT = 15.0
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Typed errors
|
||||
# =============================================================================
|
||||
# --- Typed errors ---
|
||||
|
||||
|
||||
class BillingError(Exception):
|
||||
@@ -97,9 +95,7 @@ class BillingUpgradeCapExceeded(BillingTransient):
|
||||
"""
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Base-URL + auth resolution
|
||||
# =============================================================================
|
||||
# --- Base-URL + auth resolution ---
|
||||
|
||||
|
||||
def resolve_portal_base_url(state: Optional[dict[str, Any]] = None) -> str:
|
||||
@@ -180,9 +176,7 @@ def _resolve_token_and_base(*, use_cache: bool = True) -> tuple[str, str]:
|
||||
return resolved
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# HTTP plumbing
|
||||
# =============================================================================
|
||||
# --- HTTP plumbing ---
|
||||
|
||||
|
||||
def _retry_after_seconds(headers: Any) -> Optional[int]:
|
||||
@@ -287,9 +281,7 @@ def _request(
|
||||
raise BillingError("Could not reach Nous Portal: timed out", error="network_error") from exc
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Endpoints
|
||||
# =============================================================================
|
||||
# --- Endpoints ---
|
||||
|
||||
|
||||
def _require_str(value: Any, message: str, error: str) -> str:
|
||||
@@ -342,9 +334,7 @@ def get_subscription_state(*, timeout: float = DEFAULT_TIMEOUT) -> dict[str, Any
|
||||
return _request("GET", "/api/billing/subscription", timeout=timeout)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Subscription change — preview + the pending-change resource + upgrade
|
||||
# =============================================================================
|
||||
# --- Subscription change — preview + the pending-change resource + upgrade ---
|
||||
# Chargeless lane: preview (quote only) and PUT/DELETE pending-change (schedule/clear a downgrade
|
||||
# or cancellation, effective at period end). The ONE money route: POST upgrade (prorate + charge
|
||||
# + flip the plan in one Stripe op). All require ``billing:manage`` (403 insufficient_scope ->
|
||||
|
||||
@@ -558,9 +558,7 @@ def apply_nous_managed_defaults(
|
||||
return changed
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool Gateway offer — single Y/n prompt after model selection
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tool Gateway offer — per-tool checklist after model selection
|
||||
|
||||
|
||||
def _get_gateway_direct_credentials() -> Dict[str, bool]:
|
||||
@@ -689,9 +687,7 @@ def prompt_enable_tool_gateway(config: Dict[str, object], *, force_fresh: bool =
|
||||
return changed
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Inline Nous Portal login for the Tool Gateway picker (`hermes tools`)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def ensure_nous_portal_access(*, capability: str = "the Nous Tool Gateway", coverage_category: Optional[str] = None) -> bool:
|
||||
|
||||
@@ -38,10 +38,6 @@ _JOB_HANDLE = None
|
||||
_LEDGER_LOCK = threading.Lock()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Install identity
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def install_id(project_root: Optional[Path] = None) -> str:
|
||||
"""Stable 12-hex identifier for THIS install (derived from its path)."""
|
||||
if project_root is None:
|
||||
@@ -68,9 +64,8 @@ def _process_create_time(pid: Optional[int] = None) -> Optional[float]:
|
||||
return None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Layer 1 — spawn tags
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SpawnTag:
|
||||
@@ -107,14 +102,11 @@ def parse_spawn_tag(raw: object) -> Optional[SpawnTag]:
|
||||
create = None if create_s == "-" else float(create_s)
|
||||
except ValueError:
|
||||
return None
|
||||
if pid <= 0:
|
||||
return None
|
||||
return SpawnTag(install=install, purpose=purpose, spawner_pid=pid, spawner_create=create)
|
||||
return SpawnTag(install, purpose, pid, create) if pid > 0 else None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Layer 2 — spawn ledger
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass
|
||||
class LedgerEntry:
|
||||
@@ -368,9 +360,8 @@ def reap_orphaned_mcp_helpers(*, project_root: Optional[Path] = None, kill_fn=No
|
||||
return reaped
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Layer 3 — Windows job-object self-attach
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def attach_self_to_kill_on_close_job() -> bool:
|
||||
"""Place this process in a job that dies (whole tree) when we die. Windows-only, idempotent.
|
||||
|
||||
Reference in New Issue
Block a user