And stored in the specific forms the machine can exploit.
Over a long enough timescale, though… really, really slow solar trickle charge to a space-capacitor bank? A thousand years’ suns, culminating in a glorious orgy of smelting?
That's the source, but for chemical reactions you also need a sink. For instance gasoline is not usable as an energy source without an oxidant. Take away the oxygen in Earth's atmosphere (an asteroid has no atmosphere at all) and now gasoline has no potential energy available. Asteroids have no available oxidants (regolith was already fully oxidized long ago).