import type { AgentInfo } from './agent'

export interface RuntimeStatus {
  runtime: string
  status: 'Online' | 'Degraded' | 'Offline' | 'Unknown'
  latency?: string
  detail?: string
}

export interface ModelStatus {
  provider: string
  model: string
  status: 'Online' | 'Degraded' | 'Offline' | 'Unknown'
  isLocal: boolean
  detail?: string
}

export interface ProjectHealth {
  online: number
  offline: number
  degraded: number
  unknown: number
}

export interface IncidentInfo {
  taskId?: string
  title?: string
  since?: string
}

export interface RoutingTarget {
  priority: number
  provider: string
  model: string
  purpose: string
  status: 'Online' | 'Degraded' | 'Offline' | 'Unknown'
  detail: string
}

export type TaskState = 'Backlog' | 'In progress' | 'Blocked' | 'Done'
export const TASK_STATES: TaskState[] = ['Backlog', 'In progress', 'Blocked', 'Done']

export interface OperationsSnapshot {
  generatedAt: string
  runtime: RuntimeStatus
  models: ModelStatus[]
  metrics: {
    activeAgents: number
    queuedTasks: number
    successRate: number
    incidents: number
    runtimeHealthy?: boolean
    lastIncident?: IncidentInfo
  }
  projectHealth?: ProjectHealth
  agents?: AgentInfo[]
  projects: Array<{ id: string; name: string; status: string; progress: number; updatedAt?: string }>
  tasks: Array<{
    id: string
    title: string
    state: TaskState
    priority: string
    projectId?: string | null
    updatedAt: string
  }>
  activity: Array<{ id?: number; type: string; message: string; at: string }>
}
