semantics
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Any, Optional
|
||||
from .logger import belief_scope
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# #region PluginBase [TYPE Class] [SEMANTICS plugin, interface, base, abstract]
|
||||
# @BRIEF Defines the abstract base class that all plugins must implement to be recognized by the system. It enforces a common structure for plugin metadata and execution.
|
||||
# @LAYER: Core
|
||||
@@ -14,10 +12,9 @@ class PluginBase(ABC):
|
||||
Base class for all plugins.
|
||||
Plugins must inherit from this class and implement the abstract methods.
|
||||
"""
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
# [DEF:id:Function]
|
||||
# #region id [TYPE Function]
|
||||
# @PURPOSE: Returns the unique identifier for the plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string ID.
|
||||
@@ -26,11 +23,10 @@ class PluginBase(ABC):
|
||||
"""A unique identifier for the plugin."""
|
||||
with belief_scope("id"):
|
||||
pass
|
||||
# [/DEF:id:Function]
|
||||
|
||||
# #endregion id
|
||||
@property
|
||||
@abstractmethod
|
||||
# [DEF:name:Function]
|
||||
# #region name [TYPE Function]
|
||||
# @PURPOSE: Returns the human-readable name of the plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string name.
|
||||
@@ -39,11 +35,10 @@ class PluginBase(ABC):
|
||||
"""A human-readable name for the plugin."""
|
||||
with belief_scope("name"):
|
||||
pass
|
||||
# [/DEF:name:Function]
|
||||
|
||||
# #endregion name
|
||||
@property
|
||||
@abstractmethod
|
||||
# [DEF:description:Function]
|
||||
# #region description [TYPE Function]
|
||||
# @PURPOSE: Returns a brief description of the plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string description.
|
||||
@@ -52,11 +47,10 @@ class PluginBase(ABC):
|
||||
"""A brief description of what the plugin does."""
|
||||
with belief_scope("description"):
|
||||
pass
|
||||
# [/DEF:description:Function]
|
||||
|
||||
# #endregion description
|
||||
@property
|
||||
@abstractmethod
|
||||
# [DEF:version:Function]
|
||||
# #region version [TYPE Function]
|
||||
# @PURPOSE: Returns the version of the plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string version.
|
||||
@@ -65,10 +59,9 @@ class PluginBase(ABC):
|
||||
"""The version of the plugin."""
|
||||
with belief_scope("version"):
|
||||
pass
|
||||
# [/DEF:version:Function]
|
||||
|
||||
# #endregion version
|
||||
@property
|
||||
# [DEF:required_permission:Function]
|
||||
# #region required_permission [TYPE Function]
|
||||
# @PURPOSE: Returns the required permission string to execute this plugin.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string permission.
|
||||
@@ -77,10 +70,9 @@ class PluginBase(ABC):
|
||||
"""The permission string required to execute this plugin."""
|
||||
with belief_scope("required_permission"):
|
||||
return f"plugin:{self.id}:execute"
|
||||
# [/DEF:required_permission:Function]
|
||||
|
||||
# #endregion required_permission
|
||||
@property
|
||||
# [DEF:ui_route:Function]
|
||||
# #region ui_route [TYPE Function]
|
||||
# @PURPOSE: Returns the frontend route for the plugin's UI, if applicable.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns string route or None.
|
||||
@@ -92,10 +84,9 @@ class PluginBase(ABC):
|
||||
"""
|
||||
with belief_scope("ui_route"):
|
||||
return None
|
||||
# [/DEF:ui_route:Function]
|
||||
|
||||
# #endregion ui_route
|
||||
@abstractmethod
|
||||
# [DEF:get_schema:Function]
|
||||
# #region get_schema [TYPE Function]
|
||||
# @PURPOSE: Returns the JSON schema for the plugin's input parameters.
|
||||
# @PRE: Plugin instance exists.
|
||||
# @POST: Returns dict schema.
|
||||
@@ -107,10 +98,9 @@ class PluginBase(ABC):
|
||||
"""
|
||||
with belief_scope("get_schema"):
|
||||
pass
|
||||
# [/DEF:get_schema:Function]
|
||||
|
||||
# #endregion get_schema
|
||||
@abstractmethod
|
||||
# [DEF:execute:Function]
|
||||
# #region execute [TYPE Function]
|
||||
# @PURPOSE: Executes the plugin's core logic.
|
||||
# @PARAM: params (Dict[str, Any]) - Validated input parameters.
|
||||
# @PRE: params must be a dictionary.
|
||||
@@ -123,9 +113,8 @@ class PluginBase(ABC):
|
||||
The `params` argument will be validated against the schema returned by `get_schema()`.
|
||||
"""
|
||||
pass
|
||||
# [/DEF:execute:Function]
|
||||
# #endregion execute
|
||||
# #endregion PluginBase
|
||||
|
||||
# #region PluginConfig [TYPE Class] [SEMANTICS plugin, config, schema, pydantic]
|
||||
# @BRIEF A Pydantic model used to represent the validated configuration and metadata of a loaded plugin. This object is what gets exposed to the API layer.
|
||||
# @LAYER: Core
|
||||
|
||||
Reference in New Issue
Block a user