mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: deduplicate _is_termux() into hermes_constants.is_termux()
Replace 6 identical copies of the Termux detection function across cli.py, browser_tool.py, voice_mode.py, status.py, doctor.py, and gateway.py with a single shared implementation in hermes_constants.py. Each call site imports with its original local name to preserve all existing callers (internal references and test monkeypatches).
This commit is contained in:
parent
c3141429b7
commit
69a0092c38
7 changed files with 16 additions and 18 deletions
4
cli.py
4
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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue