daemon-rewrite: Implement API (WIP)