Peace deal and prisoner swap agreed during Pakistan meeting, after heavy losses in recent battles between factions.