Direct evidence for a magnetic f-electron–mediated pairing mechanism of heavy-fermion superconductivity in CeCoIn5