feat: F-PREBUILT + F-COMM + F-WORK + G-WORK — prebuilt agents registered, agent results posted to communication, workflow results posted to communication
Check Cross-Plugin Imports / check (push) Has been cancelled

This commit is contained in:
Agent Zero
2026-08-20 21:09:41 +02:00
parent 404e085ebd
commit 864824d8cd
3 changed files with 164 additions and 0 deletions
+42
View File
@@ -232,6 +232,48 @@ class AutomationPlugin(BasePlugin):
logger.info("Registered own cron jobs from manifest")
except Exception:
logger.exception("Failed to register own cron jobs")
# Register pre-built agents in DB (if not already present)
try:
from app.plugins.builtins.automation.models import AgentDefinition
from app.plugins.builtins.automation.prebuilt.email_triage_agent import create_email_triage_agent
from app.plugins.builtins.automation.prebuilt.contact_enrichment_agent import create_contact_enrichment_agent
from app.plugins.builtins.automation.prebuilt.follow_up_agent import create_follow_up_agent
from app.plugins.builtins.automation.prebuilt.report_agent import create_report_agent
from sqlalchemy import select as sa_select
# Get first tenant + admin user for seeding
from app.models.user import User, Tenant
tenant_result = await db.execute(sa_select(Tenant).limit(1))
tenant = tenant_result.scalar_one_or_none()
if tenant:
user_result = await db.execute(
sa_select(User).where(User.tenant_id == tenant.id).limit(1)
)
user = user_result.scalar_one_or_none()
if user:
prebuilt_factories = [
("E-Mail-Triage-Agent", create_email_triage_agent),
("Kontakt-Anreicherungs-Agent", create_contact_enrichment_agent),
("Follow-Up-Agent", create_follow_up_agent),
("Berichts-Agent", create_report_agent),
]
for agent_name, factory in prebuilt_factories:
# Check if agent already exists
existing = await db.execute(
sa_select(AgentDefinition).where(
AgentDefinition.tenant_id == tenant.id,
AgentDefinition.name == agent_name,
)
)
if not existing.scalar_one_or_none():
agent = factory(tenant_id=tenant.id, user_id=user.id)
db.add(agent)
logger.info("Registered pre-built agent '%s'", agent_name)
await db.commit()
logger.info("Pre-built agents registration complete")
except Exception:
logger.exception("Failed to register pre-built agents")
logger.info("Automation plugin activated")
async def on_deactivate(self, db, service_container, event_bus) -> None: