After digging a bit more and looking into 'script' sourcecode, I found this:
man 7 pty
man 4 pts
man 3 openpty
Creating a new pseudo-terminal seems like the way to go here and I'm going to give it a shot.
Edit: It seems to be working. In case someone runs into similar issue, the project can be found at https://github.com/Baranowski/habit-vim/.