Afghanistan and Pakistan have agreed to a ceasefire during negotiations in Doha, following intense border clashes.