namespace ControlCenter; /// /// Agent operational status derived from OpenClaw Gateway session activity. /// Maps to the frontend AgentStatus type: 'active' | 'idle' | 'thinking' | 'error'. /// public enum AgentStatus { /// Agent is currently processing a turn. Active, /// Agent completed its last turn; no active work. Idle, /// LLM call in flight; tokens streaming. Thinking, /// Agent encountered an unhandled error. Error } /// /// Extended lifecycle status including offline — not all agents have active sessions. /// Used internally; clients only see (offline maps to idle). /// public enum AgentLifecycleStatus { Active, Idle, Thinking, Error, Offline } /// /// Pushed to SignalR clients when an agent's status changes. /// Matches the TypeScript AgentStatusUpdate interface from the design spec. /// /// Agent identifier, e.g. "otto", "dex". /// Human-readable name, e.g. "Otto". /// Role description, e.g. "Orchestrator Agent". /// Current operational status. /// Description of the current task, if any. /// Full session key, e.g. "agent:otto:telegram:direct:8787451565". /// Channel the agent is operating on, e.g. "telegram". /// ISO 8601 timestamp of last activity. /// Error message when status is 'error'. public record AgentStatusUpdate( string AgentId, string DisplayName, string Role, string Status, string? CurrentTask, string SessionKey, string Channel, string LastActivity, string? ErrorMessage = null ); /// /// Pushed to SignalR clients when an agent's task progress updates. /// Matches the TypeScript TaskProgressUpdate interface from the design spec. /// /// Agent identifier. /// Description of the current task. /// Task progress percentage (0–100), if trackable. /// Elapsed time string, e.g. "04m 12s". public record TaskProgressUpdate( string AgentId, string TaskDescription, int? Progress, string? Elapsed ); /// /// Data transfer object for broadcasting agent status updates /// to all connected SignalR clients via the hub's SendStatusUpdate method. /// /// This DTO provides a mutable, serialization-friendly alternative to /// for callers that construct updates /// from external data sources (e.g., HTTP API payloads). /// public class AgentStatusUpdateDto { /// /// Agent identifier, e.g. "otto", "dex", "rex". /// public string AgentId { get; set; } = string.Empty; /// /// Human-readable display name, e.g. "Otto", "Dex". /// public string DisplayName { get; set; } = string.Empty; /// /// Role description, e.g. "Orchestrator Agent", "Backend Specialist". /// public string Role { get; set; } = string.Empty; /// /// Current operational status of the agent as lowercase string: /// "active", "idle", "thinking", "error". /// public string Status { get; set; } = string.Empty; /// /// Description of the agent's current task, if any. /// public string? CurrentTask { get; set; } /// /// Full session key, e.g. "agent:otto:telegram:direct:8787451565". /// public string SessionKey { get; set; } = string.Empty; /// /// Communication channel, e.g. "telegram", "discord", "slack". /// public string Channel { get; set; } = string.Empty; /// /// ISO 8601 timestamp of the agent's last activity. /// public string LastActivity { get; set; } = string.Empty; /// /// Error message when the agent status is "error". /// public string? ErrorMessage { get; set; } /// /// Converts this DTO to an immutable record /// for use with the typed SignalR client interface. /// /// An with equivalent field values. public AgentStatusUpdate ToUpdate() => new( AgentId, DisplayName, Role, Status, CurrentTask, SessionKey, Channel, LastActivity, ErrorMessage ); } /// /// Snapshot of an agent's full card data, sent on initial connection /// or when the fleet state is requested. /// Matches the TypeScript AgentCardData interface from the design spec. /// public record AgentCardData( string Id, string DisplayName, string Role, string Status, string? CurrentTask, int? TaskProgress, string? TaskElapsed, string SessionKey, string Channel, string LastActivity, string? ErrorMessage );