We prove the conjecture of Gaiotto and Rapčák that the Y -algebras Y L,M,N [ψ] with one of the parameters L, M, N zero, are simple one-parameter quotients of the universal two-parameter W 1+∞algebra, and satisfy a symmetry known as triality. These Y -algebras are defined as the cosets of certain non-principal W-algebras and 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 W-algebras of type A. This includes (1) Feigin-Frenkel duality, (2) the coset realization of principal W-algebras due to Arakawa and us, (3) Feigin and Semikhatov's conjectured triality between subregular W-algebras, principal W-superalgebras, and affine vertex superalgebras, (4) the rationality of subregular W-algebras due to Arakawa and van Ekeren, and (5) the identification of Heisenberg cosets of subregular Walgebras with principal rational W-algebras that was conjectured in the physics literature over 25 years ago. Finally, we prove the conjectures of Procházka and Rapčák on the explicit truncation curves realizing the simple Y -algebras as W 1+∞ -quotients, and on their minimal strong generating types.