After decades of conflict between two African countries, President Trump and an adviser said the two sides, with U.S. help, had created an agreement that was now being finalized.