That sounds maybe difficult. It depends whether the terminal is inside or outside of Godot since the toplevel requires a terminal.
Terminal inside Godot? More difficult. If you use something like GitHub - lihop/godot-xterm: Terminal emulator for the Godot game engine. inside Godot, that has its own complexity and on top of that you’d have to bind the terminal events to a toplevel. If you do want that path the “simplest” (ie. very much not simple but doable) would be to adapt the down toplevel. I started down this path for a similar need (didn’t finish it); have a look at @nojb 's Initial support for Win32 by nojb · Pull Request #35 · dbuenzli/down · GitHub for how to bind an unusual terminal (ie. godot-xterm) to a toplevel.
If the terminal is outside, a simple form of RPC (ex. HTTP over localhost or domain socket) between a thread in your toplevel and a thread in Godot would work, right?
In between you have a wide range of options. If you are stuck on the more complex side of options, I am going to combine my scripting framework DkCoder with DkSDK FFI C for embedding scenarios at some point. But for now I’d suggest just keeping it simple with RPC.