Perimeter of triangle $ABC$ is $1$. Circle $\omega$ touches side $BC$, continuation of side $AB$ at $P$ and continuation of side $AC$ in $Q$. Line through midpoints $AB$ and $AC$ intersects circumcircle of $APQ$ at $X$ and $Y$.
Find length of $XY$. 

1. **Define the given elements and their relationships:**
   - Let \( O \) be the center of the circumcircle of \( \triangle APQ \).
   - Let \( I_a \) be the \( A \)-excenter of \( \triangle ABC \).
   - Let \( r_a \) be the \( A \)-exradius.
   - The circle \( \omega \) touches \( BC \) at \( T \), the extension of \( AB \) at \( P \), and the extension of \( AC \) at \( Q \).

2. **Use homothety to relate the segments:**
   - By homothety centered at \( A \) that maps the incircle to the \( A \)-excircle, the line through the midpoints of \( AB \) and \( AC \) (which is the midline of \( \triangle ABC \)) is tangent to the circle centered at \( O \) with radius \( r_a/2 \).

3. **Calculate the length of \( XY \):**
   - Since \( XY \) is tangent to the circle centered at \( O \) with radius \( r_a/2 \), the distance from \( O \) to \( XY \) is \( r_a/2 \).
   - By the same homothety, the distances from \( O \) to \( AP \) and \( AQ \) are also \( r_a/2 \).
   - Given that the perimeter of \( \triangle ABC \) is 1, and since \( AP \) and \( AQ \) are tangents from \( A \) to the \( A \)-excircle, we have \( AP = AQ = \frac{1}{2} \).

4. **Conclude the length of \( XY \):**
   - Therefore, \( XY = AP = AQ = \frac{1}{2} \).

The final answer is \(\boxed{\frac{1}{2}}\).