Japan and the United States agreed on Wednesday to map out how they will work together if Tokyo needs to use force to help protect a friendly country under attack, as they update defense cooperation guidelines for the first time in nearly two decades.