The Singularity/Apptainer backend (tools/environments/singularity.py) now ships as the official 'singularity' plugin in NousResearch/hermes-official-plugins, registered through the terminal-environment provider seam under the same backend name and config keys (terminal.backend: singularity, terminal.singularity_image / TERMINAL_SINGULARITY_IMAGE, terminal.container_*). - 'singularity' leaves BUILTIN_BACKEND_NAMES so the plugin can register it; every hardcoded classification set drops it (the provider declares is_remote/is_container/supports_streams instead). - LEFT_CORE gains a singularity row: homes whose terminal.backend (or .env TERMINAL_ENV) is singularity get the catalog plugin once, on hermes update or agent/gateway start. An unknown-backend error for 'singularity' names the install command (new row field terminal_backend). - A plugin backend receives its per-task '<backend>_image' override; batch runs register one for the active backend. - BaseEnvironment's sudo-probe knob is renamed _passwordless_sudo_probe_supported: plugin backends set it, and the old spelling trips the install scanner. - Core's scratch-dir disk warning and process-exit sweep were Singularity-only and move to the plugin; the singularity setup row, dashboard probe/row and config defaults/bridges go too. Docs point at the plugin.
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Tests for _parse_env_var and _get_env_config env-var validation."""
|
|
|
|
import importlib
|
|
from unittest.mock import patch
|
|
|
|
|
|
import sys
|
|
import tools.terminal_tool
|
|
_tt_mod = sys.modules["tools.terminal_tool"]
|
|
from tools.terminal_tool import _parse_env_var
|
|
|
|
|
|
class TestParseEnvVar:
|
|
"""Unit tests for _parse_env_var."""
|
|
|
|
# -- valid values work normally --
|
|
|
|
def test_valid_int(self):
|
|
with patch.dict("os.environ", {"TERMINAL_TIMEOUT": "300"}):
|
|
assert _parse_env_var("TERMINAL_TIMEOUT", "180") == 300
|
|
|
|
|
|
def test_get_env_config_parses_docker_forward_env_json(self):
|
|
with patch.dict("os.environ", {
|
|
"TERMINAL_ENV": "docker",
|
|
"TERMINAL_DOCKER_FORWARD_ENV": '["GITHUB_TOKEN", "NPM_TOKEN"]',
|
|
}, clear=False):
|
|
config = _tt_mod._get_env_config()
|
|
assert config["docker_forward_env"] == ["GITHUB_TOKEN", "NPM_TOKEN"]
|
|
|
|
|
|
# -- invalid int raises ValueError with env var name --
|
|
|
|
|
|
# -- invalid JSON raises ValueError with env var name --
|
|
|
|
|
|
|
|
|
|
class TestImportTimeEnvParsing:
|
|
"""Module-level env parsing should never make terminal_tool unimportable."""
|
|
|
|
def test_invalid_foreground_timeout_falls_back_to_default(self):
|
|
default = importlib.reload(_tt_mod).FOREGROUND_MAX_TIMEOUT
|
|
try:
|
|
with patch.dict("os.environ", {"TERMINAL_MAX_FOREGROUND_TIMEOUT": "5m"}, clear=False):
|
|
mod = importlib.reload(_tt_mod)
|
|
assert mod.FOREGROUND_MAX_TIMEOUT == default
|
|
finally:
|
|
importlib.reload(_tt_mod)
|