Such a protocol is already in place - the lua console.
Why not use that? It is not enabled by default, non-power users don't use it (and probably aren't even aware of it, or what to do with it). It's pretty much a perfect fit, and it would avoid complicating the code base.
Why not. I don't remember lua being able to access stdin and I think it's initialized relatively late, but I'm sure you can fix that. It would have the advantage of every frontend being able to implement whichever functionality it wants. We'll await your PRs.
OG.