pkg: An API in cockpit.js for package lookup

This will also be used by the AMD loader

Closes #1398