agent: Register the script event handler