refactor(b2): eliminate all cross-plugin imports - contracts for worker/agent_runner/workstream, declared dependency for wiki
Check Cross-Plugin Imports / check (push) Has been cancelled

This commit is contained in:
Agent Zero
2026-08-23 20:29:09 +02:00
parent 4038b74025
commit 7467c01d38
5 changed files with 25 additions and 30 deletions
+10 -19
View File
@@ -110,9 +110,9 @@ async def run_agent(
try:
from app.plugins.builtins.contracts import get_contract
mail_contract = get_contract("mail")
if mail_contract and hasattr(mail_contract, "get_recent_mails"):
if mail_contract and hasattr(mail_contract, "Mail"):
from sqlalchemy import select as _select
from app.plugins.builtins.mail.models import Mail
Mail = mail_contract.Mail
async with factory() as db:
mail_q = await db.execute(
_select(Mail)
@@ -379,23 +379,16 @@ async def run_agent(
komm = get_contract_registry().get("kommunikation")
if komm:
async with factory() as db:
# Find or create agent conversation room
from app.plugins.builtins.contracts import get_contract as _get_contract
_komm_contract = _get_contract("kommunikation")
from app.plugins.builtins.kommunikation.models import CommConversation
from sqlalchemy import select as sa_select
# Find or create agent conversation room via contract
# (find_locked_room_id matches create_plugin_room semantics)
room_title = f"Agent: {agent.name}"
existing = await db.execute(
sa_select(CommConversation).where(
CommConversation.tenant_id == agent.tenant_id,
CommConversation.title == room_title,
CommConversation.is_locked.is_(True),
CommConversation.locked_by == "automation",
CommConversation.deleted_at.is_(None),
)
conv_id = await komm.find_locked_room_id(
db=db,
tenant_id=agent.tenant_id,
plugin_name="automation",
title=room_title,
)
conv = existing.scalar_one_or_none()
if not conv:
if not conv_id:
room = await komm.create_plugin_room(
db=db,
tenant_id=agent.tenant_id,
@@ -405,8 +398,6 @@ async def run_agent(
participant_type="agent",
)
conv_id = uuid.UUID(room["conversation_id"])
else:
conv_id = conv.id
# Post result as message with action_card block
status = result_data.get("status", "unknown")