"""Cross-platform helper for reading the front browser tab's URL. This is the one genuinely OS-specific piece. Reading *your own* browser's current URL is a passive, local operation (no request to the target site), so it stays within the screen-capture / compliance posture. When it can't return a URL (common on Windows/Linux), the detector falls back to reading the address bar visually from a screenshot via the AI. """ import sys from typing import Optional def get_active_tab_url() -> Optional[str]: """Best-effort URL of the frontmost browser tab, or None if unavailable.""" try: if sys.platform == "darwin": from . import macos return macos.get_active_tab_url() if sys.platform.startswith("linux"): from . import linux return linux.get_active_tab_url() if sys.platform in ("win32", "cygwin"): from . import windows return windows.get_active_tab_url() except Exception: return None return None