The top US military officer General Joseph Dunford has accused Pakistan’s intelligence agency of having ties to armed groups, an accusation that Pakistan denies.