Sending a buffer of text to the Sonic Pi Server (Python)

I’m experimenting a bit these days with Python and Sonic Pi. I’m playing with a tiny text editor made with the package prompt-toolkit (Prompt Toolkit Documentation). What I’m trying to achieve by doing so is creating my own personal terminal interface for Sonic-Pi with mutiline support, custom syntax highlighting, etc…

I have seen that some of you have already tried to communicate with the Sonic Pi server from outside the application. My question is relatively simple: how is Sonic Pi sending a whole buffer of text to the server ? Is it possible to send a buffer of text from outside the software to the software/server parser ?

Thanks a lot for your help!

PS : is there a list of the different instructions the server can receive ? (how does Sonic Pi manages the option panel, the play / pause / record buttons, etc…) ?

Most instructions are sent as OSC messages to port 4557, for example buffers of text are sent as a /run-code message.
There’s a command-line tool written in Rust here: that I converted to Python here: that might give some insight.
And this seems to be where all the OSC commands are registered in Sonic Pi: