add plugin API. see samples/plugin.