from typing import Literal

from pydantic import BaseModel, Field


class BaseEvent(BaseModel):
    timestamp_ms: int = Field(..., description="Unix timestamp in milliseconds")


class MouseEvent(BaseEvent):
    type: Literal["click"] = "click"
    x: int
    y: int
    button: str


class KeyboardEvent(BaseEvent):
    type: Literal["keypress"] = "keypress"
    key: str
    modifiers: list[str] = Field(default_factory=list)


class CommandEvent(BaseEvent):
    type: Literal["command"] = "command"
    command: str
    cwd: str


class FileEvent(BaseEvent):
    type: Literal["file_change"] = "file_change"
    path: str
    action: Literal["modified", "created", "deleted", "moved"]


Event = MouseEvent | KeyboardEvent | CommandEvent | FileEvent
