4. If the equation $a=\left|\sqrt{1-x^{2}}-x-1\right|$ has real solutions, then the range of real number $a$ is $\qquad$ .
4. $[0,2]$.

From the problem, we have
$$
\frac{a}{\sqrt{2}}=\frac{\left|\sqrt{1-x^{2}}-x-1\right|}{\sqrt{2}} \text {. }
$$

Consider the right-hand side of the equation as the distance from the point $\left(x, \sqrt{1-x^{2}}\right)$ to the line $x-y+1=0$.

Since the range of distances from points on the upper half of the unit circle to this line is $[0, \sqrt{2}]$, the range of the real number $a$ is $[0,2]$.