^ Those are the key lines really.
It's running the command in a pseudo-terminal, capturing the output (as text) and sending it over a web socket.