Hostages to be gradually released in exchange for Palestinian detainees under agreement that could end brutal conflict in Gaza