We consider the interaction of a relativistically-moving shell , composed of thermal photons , a reversing magnetic field and a small admixture of charged particles , with a dense Wolf-Rayet wind . A thin outer layer of Wolf-Rayet material is entrained by the jet head ; it cools and becomes Rayleigh-Taylor unstable , thereby providing an additional source of inertia and variability . The gamma-rays emitted by the shell load the ambient medium with electron-positron pairs and , close to the engine , force this medium to move at nearly the same speed as the shell . We show that this pre-acceleration of the wind material defines a characteristic radiative compactness at the point where the reverse shock has completed its passage back through the shell . We argue that the prompt gamma-ray emission is triggered by this external braking , at an optical depth \sim 1 to electron scattering . Torsional waves , excited by the forced reconnection of the reversing magnetic field , carry a fluctuating current , and are damped at high frequencies by the electrostatic acceleration of electrons and positrons . We show that inverse Compton radiation by the accelerated charges is stronger than their synchrotron emission , and is beamed along the magnetic field . Thermal radiation that is advected out from the base of the jet cools the particles . The observed relation between peak energy and isotropic luminosity – both its amplitude and scaling – is reproduced if the blackbody seeds are generated in a relativistic jet core that is subject to Kelvin-Helmholtz instabilities with the Wolf-Rayet envelope . This relation is predicted to soften to E _ { peak } \sim L _ { iso } ^ { 1 / 4 } below an isotropic luminosity L _ { iso } \sim 3 \times 10 ^ { 50 } ergs s ^ { -1 } . Spectrally harder bursts will arise in outflows which encounter no dense stellar envelope . The duration of spikes in the inverse-Compton emission is narrower at higher frequencies , in agreement with the observed relation . The transition from prompt gamma-ray emission to afterglow can be explained by the termination of the thermal X-ray seed and the onset of synchrotron-self-Compton emission . GLAST will probe the mechanism of particle heating at the reverse shock by measuring the inverse-Compton scattering of the seed photons .