Alot of the actions of a wayward mimic those who have a personality disorder- so be careful of labeling her as that until she has her psych examination. I know it's easier to label her as BPD rather than face the fact that someone you love that much as done this to you willingly- but it could be that shes just plain wayward and that's it. No one wants to think their partner is mentally stable and still doing all of that- I get it.
Other than mental issues why would she lose custody? Just because of the affair?
She has custody right now and is withholding correct? What were your issues that led her to do that or were there any?? I'm just trying to figure out your sitch.