// Type definitions for Claude Code Monitor

export type EventType =
  | 'PreToolUse'
  | 'PostToolUse'
  | 'SessionStart'
  | 'SessionEnd'
  | 'SubagentStop'
  | 'UserPromptSubmit';

export type FilterType = 'ALL' | 'TOOLS' | 'AGENTS' | 'PROMPTS' | 'SESSIONS';

export interface Event {
  id: number;
  session_id: string;
  event_type: EventType;
  tool_name?: string | null;
  tool_input?: any | null;
  tool_output?: string | null;
  success?: boolean | null;
  description?: string | null;
  timestamp: number;
  created_at: string;
}

export interface Statistics {
  total_events: number;
  total_tools_used: number;
  total_agents: number;
  total_sessions: number;
  last_updated: number;
}

export interface WebSocketMessage {
  type: 'event_created' | 'stats_updated' | 'connection_status' | 'stats_reset' | 'pong';
  event?: Event;
  statistics?: Statistics;
  message?: string;
  timestamp?: number;
}

export interface EventListResponse {
  events: Event[];
  total: number;
  page: number;
  page_size: number;
  has_more: boolean;
}

// Filter mapping for event types
export const EVENT_FILTER_MAP: Record<FilterType, EventType[]> = {
  ALL: ['PreToolUse', 'PostToolUse', 'SessionStart', 'SessionEnd', 'SubagentStop', 'UserPromptSubmit'],
  TOOLS: ['PreToolUse', 'PostToolUse'],
  AGENTS: ['SubagentStop'],
  PROMPTS: ['UserPromptSubmit'],
  SESSIONS: ['SessionStart', 'SessionEnd'],
};
