From 98ad890286537e7d0f1d17b7146423c12a003111 Mon Sep 17 00:00:00 2001 From: ochenstarik-ui Date: Mon, 20 Jul 2026 22:26:25 +0700 Subject: [PATCH] =?UTF-8?q?Phase=205.2+:=20per-agent=20usage=20=D0=BB?= =?UTF-8?q?=D0=B8=D0=BC=D0=B8=D1=82=D1=8B=20=D0=BD=D0=B0=20AgentCard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/models.py | 6 +++ frontend/src/components/agents/AgentCard.tsx | 47 ++++++++++++++++---- frontend/src/components/agents/AgentGrid.tsx | 10 +++-- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/backend/models.py b/backend/models.py index c7009a3..98c00a1 100644 --- a/backend/models.py +++ b/backend/models.py @@ -8,6 +8,12 @@ class Agent(BaseModel): runtime: str = "?" model: str = "?" healthy: bool = True + cpu: float = 0 + active_runs: int = 0 + tokens_used: int = 0 + tokens_limit: int = 100000 + budget_used: float = 0 + budget_limit: float = 50 class AgentUpdate(BaseModel): status: Literal["online", "offline", "busy"] diff --git a/frontend/src/components/agents/AgentCard.tsx b/frontend/src/components/agents/AgentCard.tsx index 62c9c03..493a36a 100644 --- a/frontend/src/components/agents/AgentCard.tsx +++ b/frontend/src/components/agents/AgentCard.tsx @@ -1,20 +1,24 @@ import { motion } from 'framer-motion' -import { Cpu, Activity, Zap } from 'lucide-react' -import { Badge } from '@/components/ui/badge' +import { Cpu, Activity, Zap, Wallet } from 'lucide-react' +import { Progress } from '@/components/ui/progress' export function AgentCard({ agent }: { agent: any }) { const statusColor = { online: 'bg-emerald-500', busy: 'bg-amber-500', offline: 'bg-zinc-500', - }[agent.status] || 'bg-zinc-500' + }[agent.status] || 'bg-emerald-500' + + const tokenPercent = Math.round((agent.tokens_used / agent.tokens_limit) * 100) + const budgetPercent = Math.round((agent.budget_used / agent.budget_limit) * 100) return ( -
+ {/* Header */} +
@@ -22,10 +26,11 @@ export function AgentCard({ agent }: { agent: any }) {
{agent.runtime} ยท {agent.model}
- {agent.status} +
{agent.status}
-
+ {/* Main metrics */} +
@@ -33,16 +38,42 @@ export function AgentCard({ agent }: { agent: any }) {
CPU %
-
-
{agent.activeRuns}
+
{agent.active_runs || agent.activeRuns}
RUNS
+ {/* Per-agent Usage Limits */} +
+
+
+ + Tokens + + + {agent.tokens_used?.toLocaleString()} / {agent.tokens_limit?.toLocaleString()} + +
+ +
+ +
+
+ + Budget + + + ${agent.budget_used} / ${agent.budget_limit} + +
+ +
+
+