agent: Fix several leaks in cockpit-agent

The functions json_builder_add_value(), json_object_set_member() and
json_builder_get_root() have unexpected ownership characteristics.