refactor(agent): Separate event handlers from Agent