2026-08-04 15:06:23 +02:00
|
|
|
"""Agent Memory plugin — persistent agent memory with pgvector semantic search."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from app.plugins.base import BasePlugin
|
2026-09-13 19:45:18 +02:00
|
|
|
from app.plugins.manifest import (
|
|
|
|
|
FrontendMenuItem,
|
|
|
|
|
FrontendPageRoute,
|
|
|
|
|
PluginManifest,
|
|
|
|
|
PluginRouteDef,
|
|
|
|
|
)
|
2026-08-04 15:06:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AgentMemoryPlugin(BasePlugin):
|
|
|
|
|
"""Agent Memory plugin for persistent agent memory with semantic search."""
|
|
|
|
|
|
|
|
|
|
manifest = PluginManifest(
|
|
|
|
|
name="agent_memory",
|
|
|
|
|
version="1.0.0",
|
|
|
|
|
display_name="Agent Memory",
|
|
|
|
|
description="Persistent agent memory with pgvector semantic search. Stores facts, context, patterns, and instructions for AI agents.",
|
|
|
|
|
dependencies=["unified_search"],
|
|
|
|
|
routes=[
|
|
|
|
|
PluginRouteDef(
|
|
|
|
|
path="/api/v1/agent-memory",
|
|
|
|
|
module="app.plugins.builtins.agent_memory.routes",
|
|
|
|
|
router_attr="router",
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
events=[],
|
|
|
|
|
migrations=["0001_initial.sql"],
|
|
|
|
|
permissions=[
|
|
|
|
|
"agent_memory:read",
|
|
|
|
|
"agent_memory:write",
|
|
|
|
|
],
|
2026-09-13 19:45:18 +02:00
|
|
|
# UI-Backlog Modul 8 (2026-09-13): agent memory page, registered
|
|
|
|
|
# via the manifest (Phase Q pattern).
|
|
|
|
|
menu_items=[
|
|
|
|
|
FrontendMenuItem(
|
|
|
|
|
label_key="nav.agentMemory",
|
|
|
|
|
label="Agent Memory",
|
|
|
|
|
path="/agent-memory",
|
|
|
|
|
icon="Brain",
|
|
|
|
|
order=86,
|
|
|
|
|
permission="agent_memory:read",
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
page_routes=[
|
|
|
|
|
FrontendPageRoute(
|
|
|
|
|
path="/agent-memory",
|
|
|
|
|
component="@/pages/AgentMemory",
|
|
|
|
|
protected=True,
|
|
|
|
|
permission="agent_memory:read",
|
|
|
|
|
),
|
|
|
|
|
],
|
2026-08-04 15:06:23 +02:00
|
|
|
is_core=True,
|
|
|
|
|
author="LeoCRM Team",
|
|
|
|
|
min_app_version="1.0.0",
|
|
|
|
|
contract_version="1.0.0",
|
|
|
|
|
)
|
|
|
|
|
|
2026-08-16 01:17:18 +02:00
|
|
|
def get_entity_models(self) -> dict[str, type]:
|
|
|
|
|
from app.plugins.builtins.agent_memory.models import AgentMemory
|
|
|
|
|
return {"agent_memory": AgentMemory}
|
|
|
|
|
|
2026-08-04 15:06:23 +02:00
|
|
|
async def on_deactivate(self, db, service_container, event_bus) -> None:
|
|
|
|
|
"""Deactivate plugin: unregister contract and event listeners."""
|
|
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
|
|
|
|
get_contract_registry().unregister(self.manifest.name)
|
|
|
|
|
await super().on_deactivate(db, service_container, event_bus)
|