Libya's rival parliaments reach an initial agreement aimed at resolving the conflict that has plagued the country for more than four years.