Base types for the Mellea plugin system.Documentation Index
Fetch the complete documentation index at: https://docs.mellea.ai/llms.txt
Use this file to discover all available pages before exploring further.
Classes
CLASS PluginMeta
Metadata attached to Plugin subclasses.
Args:
name: Unique identifier for the plugin.priority: Execution priority — lower numbers execute first.
CLASS Plugin
Base class for multi-hook Mellea plugins.
Subclasses get automatic context-manager support and plugin metadata::
class PIIRedactor(Plugin, name=“pii-redactor”, priority=5):
@hook(HookType.COMPONENT_PRE_EXECUTE, mode=PluginMode.SEQUENTIAL)
async def redact_input(self, payload, ctx):
…
with PIIRedactor():
result = session.instruct(”…”)
CLASS PluginViolationError
Raised when a plugin blocks execution in enforce mode.
Args:
hook_type: The hook point where the violation occurred.reason: Human-readable reason for the violation.code: Machine-readable violation code.plugin_name: Name of the plugin that raised the violation.
CLASS MelleaBasePayload
Frozen base — all payloads are immutable by design.
Plugins must use model_copy(update=\{...\}) to propose modifications
and return the copy via PluginResult.modified_payload. The plugin
manager applies the hook’s HookPayloadPolicy to filter changes to
writable fields only.
CLASS MelleaPlugin
Base class for Mellea plugins with lifecycle hooks and typed accessors.
Use this when you need lifecycle hooks (initialize/shutdown)
or typed context accessors. For simpler plugins, prefer @hook
on standalone functions or @plugin on plain classes.
Instances support the context manager protocol for temporary activation::
class MyPlugin(MelleaPlugin):
def init(self):
super().init(PluginConfig(name=“my-plugin”, hooks=[…]))
async def some_hook(self, payload, ctx):
…
with MyPlugin() as p:
result, ctx = instruct(”…”, ctx, backend)
or async
async with MyPlugin() as p: result, ctx = await ainstruct(”…”, ctx, backend) Methods:FUNC get_backend
context: The plugin context provided by the hook framework.
- The active Backend, or
Noneif unavailable.
FUNC get_mellea_context
context: The plugin context provided by the hook framework.
- The active Mellea Context, or
Noneif unavailable.
FUNC get_session
context: The plugin context provided by the hook framework.
- The active MelleaSession, or
Noneif unavailable.