-
Notifications
You must be signed in to change notification settings - Fork 4
Plugin Development.md
arn edited this page May 7, 2026
·
1 revision
CrawlLama features a flexible plugin system that allows extending functionality through custom plugins. All plugins are hash-verified and allowlisted for security.
All plugins inherit from the Plugin base class and should be placed in the plugins/ directory.
from core.plugin_manager import Plugin, PluginMetadata
class MyPlugin(Plugin):
def get_metadata(self) -> PluginMetadata:
"""Returns plugin metadata including name, version, and author."""
pass
def initialize(self, config: Dict[str, Any]):
"""Initialize the plugin with configuration parameters."""
pass
def shutdown(self):
"""Cleanup logic executed when the plugin is unloaded."""
pass
def get_tools(self) -> List[Callable]:
"""Returns a list of tools to be registered with the agent."""
pass
def get_commands(self) -> Dict[str, Callable]:
"""Returns custom CLI commands."""
passExample: plugins/hello_plugin.py
import logging
from typing import Dict, Any, List, Callable
from core.plugin_manager import Plugin, PluginMetadata
logger = logging.getLogger("crawllama")
class HelloPlugin(Plugin):
def get_metadata(self) -> PluginMetadata:
return PluginMetadata(
name="HelloPlugin",
version="1.0.0",
description="Simple greeting plugin",
author="Developer",
dependencies=[]
)
def initialize(self, config: Dict[str, Any]):
self.greeting = config.get("greeting", "Hello")
logger.info("HelloPlugin initialized")
def get_tools(self) -> List[Callable]:
return [self.greet_tool]
def greet_tool(self, name: str) -> str:
"""Greeting tool for the agent."""
return f"{self.greeting}, {name}!"Compute the SHA256 hash of your plugin file:
sha256sum plugins/hello_plugin.pyAdd the plugin to your config.json:
{
"plugins": {
"hello_plugin": {
"enabled": true,
"sha256": "your_generated_hash_here",
"greeting": "Welcome"
}
}
}To protect the local environment, CrawlLama enforces the following:
-
Allowlisting: Plugins must be explicitly defined in
config.json. -
Hash Verification: The
sha256in the config must match the file on disk. - Explicit Loading: Plugins can be loaded or unloaded dynamically via CLI or API.
- Error Handling: Wrap tool logic in try-except blocks to prevent agent crashes.
-
Logging: Use the standard
crawllamalogger for consistent output. -
Resource Management: Implement the
shutdownmethod to close database connections or file handles. - Lazy Loading: Ensure heavy dependencies are only imported when the plugin is initialized.
CrawlLama Research Agent | GitHub Repository | Project Website Privacy-focused, local AI intelligence for the modern researcher.