In a tentative show of temporary unity, Libyan armed groups and the government have reached a deal to secure vital infrastructure in Tripoli.