2) It runs a geoprocessing service on the server. This geoprocessing service contains the arcgis module.
3) arcgis module logs into AGOL or Portal (I haven't figured it out yet), navigates to a group, and pulls down the markup layers. I will then use arcpy to manipulate them how I want (inside the same script) and then send an email to the user with the resulting FGB in a zip file.
I have many geoprocessing services running arcpy scripts when a button is clicked on the web map built with JS, but I'm unsure if the arcgis module can be run on the server (ArcGIS Enterprise 10.7). Has anybody successfully done something like this?