Merge branch 'main' into bb/gui
This commit is contained in:
@@ -214,7 +214,12 @@ def _hermes_bin_dir() -> str:
|
||||
|
||||
|
||||
def _detect_target() -> str | None:
|
||||
"""Return the Rust target triple for the current platform, or None."""
|
||||
"""Return the Rust target triple for the current platform, or None.
|
||||
|
||||
Windows is intentionally unsupported — tirith does not ship a Windows
|
||||
build. Callers should treat `None` as "this platform will never have
|
||||
tirith" and silently fall back to pattern-matching guards.
|
||||
"""
|
||||
system = platform.system()
|
||||
machine = platform.machine().lower()
|
||||
|
||||
@@ -236,6 +241,16 @@ def _detect_target() -> str | None:
|
||||
return f"{arch}-{plat}"
|
||||
|
||||
|
||||
def is_platform_supported() -> bool:
|
||||
"""True when tirith ships a prebuilt binary for this OS+arch.
|
||||
|
||||
Used by callers (CLI banner, etc.) to distinguish "tirith failed to
|
||||
install" from "tirith was never going to install here" — the latter
|
||||
is silent because there is nothing the user can do about it.
|
||||
"""
|
||||
return _detect_target() is not None
|
||||
|
||||
|
||||
def _download_file(url: str, dest: str, timeout: int = 10):
|
||||
"""Download a URL to a local file."""
|
||||
req = urllib.request.Request(url)
|
||||
@@ -448,6 +463,15 @@ def _resolve_tirith_path(configured_path: str) -> str:
|
||||
explicit = _is_explicit_path(configured_path)
|
||||
install_failed = _resolved_path is _INSTALL_FAILED
|
||||
|
||||
# Platform has no tirith build (Windows etc.). Cache the verdict and
|
||||
# return the unexpanded configured path — the spawn loop will fail-open
|
||||
# via the dedupe'd OSError handler, but only after the first call; on
|
||||
# subsequent calls the fast-path above short-circuits before spawning.
|
||||
if not explicit and not is_platform_supported():
|
||||
_resolved_path = _INSTALL_FAILED
|
||||
_install_failure_reason = "unsupported_platform"
|
||||
return expanded
|
||||
|
||||
# Explicit path: check it and stop. Never auto-download a replacement.
|
||||
if explicit:
|
||||
if os.path.isfile(expanded) and os.access(expanded, os.X_OK):
|
||||
@@ -574,6 +598,14 @@ def ensure_installed(*, log_failures: bool = True):
|
||||
return path
|
||||
return None
|
||||
|
||||
# Platform has no tirith build (e.g. Windows) — don't probe PATH,
|
||||
# don't start a download thread, don't write a disk failure marker.
|
||||
# Pattern-matching guards still run; this path stays silent.
|
||||
if not is_platform_supported():
|
||||
_resolved_path = _INSTALL_FAILED
|
||||
_install_failure_reason = "unsupported_platform"
|
||||
return None
|
||||
|
||||
configured_path = cfg["tirith_path"]
|
||||
explicit = _is_explicit_path(configured_path)
|
||||
expanded = os.path.expanduser(configured_path)
|
||||
@@ -659,6 +691,12 @@ def check_command_security(command: str) -> dict:
|
||||
if not cfg["tirith_enabled"]:
|
||||
return {"action": "allow", "findings": [], "summary": ""}
|
||||
|
||||
# Unsupported platform (Windows etc.) — tirith has no binary here and
|
||||
# never will. Skip the resolver entirely so we don't even try to spawn.
|
||||
# Pattern-matching guards still run via the rest of approval.py.
|
||||
if not is_platform_supported():
|
||||
return {"action": "allow", "findings": [], "summary": ""}
|
||||
|
||||
tirith_path = _resolve_tirith_path(cfg["tirith_path"])
|
||||
timeout = cfg["tirith_timeout"]
|
||||
fail_open = cfg["tirith_fail_open"]
|
||||
|
||||
Reference in New Issue
Block a user