I'm not sure if a javascript can install the script into the application folder without some kind of user permission interaction. Although , I have never tested this out as of yet.
In order to run applescript from javascript, I've had to make an "AppleScript-Executor.app" .app which can be triggered by jsx's file.execute() method. If this app's code tells it to always run a .scpt file in a certain location, you can write the .scpt dynamically from the jsx and execute the .app which would run it. For cleanup, the .app could remove the file too.