How to direct execute py or js script file in app internal

I want abandon usb and macbook. instead just webdriveragent integration app in my phone, and let socket receive commands, then executing.

I can execute post request to local 8100 address, when i received socket commands. but I need more Logic of my program. so I need to know how to direct execute py or js script file in app internal, rather than execute them in mac (node or python or java, etc) environment. thanks.