feat: integrate config.yaml values into environment for enhanced flexibility

- Added functionality to load values from config.yaml into the environment, allowing os.getenv() to access them.
- Ensured that existing environment variables take precedence over config values.
- Updated DiscordAdapter to resolve usernames in DISCORD_ALLOWED_USERS to numeric IDs, improving user authorization checks.
- Enhanced event handling to provide clearer logging and ensure proper synchronization of slash commands.
This commit is contained in:
teknium1 2026-02-22 17:35:45 -08:00
parent e0ed44388f
commit 92447141d9
2 changed files with 92 additions and 7 deletions

View file

@ -36,6 +36,20 @@ if _env_path.exists():
# Also try project .env as fallback
load_dotenv()
# Bridge config.yaml values into the environment so os.getenv() picks them up.
# Values already set in the environment (from .env or shell) take precedence.
_config_path = Path.home() / '.hermes' / 'config.yaml'
if _config_path.exists():
try:
import yaml as _yaml
with open(_config_path) as _f:
_cfg = _yaml.safe_load(_f) or {}
for _key, _val in _cfg.items():
if isinstance(_val, (str, int, float, bool)) and _key not in os.environ:
os.environ[_key] = str(_val)
except Exception:
pass # Non-fatal; gateway can still run with .env values
# Gateway runs in quiet mode - suppress debug output and use cwd directly (no temp dirs)
os.environ["HERMES_QUIET"] = "1"