Israel, Hamas agree to truce and hostage deal