Solution (source code)

= Solution

The $y$ component integrates to $\phi=xy e^{z-x}+g(x,z)$. Matching the $x$ component gives $g_x=2x$, and matching the $z$ component then gives the remaining derivative zero. Consequently
$$
\boxed{\phi(x,y,z)=xy e^{z-x}+x^2+C.}
$$
Direct differentiation recovers all three components, proving this is a <gradient field> globally on $\mathbb R^3$.