Agent upgrade

This pull-request contains work-in-progress code to support upgrading agents without human interaction.