forked from neurodock/NeuroDock
b74c5e9e97
- Add JarFile-based plugin.json manifest reading and validation - Implement reflection-based plugin class instantiation (Data or no-arg constructor) - Wrap Tool objects into OllamaFunctionTool with basic parameter/response handling - Implement ToolArguments storage and ToolResponse record - Extract RPCP_SOURCE constant; add plugin name validation - Update Data interface: getLoadedPlugins() returns LoadedPlugin[] - Fix launcher package references (me.zacharias.chat → me.neurodock) TODO: Extract FileSystem from JAR, populate PluginMetadata, complete OllamaFunctionArgument↔ToolArguments wrapping, invoke plugin lifecycle hooks Signed-off-by: zacharias <alienfromdia@proton.me>
60 lines
2.3 KiB
Java
60 lines
2.3 KiB
Java
package me.neurodock.plugin;
|
|
|
|
|
|
import me.neurodock.plugin.annotations.PluginEntryPoint;
|
|
import me.neurodock.plugin.tool.Tool;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/**
|
|
* Entry point for the plugin, this is required for the plugin to work, and you MUST annotate it with {@link PluginEntryPoint}
|
|
*/
|
|
public abstract class Plugin {
|
|
/**
|
|
* This is a magic constant plugin name used for when a plugin's name cant be loaded
|
|
*/
|
|
public static final String UNKNOWN_PLUGIN = "UNKNOWN PLUGIN";
|
|
|
|
/**
|
|
* This shuld be used if {@link PluginEntryPoint#requireData()} is false (default)
|
|
* @apiNote While in this constructor, it is not safe to assume any plugin is loaded other than potentially defined plugins in {@link PluginEntryPoint#dependencies()}. See {@link this#onInit}
|
|
*/
|
|
public Plugin() {}
|
|
|
|
/**
|
|
* This shuld be used if {@link PluginEntryPoint#requireData()} is true
|
|
* @apiNote While in this constructor, it is not safe to assume any plugin is loaded other than potentially defined plugins in {@link PluginEntryPoint#dependencies()}. See {@link this#onInit}
|
|
* @param data the {@link Data} generated by the plugin loader
|
|
*/
|
|
public Plugin(Data data) {}
|
|
|
|
/**
|
|
* This will be called once every plugin has been loaded
|
|
*/
|
|
public void onInit(){}
|
|
|
|
/**
|
|
* This will be called if the core gets a "fetal" exception or fails to fetch certain info AND the plugin was able to be loaded.
|
|
*/
|
|
public void onDisable(){}
|
|
|
|
/**
|
|
* This will be called after all plugins have been initialized; here it is safe to perform potential stuff where you load data from optional dependencies, or similar things
|
|
*/
|
|
public void onEnable(){}
|
|
|
|
/**
|
|
* The "main" method of a plugin, it will be the one returning a list of all tools you define.
|
|
* @return An array of all {@link Tool}s you provide in this plugin, see {@link Tool} for definitions or <a href="https://git.server.4zellen.se/Chat_things/NeuroDock/src/branch/master/MALAPITool">MAL API tool</a> for ideas or examples
|
|
*/
|
|
public Tool[] getTools(){
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* This represents your plugin's Metadata
|
|
* @return A {@link PluginMetadata} object representing the metadata for your plugin
|
|
*/
|
|
@NotNull
|
|
public abstract PluginMetadata getMetadata();
|
|
}
|