How to automatically run a script on the agent after each build and deployment?

Hi

I want to automatically run a script on the agent after each build and after each deployment.
Automatically, i.e. transparent to the user, without the user having to add a script task to the end of his/her plans.
I looked at event listeners, but to my understanding, these are executed on the server.
I looked at the Build Processor module which runs on the agent, but I couldn’t find an equivalent for deployments.

Thanks for any hints!