For what it is worth it’s not wrong to say that the triad where E is the root would be Em#5. The inversions you point out still have the same root (C) even if the bass is different.
But I agree you’ve identified the fundamental problem: we cannot infer the root note and, therefore the name (enharmonics aside), from just a set of notes and attempting to is a fool’s errand. Even with a root note, it's going to be difficult many times to have a sensible answer
The key problem with this implementation in addition to not simply taking the root note as input (or a key or scale), appears to be the chord database is pretty spartan, since it doesn't appear it would identify C-E-G as anything other than CMaj. If you want figured bass/slash notation then you'll need to specify that as well (bass note).
A number of chord namers take these as additional inputs.
The key problem with this implementation in addition to not simply taking the root note as input (or a key or scale), appears to be the chord database is pretty spartan, since it doesn't appear it would identify C-E-G as anything other than CMaj. If you want figured bass/slash notation then you'll need to specify that as well (bass note).
A number of chord namers take these as additional inputs.