"""Soft signed-out detection, plus the two invariants behind the 2026-07-26 bug hunt.
Each test here corresponds to a bug that actually escaped to a live run, so the point is to make
that whole CLASS unwritable rather than to re-check a line:
1. Sites that browse fine while withholding the composer (bsky/stackoverflow/tiktok/threads) hit
no login URL and show no password field, so the hard-wall gate saw nothing and the run
reported "couldn't find the compose box" when the truth was "you are not signed in".
2. The composer finder budgeted ~24s of reveal work into a 15s command timeout, so heavy pages
were killed mid-ladder and threw away everything, and the last two tiers were unreachable.
"""
import os
import re
from backend.apps.agents.browser import browser_send_parse as sp
from backend.apps.agents.browser import browser_login_handoff as lh
from backend.apps.agents.core.ws_manager import BROWSER_CMD_TIMEOUTS, BROWSER_CMD_TIMEOUT_DEFAULT
P_REPO_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
P_HANDLER_TS = os.path.join(P_REPO_ROOT, "frontend", "src", "shared", "browserCommandHandler.ts")
# Page-shaped perceptions, in the interactives format the agent actually sees.
BSKY_SIGNED_OUT = '[1]\n[2]