Map<String, dynamic> toJson() { return { 'type': type.value, 'invocationId': invocationId, 'result': result, 'error': error, }; }