Last update: everything's over.
He ended up telling his boyfriend about everything. It happened while I was at their place (I stayed the night with some friends and some of his family, it was their last night in their current house before moving to the city). I was asleep when he told B and didn't find out until the next morning. B said nothing to me, and completely ignored me all day (fair enough I guess, I was expecting him to hit the roof).
A sent me a text message a few hours ago. He and B talked about it for hours on the drive to the city and - personally I find this bizarre - A asked B to marry him, and B said yes.

They've been together about 4 or 5 months,
and just had a discussion about A cheating on B, and yet they're getting married.
Basically, any feelings I had left for A have been erased - this is clearly a complicated and strange relationship between A and B. So far it seems me and A are still friends (although B still isn't talking to me), but after all this, I've got zero interest in anything more with either of them.
And although I still feel guilty about everything, having everything out in the open has come as a relief - we're not hiding anything anymore - and I can move on and get over it. Thanks again for your support and advice everybody.