# generated by datamodel-codegen:
#   filename:  debug.json
#   timestamp: 2026-02-04T15:36:47+00:00

from __future__ import annotations

from enum import StrEnum
from typing import Any

from pydantic import BaseModel, ConfigDict


class DebugModels(BaseModel):
    """
    Schema for debug session management, states, and execution control
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )


class DebugState(StrEnum):
    """
    Debug session states following the state machine specification
    """

    ready = 'ready'
    running = 'running'
    paused = 'paused'
    stepping = 'stepping'
    completed = 'completed'
    error = 'error'
    stopped = 'stopped'


class PauseReason(StrEnum):
    """
    Reasons for debug execution pause
    """

    breakpoint = 'breakpoint'
    manual = 'manual'
    error = 'error'
    step = 'step'


class Breakpoint(BaseModel):
    """
    Represents a breakpoint in debug execution
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )
    nodeId: str
    """
    Action/node ID where breakpoint is set
    """
    enabled: bool
    """
    Whether the breakpoint is active
    """
    hitCount: int | None = 0
    """
    Number of times this breakpoint has been hit
    """


class DebugExecutionInfo(BaseModel):
    """
    Information about current debug execution state
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )
    currentNodeId: str | None
    """
    ID of the action currently being executed or about to execute
    """
    currentActionIndex: int
    """
    Zero-based index of current action in execution order
    """
    totalActions: int
    """
    Total number of actions in the flow
    """
    executedActions: list[str]
    """
    List of action IDs that have been executed
    """
    nextBreakpoint: str | None
    """
    ID of the next breakpoint that will be hit
    """


class DebugSession(BaseModel):
    """
    Represents a single debug execution session
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )
    sessionId: str
    """
    Unique identifier for the debug session
    """
    flowId: str
    """
    ID of the flow being debugged
    """
    breakpoints: list[str]
    """
    Set of action IDs where execution should pause
    """
    state: DebugState
    currentActionId: str | None = None
    """
    ID of the action currently being executed or about to execute
    """
    currentActionIndex: int | None = 0
    """
    Zero-based index of current action in execution order
    """
    executedActions: list[str] | None = []
    """
    List of action IDs that have been executed
    """
    pauseRequested: bool | None = False
    """
    Flag indicating manual pause was requested
    """
    stopRequested: bool | None = False
    """
    Flag indicating stop was requested
    """
    createdAt: float | None = None
    """
    Timestamp when session was created (Unix timestamp)
    """
    lastUpdated: float | None = None
    """
    Timestamp of last state change (Unix timestamp)
    """


class Type(StrEnum):
    """
    Type of debug update
    """

    debug_action_started = 'debug_action_started'
    debug_action_completed = 'debug_action_completed'
    debug_action_failed = 'debug_action_failed'
    debug_paused = 'debug_paused'
    debug_resumed = 'debug_resumed'
    debug_completed = 'debug_completed'
    debug_stopped = 'debug_stopped'
    debug_error = 'debug_error'


class DebugActionUpdate(BaseModel):
    """
    Real-time update sent during debug execution
    """

    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Type
    """
    Type of debug update
    """
    sessionId: str
    """
    Debug session ID
    """
    actionId: str | None = None
    """
    Action ID related to this update
    """
    actionIndex: int | None = None
    """
    Index of the action in execution order
    """
    state: DebugState
    """
    Current debug state
    """
    pauseReason: PauseReason | None = None
    """
    Reason for pause if state is paused
    """
    result: dict[str, Any] | None = None
    """
    Action execution result if available
    """
    error: str | None = None
    """
    Error message if action failed
    """
    variables: dict[str, Any] | None = None
    """
    Current flow variables state
    """
