A computationally grounded dynamic logic of agency, with application to legal actions