The US and the Taliban have signed an agreement aimed at paving the way towards peace in Afghanistan after more than 18 years of conflict.