Ë
    òÏj3}  ã                  ój  — d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	 d dl
mZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d d	lmZ d d
lmZ d dlm Z m!Z!m"Z"m#Z#m$Z$  ede%e&e'«      Z(e)e'e'ef   Z* ejV                  e,«      Z- G d„ ded¬«      Z.e/e'e'e%z  e&z  f   Z0 G d„ de«      Z1d*d„Z2 G d„ de«      Z3 G d„ de«      Z4	 d+	 	 	 	 	 	 	 d,d„Z5 G d„ dee(   «      Z6	 	 	 	 	 	 d-d„Z7 G d„ de8«      Z9d.d„Z:	 	 	 	 	 	 d/d„Z;	 	 	 	 	 	 d/d „Z<	 e d!e#d"e!d#e"d$iZ=h d%£Z>d&Z?d0d'„Z@dd(œ	 	 	 	 	 	 	 	 	 d1d)„ZAy)2é    )ÚannotationsN)ÚAsyncIteratorÚ
CollectionÚIteratorÚMappingÚSequence)ÚAnyÚGenericÚLiteralÚ
NamedTupleÚ	TypedDictÚTypeVarÚcast)ÚRunnableConfig)ÚNotRequired)Úuuid6)ÚSerializerProtocolÚmaybe_add_typed_methods)ÚEncryptedSerializer)ÚJsonPlusSerializer)ÚERRORÚ	INTERRUPTÚRESUMEÚ	SCHEDULEDÚChannelProtocolÚVc                  óL   — e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
ed<   y)ÚCheckpointMetadataz&Metadata associated with a checkpoint.z*Literal['input', 'loop', 'update', 'fork']ÚsourceÚintÚstepzdict[str, str]ÚparentsÚstrÚrun_idzdict[str, tuple[int, int]]Úcounters_since_delta_snapshotN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    ú_/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langgraph/checkpoint/base/__init__.pyr   r   '   s>   … Ù0à6Ó6ðð ƒIðð Óðð ƒKØ9Ø#=Ó=ðr-   r   F)Útotalc                  ód   — e Zd ZU dZded<   	 ded<   	 ded<   	 ded<   	 d	ed
<   	 ded<   	 ded<   y)Ú
Checkpointz(State snapshot at a given point in time.r    Úvr#   ÚidÚtszdict[str, Any]Úchannel_valuesÚChannelVersionsÚchannel_versionszdict[str, ChannelVersions]Úversions_seenzlist[str] | NoneÚupdated_channelsNr&   r,   r-   r.   r1   r1   ]   sS   … Ù2à
ƒFØ>ØƒGð'ð 	ƒGØ=Ø"Ó"ðð &Ó%ðð
 .Ó-ðð
 'Ó&ðr-   r1   c                óL  — t        | d   | d   | d   | d   j                  «       | d   j                  «       | d   j                  «       D ��ci c]  \  }}||j                  «       “Œ c}}| j                  dg «      j                  «       | j                  dd «      ¬	«      S c c}}w )
Nr2   r4   r3   r5   r7   r8   Úpending_sendsr9   ©r2   r4   r3   r5   r7   r8   r;   r9   )r1   ÚcopyÚitemsÚget)Ú
checkpointÚkr2   s      r.   Úcopy_checkpointrB      s¦   € ÜØ
�S‰/Ø�dÑØ�dÑØ!Ð"2Ñ3×8Ñ8Ó:Ø#Ð$6Ñ7×<Ñ<Ó>Ø/9¸/Ñ/J×/PÑ/PÔ/RÔSÑ/R¡t q¨!�q˜!Ÿ&™&›(‘{Ð/RÒSØ —n‘n _°bÓ9×>Ñ>Ó@Ø#Ÿ™Ð(:¸DÓAô	ð 	ùó Ts   ÁB c                  óL   — e Zd ZU dZded<   ded<   ded<   dZd	ed
<   dZded<   y)ÚCheckpointTuplez8A tuple containing a checkpoint and its associated data.r   Úconfigr1   r@   r   ÚmetadataNúRunnableConfig | NoneÚparent_configzlist[PendingWrite] | NoneÚpending_writes)r'   r(   r)   r*   r+   rH   rI   r,   r-   r.   rD   rD   Œ   s-   … ÙBàÓØÓØ Ó Ø+/€MÐ(Ó/Ø04€NÐ-Ô4r-   rD   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚDeltaChannelHistoryu¾  Per-channel result entry from `BaseCheckpointSaver.get_delta_channel_history`.

    !!! warning "Beta"

        Part of the `DeltaChannel` support surface; in beta. Field names and
        semantics may change.

    Storage-level view of what one channel contributed across the ancestor
    chain of a target checkpoint:

    * `writes` â€” on-path deltas oldestâ†’newest as `PendingWrite` tuples.
      Always present; possibly empty. Already filtered to one channel.
      Writes stored at the target checkpoint itself are pending for the
      next super-step and are excluded.

      Within a single checkpoint, writes are ordered by `writes_sort_key`,
      `(task_path, task_id, idx)`, which is the order live execution applies
      a super-step's task writes in. `task_id` is a hash of the path, so
      ordering by it permutes parallel tasks writing one channel, and
      reducers need not be order-invariant. Writes stored without a
      `task_path` (graph input, `update_state` and `Command` updates, rows
      predating the column) sort first, by `task_id`.
    * `seed` â€” the stored value at the nearest ancestor whose
      `channel_values[ch]` is populated. Omitted if the walk reached the
      root without finding any stored value (consumer treats absence as
      "start empty"). Typically a `_DeltaSnapshot` for delta channels with
      finite snapshot frequency, or a plain value for threads migrated
      from a pre-delta channel type.
    zlist[PendingWrite]ÚwriteszNotRequired[Any]ÚseedNr&   r,   r-   r.   rK   rK   –   s   … ñð< ÓØ
