  We develop a more general view of Stembridge's enriched $P$-partitions and
use this theory to outline the structure of peak algebras for the symmetric
group and the hyperoctahedral group. Initially we focus on commutative peak
algebras, spanned by sums of permutations with the same number of peaks, where
we consider several variations on the definition of "peak." Whereas
Stembridge's enriched $P$-partitions are related to quasisymmetric functions
(the dual coalgebra of Solomon's type A descent algebra), our generalized
enriched $P$-partitions are related to type B quasisymmetric functions (the
dual coalgebra of Solomon's type B descent algebra). Using these functions, we
move on to explore (non-commutative) peak algebras spanned by sums of
permutations with the same set of peaks. While some of these algebras have been
studied before, our approach gives explicit structure constants with a
combinatorial description.
