  We treat the Cooper pairs in the superconducting electrodes of a Josephson
junction (JJ) as an open system, coupled via Andreev scattering to external
baths of electrons. The disequilibrium between the baths generates the
direct-current bias applied to the JJ. In the weak-coupling limit we obtain a
Markovian master equation that provides a simple dynamical description
consistent with the main features of the JJ, including the form of the
current-voltage characteristic, its hysteresis, and the appearance under
periodic voltage driving of discrete Shapiro steps. For small dissipation, our
model also exhibits a self-oscillation of the JJ's electrical dipole with
frequency $\Omega = 2 e V / \hbar$ around mean voltage $V$. This
self-oscillation, associated with "hidden attractors" of the nonlinear
equations of motion, explains the observed production of monochromatic
radiation with frequency $\Omega$ and its harmonics. We argue that this picture
of the JJ as a quantum engine resolves open questions about the Josephson
effect as an irreversible process and could open new perspectives in quantum
thermodynamics and in the theory of dynamical systems.
