Refactor API types

Use specialized String/Array types that map more easily to msgpack
Add channel module

- Add channel module that exposes the API over arbitrary streams
- Add `xmemdup` for duplicating memory chunks
- Make job exit callback optional
Add server module for accepting API connections