Platform bundle: marketing publish, IT ops, packaging, agents mesh.
Volledige Foodlinkk Command Center uitbreiding met social automatisering, reclamefolder filters, Proxmox monitoring en documentatie.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Agent event logging helpers used by the Tools API."""
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from app.db import execute_returning, json_param
|
||||
|
||||
|
||||
def log_agent_event(
|
||||
*,
|
||||
agent_name: str,
|
||||
event_type: str,
|
||||
title: str,
|
||||
body: Optional[str] = None,
|
||||
agent_type: str = "openswarm",
|
||||
metadata: Optional[dict[str, Any]] = None,
|
||||
status: str = "completed",
|
||||
related_table: Optional[str] = None,
|
||||
related_id: Optional[int] = None,
|
||||
channel: str = "dashboard",
|
||||
) -> dict[str, Any]:
|
||||
row = execute_returning(
|
||||
"""
|
||||
INSERT INTO agent_events (
|
||||
agent_name, agent_type, event_type, title, body, metadata,
|
||||
status, related_table, related_id, channel
|
||||
)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
RETURNING *
|
||||
""",
|
||||
(
|
||||
agent_name,
|
||||
agent_type,
|
||||
event_type,
|
||||
title,
|
||||
body,
|
||||
json_param(metadata),
|
||||
status,
|
||||
related_table,
|
||||
related_id,
|
||||
channel,
|
||||
),
|
||||
)
|
||||
if row is None:
|
||||
raise RuntimeError("Failed to insert agent event")
|
||||
return row
|
||||
Reference in New Issue
Block a user