from typing_extensions import TypedDict
from typing import Optional

class HRState(TypedDict):
    query: str
    context: list
    intent: str
    is_hr: bool
    # Derived, not separately LLM-classified — see classify_node's
    # _DATABASE_WIRED_INTENTS/_DATABASE_CAPABLE_INTENTS and
    # date_resolver.mentions_date_expression. Both are cheap frozenset/regex
    # checks computed once per query alongside intent/is_hr, never a second
    # LLM call.
    is_database_related: bool
    has_date_expression: bool
    moderation: dict
    output_guardrail: dict
    response_text: str
    error: Optional[str]
    usage_events: list
    # Apply-leave / leave-balance conversation (see leave_action_node) —
    # is_manager is deliberately NOT here: it's fetched lazily inside
    # leave_action_node so erp-api's availability never affects ordinary chat.
    bearer_token: str
    company_id: str
    conversation_id: str
    # Same-turn node handoff (see attendance_node -> regularisation_node).
    # Set by a node that wants the graph to continue straight into another
    # node in the SAME invocation rather than ending on END. Any node that
    # reads this should treat it as consumed (it isn't auto-cleared between
    # turns since a fresh HRState is built per request).
    route_to: Optional[str]
    # Set by ownership_guard_node (the very first node, START -> here) — True
    # when the query asks for another employee's/a group's attendance data
    # and the caller isn't privileged; _route_after_ownership reads this to
    # end the turn immediately instead of continuing to classify_node.
    blocked: Optional[bool]
