Phase 9: Plugin system for extensibility and advanced customization
This commit is contained in:
1 parent
c54f2a33c8
commit
98b6f10ea4
5 files changed
+596
No files matched your search
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Base plugin class for MaxClaw Agent
|
||||
"""
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List, Dict, Any, Optional
|
||||
from langchain.tools import Tool
|
||||
|
||||
|
||||
class BasePlugin(ABC):
|
||||
"""Base class for MaxClaw plugins"""
|
||||
|
||||
def __init__(self, name: str, version: str = "1.0.0", description: str = ""):
|
||||
"""
|
||||
Initialize plugin
|
||||
|
||||
Args:
|
||||
name: Plugin name
|
||||
version: Plugin version
|
||||
description: Plugin description
|
||||
"""
|
||||
self.name = name
|
||||
self.version = version
|
||||
self.description = description
|
||||
self.enabled = True
|
||||
|
||||
@abstractmethod
|
||||
def get_tools(self) -> List[Tool]:
|
||||
"""
|
||||
Get tools provided by this plugin
|
||||
|
||||
Returns:
|
||||
List of tools
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_commands(self) -> Dict[str, callable]:
|
||||
"""
|
||||
Get commands provided by this plugin
|
||||
|
||||
Returns:
|
||||
Dictionary mapping command names to functions
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_load(self):
|
||||
"""Called when plugin is loaded"""
|
||||
pass
|
||||
|
||||
def on_unload(self):
|
||||
"""Called when plugin is unloaded"""
|
||||
pass
|
||||
|
||||
def get_info(self) -> Dict[str, Any]:
|
||||
"""
|
||||
Get plugin information
|
||||
|
||||
Returns:
|
||||
Dictionary with plugin info
|
||||
"""
|
||||
return {
|
||||
"name": self.name,
|
||||
"version": self.version,
|
||||
"description": self.description,
|
||||
"enabled": self.enabled,
|
||||
"tools_count": len(self.get_tools()),
|
||||
"commands_count": len(self.get_commands())
|
||||
}
|
||||
|
||||
def enable(self):
|
||||
"""Enable the plugin"""
|
||||
self.enabled = True
|
||||
|
||||
def disable(self):
|
||||
"""Disable the plugin"""
|
||||
self.enabled = False
|
||||
|
||||
def is_enabled(self) -> bool:
|
||||
"""Check if plugin is enabled"""
|
||||
return self.enabled
|
||||
Reference in new issue
Block a user