Under the CEPT agreement, US General and Amateur Extra class licensee can operate in Europe while traveling there. Does that privilege still apply if the person semi or permanently resides in that European country either as a legal foreigner or dual citizen?
TL;DR Not under CEPT rules.
First of all, it's not the CEPT agreement that USA is part of, it's one of many CEPT agreements and recommendations, namely the CEPT T/R 61-01. My advice is to always actually read the agreements and not just rely on the hear-say.
If you go through the agreement, you'll be able to see that the T/R 61-01 is exclusively for non-permanent residents. Don't forget that you need the "CEPT radio amateur licence", which is for the US interpreted as the hard-copy of your license and the FCC public notice.
Now, what about permanent residency? Well, that is covered by the recommendation T/R 61-02. The way it works is that, after passing your license exam for a class equivalent to the CEPT class, you can (or could if USA were part of T/R 61-02) receive the Harmonized Amateur Radio Examination Certificate (HAREC). The licensing authority in the country you're residing in takes the HAREC as the proof that you passed the appropriate exams and issues you with the license for the national class that's equivalent to the CEPT class. Note that some countries still require proof of Morse code exam for their highest license! It's possible to have several license classes that are equivalent to the CEPT class.
As I've mentioned, and can be seen in the annex 4 of the T/R 61-02, USA is not part of that agreement.
What can you do? Well, go outside of the requirements of the CEPT T/R 61-02 and see what you can do. First step is to understand that Europe is not a country (yet at least) and that things in European countries can work differently. It could happen that the country that you're going to be residing in will accept your US license. It could be that there's a more complicated or more expensive procedure you need to go through to get your license accepted.
For example, in Germany issuing the amateur radio license costs 70€. If you don't have a HAREC, then you need to go through a recognition procedure which is another 130€ on top of the issuing fee.