5d60d33db1
Volledige Foodlinkk Command Center uitbreiding met social automatisering, reclamefolder filters, Proxmox monitoring en documentatie.
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""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
|