  We prove the conjecture of Gaiotto and Rap\v{c}\'ak that the $Y$-algebras
$Y_{L,M,N}[\psi]$ with one of the parameters $L,M,N$ zero, are simple
one-parameter quotients of the universal two-parameter
$\mathcal{W}_{1+\infty}$-algebra, and satisfy a symmetry known as triality.
These $Y$-algebras are defined as the cosets of certain non-principal
$\mathcal{W}$-algebras and $\mathcal{W}$-superalgebras by their affine vertex
subalgebras, and triality is an isomorphism between three such algebras.
Special cases of our result provide new and unified proofs of many theorems and
open conjectures in the literature on $\mathcal{W}$-algebras of type $A$. This
includes (1) Feigin-Frenkel duality, (2) the coset realization of principal
$\mathcal{W}$-algebras due to Arakawa and us, (3) Feigin and Semikhatov's
conjectured triality between subregular $\mathcal{W}$-algebras, principal
$\mathcal{W}$-superalgebras, and affine vertex superalgebras, (4) the
rationality of subregular $\mathcal{W}$-algebras due to Arakawa and van Ekeren,
(5) the identification of Heisenberg cosets of subregular
$\mathcal{W}$-algebras with principal rational $\mathcal{W}$-algebras that was
conjectured in the physics literature over 25 years ago. Finally, we prove the
conjectures of Proch\'azka and Rap\v{c}\'ak on the explicit truncation curves
realizing the simple $Y$-algebras as $\mathcal{W}_{1+\infty}$-quotients, and on
their minimal strong generating types.
