Refactor agent and proxy, move all v1 code to v1 model