Drive it from outside the process
Every window opens a local pipe another program can talk to: ask what tabs and panes exist, read back exactly what one of them printed, or type into a specific pane. No simulated keystrokes, no guessing which window is focused. Microsoft looked at this exact idea twice and passed on it; their own automation surface can't reach a pane running inside WSL.
How the control pipe works# \\.\pipe\wt-control-<pid>, one JSON object per line → {"op":"list-panes","reason":"find my build pane", "caller":"deploy.ps1 (pid 4242)"} → {"op":"capture-pane","pane":"1.0.0","lines":20} → {"op":"send-input","pane":"1.1.0","text":"git status", "requireContains":"PS C:\\"} ← {"ok":false,"error":"needle-gone"} # the prompt moved: nothing was written