(#3910) Query node before fetching catalog to determine environment
This makes the agent query for its node before getting a catalog so that it
can determine the correct environment from that node. This allows an ENC to
override the agent's environment without incurring an extra catalog
compilation.
It also sets the default node terminus to rest in the agent application.