Both branches of the legislature agreed to spend tax surplus on health care, affordable housing, MBTA safety improvements and other needs.