Ôr-   rK   c                ó   — | ||fS )ag  Sort key for the writes of one super-step.

    Live execution applies a super-step's tasks in this order, so a saver
    that replays stored writes, as `get_delta_channel_history` does, must
    sort them by it too, or an order-sensitive reducer rebuilds a different
    value than the run produced. `task_path` is the string passed to
    `put_writes`.
    r,   )Ú	task_pathÚtask_idÚidxs      r.   Úwrites_sort_keyrR   ¹   s   € ð �w Ð$Ð$r-   c                  ó  — e Zd ZU dZ e«       Zded<   ddœ	 	 	 d!d„Zed"d„«       Z	d#d„Z
d$d	„Zdddd
œ	 	 	 	 	 	 	 	 	 d%d„Z	 	 	 	 	 	 	 	 	 	 d&d„Z	 d'	 	 	 	 	 	 	 	 	 d(d„Z	 	 	 	 d)d„Z	 	 	 	 d*d„Z	 	 	 	 	 	 d+d„Zddœ	 	 	 	 	 d,d„Zd#d„Zd$d„Zdddd
œ	 	 	 	 	 	 	 	 	 d-d„Z	 	 	 	 	 	 	 	 	 	 d&d„Z	 d'	 	 	 	 	 	 	 	 	 d(d„Z	 	 	 	 d)d„Z	 	 	 	 d*d„Z	 	 	 	 	 	 d+d„Zddœ	 	 	 	 	 d,d„Z	 	 	 	 	 	 d.d„Z	 	 	 	 	 	 d.d„Zd/d„Z	 	 	 	 d0d „Zy)1ÚBaseCheckpointSavera|  Base class for creating a graph checkpointer.

    Checkpointers allow LangGraph agents to persist their state
    within and across multiple interactions.

    When a checkpointer is configured, you should pass a `thread_id` in the config when
    invoking the graph:

    ```python
    config = {"configurable": {"thread_id": "my-thread"}}
    graph.invoke(inputs, config)
    ```

    The `thread_id` is the primary key used to store and retrieve checkpoints. Without
    it, the checkpointer cannot save state, resume from interrupts, or enable
    time-travel debugging.

    How you choose ``thread_id`` depends on your use case:

    - **Single-shot workflows**: Use a unique ID (e.g., uuid4) for each run when
        executions are independent.
    - **Conversational memory**: Reuse the same `thread_id` across invocations
        to accumulate state (e.g., chat history) within a conversation.

    Attributes:
        serde (SerializerProtocol): Serializer for encoding/decoding checkpoints.

    Note:
        When creating a custom checkpoint saver, consider implementing async
        versions to avoid blocking the main thread.
    r   ÚserdeN)rU   c               ó@   — t        |xs | j                  «      | _        y )N)r   rU   )ÚselfrU   s     r.   Ú__init__zBaseCheckpointSaver.__init__ê   s   € ô
 -¨UÒ-@°d·j±jÓAˆ�
r-   c                ó   — g S )zŠDefine the configuration options for the checkpoint saver.

        Returns:
            list: List of configuration field specs.
        r,   )rW   s    r.   Úconfig_specsz BaseCheckpointSaver.config_specsñ   s	   € ð ˆ	r-   c                óB   — | j                  |«      x}r|j                  S y)zäFetch a checkpoint using the given configuration.

        Args:
            config: Configuration specifying which checkpoint to retrieve.

        Returns:
            The requested checkpoint, or `None` if not found.
        N)Ú	get_tupler@   ©rW   rE   Úvalues      r.   r?   zBaseCheckpointSaver.getú   s)   € ð —N‘N 6Ó*Ð*ˆ5Ð*Ø×#Ñ#Ð#ð +r-   c                ó   — t         ‚)a¢  Fetch a checkpoint tuple using the given configuration.

        Args:
            config: Configuration specifying which checkpoint to retrieve.

        Returns:
            The requested checkpoint tuple, or `None` if not found. Its
                `pending_writes` must be in `writes_sort_key` order.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        ©ÚNotImplementedError©rW   rE   s     r.   r\   zBaseCheckpointSaver.get_tuple  s
   € ô "Ð!r-   )ÚfilterÚbeforeÚlimitc               ó   — t         ‚)aï  List checkpoints that match the given criteria.

        Args:
            config: Base configuration for filtering checkpoints.
            filter: Additional filtering criteria.
            before: List checkpoints created before this configuration.
            limit: Maximum number of checkpoints to return.

        Returns:
            Iterator of matching checkpoint tuples.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   ©rW   rE   rc   rd   re   s        r.   ÚlistzBaseCheckpointSaver.list  ó
   € ô, "Ð!r-   c                ó   — t         ‚)a   Store a checkpoint with its configuration and metadata.

        Args:
            config: Configuration for the checkpoint.
            checkpoint: The checkpoint to store.
            metadata: Additional metadata for the checkpoint.
            new_versions: New channel versions as of this write.

        Returns:
            RunnableConfig: Updated configuration after storing the checkpoint.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   ©rW   rE   r@   rF   Únew_versionss        r.   ÚputzBaseCheckpointSaver.put-  s
   € ô* "Ð!r-   c                ó   — t         ‚)a›  Store intermediate writes linked to a checkpoint.

        Args:
            config: Configuration of the related checkpoint.
            writes: List of writes to store.
            task_id: Identifier for the task creating the writes.
            task_path: Path of the task creating the writes.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   ©rW   rE   rL   rP   rO   s        r.   Ú
put_writeszBaseCheckpointSaver.put_writesD  s
   € ô$ "Ð!r-   c                ó   — t         ‚©z©Delete all checkpoints and writes associated with a specific thread ID.

        Args:
            thread_id: The thread ID whose checkpoints should be deleted.
        r`   ©rW   Ú	thread_ids     r.   Údelete_threadz!BaseCheckpointSaver.delete_threadX  s
   € ô "Ð!r-   c                ó   — t         ‚)u  Delete all checkpoints and writes associated with the given run IDs.

        Args:
            run_ids: The run IDs whose checkpoints should be deleted.

        !!! warning "DeltaChannel"

            Deleting a run that produced ancestor `checkpoint_writes` â€” or
            the only `_DeltaSnapshot` blob â€” for a still-live thread will
            break reconstruction of any `DeltaChannel` whose history
            depended on those rows. See the `DeltaChannel` note on `prune`
            for safe-recovery strategies.
        r`   ©rW   Úrun_idss     r.   Údelete_for_runsz#BaseCheckpointSaver.delete_for_runsc  s
   € ô" "Ð!r-   c                ó   — t         ‚)u;  Copy all checkpoints and writes from one thread to another.

        Args:
            source_thread_id: The thread ID to copy from.
            target_thread_id: The thread ID to copy to.

        !!! warning "DeltaChannel"

            Implementations must copy the **complete** parent chain (all
            ancestor checkpoints and their `checkpoint_writes`) â€” copying
            only the head checkpoint will leave the target thread with
            `DeltaChannel` state that cannot be reconstructed (no path back
            to a `_DeltaSnapshot` ancestor). Equivalently, the copy must
            include enough ancestors that every `DeltaChannel`-backed key
            has either a `_DeltaSnapshot` in `channel_values` somewhere in
            the chain, or a complete write history back to the chain root.
        r`   ©rW   Úsource_thread_idÚtarget_thread_ids      r.   Úcopy_threadzBaseCheckpointSaver.copy_threadv  ri   r-   Úkeep_latest)Ústrategyc               ó   — t         ‚)uT  Prune checkpoints for the given threads.

        Args:
            thread_ids: The thread IDs to prune.
            strategy: The pruning strategy. `"keep_latest"` retains only the most
                recent checkpoint per namespace. `"delete"` removes all checkpoints.

        !!! warning "DeltaChannel"

            Custom implementations must be `DeltaChannel`-aware. `DeltaChannel`
            stores only a sentinel in `channel_values` for non-snapshot steps;
            reconstruction walks the parent chain via
            `get_delta_channel_history`, accumulating rows from
            `checkpoint_writes` until it reaches an ancestor whose
            `channel_values` contains a `_DeltaSnapshot` blob (written every
            `snapshot_frequency` updates).

            A naive `"keep_latest"` that drops intermediate checkpoints and
            their writes can sever that chain: the surviving "latest"
            checkpoint is rarely a snapshot point itself, so its delta
            channels would silently reconstruct as empty (no error raised â€”
            `get_delta_channel_history` simply returns no `seed`). Safe
            options when the graph uses `DeltaChannel`:

            * Walk back from each kept checkpoint and preserve every
              ancestor (plus its `checkpoint_writes`) up to the nearest one
              whose `channel_values` already contains a `_DeltaSnapshot` for
              every `DeltaChannel`-backed key.
            * Force a fresh snapshot on the kept checkpoint before deleting
              ancestors â€” rewrite `channel_values[k] = _DeltaSnapshot(value)`
              for each delta channel `k` (resolving `value` via the existing
              ancestor walk first), then prune.
            * Skip pruning threads whose graph uses `DeltaChannel` until one
              of the above is implemented.
        r`   ©rW   Ú
