We study an initially inverted three-level atom in the lambda configuration embedded in a waveguide, interacting with a propagating single-photon pulse. Depending on the temporal shape of the pulse, the system behaves either as an optimal universal cloning machine, or as a highly efficient deterministic source of maximally entangled photon pairs. This quantum transistor operates over a wide range of frequencies, and can be implemented with today's solid-state technologies.