Files
hermes-agent/tests/tools/test_terminal_sandbox_builder_dispatch.py
Teknium d99af4187b refactor: move the Singularity terminal backend out of core into the singularity catalog plugin
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.
2026-10-22 05:26:10 -07:00

68 lines
1.8 KiB
Python

"""Regression coverage for sandbox backend builder dispatch (#112715)."""
import pytest
from tools import terminal_tool_backends as backends
@pytest.mark.parametrize(
("env_type", "expects_image"),
[
("daytona", True),
("vercel_sandbox", False),
],
)
def test_create_environment_dispatches_each_sandbox_builder_once(
monkeypatch, env_type, expects_image
):
"""The bound backend name must not collide with the generic dispatcher kwarg."""
received = {}
class FakeEnvironment:
def __init__(self, **kwargs):
received.update(kwargs)
monkeypatch.setitem(
backends._SANDBOX_ROWS,
env_type,
(lambda: FakeEnvironment, expects_image, lambda _cc, _kwargs: {}),
)
environment = backends._create_environment(
env_type=env_type,
image="test-image",
cwd="/workspace",
timeout=42,
container_config={},
task_id="test-task",
)
assert isinstance(environment, FakeEnvironment)
assert received["cwd"] == "/workspace"
assert received["timeout"] == 42
assert received["task_id"] == "test-task"
assert ("image" in received) is expects_image
def test_create_environment_keeps_env_type_for_plugin_backends(monkeypatch):
"""Unknown backends still receive their name for plugin provider lookup."""
received = {}
def build_plugin_env(**kwargs):
received.update(kwargs)
return object()
monkeypatch.setattr(backends, "_build_plugin_env", build_plugin_env)
backends._create_environment(
env_type="plugin-sandbox",
image="test-image",
cwd="/workspace",
timeout=42,
container_config={},
task_id="test-task",
)
assert received["env_type"] == "plugin-sandbox"
assert received["image"] == "test-image"