Higher-spin charges in Hamiltonian form. I. Bose fields