For Bamboo there are essentially 2 modes of operations - on the agent or on the server. (Local agents are technically on the server but I would highly recommend ignoring that since if you introduce remote agents into the mix - your code will break).
The reason I bring this up is that the server code can inject pretty much anything it wants. Things running on the agents - don’t have access to the database, user authentication etc. They get the build info and the directory. They can generate data and send it back to the server to be processed. In your case BuildResultsSummaryManager is dependent on the database thus not available on the agent.
That said - you can break your code up and do things before the build gets sent to the remote agent (take a look at https://developer.atlassian.com/server/bamboo/custom-build-definition-transformer-module ). You can then use the postBuildProcesserServer to interpret on the server.
There used to be a pretty graph on developer.atlassian.com that explained the build cycle for Bamboo, but it seems to have been removed (there doesn’t seem to be much of documentation for Bamboo nowadays). I swear there was a more straight forward module to handle intra-agent-server communications as well.