The two Koreas have agreed to rid their peninsula of nuclear weapons in historic talks between the two leaders.