mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
* fix: show correct env var name in provider API key error (#9506) The error message for missing provider API keys dynamically built the env var name as PROVIDER_API_KEY (e.g. ALIBABA_API_KEY), but some providers use different names (alibaba uses DASHSCOPE_API_KEY). Users following the error message set the wrong variable. Fix: look up the actual env var from PROVIDER_REGISTRY before building the error. Falls back to the dynamic name if the registry lookup fails. Closes #9506 * fix: five HERMES_HOME profile-isolation leaks (#5947) Bug A: Thread session_title from session_db to memory provider init kwargs so honcho can derive chat-scoped session keys instead of falling back to cwd-based naming that merges all gateway users into one session. Bug B: Replace 14 hardcoded ~/.hermes/skills/ paths across 10 skill files with HERMES_HOME-aware alternatives (${HERMES_HOME:-$HOME/.hermes} in shell, os.environ.get('HERMES_HOME', ...) in Python). Bug C: install.sh now respects HERMES_HOME env var and adds --hermes-home flag. Previously --dir only set INSTALL_DIR while HERMES_HOME was always hardcoded to $HOME/.hermes. Bug D: Remove hardcoded ~/.hermes/honcho.json fallback in resolve_config_path(). Non-default profiles no longer silently inherit the default profile's honcho config. Falls through to ~/.honcho/config.json (global) instead. Bug E: Guard _edit_skill, _patch_skill, _delete_skill, _write_file, and _remove_file against writing to skills found in external_dirs. Skills outside the local SKILLS_DIR are now read-only from the agent's perspective. Closes #5947
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""
|
|
Loader for G0DM0D3 scripts. Handles the exec-scoping issues.
|
|
|
|
Usage in execute_code:
|
|
exec(open(os.path.expanduser(
|
|
os.path.join(os.environ.get("HERMES_HOME", os.path.expanduser("~/.hermes")), "skills/red-teaming/godmode/scripts/load_godmode.py")
|
|
)).read())
|
|
|
|
# Now all functions are available:
|
|
# - auto_jailbreak(), undo_jailbreak()
|
|
# - race_models(), race_godmode_classic()
|
|
# - generate_variants(), obfuscate_query(), detect_triggers()
|
|
# - score_response(), is_refusal(), count_hedges()
|
|
# - escalate_encoding()
|
|
"""
|
|
|
|
import os, sys
|
|
from pathlib import Path
|
|
|
|
_gm_scripts_dir = Path(os.getenv("HERMES_HOME", Path.home() / ".hermes")) / "skills" / "red-teaming" / "godmode" / "scripts"
|
|
|
|
_gm_old_argv = sys.argv
|
|
sys.argv = ["_godmode_loader"]
|
|
|
|
def _gm_load(path):
|
|
ns = dict(globals())
|
|
ns["__name__"] = "_godmode_module"
|
|
ns["__file__"] = str(path)
|
|
exec(compile(open(path).read(), str(path), 'exec'), ns)
|
|
return ns
|
|
|
|
for _gm_script in ["parseltongue.py", "godmode_race.py", "auto_jailbreak.py"]:
|
|
_gm_path = _gm_scripts_dir / _gm_script
|
|
if _gm_path.exists():
|
|
_gm_ns = _gm_load(_gm_path)
|
|
for _gm_k, _gm_v in _gm_ns.items():
|
|
if not _gm_k.startswith('_gm_') and (callable(_gm_v) or _gm_k.isupper()):
|
|
globals()[_gm_k] = _gm_v
|
|
|
|
sys.argv = _gm_old_argv
|
|
|
|
# Cleanup loader vars
|
|
for _gm_cleanup in ['_gm_scripts_dir', '_gm_old_argv', '_gm_load', '_gm_ns', '_gm_k',
|
|
'_gm_v', '_gm_script', '_gm_path', '_gm_cleanup']:
|
|
globals().pop(_gm_cleanup, None)
|