Add types for lifecycle events.

I'll repeat a question from #1028: error reporting/handling, and input and output arguments.

We should convey failure of a hook to the user somehow. 

Have you thought about a mechanism to return the output to the user? Probably we need an event stream they can listen on. In this case, it would be nice to be able to get structured data back, so we could grow this into a real API. 

Similarly, I'd like to pass structured information to the hook, so that we can grow it into a real API. In other threads, we've discussed environment variables, but structured data (e.g., JSON) seems better.