Eighteen countries have signed an agreement on AI safety, based on the principle that it should be secure by design.