mindroot.lib.plugins package¶
Submodules¶
mindroot.lib.plugins.installation module¶
- mindroot.lib.plugins.installation.check_plugin_dependencies(plugin_path)[source]¶
Check if all plugin dependencies are met.
- Parameters:
plugin_path (str) – Path to plugin directory
- Returns:
True if all dependencies are met
- Return type:
bool
- mindroot.lib.plugins.installation.download_github_files(repo_path, tag=None)[source]¶
Download GitHub repo files to temp directory.
- Parameters:
repo_path (str) – GitHub repository path (user/repo)
tag (str, optional) – Specific tag to download
- Returns:
(plugin_dir, plugin_root, plugin_info)
- Return type:
tuple
- mindroot.lib.plugins.installation.install_plugin_dependencies(plugin_path)[source]¶
Install plugin dependencies from requirements.txt.
- Parameters:
plugin_path (str) – Path to plugin directory
- Returns:
True if installation successful
- Return type:
bool
- async mindroot.lib.plugins.installation.install_recommended_plugins(agent_name, context=None)[source]¶
Install plugins recommended for an agent based on its required_plugins list.
- Parameters:
agent_name (str) – Name of the agent
- Returns:
Results of plugin installation
- Return type:
dict
- async mindroot.lib.plugins.installation.plugin_install(plugin_name, source='pypi', source_path=None, remote_source=None)[source]¶
Install a plugin from various sources.
- Parameters:
plugin_name (str) – Name of the plugin
source (str) – Installation source (‘pypi’, ‘local’, ‘github’)
source_path (str, optional) – Path or GitHub repo reference
remote_source (str, optional) – Remote source for the plugin (e.g., GitHub repo path)
- Returns:
True if installation successful
- Return type:
bool
mindroot.lib.plugins.l8n_static_handler module¶
- class mindroot.lib.plugins.l8n_static_handler.TranslatedStaticFiles(*, directory: str, plugin_name: str = None, **kwargs)[source]¶
Bases:
StaticFilesCustom StaticFiles handler that applies l8n translations to JavaScript files.
- apply_translations_to_js(content: str, language: str, file_path: str) str[source]¶
Apply translations to JavaScript content.
This looks for __TRANSLATE_key__ placeholders in JS files and replaces them with translated strings. If translations are missing, returns None to signal that the original file should be served instead.
- mindroot.lib.plugins.l8n_static_handler.create_js_translation_object(translations: dict) str[source]¶
Create a JavaScript object containing translations.
This can be injected into JS files to provide client-side translation support.
- Parameters:
translations – Dictionary of translation key-value pairs
- Returns:
JavaScript code defining a translation object
- mindroot.lib.plugins.l8n_static_handler.inject_translations_into_js(content: str, translations: dict) str[source]¶
Inject translation object into JavaScript content.
This prepends translation definitions to JS files.
- Parameters:
content – Original JavaScript content
translations – Translation dictionary
- Returns:
JavaScript content with translations injected
- mindroot.lib.plugins.l8n_static_handler.mount_translated_static_files(app, plugin_name: str, category: str)[source]¶
Mount plugin static files with translation support.
- Parameters:
app (FastAPI) – The FastAPI application instance
plugin_name (str) – Name of the plugin
category (str) – Plugin category (‘core’ or ‘installed’)
mindroot.lib.plugins.loader module¶
- async mindroot.lib.plugins.loader.load(app=None)[source]¶
Load all enabled plugins with l8n translation support.
- Parameters:
app (FastAPI, optional) – The FastAPI application instance
- Raises:
Exception – If no FastAPI instance is provided or found
- mindroot.lib.plugins.loader.load_middleware(app, plugin_name, plugin_path, category)[source]¶
Load plugin middleware if it exists.
- Parameters:
app (FastAPI) – The FastAPI application instance
plugin_name (str) – Name of the plugin
plugin_path (str) – Import path of the plugin
- mindroot.lib.plugins.loader.mount_static_files(app, plugin_name, category)[source]¶
Mount plugin static files with translation support if available.
- Parameters:
app (FastAPI) – The FastAPI application instance
plugin_name (str) – Name of the plugin
category (str) – Plugin category (‘core’ or ‘installed’)
mindroot.lib.plugins.loader_with_l8n module¶
- async mindroot.lib.plugins.loader_with_l8n.load(app=None)[source]¶
Load all enabled plugins with l8n translation support.
- Parameters:
app (FastAPI, optional) – The FastAPI application instance
- Raises:
Exception – If no FastAPI instance is provided or found
- mindroot.lib.plugins.loader_with_l8n.load_middleware(app, plugin_name, plugin_path, category)[source]¶
Load plugin middleware if it exists.
- Parameters:
app (FastAPI) – The FastAPI application instance
plugin_name (str) – Name of the plugin
plugin_path (str) – Import path of the plugin
- mindroot.lib.plugins.loader_with_l8n.mount_static_files(app, plugin_name, category)[source]¶
Mount plugin static files with translation support if available.
- Parameters:
app (FastAPI) – The FastAPI application instance
plugin_name (str) – Name of the plugin
category (str) – Plugin category (‘core’ or ‘installed’)
mindroot.lib.plugins.manifest module¶
- mindroot.lib.plugins.manifest.create_default_plugin_manifest()[source]¶
Create a new default manifest file.
This function first attempts migration, then creates from default template if needed.
- mindroot.lib.plugins.manifest.list_enabled(include_category=True)[source]¶
List all enabled plugins.
- Parameters:
include_category (bool) – Whether to include the category in results
- Returns:
List of enabled plugins, optionally with categories
- Return type:
list
- mindroot.lib.plugins.manifest.load_plugin_manifest()[source]¶
Load the plugin manifest file.
- Returns:
The manifest data structure
- Return type:
dict
- mindroot.lib.plugins.manifest.save_plugin_manifest(manifest)[source]¶
Save the plugin manifest file.
- Parameters:
manifest (dict) – The manifest data structure to save
- mindroot.lib.plugins.manifest.toggle_plugin_state(plugin_name, enabled)[source]¶
Toggle a plugin’s enabled state.
- Parameters:
plugin_name (str) – Name of the plugin
enabled (bool) – New enabled state
- Returns:
True if successful, False if plugin not found
- Return type:
bool
- mindroot.lib.plugins.manifest.update_plugin_manifest(plugin_name, source, source_path, remote_source=None, version='0.0.1', metadata=None)[source]¶
Update or add a plugin entry in the manifest.
- Parameters:
plugin_name (str) – Name of the plugin
source (str) – Source type (‘core’, ‘local’, ‘github’)
source_path (str) – Path to the plugin
remote_source (str, optional) – GitHub repository reference
version (str, optional) – Plugin version
metadata (dict, optional) – Plugin metadata including commands and services
mindroot.lib.plugins.mapping module¶
mindroot.lib.plugins.paths module¶
Module contents¶
Plugin system for managing, installing, and loading plugins.
This module provides the main interface for the plugin system, including: - Plugin installation and updates - Plugin loading and initialization - Manifest management - Path resolution
- Typical usage:
from lib.plugins import load, plugin_install, toggle_plugin_state
# Install a plugin plugin_install(‘my-plugin’, source=’github’, source_path=’user/repo’)
# Load plugins in FastAPI app await load(app)
- mindroot.lib.plugins.check_plugin_dependencies(plugin_path)[source]¶
Check if all plugin dependencies are met.
- Parameters:
plugin_path (str) – Path to plugin directory
- Returns:
True if all dependencies are met
- Return type:
bool
- mindroot.lib.plugins.get_plugin_import_path(plugin_name)[source]¶
Get the Python import path for a plugin.
- Parameters:
plugin_name (str) – Name of the plugin
- Returns:
Import path for the plugin or None if not found
- Return type:
str
- mindroot.lib.plugins.get_plugin_path(plugin_name)[source]¶
Get the filesystem path for a plugin.
- Parameters:
plugin_name (str) – Name of the plugin
- Returns:
Absolute path to the plugin directory or None if not found
- Return type:
str
- mindroot.lib.plugins.install_plugin_dependencies(plugin_path)[source]¶
Install plugin dependencies from requirements.txt.
- Parameters:
plugin_path (str) – Path to plugin directory
- Returns:
True if installation successful
- Return type:
bool
- mindroot.lib.plugins.list_enabled(include_category=True)[source]¶
List all enabled plugins.
- Parameters:
include_category (bool) – Whether to include the category in results
- Returns:
List of enabled plugins, optionally with categories
- Return type:
list
- async mindroot.lib.plugins.load(app=None)[source]¶
Load all enabled plugins with l8n translation support.
- Parameters:
app (FastAPI, optional) – The FastAPI application instance
- Raises:
Exception – If no FastAPI instance is provided or found
- mindroot.lib.plugins.load_plugin_manifest()[source]¶
Load the plugin manifest file.
- Returns:
The manifest data structure
- Return type:
dict
- async mindroot.lib.plugins.plugin_install(plugin_name, source='pypi', source_path=None, remote_source=None)[source]¶
Install a plugin from various sources.
- Parameters:
plugin_name (str) – Name of the plugin
source (str) – Installation source (‘pypi’, ‘local’, ‘github’)
source_path (str, optional) – Path or GitHub repo reference
remote_source (str, optional) – Remote source for the plugin (e.g., GitHub repo path)
- Returns:
True if installation successful
- Return type:
bool
- mindroot.lib.plugins.plugin_update(plugin_name)[source]¶
Update an installed plugin.
- Parameters:
plugin_name (str) – Name of the plugin to update
- Returns:
True if update successful
- Return type:
bool
- mindroot.lib.plugins.save_plugin_manifest(manifest)[source]¶
Save the plugin manifest file.
- Parameters:
manifest (dict) – The manifest data structure to save
- mindroot.lib.plugins.toggle_plugin_state(plugin_name, enabled)[source]¶
Toggle a plugin’s enabled state.
- Parameters:
plugin_name (str) – Name of the plugin
enabled (bool) – New enabled state
- Returns:
True if successful, False if plugin not found
- Return type:
bool
- mindroot.lib.plugins.update_plugin_manifest(plugin_name, source, source_path, remote_source=None, version='0.0.1', metadata=None)[source]¶
Update or add a plugin entry in the manifest.
- Parameters:
plugin_name (str) – Name of the plugin
source (str) – Source type (‘core’, ‘local’, ‘github’)
source_path (str) – Path to the plugin
remote_source (str, optional) – GitHub repository reference
version (str, optional) – Plugin version
metadata (dict, optional) – Plugin metadata including commands and services