The Kurdish-led Syrian Democratic Forces (SDF) have agreed to withdraw from Aleppo after days of deadly violence.