SysOps: deploy-all — 2026-06-09 10:41 UTC
This commit is contained in:
@@ -10,7 +10,13 @@ def list_souls() -> list[dict[str, Any]]:
|
||||
rows = fetch_all(
|
||||
"""SELECT s.*,
|
||||
(SELECT COUNT(*) FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key) AS event_count,
|
||||
(SELECT MAX(created_at) FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key) AS last_event_at
|
||||
(SELECT MAX(created_at) FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key) AS last_event_at,
|
||||
(SELECT title FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key
|
||||
ORDER BY created_at DESC LIMIT 1) AS current_task,
|
||||
(SELECT status FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key
|
||||
ORDER BY created_at DESC LIMIT 1) AS current_status,
|
||||
(SELECT event_type FROM agent_events e WHERE LOWER(e.agent_name) = s.agent_key
|
||||
ORDER BY created_at DESC LIMIT 1) AS current_event_type
|
||||
FROM agent_souls s ORDER BY s.display_name"""
|
||||
)
|
||||
return [dict(r) for r in rows]
|
||||
@@ -25,13 +31,27 @@ def get_soul(agent_key: str) -> Optional[dict[str, Any]]:
|
||||
)
|
||||
if not row:
|
||||
return None
|
||||
events = fetch_all(
|
||||
"""SELECT id, event_type, title, status, created_at FROM agent_events
|
||||
WHERE LOWER(agent_name) = %s ORDER BY created_at DESC LIMIT 15""",
|
||||
(agent_key.lower(),),
|
||||
)
|
||||
out = dict(row)
|
||||
out["recent_events"] = [dict(e) for e in events]
|
||||
out["recent_events"] = list_agent_events(agent_key, limit=15)
|
||||
return out
|
||||
|
||||
|
||||
def list_agent_events(agent_key: str, limit: int = 50) -> list[dict[str, Any]]:
|
||||
rows = fetch_all(
|
||||
"""SELECT id, agent_name, event_type, title, body, status, channel, metadata, created_at, completed_at
|
||||
FROM agent_events
|
||||
WHERE LOWER(agent_name) = %s
|
||||
ORDER BY created_at DESC
|
||||
LIMIT %s""",
|
||||
(agent_key.lower(), limit),
|
||||
)
|
||||
out: list[dict[str, Any]] = []
|
||||
for row in rows:
|
||||
ev = dict(row)
|
||||
for key in ("created_at", "completed_at"):
|
||||
if ev.get(key) is not None and hasattr(ev[key], "isoformat"):
|
||||
ev[key] = ev[key].isoformat()
|
||||
out.append(ev)
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user