def register_plugin(func: Union[Callable[..., Any], Type[Plugin]]):
    """
    register a plugin, the plugin could be a class or a callable function

    :param func: the plugin class or a callable function
    """
    global register_plugin_inner

    if "register_plugin_inner" not in globals() or register_plugin_inner is None:
        print("no registry for loading plugin")
    elif isinstance(func, type) and issubclass(func, Plugin):
        register_plugin_inner(func)
    elif callable(func):
        func_name = func.__name__

        def callable_func(self: Plugin, *args: List[Any], **kwargs: Dict[str, Any]):
            self.log("info", "calling function " + func_name)
            result = func(*args, **kwargs)
            return result

        wrapper_cls = type(
            f"FuncPlugin_{func_name}",
            (Plugin,),
            {
                "__call__": callable_func,
            },
        )
        register_plugin_inner(wrapper_cls)
    else:
        raise Exception(
            "only callable function or plugin class could be registered as Plugin",
        )
    return func

    register a plugin, the plugin could be a class or a callable function

    :param func: the plugin class or a callable function
    
taskweaver/plugin/register.py