53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""Unified AIOS operations command center view model."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from typing import Any
|
|
|
|
|
|
def utc_now() -> str:
|
|
return datetime.now(timezone.utc).isoformat()
|
|
|
|
|
|
class OperationsCommandCenter:
|
|
def build(
|
|
self,
|
|
tasks: list[dict[str, Any]] | None = None,
|
|
health: dict[str, Any] | None = None,
|
|
blockers: list[dict[str, Any]] | None = None,
|
|
searches: list[dict[str, Any]] | None = None,
|
|
) -> dict[str, Any]:
|
|
tasks = tasks or []
|
|
blockers = blockers or []
|
|
searches = searches or []
|
|
return {
|
|
"module": "operations-command-center",
|
|
"route": "/admin/ai-evolution/operations",
|
|
"title": "AIOS 自治运营驾驶舱",
|
|
"generated_at": utc_now(),
|
|
"health": health or {},
|
|
"tasks": {
|
|
"active": len([t for t in tasks if t.get("status") in {"running", "pending", "waiting_approval"}]),
|
|
"blocked": len([t for t in tasks if t.get("status") == "blocked"]),
|
|
"completed": len([t for t in tasks if t.get("status") == "completed"]),
|
|
},
|
|
"blockers": {
|
|
"total": len(blockers),
|
|
"p0": len([b for b in blockers if b.get("severity") in {"p0", "critical"}]),
|
|
"recurring": len([b for b in blockers if b.get("mechanism_gap")]),
|
|
},
|
|
"search": {
|
|
"recent": len(searches),
|
|
},
|
|
"loops": {
|
|
"task_loop": True,
|
|
"health_loop": True,
|
|
"optimization_loop": True,
|
|
"notification_loop": True,
|
|
},
|
|
}
|
|
|
|
|
|
__all__ = ["OperationsCommandCenter"]
|