For cooling this exists in many forms: there are the window air conditioners, and "portable" window air conditioners which have a duct that connects to the window. The problem with the latter is that they're loud and the ducts result in a lot of heat loss.
For heating there are some portable air conditioners that use a heat pump but they're subject to the same issue described above. More common is resistive electrical heat in the form of coils or an oil filled container that radiates heat.
A portable mini split, where it connects through the window would give you a similar advantage as a portable air conditioner, but with more efficiency and being less loud.