Nepal’s three main parties reach a deal to avoid a political crisis, amid reports the prime minister is to resign.