agent: Implement CockpitRestJson and the 'rest-json1' payload type

This is an implementation of the REST JSON payload type. It's fairly
complete, supporting streaming, monitoring, and other necessary
things.

Monitoring currently is only driven by an interval, where it could
also be driven off of output from another request.

Part of fix for #268, #267 and #265
web: Allow Channel.close() to accept a problem

Even though it's on the web side, we should allow Channel.close()
to accept a problem code which listeners can then react to. This allows
a consistent flow of problem codes no matter where they come from.
The problem code doesn't need to be sent to the web service or agent.
web: Use new rest-json1 protocol to implement web rest client