I’m not sure why you want to check if the user is authenticated, you cannot get into the panel if you are not authenticated. In either case, you can get from the admin context which type of user it is.
Also, from the admin context you could check if the action is ran from admin or from CLI, but I’m not sure about that.