thread_idsr€   s      r.   ÚprunezBaseCheckpointSaver.pruneŽ  s   € ôR "Ð!r-   c              ƒ  ó^   K  — | j                  |«      ƒ d{  –—† x}r|j                  S y7 Œ­w)zóAsynchronously fetch a checkpoint using the given configuration.

        Args:
            config: Configuration specifying which checkpoint to retrieve.

        Returns:
            The requested checkpoint, or `None` if not found.
        N)Ú
aget_tupler@   r]   s      r.   ÚagetzBaseCheckpointSaver.aget¹  s3   è ø€ ð Ÿ/™/¨&Ó1×1Ð1ˆ5Ð1Ø×#Ñ#Ð#ð 2Ð1ús   ‚-—+˜-c              ƒ  ó   K  — t         ‚­w)a±  Asynchronously fetch a checkpoint tuple using the given configuration.

        Args:
            config: Configuration specifying which checkpoint to retrieve.

        Returns:
            The requested checkpoint tuple, or `None` if not found. Its
                `pending_writes` must be in `writes_sort_key` order.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   rb   s     r.   r†   zBaseCheckpointSaver.aget_tupleÅ  s   è ø€ ô "Ð!ùó   ‚	c              ó   K  — t         ‚­w)a  Asynchronously list checkpoints that match the given criteria.

        Args:
            config: Base configuration for filtering checkpoints.
            filter: Additional filtering criteria for metadata.
            before: List checkpoints created before this configuration.
            limit: Maximum number of checkpoints to return.

        Returns:
            Async iterator of matching checkpoint tuples.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   rg   s        r.   ÚalistzBaseCheckpointSaver.alistÔ  s   è ø€ ô, "Ð!ùr‰   c              ƒ  ó   K  — t         ‚­w)a  Asynchronously store a checkpoint with its configuration and metadata.

        Args:
            config: Configuration for the checkpoint.
            checkpoint: The checkpoint to store.
            metadata: Additional metadata for the checkpoint.
            new_versions: New channel versions as of this write.

        Returns:
            RunnableConfig: Updated configuration after storing the checkpoint.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   rk   s        r.   ÚaputzBaseCheckpointSaver.aputí  s   è ø€ ô* "Ð!ùr‰   c              ƒ  ó   K  — t         ‚­w)aª  Asynchronously store intermediate writes linked to a checkpoint.

        Args:
            config: Configuration of the related checkpoint.
            writes: List of writes to store.
            task_id: Identifier for the task creating the writes.
            task_path: Path of the task creating the writes.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        r`   ro   s        r.   Úaput_writeszBaseCheckpointSaver.aput_writes  ó   è ø€ ô$ "Ð!ùr‰   c              ƒ  ó   K  — t         ‚­wrr   r`   rs   s     r.   Úadelete_threadz"BaseCheckpointSaver.adelete_thread  s   è ø€ ô "Ð!ùr‰   c              ƒ  ó   K  — t         ‚­w)uÑ  Asynchronously delete all checkpoints and writes for the given run IDs.

        Args:
            run_ids: The run IDs whose checkpoints should be deleted.

        !!! warning "DeltaChannel"

            See `delete_for_runs` â€” deleting rows a still-live thread's
            `DeltaChannel` reconstruction depends on (writes between the
            head and its nearest `_DeltaSnapshot` ancestor) will silently
            corrupt that channel's state.
        r`   rw   s     r.   Úadelete_for_runsz$BaseCheckpointSaver.adelete_for_runs#  s   è ø€ ô  "Ð!ùr‰   c              ƒ  ó   K  — t         ‚­w)uê  Asynchronously copy all checkpoints and writes from one thread to another.

        Args:
            source_thread_id: The thread ID to copy from.
            target_thread_id: The thread ID to copy to.

        !!! warning "DeltaChannel"

            See `copy_thread` â€” the copy must carry the complete parent
            chain (or at least back to a `_DeltaSnapshot` ancestor for every
            `DeltaChannel`) so the target thread can reconstruct delta
            state.
        r`   r{   s      r.   Úacopy_threadz BaseCheckpointSaver.acopy_thread5  r�   r‰   c             ƒ  ó   K  — t         ‚­w)ax  Asynchronously prune checkpoints for the given threads.

        Args:
            thread_ids: The thread IDs to prune.
            strategy: The pruning strategy. `"keep_latest"` retains only the most
                recent checkpoint per namespace. `"delete"` removes all checkpoints.

        !!! warning "DeltaChannel"

            See `prune` for the full `DeltaChannel` caveat. In short:
            `"keep_latest"` must not drop ancestor checkpoints / writes that
            sit between the kept checkpoint and the nearest `_DeltaSnapshot`
            ancestor, or delta channels will silently reconstruct as empty.
        r`   r‚   s      r.   ÚaprunezBaseCheckpointSaver.apruneI  s   è ø€ ô( "Ð!ùr‰   c               ód  — |si S |D �ci c]  }|g “Œ }}i }t        |«      }| j                  |«      }|r|j                  nd}|�³|r±| j                  |«      }	|	€n�|	j                  r8t	        |	j                  «      D ]   }
|
d   }||v sŒ||   j                  |
«       Œ" t        |«      D ]:  }||	j                  d   v sŒ|	j                  d   |   ||<   |j                  |«       Œ< |	j                  }|�|rŒ±i }|D ],  }dt        t	        ||   «      «      i}||v r||   |d<   |||<   Œ. |S c c}w )u\  Walk the parent chain returning per-channel writes + seed.

        !!! warning "Beta"

            This method is part of the `DeltaChannel` support surface and is
            in beta. The signature, return shape (`DeltaChannelHistory`), and
            interaction with `_DeltaSnapshot` blobs may change. Override at
            your own risk; the default implementation will continue to work
            against the public `BaseCheckpointSaver` contract.

        For each requested channel, walks ancestors of the checkpoint
        identified by `config` (following `parent_config`) and accumulates
        `pending_writes` for that channel. The walk terminates per-channel
        at the nearest ancestor whose `channel_values[ch]` is populated;
        that value is returned as `seed`. If the walk reaches the root
        without finding a stored value, `seed` is omitted from that
        channel's entry â€” the consumer treats the absence as "start
        empty."

        Walks the **parent chain** (not `list(before=...)`): for forked
        threads, only on-path ancestors contribute.

        The default implementation walks `get_tuple` + `parent_config`
        once for all channels â€” each ancestor visited once, not once per
        channel. Savers with direct storage access (`InMemorySaver`,
        `PostgresSaver`) override for performance; the return contract is
        fixed here.

        `PendingWrite` carries no `task_path`, so this default replays each
        checkpoint's writes in `get_tuple`'s `pending_writes` order, which
        `get_tuple` must return in `writes_sort_key` order.

        Args:
            config: Configuration identifying the target checkpoint.
            channels: Channel names to walk for. Empty â†’ empty mapping.

        Returns:
            Per-channel `DeltaChannelHistory` for every name in `channels`.
        Né   r5   rL   rM   )	Úsetr\   rH   rI   ÚreversedÚappendrh   r@   Údiscard©rW   rE   ÚchannelsÚcÚcollected_by_chÚ
seed_by_chÚ	remainingÚtarget_tupleÚcursor_configÚtupÚwriteÚchÚresultÚentrys                 r.   Úget_delta_channel_historyz-BaseCheckpointSaver.get_delta_channel_history_  si  € ñT ØˆIÙIQÓ9RÉÀA¸!¸R¹%ÈˆÐ9RØ%'ˆ
Ü! (›mˆ	Ø—~‘~ fÓ-ˆá*6ˆL×&Ò&¸Dð 	ð Ð'©IØ—.‘. Ó/ˆCØˆ{ØØ×!Ò!Ü% c×&8Ñ&8Ö9�EØ˜q™�BØ˜Y’Ø'¨Ñ+×2Ñ2°5Õ9ð :ô ˜9–o�Ø˜Ÿ™Ð(8Ñ9Ò9Ø%(§^¡^Ð4DÑ%EÀbÑ%I�J˜r‘NØ×%Ñ% bÕ)ð &ð  ×-Ñ-ˆMð Ð'ªIð 24ˆÛˆBØ*2´D¼À/ÐRTÑBUÓ9VÓ4WÐ)XˆEØ�ZÑØ *¨2¡��f‘ØˆF�2ŠJð	 ð
 ˆùò7 :Ss   ‰
D-c             ƒ  ó–  K  — |si S |D �ci c]  }|g “Œ }}i }t        |«      }| j                  |«      ƒ d{  –—† }|r|j                  nd}|�»|r¹| j                  |«      ƒ d{  –—† }	|	€n�|	j                  r8t	        |	j                  «      D ]   }
|
d   }||v sŒ||   j                  |
«       Œ" t        |«      D ]:  }||	j                  d   v sŒ|	j                  d   |   ||<   |j                  |«       Œ< |	j                  }|�|rŒ¹i }|D ],  }dt        t	        ||   «      «      i}||v r||   |d<   |||<   Œ. |S c c}w 7 �Œ7 Œá­w)zâAsync version of `get_delta_channel_history`.

        !!! warning "Beta"

            This method is part of the `DeltaChannel` support surface and is
            in beta. See `get_delta_channel_history` for caveats.
        Nrš   r5   rL   rM   )	r›   r†   rH   rI   rœ   r�   rh   r@   rž   rŸ   s                 r.   Úaget_delta_channel_historyz.BaseCheckpointSaver.aget_delta_channel_history¨  s}  è ø€ ñ ØˆIÙIQÓ9RÉÀA¸!¸R¹%ÈˆÐ9RØ%'ˆ
Ü! (›mˆ	Ø!Ÿ_™_¨VÓ4×4ˆá*6ˆL×&Ò&¸Dð 	ð Ð'©IØŸ™¨Ó6×6ˆCØˆ{ØØ×!Ò!Ü% c×&8Ñ&8Ö9�EØ˜q™�BØ˜Y’Ø'¨Ñ+×2Ñ2°5Õ9ð :ô ˜9–o�Ø˜Ÿ™Ð(8Ñ9Ò9Ø%(§^¡^Ð4DÑ%EÀbÑ%I�J˜r‘NØ×%Ñ% bÕ)ð &ð  ×-Ñ-ˆMð Ð'ªIð 24ˆÛˆBØ*2´D¼À/ÐRTÑBUÓ9VÓ4WÐ)XˆEØ�ZÑØ *¨2¡��f‘ØˆF�2ŠJð	 ð
 ˆùò7 :Sð 5ùð
 7ús=   ‚	E	‹
D?•#E	¸E¹,E	Á%EÁ&4E	Â5E	Ã8E	Ä
;E	ÅE	c                ó>   — t        |t        «      rt        ‚|€y|dz   S )aë  Generate the next version ID for a channel.

        Default is to use integer versions, incrementing by `1`.

        If you override, you can use `str`/`int`/`float` versions, as long as they are monotonically increasing.

        Args:
            current: The current version identifier (`int`, `float`, or `str`).
            channel: Deprecated argument, kept for backwards compatibility.

        Returns:
            V: The next version identifier, which must be increasing.
        rš   )Ú
isinstancer#   ra   )rW   ÚcurrentÚchannels      r.   Úget_next_versionz$BaseCheckpointSaver.get_next_versionÑ  s&   € ô �gœsÔ#Ü%Ð%Øˆ_Øà˜Q‘;Ðr-   c                óœ   — t        | j                  |«      }|| j                  u r| S t        j                  | «      }t        |«      |_        |S )z8Return a shallow clone with a derived msgpack allowlist.)Ú_with_msgpack_allowlistrU   r=   r   )rW   Úextra_allowlistrU   Úclones       r.   Úwith_allowlistz"BaseCheckpointSaver.with_allowlistæ  sC   € ô (¨¯
©
°OÓDˆØ�D—J‘JÑØˆKÜ—	‘	˜$“ˆÜ-¨eÓ4ˆŒØˆr-   )rU   zSerializerProtocol | NoneÚreturnÚNone)r¹   rh   )rE   r   r¹   zCheckpoint | None)rE   r   r¹   zCheckpointTuple | None)
rE   rG   rc   údict[str, Any] | Nonerd   rG   re   ú
int | Noner¹   zIterator[CheckpointTuple])
rE   r   r@   r1   rF   r   rl   r6   r¹   r   )Ú )
rE   r   rL   zSequence[tuple[str, Any]]rP   r#   rO   r#   r¹   rº   )rt   r#   r¹   rº   )rx   úSequence[str]r¹   rº   )r|   r#   r}   r#   r¹   rº   )rƒ   r¾   r€   r#   r¹   rº   )
rE   rG   rc   r»   rd   rG   re   r¼   r¹   zAsyncIterator[CheckpointTuple])rE   r   r    r¾   r¹   z!Mapping[str, DeltaChannelHistory])r±   zV | Noner²   rº   r¹   r   )r¶   úCollection[tuple[str, ...]]r¹   zBaseCheckpointSaver[V]) r'   r(   r)   r*   r   rU   r+   rX   ÚpropertyrZ   r?   r\   rh   rm   rp   ru   ry   r~   r„   r‡   r†   r‹   r�   r�   r’   r”   r–   r˜   r¬   r®   r³   r¸   r,   r-   r.   rT   rT   Ç   s  … ññ@ !3Ó 4€EÐÓ4ð
 ,0ñBð )ðBð 
ó	Bð òó ðó
$ó"ð& )-Ø(,Ø ñ"à%ð"ð &ð	"ð
 &ð"ð ð"ð 
#ó"ð0"àð"ð ð"ð %ð	"ð
 &ð"ð 
ó"ð8 ð"àð"ð *ð"ð ð	"ð
 ð"ð 
ó"ð(	"àð	"ð 
ó	"ð"àð"ð 
ó"ð&"àð"ð ð"ð 
ó	"ð8 &ñ	)"à!ð)"ð ð	)"ð
 
ó)"óV
$ó"ð& )-Ø(,Ø ñà%ðð &ð	ð
 &ðð ðð 
(óð2"àð"ð ð"ð %ð	"ð
 &ð"ð 
ó"ð8 ð"àð"ð *ð"ð ð	"ð
 ð"ð 
ó"ð(	"àð	"ð 
ó	"ð"àð"ð 
ó"ð$"àð"ð ð"ð 
ó	"ð0 &ñ	"à!ð"ð ð	"ð
 
ó"ð,GØ'ðGØ3@ðGà	*óGðR'Ø'ð'Ø3@ð'à	*ó'óRð*	Ø:ð	à	ô	r-   rT   c                óL  — t        | t        «      r| j                  |«      S t        | t        «      rI| j                  }t        |t        «      r-|j                  |«      }||u r| S t        | j
                  |«      S t        j                  dt        | «      j                  «       | S )NzfSerializer %s does not support msgpack allowlist. Strict msgpack deserialization will not be enforced.)
r°   r   Úwith_msgpack_allowlistr   rU   ÚcipherÚloggerÚwarningÚtyper'   )rU   r¶   ÚinnerÚupdated_inners       r.   rµ   rµ   ò  s’   € ô �%Ô+Ô,Ø×+Ñ+¨OÓ<Ð<Ü�%Ô,Ô-Ø—‘ˆÜ�eÔ/Ô0Ø!×8Ñ8¸ÓIˆMØ Ñ%Ø�Ü& u§|¡|°]ÓCÐCÜ
‡N�Nð	?äˆU‹×Ñôð
 €Lr-   c                  ó   — e Zd ZdZy)ÚEmptyChannelErrorziRaised when attempting to get the value of a channel that hasn't been updated
    for the first time yet.N)r'   r(   r)   r*   r,   r-   r.   rÊ   rÊ     s   „ ñð 	r-   rÊ   c                ó*   — | d   j                  d«      S )zGet checkpoint ID.ÚconfigurableÚcheckpoint_id)r?   )rE   s    r.   Úget_checkpoint_idrÎ     s   € à�.Ñ!×%Ñ% oÓ6Ð6r-   c           	     óê  — |j                  «       D ��ci c]*  \  }}|t        |t        «      r|j                  dd«      n|“Œ, }}}| j	                  d«      | j	                  d«      fD ]‚  }|sŒ|j                  «       D ]j  \  }}||v s|t
        v s|j                  d«      rŒ$t        |t        «      r|j                  dd«      ||<   ŒJt        |t        t        t        f«      sŒf|||<   Œl Œ„ |S c c}}w )ú9Get checkpoint metadata in a backwards-compatible manner.Ú r½   rF   rÌ   Ú__)
r>   r°   r#   Úreplacer?   ÚEXCLUDED_METADATA_KEYSÚ
startswithr    ÚboolÚfloat)rE   rF   rA   r2   ÚobjÚkeys         r.   Úget_checkpoint_metadatarÚ     sê   € ð —N‘NÔ$ôá$‰DˆAˆqð 	
¤j°´CÔ&8ˆ1�9‰9�X˜rÔ"¸aÑ?Ø$ð ñ ð —
‘
˜:Ó&¨¯
©
°>Ó(BÓCˆÙØØ—i‘i–k‰FˆC�Ø�h‰ #Ô)?Ñ"?À3Ç>Á>ÐRVÔCWØÜ˜AœsÔ#Ø !§	¡	¨(°BÓ 7�˜’Ü˜A¤¤T¬5Ð1Õ2Ø !�˜’ñ "ð Dð €Oùós   ”/C/c                ó~   — t        | |«      }d|v r,t        t        t        t        f   |«      j                  d«       |S )rÐ   rL   )rÚ   r   Údictr#   r	   Úpop)rE   rF   Úcheckpoint_metadatas      r.   Ú$get_serializable_checkpoint_metadatarß   '  s>   € ô 2°&¸(ÓCÐØÐ&Ñ&ÜŒT”#”s�(‰^Ð0Ó1×5Ñ5°hÔ?ØÐr-   éÿÿÿÿéþÿÿÿéýÿÿÿéüÿÿÿ>	   rt   rÍ   Úcheckpoint_nsÚcheckpoint_mapÚlanggraph_nodeÚlanggraph_pathÚlanggraph_stepÚlanggraph_triggersÚlanggraph_checkpoint_nsé   c            
     ó´   — ddl m } m} t        t        t	        t        d¬«      «      | j                  |j                  «      j                  «       i i i g d ¬«      S )Nr   ©ÚdatetimeÚtimezonerá   ©Ú	clock_seq)r2   r3   r4   r5   r7   r8   r;   r9   )	rî   rï   r1   ÚLATEST_VERSIONr#   r   ÚnowÚutcÚ	isoformatrí   s     r.   Úempty_checkpointrö   K  sJ   € ß+äÜ
ÜŒu˜rÔ"Ó#Ø�<‰<˜Ÿ™Ó%×/Ñ/Ó1ØØØØØô	ð 	r-   )r3   c               ó†  — ddl m }m} |j                  |j                  «      j	                  «       }|€| d   }n6i }|j                  «       D ]!  \  }}	|| d   vrŒ	 |	j                  «       ||<   Œ# t        t        ||xs t        t        |¬«      «      || d   | d   | j                  dg «      d¬	«      S # t        $ r Y Œsw xY w)
z+Create a checkpoint for the given channels.r   rí   Nr5   r7   rð   r8   r;   r<   )rî   rï   ró   rô   rõ   r>   r@   rÊ   r1   rò   r#   r   r?   )
r@   r    r!   r3   rî   rï   r4   ÚvaluesrA   r2   s
             r.   Úcreate_checkpointrù   Z  sÒ   € ÷ ,à	�‰�h—l‘lÓ	#×	-Ñ	-Ó	/€BØÐØÐ,Ñ-‰àˆØ—N‘NÖ$‰DˆAˆqØ˜
Ð#5Ñ6Ñ6ØðØŸL™L›N��q’	ð	 %ô Ü
ØØÒ+””U TÔ*Ó+ØØ#Ð$6Ñ7Ø  Ñ1Ø —n‘n _°bÓ9Øô	ð 	øô %ò Ùðús   ÁB4Â4	C Â?C )r@   r1   r¹   r1   )r½   r   )rO   r#   rP   r#   rQ   r    r¹   ztuple[str, str, int])rU   r   r¶   r¿   r¹   r   )rE   r   r¹   ú
str | None)rE   r   rF   r   r¹   r   )r¹   r1   )
r@   r1   r    z$Mapping[str, ChannelProtocol] | Noner!   r    r3   rú   r¹   r1   )BÚ
__future__r   r=   ÚloggingÚcollections.abcr   r   r   r   r   Útypingr	   r
   r   r   r   r   r   Úlangchain_core.runnablesr   Útyping_extensionsr   Úlanggraph.checkpoint.base.idr   Úlanggraph.checkpoint.serde.baser   r   Ú$langgraph.checkpoint.serde.encryptedr   Ú#langgraph.checkpoint.serde.jsonplusr   Ú langgraph.checkpoint.serde.typesr   r   r   r   r   r    r×   r#   r   ÚtupleÚPendingWriteÚ	getLoggerr'   rÄ   r   rÜ   r6   r1   rB   rD   rK   rR   rT   rµ   Ú	ExceptionrÊ   rÎ   rÚ   rß   ÚWRITES_IDX_MAPrÔ   rò   rö   rù   r,   r-   r.   Ú<module>r     sÙ  ðÝ "ã Û ß RÕ R÷÷ ñ õ 4Ý )å .ß WÝ DÝ B÷õ ñ ˆC��e˜SÓ!€Ø�S˜#˜s�]Ñ#€ð 
ˆ×	Ñ	˜8Ó	$€ô0˜¨%õ 0ðf �s˜C #™I¨Ñ-Ð-Ñ.€ô�ô óD
ô5�jô 5ô ˜)ô  ðH 34ð%Øð%Ø ð%Ø,/ð%àó%ôh˜' !™*ô hðVØðØ0Kðàóô(	˜	ô 	ó7ð
ØðØ&8ðàóð*ØðØ&8ðàóðð ˜˜Y¨¨I°r¸6À2ÐF€ò
Ð ð €óð( ñØðà2ðð ðð
 	ðð ôr-   