From 0a231c078364b454fc096ff952e298ddddc53db1 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Thu, 26 Feb 2026 20:02:46 -0800 Subject: [PATCH] feat(config): synchronize terminal settings with environment variables - Added functionality to keep the .env file in sync with terminal configuration settings in config.yaml, ensuring terminal_tool can directly access necessary environment variables. - Updated setup wizard to save selected backend and associated Docker image to .env for improved consistency and usability. --- hermes_cli/config.py | 13 +++++++++++++ hermes_cli/setup.py | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index 0b2868fa..eabbcc30 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -815,6 +815,19 @@ def set_config_value(key: str, value: str): with open(config_path, 'w') as f: yaml.dump(user_config, f, default_flow_style=False, sort_keys=False) + # Keep .env in sync for keys that terminal_tool reads directly from env vars. + # config.yaml is authoritative, but terminal_tool only reads TERMINAL_ENV etc. + _config_to_env_sync = { + "terminal.backend": "TERMINAL_ENV", + "terminal.docker_image": "TERMINAL_DOCKER_IMAGE", + "terminal.singularity_image": "TERMINAL_SINGULARITY_IMAGE", + "terminal.modal_image": "TERMINAL_MODAL_IMAGE", + "terminal.cwd": "TERMINAL_CWD", + "terminal.timeout": "TERMINAL_TIMEOUT", + } + if key in _config_to_env_sync: + save_env_value(_config_to_env_sync[key], str(value)) + print(f"✓ Set {key} = {value} in {config_path}") diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index 06022681..8b725b72 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -1015,6 +1015,14 @@ def run_setup_wizard(args): print_success("Terminal set to SSH") # else: Keep current (selected_backend is None) + # Sync terminal backend to .env so terminal_tool picks it up directly. + # config.yaml is the source of truth, but terminal_tool reads TERMINAL_ENV. + if selected_backend: + save_env_value("TERMINAL_ENV", selected_backend) + docker_image = config.get('terminal', {}).get('docker_image') + if docker_image: + save_env_value("TERMINAL_DOCKER_IMAGE", docker_image) + # ========================================================================= # Step 5: Agent Settings # =========================================================================