refactor(config): migrate remaining 33 cfg_get call sites (#17311)
Completes the cfg_get migration started in PR #17304. Covers the remaining hermes_cli/ and plugins/ config-access sites that the first PR intentionally left opportunistic. Migrated (33 sites across 14 files): hermes_cli/setup.py 13 sites (terminal.*, agent.*, display.*, compression.*, tts.*) hermes_cli/tools_config.py 7 sites (tts.*, browser.*, web.*, platform_toolsets.*) hermes_cli/plugins_cmd.py 3 sites (plugins.*, memory.*, context.*) plugins/memory/honcho/cli.py 3 sites (hosts.*) hermes_cli/web_server.py 1 site (dashboard.*) hermes_cli/skills_config.py 1 site (platform_disabled) hermes_cli/plugins.py 1 site (plugins.disabled) hermes_cli/status.py 1 site (terminal.backend) hermes_cli/mcp_config.py 1 site (mcp_servers.*) hermes_cli/webhook.py 1 site (platforms.webhook) plugins/memory/__init__.py 1 site (memory.provider) plugins/memory/hindsight/ 1 site (banks.hermes) plugins/memory/holographic/ 1 site (plugins.hermes-memory-store) run_agent.py 1 site (auxiliary.compression) The helper supports non-literal keys too, so e.g. cfg.get('hosts', {}).get(HOST, {}) becomes cfg_get(cfg, 'hosts', HOST, default={}) Migration bugs caught and fixed during this PR: 1. An AST-based batch rewrite naïvely captured the first word token in a chain, which corrupted 'self._config.get(...).get(...)' into 'self.cfg_get(_config, ...)' (dropping 'self.', creating a broken method call). Plugins/memory/hindsight caught it via its test suite. Fixed manually to 'cfg_get(self._config, ...)'. 2. Import-extension heuristic rewrote multi-line parenthesized imports ('from X import (\n A,\n B,\n)') as 'from X import cfg_get, (' — syntactically broken. Fixed by inserting cfg_get as the first name inside the parentheses. Combined with PR #17304, the cfg_get migration now covers: PR #17304 (first batch): 20 sites in tools/ + gateway/ PR #17317 (this one): 33 sites in hermes_cli/ + plugins/ + run_agent.py Total: 53 sites migrated. Remaining ~8 sites are either: - Function-call chains (e.g. '_load_stt_config().get(...).get(...)') that would need double-evaluation or a local binding to migrate cleanly — intentionally deferred. - JSON response-navigation (e.g. 'response_data.get('data',{}).get('web')) which is unrelated to config access and shouldn't use cfg_get. Verified: - 412/412 tests/plugins/ pass (including the hindsight test that caught the self.X regex bug before commit) - 3181/3189 tests/hermes_cli/ pass (8 pre-existing failures on main, verified by git-stash comparison) - Live 'hermes status' and 'hermes config' render correctly (exercise the migrated terminal.backend, tts.provider, browser.cloud_provider, compression.threshold, display.tool_progress sites) - Live 'hermes chat': 1 turn + /quit, zero errors in 11-line log window No semantic changes — cfg_get was already proven to be a 1:1 match for the original .get("X",{}).get("Y",default) pattern in PR #17304.
This commit is contained in:
@@ -16,6 +16,7 @@ import time
|
|||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
from hermes_cli.config import (
|
from hermes_cli.config import (
|
||||||
|
cfg_get,
|
||||||
load_config,
|
load_config,
|
||||||
save_config,
|
save_config,
|
||||||
get_env_value,
|
get_env_value,
|
||||||
@@ -716,7 +717,7 @@ def cmd_mcp_configure(args):
|
|||||||
|
|
||||||
# Update config
|
# Update config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
server_entry = config.get("mcp_servers", {}).get(name, {})
|
server_entry = cfg_get(config, "mcp_servers", name, default={})
|
||||||
|
|
||||||
if len(chosen) == total:
|
if len(chosen) == total:
|
||||||
# All selected → remove include/exclude (register all)
|
# All selected → remove include/exclude (register all)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ from typing import Any, Callable, Dict, List, Optional, Set, Union
|
|||||||
|
|
||||||
from hermes_constants import get_hermes_home
|
from hermes_constants import get_hermes_home
|
||||||
from utils import env_var_enabled
|
from utils import env_var_enabled
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
@@ -115,7 +116,7 @@ def _get_disabled_plugins() -> set:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
disabled = config.get("plugins", {}).get("disabled", [])
|
disabled = cfg_get(config, "plugins", "disabled", default=[])
|
||||||
return set(disabled) if isinstance(disabled, list) else set()
|
return set(disabled) if isinstance(disabled, list) else set()
|
||||||
except Exception:
|
except Exception:
|
||||||
return set()
|
return set()
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from pathlib import Path
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from hermes_constants import get_hermes_home
|
from hermes_constants import get_hermes_home
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -519,7 +520,7 @@ def _get_disabled_set() -> set:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
disabled = config.get("plugins", {}).get("disabled", [])
|
disabled = cfg_get(config, "plugins", "disabled", default=[])
|
||||||
return set(disabled) if isinstance(disabled, list) else set()
|
return set(disabled) if isinstance(disabled, list) else set()
|
||||||
except Exception:
|
except Exception:
|
||||||
return set()
|
return set()
|
||||||
@@ -763,7 +764,7 @@ def _get_current_memory_provider() -> str:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
return config.get("memory", {}).get("provider", "") or ""
|
return cfg_get(config, "memory", "provider", default="") or ""
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@@ -773,7 +774,7 @@ def _get_current_context_engine() -> str:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
return config.get("context", {}).get("engine", "compressor") or "compressor"
|
return cfg_get(config, "context", "engine", default="compressor") or "compressor"
|
||||||
except Exception:
|
except Exception:
|
||||||
return "compressor"
|
return "compressor"
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ def _set_reasoning_effort(config: Dict[str, Any], effort: str) -> None:
|
|||||||
|
|
||||||
# Import config helpers
|
# Import config helpers
|
||||||
from hermes_cli.config import (
|
from hermes_cli.config import (
|
||||||
|
cfg_get,
|
||||||
DEFAULT_CONFIG,
|
DEFAULT_CONFIG,
|
||||||
get_hermes_home,
|
get_hermes_home,
|
||||||
get_config_path,
|
get_config_path,
|
||||||
@@ -441,7 +442,7 @@ def _print_setup_summary(config: dict, hermes_home):
|
|||||||
tool_status.append(("Image Generation", False, "FAL_KEY or OPENAI_API_KEY"))
|
tool_status.append(("Image Generation", False, "FAL_KEY or OPENAI_API_KEY"))
|
||||||
|
|
||||||
# TTS — show configured provider
|
# TTS — show configured provider
|
||||||
tts_provider = config.get("tts", {}).get("provider", "edge")
|
tts_provider = cfg_get(config, "tts", "provider", default="edge")
|
||||||
if subscription_features.tts.managed_by_nous:
|
if subscription_features.tts.managed_by_nous:
|
||||||
tool_status.append(("Text-to-Speech (OpenAI via Nous subscription)", True, None))
|
tool_status.append(("Text-to-Speech (OpenAI via Nous subscription)", True, None))
|
||||||
elif tts_provider == "elevenlabs" and get_env_value("ELEVENLABS_API_KEY"):
|
elif tts_provider == "elevenlabs" and get_env_value("ELEVENLABS_API_KEY"):
|
||||||
@@ -480,7 +481,7 @@ def _print_setup_summary(config: dict, hermes_home):
|
|||||||
|
|
||||||
if subscription_features.modal.managed_by_nous:
|
if subscription_features.modal.managed_by_nous:
|
||||||
tool_status.append(("Modal Execution (Nous subscription)", True, None))
|
tool_status.append(("Modal Execution (Nous subscription)", True, None))
|
||||||
elif config.get("terminal", {}).get("backend") == "modal":
|
elif cfg_get(config, "terminal", "backend") == "modal":
|
||||||
if subscription_features.modal.direct_override:
|
if subscription_features.modal.direct_override:
|
||||||
tool_status.append(("Modal Execution (direct Modal)", True, None))
|
tool_status.append(("Modal Execution (direct Modal)", True, None))
|
||||||
else:
|
else:
|
||||||
@@ -1179,7 +1180,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
print_info(f" Guide: {_DOCS_BASE}/developer-guide/environments")
|
print_info(f" Guide: {_DOCS_BASE}/developer-guide/environments")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
current_backend = config.get("terminal", {}).get("backend", "local")
|
current_backend = cfg_get(config, "terminal", "backend", default="local")
|
||||||
is_linux = _platform.system() == "Linux"
|
is_linux = _platform.system() == "Linux"
|
||||||
|
|
||||||
# Build backend choices with descriptions
|
# Build backend choices with descriptions
|
||||||
@@ -1228,7 +1229,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
print_info(
|
print_info(
|
||||||
" the agent starts. CLI mode always starts in the current directory."
|
" the agent starts. CLI mode always starts in the current directory."
|
||||||
)
|
)
|
||||||
current_cwd = config.get("terminal", {}).get("cwd", "")
|
current_cwd = cfg_get(config, "terminal", "cwd", default="")
|
||||||
cwd = prompt(" Messaging working directory", current_cwd or str(Path.home()))
|
cwd = prompt(" Messaging working directory", current_cwd or str(Path.home()))
|
||||||
if cwd:
|
if cwd:
|
||||||
config["terminal"]["cwd"] = cwd
|
config["terminal"]["cwd"] = cwd
|
||||||
@@ -1259,9 +1260,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
print_info(f"Docker found: {docker_bin}")
|
print_info(f"Docker found: {docker_bin}")
|
||||||
|
|
||||||
# Docker image
|
# Docker image
|
||||||
current_image = config.get("terminal", {}).get(
|
current_image = cfg_get(config, "terminal", "docker_image", default="nikolaik/python-nodejs:python3.11-nodejs20")
|
||||||
"docker_image", "nikolaik/python-nodejs:python3.11-nodejs20"
|
|
||||||
)
|
|
||||||
image = prompt(" Docker image", current_image)
|
image = prompt(" Docker image", current_image)
|
||||||
config["terminal"]["docker_image"] = image
|
config["terminal"]["docker_image"] = image
|
||||||
save_env_value("TERMINAL_DOCKER_IMAGE", image)
|
save_env_value("TERMINAL_DOCKER_IMAGE", image)
|
||||||
@@ -1281,9 +1280,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
else:
|
else:
|
||||||
print_info(f"Found: {sing_bin}")
|
print_info(f"Found: {sing_bin}")
|
||||||
|
|
||||||
current_image = config.get("terminal", {}).get(
|
current_image = cfg_get(config, "terminal", "singularity_image", default="docker://nikolaik/python-nodejs:python3.11-nodejs20")
|
||||||
"singularity_image", "docker://nikolaik/python-nodejs:python3.11-nodejs20"
|
|
||||||
)
|
|
||||||
image = prompt(" Container image", current_image)
|
image = prompt(" Container image", current_image)
|
||||||
config["terminal"]["singularity_image"] = image
|
config["terminal"]["singularity_image"] = image
|
||||||
save_env_value("TERMINAL_SINGULARITY_IMAGE", image)
|
save_env_value("TERMINAL_SINGULARITY_IMAGE", image)
|
||||||
@@ -1302,7 +1299,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
get_nous_subscription_features(config).nous_auth_present
|
get_nous_subscription_features(config).nous_auth_present
|
||||||
and is_managed_tool_gateway_ready("modal")
|
and is_managed_tool_gateway_ready("modal")
|
||||||
)
|
)
|
||||||
modal_mode = normalize_modal_mode(config.get("terminal", {}).get("modal_mode"))
|
modal_mode = normalize_modal_mode(cfg_get(config, "terminal", "modal_mode"))
|
||||||
use_managed_modal = False
|
use_managed_modal = False
|
||||||
if managed_modal_available:
|
if managed_modal_available:
|
||||||
modal_choices = [
|
modal_choices = [
|
||||||
@@ -1439,9 +1436,7 @@ def setup_terminal_backend(config: dict):
|
|||||||
print_success(" Configured")
|
print_success(" Configured")
|
||||||
|
|
||||||
# Daytona image
|
# Daytona image
|
||||||
current_image = config.get("terminal", {}).get(
|
current_image = cfg_get(config, "terminal", "daytona_image", default="nikolaik/python-nodejs:python3.11-nodejs20")
|
||||||
"daytona_image", "nikolaik/python-nodejs:python3.11-nodejs20"
|
|
||||||
)
|
|
||||||
image = prompt(" Sandbox image", current_image)
|
image = prompt(" Sandbox image", current_image)
|
||||||
config["terminal"]["daytona_image"] = image
|
config["terminal"]["daytona_image"] = image
|
||||||
save_env_value("TERMINAL_DAYTONA_IMAGE", image)
|
save_env_value("TERMINAL_DAYTONA_IMAGE", image)
|
||||||
@@ -1545,7 +1540,7 @@ def setup_agent_settings(config: dict):
|
|||||||
|
|
||||||
# ── Max Iterations ──
|
# ── Max Iterations ──
|
||||||
current_max = get_env_value("HERMES_MAX_ITERATIONS") or str(
|
current_max = get_env_value("HERMES_MAX_ITERATIONS") or str(
|
||||||
config.get("agent", {}).get("max_turns", 90)
|
cfg_get(config, "agent", "max_turns", default=90)
|
||||||
)
|
)
|
||||||
print_info("Maximum tool-calling iterations per conversation.")
|
print_info("Maximum tool-calling iterations per conversation.")
|
||||||
print_info("Higher = more complex tasks, but costs more tokens.")
|
print_info("Higher = more complex tasks, but costs more tokens.")
|
||||||
@@ -1573,7 +1568,7 @@ def setup_agent_settings(config: dict):
|
|||||||
print_info(" all — Show every tool call with a short preview")
|
print_info(" all — Show every tool call with a short preview")
|
||||||
print_info(" verbose — Full args, results, and debug logs")
|
print_info(" verbose — Full args, results, and debug logs")
|
||||||
|
|
||||||
current_mode = config.get("display", {}).get("tool_progress", "all")
|
current_mode = cfg_get(config, "display", "tool_progress", default="all")
|
||||||
mode = prompt("Tool progress mode", current_mode)
|
mode = prompt("Tool progress mode", current_mode)
|
||||||
if mode.lower() in ("off", "new", "all", "verbose"):
|
if mode.lower() in ("off", "new", "all", "verbose"):
|
||||||
if "display" not in config:
|
if "display" not in config:
|
||||||
@@ -1593,7 +1588,7 @@ def setup_agent_settings(config: dict):
|
|||||||
|
|
||||||
config.setdefault("compression", {})["enabled"] = True
|
config.setdefault("compression", {})["enabled"] = True
|
||||||
|
|
||||||
current_threshold = config.get("compression", {}).get("threshold", 0.50)
|
current_threshold = cfg_get(config, "compression", "threshold", default=0.50)
|
||||||
threshold_str = prompt("Compression threshold (0.5-0.95)", str(current_threshold))
|
threshold_str = prompt("Compression threshold (0.5-0.95)", str(current_threshold))
|
||||||
try:
|
try:
|
||||||
threshold = float(threshold_str)
|
threshold = float(threshold_str)
|
||||||
@@ -2601,11 +2596,11 @@ def _get_section_config_summary(config: dict, section_key: str) -> Optional[str]
|
|||||||
return "configured"
|
return "configured"
|
||||||
|
|
||||||
elif section_key == "terminal":
|
elif section_key == "terminal":
|
||||||
backend = config.get("terminal", {}).get("backend", "local")
|
backend = cfg_get(config, "terminal", "backend", default="local")
|
||||||
return f"backend: {backend}"
|
return f"backend: {backend}"
|
||||||
|
|
||||||
elif section_key == "agent":
|
elif section_key == "agent":
|
||||||
max_turns = config.get("agent", {}).get("max_turns", 90)
|
max_turns = cfg_get(config, "agent", "max_turns", default=90)
|
||||||
return f"max turns: {max_turns}"
|
return f"max turns: {max_turns}"
|
||||||
|
|
||||||
elif section_key == "gateway":
|
elif section_key == "gateway":
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Config stored in ~/.hermes/config.yaml under:
|
|||||||
"""
|
"""
|
||||||
from typing import List, Optional, Set
|
from typing import List, Optional, Set
|
||||||
|
|
||||||
from hermes_cli.config import load_config, save_config
|
from hermes_cli.config import cfg_get, load_config, save_config
|
||||||
from hermes_cli.colors import Colors, color
|
from hermes_cli.colors import Colors, color
|
||||||
from hermes_cli.platforms import PLATFORMS as _PLATFORMS
|
from hermes_cli.platforms import PLATFORMS as _PLATFORMS
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ def get_disabled_skills(config: dict, platform: Optional[str] = None) -> Set[str
|
|||||||
global_disabled = set(skills_cfg.get("disabled", []))
|
global_disabled = set(skills_cfg.get("disabled", []))
|
||||||
if platform is None:
|
if platform is None:
|
||||||
return global_disabled
|
return global_disabled
|
||||||
platform_disabled = skills_cfg.get("platform_disabled", {}).get(platform)
|
platform_disabled = cfg_get(skills_cfg, "platform_disabled", platform)
|
||||||
if platform_disabled is None:
|
if platform_disabled is None:
|
||||||
return global_disabled
|
return global_disabled
|
||||||
return set(platform_disabled)
|
return set(platform_disabled)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PROJECT_ROOT = Path(__file__).parent.parent.resolve()
|
|||||||
|
|
||||||
from hermes_cli.auth import AuthError, resolve_provider
|
from hermes_cli.auth import AuthError, resolve_provider
|
||||||
from hermes_cli.colors import Colors, color
|
from hermes_cli.colors import Colors, color
|
||||||
from hermes_cli.config import get_env_path, get_env_value, get_hermes_home, load_config
|
from hermes_cli.config import cfg_get, get_env_path, get_env_value, get_hermes_home, load_config
|
||||||
from hermes_cli.models import provider_label
|
from hermes_cli.models import provider_label
|
||||||
from hermes_cli.nous_subscription import get_nous_subscription_features
|
from hermes_cli.nous_subscription import get_nous_subscription_features
|
||||||
from hermes_cli.runtime_provider import resolve_requested_provider
|
from hermes_cli.runtime_provider import resolve_requested_provider
|
||||||
@@ -306,7 +306,7 @@ def show_status(args):
|
|||||||
# (hermes status doesn't go through cli.py's config loading)
|
# (hermes status doesn't go through cli.py's config loading)
|
||||||
try:
|
try:
|
||||||
_cfg = load_config()
|
_cfg = load_config()
|
||||||
terminal_env = _cfg.get("terminal", {}).get("backend", "local")
|
terminal_env = cfg_get(_cfg, "terminal", "backend", default="local")
|
||||||
except Exception:
|
except Exception:
|
||||||
terminal_env = "local"
|
terminal_env = "local"
|
||||||
print(f" Backend: {terminal_env}")
|
print(f" Backend: {terminal_env}")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from typing import Dict, List, Optional, Set
|
|||||||
|
|
||||||
|
|
||||||
from hermes_cli.config import (
|
from hermes_cli.config import (
|
||||||
|
cfg_get,
|
||||||
load_config, save_config, get_env_value, save_env_value,
|
load_config, save_config, get_env_value, save_env_value,
|
||||||
)
|
)
|
||||||
from hermes_cli.colors import Colors, color
|
from hermes_cli.colors import Colors, color
|
||||||
@@ -965,7 +966,7 @@ def _save_platform_tools(config: dict, platform: str, enabled_toolset_keys: Set[
|
|||||||
platform_default_keys = {p["default_toolset"] for p in PLATFORMS.values()}
|
platform_default_keys = {p["default_toolset"] for p in PLATFORMS.values()}
|
||||||
|
|
||||||
# Get existing toolsets for this platform
|
# Get existing toolsets for this platform
|
||||||
existing_toolsets = config.get("platform_toolsets", {}).get(platform, [])
|
existing_toolsets = cfg_get(config, "platform_toolsets", platform, default=[])
|
||||||
if not isinstance(existing_toolsets, list):
|
if not isinstance(existing_toolsets, list):
|
||||||
existing_toolsets = []
|
existing_toolsets = []
|
||||||
existing_toolsets = [str(ts) for ts in existing_toolsets]
|
existing_toolsets = [str(ts) for ts in existing_toolsets]
|
||||||
@@ -1352,23 +1353,23 @@ def _is_provider_active(provider: dict, config: dict) -> bool:
|
|||||||
if provider.get("tts_provider"):
|
if provider.get("tts_provider"):
|
||||||
return (
|
return (
|
||||||
feature.managed_by_nous
|
feature.managed_by_nous
|
||||||
and config.get("tts", {}).get("provider") == provider["tts_provider"]
|
and cfg_get(config, "tts", "provider") == provider["tts_provider"]
|
||||||
)
|
)
|
||||||
if "browser_provider" in provider:
|
if "browser_provider" in provider:
|
||||||
current = config.get("browser", {}).get("cloud_provider")
|
current = cfg_get(config, "browser", "cloud_provider")
|
||||||
return feature.managed_by_nous and provider["browser_provider"] == current
|
return feature.managed_by_nous and provider["browser_provider"] == current
|
||||||
if provider.get("web_backend"):
|
if provider.get("web_backend"):
|
||||||
current = config.get("web", {}).get("backend")
|
current = cfg_get(config, "web", "backend")
|
||||||
return feature.managed_by_nous and current == provider["web_backend"]
|
return feature.managed_by_nous and current == provider["web_backend"]
|
||||||
return feature.managed_by_nous
|
return feature.managed_by_nous
|
||||||
|
|
||||||
if provider.get("tts_provider"):
|
if provider.get("tts_provider"):
|
||||||
return config.get("tts", {}).get("provider") == provider["tts_provider"]
|
return cfg_get(config, "tts", "provider") == provider["tts_provider"]
|
||||||
if "browser_provider" in provider:
|
if "browser_provider" in provider:
|
||||||
current = config.get("browser", {}).get("cloud_provider")
|
current = cfg_get(config, "browser", "cloud_provider")
|
||||||
return provider["browser_provider"] == current
|
return provider["browser_provider"] == current
|
||||||
if provider.get("web_backend"):
|
if provider.get("web_backend"):
|
||||||
current = config.get("web", {}).get("backend")
|
current = cfg_get(config, "web", "backend")
|
||||||
return current == provider["web_backend"]
|
return current == provider["web_backend"]
|
||||||
if provider.get("imagegen_backend"):
|
if provider.get("imagegen_backend"):
|
||||||
image_cfg = config.get("image_gen", {})
|
image_cfg = config.get("image_gen", {})
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ if str(PROJECT_ROOT) not in sys.path:
|
|||||||
|
|
||||||
from hermes_cli import __version__, __release_date__
|
from hermes_cli import __version__, __release_date__
|
||||||
from hermes_cli.config import (
|
from hermes_cli.config import (
|
||||||
|
cfg_get,
|
||||||
DEFAULT_CONFIG,
|
DEFAULT_CONFIG,
|
||||||
OPTIONAL_ENV_VARS,
|
OPTIONAL_ENV_VARS,
|
||||||
get_config_path,
|
get_config_path,
|
||||||
@@ -2902,7 +2903,7 @@ async def get_dashboard_themes():
|
|||||||
them without a stub.
|
them without a stub.
|
||||||
"""
|
"""
|
||||||
config = load_config()
|
config = load_config()
|
||||||
active = config.get("dashboard", {}).get("theme", "default")
|
active = cfg_get(config, "dashboard", "theme", default="default")
|
||||||
user_themes = _discover_user_themes()
|
user_themes = _discover_user_themes()
|
||||||
seen = set()
|
seen = set()
|
||||||
themes = []
|
themes = []
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from typing import Dict
|
|||||||
|
|
||||||
from hermes_constants import display_hermes_home
|
from hermes_constants import display_hermes_home
|
||||||
from utils import atomic_replace
|
from utils import atomic_replace
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
|
|
||||||
_SUBSCRIPTIONS_FILENAME = "webhook_subscriptions.json"
|
_SUBSCRIPTIONS_FILENAME = "webhook_subscriptions.json"
|
||||||
@@ -60,7 +61,7 @@ def _get_webhook_config() -> dict:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
return cfg.get("platforms", {}).get("webhook", {})
|
return cfg_get(cfg, "platforms", "webhook", default={})
|
||||||
except Exception:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -314,7 +315,7 @@ def _get_active_memory_provider() -> Optional[str]:
|
|||||||
try:
|
try:
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
config = load_config()
|
config = load_config()
|
||||||
return config.get("memory", {}).get("provider") or None
|
return cfg_get(config, "memory", "provider") or None
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ from typing import Any, Dict, List
|
|||||||
from agent.memory_provider import MemoryProvider
|
from agent.memory_provider import MemoryProvider
|
||||||
from hermes_constants import get_hermes_home
|
from hermes_constants import get_hermes_home
|
||||||
from tools.registry import tool_error
|
from tools.registry import tool_error
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -913,7 +914,7 @@ class HindsightMemoryProvider(MemoryProvider):
|
|||||||
self._api_url = self._config.get("api_url") or os.environ.get("HINDSIGHT_API_URL", default_url)
|
self._api_url = self._config.get("api_url") or os.environ.get("HINDSIGHT_API_URL", default_url)
|
||||||
self._llm_base_url = self._config.get("llm_base_url", "")
|
self._llm_base_url = self._config.get("llm_base_url", "")
|
||||||
|
|
||||||
banks = self._config.get("banks", {}).get("hermes", {})
|
banks = cfg_get(self._config, "banks", "hermes", default={})
|
||||||
static_bank_id = self._config.get("bank_id") or banks.get("bankId", "hermes")
|
static_bank_id = self._config.get("bank_id") or banks.get("bankId", "hermes")
|
||||||
self._bank_id_template = self._config.get("bank_id_template", "") or ""
|
self._bank_id_template = self._config.get("bank_id_template", "") or ""
|
||||||
self._bank_id = _resolve_bank_id_template(
|
self._bank_id = _resolve_bank_id_template(
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ from agent.memory_provider import MemoryProvider
|
|||||||
from tools.registry import tool_error
|
from tools.registry import tool_error
|
||||||
from .store import MemoryStore
|
from .store import MemoryStore
|
||||||
from .retrieval import FactRetriever
|
from .retrieval import FactRetriever
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -102,7 +103,7 @@ def _load_plugin_config() -> dict:
|
|||||||
import yaml
|
import yaml
|
||||||
with open(config_path) as f:
|
with open(config_path) as f:
|
||||||
all_config = yaml.safe_load(f) or {}
|
all_config = yaml.safe_load(f) or {}
|
||||||
return all_config.get("plugins", {}).get("hermes-memory-store", {}) or {}
|
return cfg_get(all_config, "plugins", "hermes-memory-store", default={}) or {}
|
||||||
except Exception:
|
except Exception:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from hermes_constants import get_hermes_home
|
from hermes_constants import get_hermes_home
|
||||||
from plugins.memory.honcho.client import resolve_active_host, resolve_config_path, HOST
|
from plugins.memory.honcho.client import resolve_active_host, resolve_config_path, HOST
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
|
|
||||||
def clone_honcho_for_profile(profile_name: str) -> bool:
|
def clone_honcho_for_profile(profile_name: str) -> bool:
|
||||||
@@ -106,7 +107,7 @@ def cmd_enable(args) -> None:
|
|||||||
|
|
||||||
# If this is a new profile host block with no settings, clone from default
|
# If this is a new profile host block with no settings, clone from default
|
||||||
if not block.get("aiPeer"):
|
if not block.get("aiPeer"):
|
||||||
default_block = cfg.get("hosts", {}).get(HOST, {})
|
default_block = cfg_get(cfg, "hosts", HOST, default={})
|
||||||
for key in ("recallMode", "writeFrequency", "sessionStrategy",
|
for key in ("recallMode", "writeFrequency", "sessionStrategy",
|
||||||
"contextTokens", "dialecticReasoningLevel", "dialecticDynamic",
|
"contextTokens", "dialecticReasoningLevel", "dialecticDynamic",
|
||||||
"dialecticMaxChars", "messageMaxChars", "dialecticMaxInputChars",
|
"dialecticMaxChars", "messageMaxChars", "dialecticMaxInputChars",
|
||||||
@@ -139,7 +140,7 @@ def cmd_disable(args) -> None:
|
|||||||
cfg = _read_config()
|
cfg = _read_config()
|
||||||
host = _host_key()
|
host = _host_key()
|
||||||
label = f"[{host}] " if host != "hermes" else ""
|
label = f"[{host}] " if host != "hermes" else ""
|
||||||
block = cfg.get("hosts", {}).get(host, {})
|
block = cfg_get(cfg, "hosts", host, default={})
|
||||||
|
|
||||||
if not block or block.get("enabled") is False:
|
if not block or block.get("enabled") is False:
|
||||||
print(f" {label}Honcho is already disabled.\n")
|
print(f" {label}Honcho is already disabled.\n")
|
||||||
@@ -212,7 +213,7 @@ def sync_honcho_profiles_quiet() -> int:
|
|||||||
if not cfg:
|
if not cfg:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
default_block = cfg.get("hosts", {}).get(HOST, {})
|
default_block = cfg_get(cfg, "hosts", HOST, default={})
|
||||||
has_key = bool(cfg.get("apiKey") or os.environ.get("HONCHO_API_KEY"))
|
has_key = bool(cfg.get("apiKey") or os.environ.get("HONCHO_API_KEY"))
|
||||||
if not default_block and not has_key:
|
if not default_block and not has_key:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ from agent.trajectory import (
|
|||||||
save_trajectory as _save_trajectory_to_file,
|
save_trajectory as _save_trajectory_to_file,
|
||||||
)
|
)
|
||||||
from utils import atomic_json_write, base_url_host_matches, base_url_hostname, env_var_enabled, normalize_proxy_url
|
from utils import atomic_json_write, base_url_host_matches, base_url_hostname, env_var_enabled, normalize_proxy_url
|
||||||
|
from hermes_cli.config import cfg_get
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1788,7 +1789,7 @@ class AIAgent:
|
|||||||
# compression model. Custom endpoints often cannot report this via
|
# compression model. Custom endpoints often cannot report this via
|
||||||
# /models, so the startup feasibility check needs the config hint.
|
# /models, so the startup feasibility check needs the config hint.
|
||||||
try:
|
try:
|
||||||
_aux_cfg = _agent_cfg.get("auxiliary", {}).get("compression", {})
|
_aux_cfg = cfg_get(_agent_cfg, "auxiliary", "compression", default={})
|
||||||
except Exception:
|
except Exception:
|
||||||
_aux_cfg = {}
|
_aux_cfg = {}
|
||||||
if isinstance(_aux_cfg, dict):
|
if isinstance(_aux_cfg, dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user