export type SessionCloseReason =
  | 'idle_timeout' | 'duration_cap' | 'host_disconnect' | 'maintenance'
  | 'admin_kill' | 'connection_change' | 'session_cap_evict' | 'worker_shutdown';

export type AttachMessage = {
  type: 'attach';
  acting_user_id: string;
  can_write: boolean;
  connection_id: string;
  cols: number;
  rows: number;
};
export type ReplayBeginMessage = { type: 'replay_begin'; bytes: number };
export type ReplayEndMessage = { type: 'replay_end' };
export type NoticeMessage = { type: 'notice'; severity: 'info' | 'warn' | 'error'; msg: string };
export type CloseMessage = { type: 'close'; reason: SessionCloseReason };
export type ResizeMessage = { type: 'resize'; cols: number; rows: number };

export type ServerTextMessage = AttachMessage | ReplayBeginMessage | ReplayEndMessage | NoticeMessage | CloseMessage;
export type ClientTextMessage = ResizeMessage;

export interface ConsoleStatus {
  active: boolean;
  connection_id?: string;
  started_at?: string;
  last_activity_at?: string;
  cols?: number;
  rows?: number;
}
