File size: 1,591 Bytes
b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 a7c4301 b8e5043 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | """Base plugin class - all plugins must inherit from this."""
from __future__ import annotations
class BasePlugin:
"""Base class for all Entelechy plugins.
Subclasses are automatically registered via __init_subclass__.
"""
# Plugin metadata (override in subclasses)
plugin_name: str = ""
plugin_description: str = ""
plugin_version: str = "1.0.0"
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
# Lazy import to avoid circular dependency
from plugins.registry import plugin_registry
plugin_registry.register_plugin_class(cls)
def __init__(self, context: dict | None = None):
self.context = context or {}
async def initialize(self):
"""Called when the plugin is activated. Override for setup logic."""
pass
async def terminate(self):
"""Called when the plugin is deactivated. Override for cleanup."""
pass
def get_tools(self) -> list[dict]:
"""Return tool definitions this plugin provides.
Each tool dict should have: name, description, input_schema.
Override in subclasses to expose tools.
"""
return []
async def execute_tool(self, tool_name: str, args: dict) -> str:
"""Execute a tool provided by this plugin.
Args:
tool_name: Name of the tool to execute.
args: Tool arguments dict.
Returns:
String result of the tool execution.
"""
return f"Tool '{tool_name}' not implemented in plugin '{self.plugin_name}'"
|