mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-13 03:52:00 +00:00
fix(honcho): allow self-hosted local instances without API key (#3644)
Self-hosted Honcho on localhost doesn't require authentication, but both the activation gates and the SDK client required an API key. Combined fix from three contributor PRs: - Relax all 8 activation gates to accept (api_key OR base_url) as valid credentials (#3482 by @cameronbergh) - Use 'local' placeholder for the SDK client when base_url points to localhost/127.0.0.1/::1 (#3570 by @ygd58) Files changed: run_agent.py (2 gates), cli.py (1 gate), gateway/run.py (1 gate), honcho_integration/cli.py (2 gates), hermes_cli/doctor.py (2 gates), honcho_integration/client.py (SDK). Co-authored-by: cameronbergh <cameronbergh@users.noreply.github.com> Co-authored-by: ygd58 <ygd58@users.noreply.github.com> Co-authored-by: devorun <devorun@users.noreply.github.com>
This commit is contained in:
parent
d35567c6e0
commit
0bd7e95dfc
6 changed files with 27 additions and 12 deletions
2
cli.py
2
cli.py
|
|
@ -6103,7 +6103,7 @@ class HermesCLI:
|
||||||
from honcho_integration.client import HonchoClientConfig
|
from honcho_integration.client import HonchoClientConfig
|
||||||
from agent.display import honcho_session_line, write_tty
|
from agent.display import honcho_session_line, write_tty
|
||||||
hcfg = HonchoClientConfig.from_global_config()
|
hcfg = HonchoClientConfig.from_global_config()
|
||||||
if hcfg.enabled and hcfg.api_key and hcfg.explicitly_configured:
|
if hcfg.enabled and (hcfg.api_key or hcfg.base_url) and hcfg.explicitly_configured:
|
||||||
sname = hcfg.resolve_session_name(session_id=self.session_id)
|
sname = hcfg.resolve_session_name(session_id=self.session_id)
|
||||||
if sname:
|
if sname:
|
||||||
write_tty(honcho_session_line(hcfg.workspace_id, sname) + "\n")
|
write_tty(honcho_session_line(hcfg.workspace_id, sname) + "\n")
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ class GatewayRunner:
|
||||||
from honcho_integration.session import HonchoSessionManager
|
from honcho_integration.session import HonchoSessionManager
|
||||||
|
|
||||||
hcfg = HonchoClientConfig.from_global_config()
|
hcfg = HonchoClientConfig.from_global_config()
|
||||||
if not hcfg.enabled or not hcfg.api_key:
|
if not hcfg.enabled or not (hcfg.api_key or hcfg.base_url):
|
||||||
return None, hcfg
|
return None, hcfg
|
||||||
|
|
||||||
client = get_honcho_client(hcfg)
|
client = get_honcho_client(hcfg)
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ def _honcho_is_configured_for_doctor() -> bool:
|
||||||
from honcho_integration.client import HonchoClientConfig
|
from honcho_integration.client import HonchoClientConfig
|
||||||
|
|
||||||
cfg = HonchoClientConfig.from_global_config()
|
cfg = HonchoClientConfig.from_global_config()
|
||||||
return bool(cfg.enabled and cfg.api_key)
|
return bool(cfg.enabled and (cfg.api_key or cfg.base_url))
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -708,8 +708,8 @@ def run_doctor(args):
|
||||||
check_warn("Honcho config not found", "run: hermes honcho setup")
|
check_warn("Honcho config not found", "run: hermes honcho setup")
|
||||||
elif not hcfg.enabled:
|
elif not hcfg.enabled:
|
||||||
check_info(f"Honcho disabled (set enabled: true in {_honcho_cfg_path} to activate)")
|
check_info(f"Honcho disabled (set enabled: true in {_honcho_cfg_path} to activate)")
|
||||||
elif not hcfg.api_key:
|
elif not (hcfg.api_key or hcfg.base_url):
|
||||||
check_fail("Honcho API key not set", "run: hermes honcho setup")
|
check_fail("Honcho API key or base URL not set", "run: hermes honcho setup")
|
||||||
issues.append("No Honcho API key — run 'hermes honcho setup'")
|
issues.append("No Honcho API key — run 'hermes honcho setup'")
|
||||||
else:
|
else:
|
||||||
from honcho_integration.client import get_honcho_client, reset_honcho_client
|
from honcho_integration.client import get_honcho_client, reset_honcho_client
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ def cmd_status(args) -> None:
|
||||||
print(f" {peer}: {mode}")
|
print(f" {peer}: {mode}")
|
||||||
print(f" Write freq: {hcfg.write_frequency}")
|
print(f" Write freq: {hcfg.write_frequency}")
|
||||||
|
|
||||||
if hcfg.enabled and hcfg.api_key:
|
if hcfg.enabled and (hcfg.api_key or hcfg.base_url):
|
||||||
print("\n Connection... ", end="", flush=True)
|
print("\n Connection... ", end="", flush=True)
|
||||||
try:
|
try:
|
||||||
get_honcho_client(hcfg)
|
get_honcho_client(hcfg)
|
||||||
|
|
@ -278,7 +278,7 @@ def cmd_status(args) -> None:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"FAILED ({e})\n")
|
print(f"FAILED ({e})\n")
|
||||||
else:
|
else:
|
||||||
reason = "disabled" if not hcfg.enabled else "no API key"
|
reason = "disabled" if not hcfg.enabled else "no API key or base URL"
|
||||||
print(f"\n Not connected ({reason})\n")
|
print(f"\n Not connected ({reason})\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -417,9 +417,18 @@ def get_honcho_client(config: HonchoClientConfig | None = None) -> Honcho:
|
||||||
else:
|
else:
|
||||||
logger.info("Initializing Honcho client (host: %s, workspace: %s)", config.host, config.workspace_id)
|
logger.info("Initializing Honcho client (host: %s, workspace: %s)", config.host, config.workspace_id)
|
||||||
|
|
||||||
|
# Local Honcho instances don't require an API key, but the SDK
|
||||||
|
# expects a non-empty string. Use a placeholder for local URLs.
|
||||||
|
_is_local = resolved_base_url and (
|
||||||
|
"localhost" in resolved_base_url
|
||||||
|
or "127.0.0.1" in resolved_base_url
|
||||||
|
or "::1" in resolved_base_url
|
||||||
|
)
|
||||||
|
effective_api_key = config.api_key or ("local" if _is_local else None)
|
||||||
|
|
||||||
kwargs: dict = {
|
kwargs: dict = {
|
||||||
"workspace_id": config.workspace_id,
|
"workspace_id": config.workspace_id,
|
||||||
"api_key": config.api_key,
|
"api_key": effective_api_key,
|
||||||
"environment": config.environment,
|
"environment": config.environment,
|
||||||
}
|
}
|
||||||
if resolved_base_url:
|
if resolved_base_url:
|
||||||
|
|
|
||||||
14
run_agent.py
14
run_agent.py
|
|
@ -1084,8 +1084,8 @@ class AIAgent:
|
||||||
else:
|
else:
|
||||||
if not hcfg.enabled:
|
if not hcfg.enabled:
|
||||||
logger.debug("Honcho disabled in global config")
|
logger.debug("Honcho disabled in global config")
|
||||||
elif not hcfg.api_key:
|
elif not (hcfg.api_key or hcfg.base_url):
|
||||||
logger.debug("Honcho enabled but no API key configured")
|
logger.debug("Honcho enabled but no API key or base URL configured")
|
||||||
else:
|
else:
|
||||||
logger.debug("Honcho enabled but missing API key or disabled in config")
|
logger.debug("Honcho enabled but missing API key or disabled in config")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -2292,8 +2292,14 @@ class AIAgent:
|
||||||
# ── Honcho integration helpers ──
|
# ── Honcho integration helpers ──
|
||||||
|
|
||||||
def _honcho_should_activate(self, hcfg) -> bool:
|
def _honcho_should_activate(self, hcfg) -> bool:
|
||||||
"""Return True when remote Honcho should be active."""
|
"""Return True when Honcho should be active.
|
||||||
if not hcfg or not hcfg.enabled or not hcfg.api_key:
|
|
||||||
|
Self-hosted Honcho may be configured with a base_url and no API key,
|
||||||
|
so activation should accept either credential style.
|
||||||
|
"""
|
||||||
|
if not hcfg or not hcfg.enabled:
|
||||||
|
return False
|
||||||
|
if not (hcfg.api_key or hcfg.base_url):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue