§
    šŠtjè  ã                  óh   — d Z ddlmZ ddlmZ ddlmZ erddlmZ ddl	m
Z
mZ  G d„ d¦  «        Zd	S )
z@Replay state for subgraph checkpoint loading during time-travel.é    )Úannotations)ÚTYPE_CHECKING)ÚNS_END)ÚRunnableConfig)ÚBaseCheckpointSaverÚCheckpointTuplec                  ó6   — e Zd ZdZdZdd„Zdd
„Zdd„Zdd„ZdS )ÚReplayStateaÛ  Tracks which subgraphs have already loaded their pre-replay checkpoint.

    During a parent replay, each subgraph's first invocation should restore the
    checkpoint from before the replay point. Subsequent invocations of the same
    subgraph (e.g. in a loop) should use normal checkpoint loading so they pick
    up freshly created checkpoints.

    The single `ReplayState` instance is shared by reference across all derived
    configs within one parent execution.
    )Úcheckpoint_idÚ_visited_nsr   ÚstrÚreturnÚNonec                ó:   — || _         t          ¦   «         | _        d S )N)r   Úsetr   )Úselfr   s     úY/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph/_internal/_replay.pyÚ__init__zReplayState.__init__   s   € Ø*ˆÔõ &)¡U¤UˆÔÐÐó    Úcheckpoint_nsÚboolc                ó¨   — t           |v r!|                     t           d¦  «        d         n|}|| j        v rdS | j                             |¦  «         dS )a
  Return True the first time a subgraph namespace is seen.

        The task-id suffix is stripped so that the same logical subgraph
        (e.g. ``"sub_node"``) is recognized across loop iterations even
        though each iteration has a different task id.
        é   r   FT)r   Úrsplitr   Úadd)r   r   Ú	stable_nss      r   Ú_is_first_visitzReplayState._is_first_visit"   se   € õ ˜Ð&Ð&ð × Ò ¥¨Ñ+Ô+¨AÔ.Ð.àð 	ð
 ˜Ô(Ð(Ð(Ø�5ØÔ×Ò˜YÑ'Ô'Ð'Øˆtr   Úcheckpointerr   Úcheckpoint_configr   úCheckpointTuple | Nonec                ó¨   — |                       |¦  «        r)|                     |dd| j        iid¬¦  «        D ]}|c S dS |                     |¦  «        S )aL  Load the right checkpoint for a subgraph during replay.

        On the first call for a given subgraph namespace, returns the latest
        checkpoint created *before* the replay point. On subsequent calls
        (e.g. the same subgraph in a later loop iteration), falls back to
        normal latest-checkpoint loading.
        Úconfigurabler   r   ©ÚbeforeÚlimitN)r   Úlistr   Ú	get_tuple©r   r   r   r   Úsaveds        r   Úget_checkpointzReplayState.get_checkpoint4   sy   € ð ×Ò Ñ.Ô.ð 	Ø%×*Ò*Ø!Ø&¨¸$Ô:LÐ(MÐNØð +ñ ô ð ð �ð
 ���Ø�4Ø×%Ò%Ð&7Ñ8Ô8Ð8r   c              ƒ  óÄ   K  — |                       |¦  «        r/|                     |dd| j        iid¬¦  «        2 3 d{V —†}|c S 6 dS |                     |¦  «        ƒ d{V —†S )z"Async version of `get_checkpoint`.r"   r   r   r#   N)r   Úalistr   Ú
aget_tupler(   s        r   Úaget_checkpointzReplayState.aget_checkpointK   s¯   è è € ð ×Ò Ñ.Ô.ð 	Ø+×1Ò1Ø!Ø&¨¸$Ô:LÐ(MÐNØð  2ñ  ô  ð ð ð ð ð ð ð �eð
 ���ð ð �4Ø!×,Ò,Ð->Ñ?Ô?Ð?Ð?Ð?Ð?Ð?Ð?Ð?s   ¹AN)r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r    )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r*   r.   © r   r   r
   r
      s{   € € € € € ð	ð 	ð 1€Ið+ð +ð +ð +ðð ð ð ð$9ð 9ð 9ð 9ð.@ð @ð @ð @ð @ð @r   r
   N)r2   Ú
__future__r   Útypingr   Úlanggraph._internal._constantsr   Úlangchain_core.runnablesr   Úlanggraph.checkpoint.baser   r   r
   r4   r   r   ú<module>r:      sº   ðØ FÐ Fà "Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  à 1Ð 1Ð 1Ð 1Ð 1Ð 1àð OØ7Ð7Ð7Ð7Ð7Ð7ØNÐNÐNÐNÐNÐNÐNÐNðL@ð L@ð L@ð L@ð L@ñ L@ô L@ð L@ð L@ð L@r   