The username is not passed to the script.
What you may need to do is include the username as part of your search results. Its messy, but it will work. You can do so with something like the following, using the append command to add an additional row containing the username. Your script will need to look for this row/field and get the username in that fashion.
index=_internal | stats count by component | append [ rest /services/authentication/current-context/context | fields + username ]
Alternatively, your script could look at the splunk internal logs, and tie a few events together to determine who is calling the script.
... View more