"""Type stubs for langgraph.graph module."""

from collections.abc import Callable, Iterator
from typing import Any, Literal, TypeVar, overload

_StateT = TypeVar("_StateT")

END: str

class StateGraph:
    """A graph that maintains state across node executions."""

    def __init__(self, state_schema: type[Any]) -> None: ...
    @overload
    def add_node(self, name: str, action: Callable[[Any], Any]) -> StateGraph: ...
    @overload
    def add_node(self, action: Callable[[Any], Any]) -> StateGraph: ...
    def add_edge(self, start: str, end: str) -> StateGraph: ...
    def add_conditional_edges(
        self,
        source: str,
        path: Callable[[Any], str],
        path_map: dict[str, str],
    ) -> StateGraph: ...
    def set_entry_point(self, node: str) -> StateGraph: ...
    def compile(
        self,
        checkpointer: Any = None,
        *,
        cache: Any = None,
        store: Any = None,
        interrupt_before: list[str] | Literal["*"] | None = None,
        interrupt_after: list[str] | Literal["*"] | None = None,
        debug: bool = False,
        name: str | None = None,
    ) -> CompiledStateGraph: ...

class CompiledStateGraph:
    """A compiled state graph ready for execution."""

    def invoke(
        self, input: dict[str, Any], config: dict[str, Any] | None = None
    ) -> dict[str, Any]: ...
    async def ainvoke(
        self, input: dict[str, Any], config: dict[str, Any] | None = None
    ) -> dict[str, Any]: ...
    def stream(
        self, input: dict[str, Any], config: dict[str, Any] | None = None
    ) -> Iterator[dict[str, Any]]: ...

__all__ = ["END", "CompiledStateGraph", "StateGraph"]
