  We formulate the equations of motion of a free scalar field in the flat and
$AdS$ space of an arbitrary dimension in the form of some "higher spin"
covariant constancy conditions. Klein-Gordon equation is interpreted as a
non-trivial cohomology of a certain "\sgm-complex". The action principle for a
scalar field is formulated in terms of the "higher-spin" covariant derivatives
for an arbitrary mass in $AdS_d$ and for a non-zero mass in the flat space. The
constructed action is shown to be equivalent to the standard first-order
Klein-Gordon action at the quadratic level but becomes different at the
interaction level because of the presence of an infinite set of auxiliary
fields which do not contribute at the free level. The example of Yang-Mills
current interaction is considered in some detail. It is shown in particular how
the proposed action generates the pseudolocally exact form of the matter
currents in $AdS_d$.
