diff --git a/cli.py b/cli.py index cc9ca214b..b93fde77a 100644 --- a/cli.py +++ b/cli.py @@ -1017,9 +1017,7 @@ _IMAGE_EXTENSIONS = frozenset({ }) -def _is_termux_environment() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux as _is_termux_environment def _termux_example_image_path(filename: str = "cat.png") -> str: diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py index e90631a98..fb629e0f1 100644 --- a/hermes_cli/doctor.py +++ b/hermes_cli/doctor.py @@ -54,9 +54,7 @@ _PROVIDER_ENV_HINTS = ( ) -def _is_termux() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux as _is_termux def _python_install_cmd() -> str: diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index 9e215ff2e..b19ceaac9 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -226,9 +226,7 @@ def is_linux() -> bool: return sys.platform.startswith('linux') -def is_termux() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux def supports_systemd_services() -> bool: diff --git a/hermes_cli/status.py b/hermes_cli/status.py index a04d57013..11f4371b6 100644 --- a/hermes_cli/status.py +++ b/hermes_cli/status.py @@ -79,9 +79,7 @@ def _effective_provider_label() -> str: return provider_label(effective) -def _is_termux() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux as _is_termux def show_status(args): diff --git a/hermes_constants.py b/hermes_constants.py index 638d36a33..09005227a 100644 --- a/hermes_constants.py +++ b/hermes_constants.py @@ -93,6 +93,16 @@ def parse_reasoning_effort(effort: str) -> dict | None: return None +def is_termux() -> bool: + """Return True when running inside a Termux (Android) environment. + + Checks ``TERMUX_VERSION`` (set by Termux) or the Termux-specific + ``PREFIX`` path. Import-safe — no heavy deps. + """ + prefix = os.getenv("PREFIX", "") + return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) + + OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1" OPENROUTER_MODELS_URL = f"{OPENROUTER_BASE_URL}/models" OPENROUTER_CHAT_URL = f"{OPENROUTER_BASE_URL}/chat/completions" diff --git a/tools/browser_tool.py b/tools/browser_tool.py index 5fc028b6c..9ad8ba48b 100644 --- a/tools/browser_tool.py +++ b/tools/browser_tool.py @@ -285,9 +285,7 @@ def _get_cloud_provider() -> Optional[CloudBrowserProvider]: return _cached_cloud_provider -def _is_termux_environment() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux as _is_termux_environment def _browser_install_hint() -> str: diff --git a/tools/voice_mode.py b/tools/voice_mode.py index d8ddfd238..b6f0df29a 100644 --- a/tools/voice_mode.py +++ b/tools/voice_mode.py @@ -48,9 +48,7 @@ def _audio_available() -> bool: return False -def _is_termux_environment() -> bool: - prefix = os.getenv("PREFIX", "") - return bool(os.getenv("TERMUX_VERSION") or "com.termux/files/usr" in prefix) +from hermes_constants import is_termux as _is_termux_environment def _voice_capture_install_hint() -> str: