We explore the dependence of the performance bounds of heat engines and refrigerators on the initial quantum state and the subsequent evolution of their piston, modeled by a quantized harmonic oscillator. Our goal is to provide a fully quantized treatment of self-contained (autonomous) heat machines, as opposed to their prevailing semiclassical description that consists of a quantum system alternately coupled to a hot or a cold heat bath, and parametrically driven by a classical time-dependent piston or field. Here by contrast, there is no external time-dependent driving. Instead, the evolution is caused by the stationary simultaneous interaction of two heat baths (having distinct spectra and temperatures) with a single two-level system that is in turn coupled to the quantum piston. The fully quantized treatment we put forward allows us to investigate work extraction and refrigeration by the tools of quantum-optical amplifier and dissipation theory, particularly, by the analysis of amplified or dissipated phase-plane quasiprobability distributions. Our main insight is that quantum states may be thermodynamic resources and can provide a powerful handle, or control, on the efficiency of the heat machine. In particular, a piston initialized in a coherent state can cause the engine to produce work at an efficiency above the Carnot bound in the linear amplification regime. In the refrigeration regime, the coefficient of performance can transgress the Carnot bound if the piston is initialized in a Fock state. The piston may be realized by a vibrational mode, as in nanomechanical setups, or an electromagnetic field mode, as in cavitybased scenarios.