Add scope attribute to classes promise. RM #1941 

By setting scope => namespace, it's now possible to define a global class directly
from an agent bundle.

See discussion in RM #1941.

Also includes fix for RM #2418/Pull #492. I can remove that if necessary.