Skip to content

The agent that grows with you

fix(pm): keep platform detection out of bootstrap imports

ethernet093c45325c80
diff --git a/apps/desktop/electron/fixtures/source-backend.py b/apps/desktop/electron/fixtures/source-backend.py
index dec6e16fcf1..77c2f6727a8 100644
--- a/apps/desktop/electron/fixtures/source-backend.py
+++ b/apps/desktop/electron/fixtures/source-backend.py
@@ -22,7 +22,9 @@ def main() -> None:
temp = Path(sys.argv[1])
root = Path(os.environ["HERMES_HOME"]) / "hermes-agent"
root.mkdir(parents=True)
- for name in ("hermes_cli", "pm", "agent", "tools", "gateway", "tui_gateway", "cron", "plugins"):
+ for name in (
+ "hermes_cli", "hermes_platform", "pm", "agent", "tools", "gateway", "tui_gateway", "cron", "plugins",
+ ):
shutil.copytree(repository / name, root / name,
ignore=shutil.ignore_patterns("__pycache__", "*.pyc"))
for source in repository.glob("*.py"):
diff --git a/hermes_constants.py b/hermes_constants.py
index 535bf2b2dc2..77f2977145f 100644
--- a/hermes_constants.py
+++ b/hermes_constants.py
@@ -13,8 +13,6 @@ from collections.abc import MutableMapping
from contextvars import ContextVar, Token
from pathlib import Path
-from hermes_platform.host.runtime import _detect_container, is_container, is_termux, is_wsl # noqa: F401
-
_profile_fallback_warned: bool = False
_UNSET = object()
_HERMES_HOME_OVERRIDE: ContextVar[str | object] = ContextVar("_HERMES_HOME_OVERRIDE", default=_UNSET)
@@ -1083,6 +1081,34 @@ def resolve_reasoning_config(cfg: dict | None, model: str = "") -> dict | None:
return result
+def is_termux() -> bool:
+ """Delegate Termux detection without making the bootstrap constants module depend on the full package."""
+ from hermes_platform.host.runtime import is_termux as detect
+
+ return detect()
+
+
+def is_wsl() -> bool:
+ """Delegate WSL detection without making the bootstrap constants module depend on the full package."""
+ from hermes_platform.host.runtime import is_wsl as detect
+
+ return detect()
+
+
+def is_container() -> bool:
+ """Delegate container detection without making the bootstrap constants module depend on the full package."""
+ from hermes_platform.host.runtime import is_container as detect
+
+ return detect()
+
+
+def _detect_container() -> bool:
+ """Keep the historical test seam while delegating canonical detection."""
+ from hermes_platform.host.runtime import _detect_container as detect
+
+ return detect()
+
+
def windows_path_to_wsl(path: str) -> str | None:
"""Convert a Windows drive path (``C:\\...``) to its ``/mnt/<drive>/...`` form."""
match = re.match(r"^([A-Za-z]):[\\/](.*)$", str(path or "").strip())
diff --git a/tests/hermes_cli/test_update_finish.py b/tests/hermes_cli/test_update_finish.py
index f6ad692ee21..81e8ee46f2f 100644
--- a/tests/hermes_cli/test_update_finish.py
+++ b/tests/hermes_cli/test_update_finish.py
@@ -44,7 +44,7 @@ def completion(tmp_path, monkeypatch):
# in the working checkout is modified, even by import-time self-heals.
for path in ROOT.glob("*.py"):
shutil.copy2(path, source / path.name)
- for name in ("hermes_cli", "pm", "agent", "gateway", "tools", "cron"):
+ for name in ("hermes_cli", "hermes_platform", "pm", "agent", "gateway", "tools", "cron"):
shutil.copytree(ROOT / name, source / name,
ignore=shutil.ignore_patterns("__pycache__", "web_dist", "tui_dist"))
shutil.copytree(ROOT / "scripts/build", source / "scripts/build",
diff --git a/tests/scripts/test_fresh_source_install.py b/tests/scripts/test_fresh_source_install.py
index 08260e8948f..d544a892580 100644
--- a/tests/scripts/test_fresh_source_install.py
+++ b/tests/scripts/test_fresh_source_install.py
@@ -65,7 +65,7 @@ def test_current_installer_publishes_real_dependencies_and_warm_path(tmp_path, s
run([uv, "python", "install", "--no-bin", minor])
source = tmp_path / "fixture source"
source.mkdir()
- for name in ("pm", "hermes_cli"):
+ for name in ("pm", "hermes_cli", "hermes_platform"):
shutil.copytree(ROOT / name, source / name, ignore=shutil.ignore_patterns("__pycache__"))
for name in ("utils.py", "hermes_constants.py", "hermes_yaml.py", "hermes_bootstrap.py", "setup-hermes.sh"):
shutil.copy2(ROOT / name, source / name)