Skip to content

The agent that grows with you

feat(termux): support apt-managed Hermes installs

adybag14-cyber26466d059417
diff --git a/hermes_cli/banner.py b/hermes_cli/banner.py
index a1cd4748f61..259c454bab8 100644
--- a/hermes_cli/banner.py
+++ b/hermes_cli/banner.py
@@ -406,7 +406,7 @@ def check_for_updates() -> Optional[int]:
# (web_server.py); mirror that here so the banner/TUI surfaces agree.
try:
from hermes_cli.config import detect_install_method, get_project_root
- if detect_install_method(get_project_root()) == "docker":
+ if detect_install_method(get_project_root()) in {"docker", "apt"}:
return None
except Exception:
pass
diff --git a/hermes_cli/config.py b/hermes_cli/config.py
index 1137e100a6e..a5b9c1dc1ef 100644
--- a/hermes_cli/config.py
+++ b/hermes_cli/config.py
@@ -410,7 +410,7 @@ def _install_method_project_root(project_root: Optional[Path] = None) -> Path:
def detect_install_method(project_root: Optional[Path] = None) -> str:
- """Detect how Hermes was installed: 'docker', 'nix', 'nixos', 'git', or 'unknown'.
+ """Detect how Hermes was installed: 'apt', 'docker', 'nix', 'nixos', 'git', or 'unknown'.
Resolution order:
1. Code-scoped stamp ``<install tree>/.install_method`` (next to the
@@ -454,7 +454,7 @@ def detect_install_method(project_root: Optional[Path] = None) -> str:
See issue #34397.
"""
root = _install_method_project_root(project_root)
- supported_methods = {"docker", "nix", "nixos", "git", "unknown"}
+ supported_methods = {"apt", "docker", "nix", "nixos", "git", "unknown"}
# 1. Code-scoped stamp — authoritative, immune to shared $HERMES_HOME.
try:
@@ -548,6 +548,8 @@ def recommended_update_command_for_method(method: str) -> str:
return _NIX_UPDATE_MSG
if method == "docker":
return "docker pull nousresearch/hermes-agent:latest"
+ if method == "apt":
+ return "pkg upgrade hermes-agent"
return "hermes update"
diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py
index b070e1c22bf..e12c9605aa6 100644
--- a/hermes_cli/doctor.py
+++ b/hermes_cli/doctor.py
@@ -90,8 +90,8 @@ def _sqlite_upgrade_hint(install_method: str | None = None) -> str:
if method == "docker":
command = recommended_update_command_for_method(method)
action = f"run `{command}`, then recreate all Hermes containers"
- elif method in {"nix", "nixos"}:
- action = recommended_update_command_for_method(method)
+ elif method in {"nix", "nixos", "apt"}:
+ action = f"run `{recommended_update_command_for_method(method)}`"
else:
action = "run `hermes update`"
return (
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index 299c82a5bde..3d1051e71d1 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -9918,7 +9918,7 @@ def cmd_update(args):
print(format_docker_update_message())
sys.exit(1)
- if install_method in {"nix", "nixos"}:
+ if install_method in {"nix", "nixos", "apt"}:
print(recommended_update_command_for_method(install_method))
sys.exit(1)
diff --git a/hermes_cli/observability/schemas/hermes.shared_metrics.v2.schema.json b/hermes_cli/observability/schemas/hermes.shared_metrics.v2.schema.json
index 5d0bea610a7..0052569679d 100644
--- a/hermes_cli/observability/schemas/hermes.shared_metrics.v2.schema.json
+++ b/hermes_cli/observability/schemas/hermes.shared_metrics.v2.schema.json
@@ -58,7 +58,7 @@
},
"install_method": {
"type": "string",
- "enum": ["docker", "git", "homebrew", "nixos", "pip", "unknown"]
+ "enum": ["apt", "docker", "git", "homebrew", "nixos", "pip", "unknown"]
},
"os_family": {
"type": "string",
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index e1df0aa1ae6..e914d38bb7f 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -2541,7 +2541,7 @@ def _cmd_update_check(branch: str = "main", *, branch_explicit: bool = False):
print(format_docker_update_message())
sys.exit(1)
- if method in {"nix", "nixos"}:
+ if method in {"nix", "nixos", "apt"}:
print(recommended_update_command_for_method(method))
sys.exit(1)
diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py
index e78121393b7..8a8f5294193 100644
--- a/hermes_cli/web_server.py
+++ b/hermes_cli/web_server.py
@@ -4694,7 +4694,7 @@ async def update_hermes():
"update_command": recommended_update_command_for_method(install_method),
}
- if install_method in {"nix", "nixos"}:
+ if install_method in {"nix", "nixos", "apt"}:
message = recommended_update_command_for_method(install_method)
_record_completed_action("hermes-update", message, exit_code=1)
return {
@@ -4847,6 +4847,11 @@ async def check_hermes_update(force: bool = False):
if install_method == "docker":
payload["message"] = format_docker_update_message()
return payload
+ if install_method == "apt":
+ payload["message"] = (
+ "Hermes is managed by Termux APT; run `pkg upgrade hermes-agent`."
+ )
+ return payload
# banner.check_for_updates() handles git / nix-revision paths and
# caches the result for 6h. ``force`` busts the cache so the "Check now"
diff --git a/tests/hermes_cli/test_cmd_update_apt.py b/tests/hermes_cli/test_cmd_update_apt.py
new file mode 100644
index 00000000000..0b77cabe4c4
--- /dev/null
+++ b/tests/hermes_cli/test_cmd_update_apt.py
@@ -0,0 +1,45 @@
+"""APT-managed Hermes installs must never fall through to the git updater."""
+
+from __future__ import annotations
+
+from types import SimpleNamespace
+from unittest.mock import patch
+
+import pytest
+
+from hermes_cli.main import _cmd_update_check, cmd_update
+
+
+def test_apt_stamp_is_detected_and_recommends_pkg_upgrade(tmp_path):
+ from hermes_cli.config import detect_install_method, recommended_update_command_for_method
+
+ (tmp_path / ".install_method").write_text("apt\n", encoding="utf-8")
+ assert detect_install_method(project_root=tmp_path) == "apt"
+ assert recommended_update_command_for_method("apt") == "pkg upgrade hermes-agent"
+
+
+@patch("hermes_cli.config.is_managed", return_value=False)
+@patch("hermes_cli.config.detect_install_method", return_value="apt")
+@patch("subprocess.run")
+def test_cmd_update_apt_prints_pkg_guidance_without_git(
+ mock_run, _mock_method, _mock_managed, capsys
+):
+ with pytest.raises(SystemExit) as excinfo:
+ cmd_update(SimpleNamespace(check=False))
+
+ assert excinfo.value.code == 1
+ assert "pkg upgrade hermes-agent" in capsys.readouterr().out
+ assert mock_run.call_args_list == []
+
+
+@patch("hermes_cli.config.detect_install_method", return_value="apt")
+@patch("subprocess.run")
+def test_cmd_update_check_apt_prints_pkg_guidance_without_git(
+ mock_run, _mock_method, capsys
+):
+ with pytest.raises(SystemExit) as excinfo:
+ _cmd_update_check()
+
+ assert excinfo.value.code == 1
+ assert "pkg upgrade hermes-agent" in capsys.readouterr().out
+ assert mock_run.call_args_list == []