export const PROTOCOL_VERSION = '1.0'

export interface Event<T = unknown> {
  type: string
  timestamp: number
  deviceId: string
  sessionId: string
  payload: T
}

export const EventTypes = {
  Logcat: 'logcat',
  NetworkRequest: 'network.request',
  NetworkResponse: 'network.response',
  PrefsUpdate: 'prefs.update',
  FileList: 'file.list',
  DeviceInfo: 'device.info',
} as const

export interface LogcatPayload {
  tag: string
  priority: 'V' | 'D' | 'I' | 'W' | 'E' | 'A'
  message: string
  pid: number
}

export interface NetworkRequestPayload {
  requestId: string
  url: string
  method: string
  headers: Record<string, string>
  body?: string
}

export interface NetworkResponsePayload {
  requestId: string
  statusCode: number
  headers: Record<string, string>
  body?: string
  size: number
  durationMs: number
}

export interface PrefsUpdatePayload {
  file: string
  prefs: Record<string, string>
}

export interface DeviceInfoPayload {
  manufacturer: string
  model: string
  androidVersion: string
  abi: string
  ram: number
}
