async fn run_cli_login_pty(
state: Arc<AppState>,
cli_path: String,
login_args: Vec<String>,
auth_env: HashMap<String, String>,
) -> Result<Value, String>Expand description
PTY-backed variant of run_cli_login. Used for providers whose auth
subcommand requires an interactive TTY (currently OpenClaw —
openclaw models auth login --provider <id> exits immediately with
“requires an interactive TTY” when stdin is a pipe).
Same return shape as run_cli_login: { auth_url: <url or null> }.
Writes the master writer into state.cli_login_stdin so
set_provider_auth can deliver an OAuth code if the CLI prompts
for one.
CRITICAL ConPTY lifetime contract on Windows: the PtyPair (master + slave) MUST stay alive across child.wait(). Same hazard pattern agentmux-bashwrap navigates. The blocking wait task takes ownership of the pair so the destructor runs after the child reaps.