A deal between two leading factions in Afghanistan has aroused hopes that the long agony of the war-torn country may be nearing an end.