6. Given a pyramid $S-ABCD$ with a height of $\frac{\sqrt{2}}{4}$, the base is a square with side length 1, and points $S, A, B, C, D$ are all on the same sphere with a radius of 1. Then the maximum length of the lateral edge $SA$ is $\qquad$.
6. $\frac{\sqrt{6+2 \sqrt{7}}}{2}$.

As shown in Figure 1, draw a perpendicular from the center of the sphere $O$ to the plane $ABCD$, and let the foot of the perpendicular be $H$.
Then, $OA=1, AH=\frac{\sqrt{2}}{2}$.
Thus, $OH=\sqrt{OA^2 - AH^2} = \frac{\sqrt{2}}{2}$.
Since $\frac{\sqrt{2}}{4} + \frac{\sqrt{2}}{2} > 1$, the possible positions of point $S$ are all on a plane $\alpha$ parallel to the plane $ABCD$.
Let the intersection of plane $\alpha$ with $OH$ be $G$, and $GH = \frac{\sqrt{2}}{4}$.
Then, $OG = \frac{\sqrt{2}}{4}$.
Let the projection of point $A$ on plane $\alpha$ be $A'$.
As shown in Figure 2, in plane $\alpha$, the points on the circle $\Gamma$ with radius $\sqrt{R^2 - OG^2} = \frac{\sqrt{14}}{4}$ are all possible positions of point $S$, and $A'G = \frac{\sqrt{2}}{2}$.

To maximize the length of $AS$, we need to maximize the length of $A'S$.

It is easy to see that points $A'$, $G$, and $S$ are collinear, and the length of $A'S$ is maximized when points $A'$ and $S$ are on opposite sides of point $G$. The maximum value of $A'S$ is $\frac{\sqrt{14}}{4} + \frac{\sqrt{2}}{2}$.
Then, $SA_{\text{max}} = \sqrt{\left(\frac{\sqrt{14}}{4} + \frac{\sqrt{2}}{2}\right)^2 + \left(\frac{\sqrt{2}}{4}\right)^2} = \frac{\sqrt{6+2 \sqrt{7}}}{2}$.