Refactor to support Heartbeat Input API.
- flow state stored locally (flow.js)
- data validation
- phonehome knows packet formats