That's some tricky legal area. I think the jurisprudence is still maturing the founding fathers never having imagined anything remotely like a Trump jumping through all the hoops to the White House.
There is talking with foreign governments, and there is colluding with them for opposition research. The former is not a big deal, and in fact it might be a common practice for candidates with good chances of winning. The latter borders on treason. But that is just my layman's opinion.