Code cleanup:

- move communication between deploy and agent to protocol
- simplify imports