Instead of downloading and using the manifest tool mimic the behavior of the CLI commands used. This is now possible with the v2 of the manifest tool library which can be used in this manner. Use the new coding conventions for the plugin.