Amazon agreed to buy 50 percent of closely held Pets.com.