import type { Agent } from '../types';

/** Dashboard WebSocket payloads — keep in sync with server/internal/api/ws_types.go */
export interface WSDashboardInit {
  agents: Agent[];
}

export interface WSAgentOffline {
  agent_id: string;
}

export interface WSStatsUpdate {
  agent_id: string;
  hashrate_15s: number;
  hashrate_1m: number;
  hashrate_15m: number;
  cpu_usage_pct: number;
  memory_usage_pct?: number;
  uptime_seconds?: number;
  shares_submitted?: number;
  shares_accepted?: number;
}

export interface WSCommandResult {
  agent_id?: string;
  action?: string;
  success?: boolean;
  message?: string;
}

export interface WSAgentLog {
  agent_id: string;
  content: string;
}

export interface WSServerLog {
  line: string;
}

export type WSPayload =
  | WSDashboardInit
  | Agent
  | WSAgentOffline
  | WSStatsUpdate
  | import('../types').Share
  | import('../types').FleetAlert
  | import('../types').PoolStatus[]
  | import('../types').AIActivityEntry
  | WSCommandResult
  | WSAgentLog
  | WSServerLog;

export interface WSMessageTyped<T extends string = string> {
  type: T;
  payload: WSPayload;
}
