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: https://github.com/lpil/sonic-pi-tool that I converted to Python here: https://github.com/emlyn/sonic-pi-tool that might give some insight.
And this seems to be where all the OSC commands are registered in Sonic Pi: https://github.com/samaaron/sonic-pi/blob/37dc97080c7cfb10f39452f3100d5e2430cee0b4/app/server/ruby/bin/sonic-pi-server.rb#L275