fix(honcho): read base_url and defaultHost from honcho.json host blocks

Fixes Honcho client initialization for setup-generated configs that store
connection details in a named host block (e.g. "local"). Previously:
- base_url was only read from flat config root, not from host_block.
- resolve_active_host() ignored defaultHost and always used the Hermes
  profile key ("hermes"), so the host block lookup returned {} and the
  api_key was also lost.

Fixes NousResearch/hermes-agent#61661
This commit is contained in:
Hermes Pi 2026-07-10 00:27:13 +02:00 committed by Teknium
parent 602998b76c
commit cd268c1226

View file

@ -63,6 +63,19 @@ def resolve_active_host() -> str:
if explicit:
return explicit
# Respect defaultHost from honcho.json when no profile override is set.
# This keeps setup-generated configs (e.g. host block "local") in sync with
# the host key the rest of the plugin resolves.
try:
path = resolve_config_path()
if path.exists():
raw = json.loads(path.read_text(encoding="utf-8"))
default_host = raw.get("defaultHost", "").strip()
if default_host:
return default_host
except Exception:
pass
try:
from hermes_cli.profiles import get_active_profile_name
profile = get_active_profile_name()
@ -477,7 +490,9 @@ class HonchoClientConfig:
)
base_url = (
raw.get("baseUrl")
host_block.get("baseUrl")
or host_block.get("base_url")
or raw.get("baseUrl")
or raw.get("base_url")
or os.environ.get("HONCHO_BASE_URL", "").strip()
or None