from __future__ import annotations

from typing import TypedDict

from langgraph.graph import END, StateGraph

from src.agent_core import run


class AgentState(TypedDict):
    message: str
    response: str


def _invoke_agent(state: AgentState) -> AgentState:
    message = state.get("message", "")
    response = run(message)
    return {"message": message, "response": response}


_builder = StateGraph(AgentState)
_builder.add_node("invoke_agent", _invoke_agent)
_builder.set_entry_point("invoke_agent")
_builder.add_edge("invoke_agent", END)

agent = _builder.compile()
