diff --git a/cli.py b/cli.py index 6c44ef61b..05ed260df 100755 --- a/cli.py +++ b/cli.py @@ -297,6 +297,7 @@ def load_cli_config() -> Dict[str, Any]: "container_disk": "TERMINAL_CONTAINER_DISK", "container_persistent": "TERMINAL_CONTAINER_PERSISTENT", "docker_volumes": "TERMINAL_DOCKER_VOLUMES", + "sandbox_dir": "TERMINAL_SANDBOX_DIR", # Sudo support (works with all backends) "sudo_password": "SUDO_PASSWORD", } diff --git a/gateway/run.py b/gateway/run.py index 8a89e0fbe..e4e56936d 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -75,6 +75,7 @@ if _config_path.exists(): "container_memory": "TERMINAL_CONTAINER_MEMORY", "container_disk": "TERMINAL_CONTAINER_DISK", "container_persistent": "TERMINAL_CONTAINER_PERSISTENT", + "sandbox_dir": "TERMINAL_SANDBOX_DIR", } for _cfg_key, _env_var in _terminal_env_map.items(): if _cfg_key in _terminal_cfg: @@ -107,11 +108,13 @@ os.environ["HERMES_QUIET"] = "1" # Enable interactive exec approval for dangerous commands on messaging platforms os.environ["HERMES_EXEC_ASK"] = "1" -# Set terminal working directory for messaging platforms -# Uses MESSAGING_CWD if set, otherwise defaults to home directory -# This is separate from CLI which uses the directory where `hermes` is run -messaging_cwd = os.getenv("MESSAGING_CWD") or str(Path.home()) -os.environ["TERMINAL_CWD"] = messaging_cwd +# Set terminal working directory for messaging platforms. +# If the user set an explicit path in config.yaml (not "." or "auto"), +# respect it. Otherwise use MESSAGING_CWD or default to home directory. +_configured_cwd = os.environ.get("TERMINAL_CWD", "") +if not _configured_cwd or _configured_cwd in (".", "auto", "cwd"): + messaging_cwd = os.getenv("MESSAGING_CWD") or str(Path.home()) + os.environ["TERMINAL_CWD"] = messaging_cwd from gateway.config import ( Platform, diff --git a/hermes_cli/config.py b/hermes_cli/config.py index 6724c1d7d..67b02b992 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -1004,6 +1004,7 @@ def set_config_value(key: str, value: str): "terminal.daytona_image": "TERMINAL_DAYTONA_IMAGE", "terminal.cwd": "TERMINAL_CWD", "terminal.timeout": "TERMINAL_TIMEOUT", + "terminal.sandbox_dir": "TERMINAL_SANDBOX_DIR", } if key in _config_to_env_sync: save_env_value(_config_to_env_sync[key], str(value))