Leaders welcomed the agreement between Israel and Hamas, projecting optimism that an end to the war could be near.