§
    ™ŠtjÃw  ã                  óP  — 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 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j*        e+¦  «        Z, G d„ ded¬¦  «        Z-e.e&e&e$z  e%z  f         Z/ G d„ de¦  «        Z0d8d„Z1 G d„ de¦  «        Z2 G d„ de¦  «        Z3 G d„ dee'         ¦  «        Z4d9d „Z5 G d!„ d"e6¦  «        Z7d:d&„Z8d;d(„Z9d;d)„Z:	 ed*e"d+e d,e!d-iZ;h d.£Z<d/Z=d<d0„Z>dd1œd=d7„Z?dS )>é    )ÚannotationsN)ÚAsyncIteratorÚ
CollectionÚIteratorÚMappingÚSequence)ÚAnyÚGenericÚLiteralÚ
NamedTupleÚ	TypedDictÚTypeVar)ÚRunnableConfig)ÚNotRequired)Úuuid6)ÚSerializerProtocolÚmaybe_add_typed_methods)ÚEncryptedSerializer)ÚJsonPlusSerializer)ÚERRORÚ	INTERRUPTÚRESUMEÚ	SCHEDULEDÚChannelProtocolÚVc                  óN   — e Zd ZU dZded<   	 ded<   	 ded<   	 ded	<   	 d
ed<   dS )Ú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/CA-Chatbot/venv/lib/python3.11/site-packages/langgraph/checkpoint/base/__init__.pyr   r   &   sj   € € € € € € Ø0Ð0à6Ð6Ð6Ñ6ðð €I€I�Iðð ÐÐÑðð €K€K�KØ9Ø=Ð=Ð=Ñ=ðð r,   r   F)Útotalc                  óf   — 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<   dS )Ú
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-   r0   r0   \   s‰   € € € € € € Ø2Ð2à
€F€F�FØ>Ø€G€G�Gð'ð €G€G�GØ=Ø"Ð"Ð"Ñ"ðð &Ð%Ð%Ñ%ðð
 .Ð-Ð-Ñ-ðð
 'Ð&Ð&Ñ&ðð r,   r0   Ú
checkpointÚreturnc                ól  — t          | d         | d         | d         | d                              ¦   «         | d                              ¦   «         d„ | d                              ¦   «         D ¦   «         |                      dg ¦  «                             ¦   «         |                      d	d ¦  «        ¬
¦  «        S )Nr1   r3   r2   r4   r6   c                ó>   — i | ]\  }}||                      ¦   «         “ŒS r+   )Úcopy©Ú.0Úkr1   s      r-   ú
<dictcomp>z#copy_checkpoint.<locals>.<dictcomp>…   s&   € ÐSÐSÐS¡t q¨!�q˜!Ÿ&š&™(œ(ÐSÐSÐSr,   r7   Úpending_sendsr8   ©r1   r3   r2   r4   r6   r7   rB   r8   )r0   r=   ÚitemsÚget)r9   s    r-   Úcopy_checkpointrF   ~   s«   € ÝØ
�SŒ/Ø�dÔØ�dÔØ!Ð"2Ô3×8Ò8Ñ:Ô:Ø#Ð$6Ô7×<Ò<Ñ>Ô>ØSÐS¨z¸/Ô/J×/PÒ/PÑ/RÔ/RÐSÑSÔSØ —n’n _°bÑ9Ô9×>Ò>Ñ@Ô@Ø#ŸšÐ(:¸DÑAÔAð	ñ 	ô 	ð 	r,   c                  óN   — 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<   dS )ÚCheckpointTuplez8A tuple containing a checkpoint and its associated data.r   Úconfigr0   r9   r   ÚmetadataNúRunnableConfig | NoneÚparent_configzlist[PendingWrite] | NoneÚpending_writes)r&   r'   r(   r)   r*   rL   rM   r+   r,   r-   rH   rH   ‹   s^   € € € € € € ØBÐBàÐÐÑØÐÐÑØ Ð Ð Ñ Ø+/€MÐ/Ð/Ð/Ñ/Ø04€NÐ4Ð4Ð4Ñ4Ð4Ð4r,   rH   c                  ó(   — e Zd ZU dZded<   ded<   dS )Ú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.
    * `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-   rO   rO   •   s6   € € € € € € ðð ð, ÐÐÑØÐÐÑÐÐr,   rO   c                  ó0  — e Zd ZU dZ e¦   «         Zded<   ddœdMd	„ZedNd„¦   «         Z	dOd„Z
dPd„ZddddœdQd„ZdRd!„Z	 dSdTd(„ZdUd*„ZdVd-„ZdWd0„Zd1d2œdXd5„ZdOd6„ZdPd7„ZddddœdYd9„ZdRd:„Z	 dSdTd;„ZdUd<„ZdVd=„ZdWd>„Zd1d2œdXd?„ZdZdB„ZdZdC„Zd[dH„Zd\dL„ZdS )]Ú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)rT   úSerializerProtocol | Noner:   ÚNonec               ó<   — t          |p| j        ¦  «        | _        d S )N)r   rT   )ÚselfrT   s     r-   Ú__init__zBaseCheckpointSaver.__init__Ó   s   € õ
 -¨UÐ-@°d´jÑAÔAˆŒ
ˆ
ˆ
r,   Úlistc                ó   — g S )zŠDefine the configuration options for the checkpoint saver.

        Returns:
            list: List of configuration field specs.
        r+   )rX   s    r-   Úconfig_specsz BaseCheckpointSaver.config_specsÚ   s	   € ð ˆ	r,   rI   r   úCheckpoint | Nonec                óB   — |                       |¦  «        x}r|j        S dS )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_tupler9   ©rX   rI   Úvalues      r-   rE   zBaseCheckpointSaver.getã   s0   € ð —N’N 6Ñ*Ô*Ð*ˆ5ð 	$ØÔ#Ð#ð	$ð 	$r,   úCheckpointTuple | Nonec                ó   — t           ‚)aY  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.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        ©ÚNotImplementedError©rX   rI   s     r-   r_   zBaseCheckpointSaver.get_tupleï   s
   € õ "Ð!r,   )ÚfilterÚbeforeÚlimitrK   rg   údict[str, Any] | Nonerh   ri   ú
int | NoneúIterator[CheckpointTuple]c               ó   — 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.
        rd   ©rX   rI   rg   rh   ri   s        r-   rZ   zBaseCheckpointSaver.listý   ó
   € õ, "Ð!r,   r9   r0   rJ   r   Únew_versionsr5   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.
        rd   ©rX   rI   r9   rJ   rp   s        r-   ÚputzBaseCheckpointSaver.put  s
   € õ* "Ð!r,   Ú rP   úSequence[tuple[str, Any]]Útask_idr"   Ú	task_pathc                ó   — 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.
        rd   ©rX   rI   rP   rv   rw   s        r-   Ú
put_writeszBaseCheckpointSaver.put_writes,  s
   € õ$ "Ð!r,   Ú	thread_idc                ó   — t           ‚©z©Delete all checkpoints and writes associated with a specific thread ID.

        Args:
            thread_id: The thread ID whose checkpoints should be deleted.
        rd   ©rX   r{   s     r-   Údelete_threadz!BaseCheckpointSaver.delete_thread@  s
   € õ "Ð!r,   Úrun_idsúSequence[str]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.
        rd   ©rX   r€   s     r-   Údelete_for_runsz#BaseCheckpointSaver.delete_for_runsK  s
   € õ" "Ð!r,   Úsource_thread_idÚtarget_thread_idc                ó   — 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.
        rd   ©rX   r…   r†   s      r-   Úcopy_threadzBaseCheckpointSaver.copy_thread^  ro   r,   Úkeep_latest)ÚstrategyÚ
thread_idsr‹   c               ó   — 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.
        rd   ©rX   rŒ   r‹   s      r-   ÚprunezBaseCheckpointSaver.prunev  s   € õR "Ð!r,   c              ƒ  óR   K  — |                       |¦  «        ƒ d{V —†x}r|j        S dS )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_tupler9   r`   s      r-   ÚagetzBaseCheckpointSaver.aget¡  sF   è è € ð Ÿ/š/¨&Ñ1Ô1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ˆ5ð 	$ØÔ#Ð#ð	$ð 	$r,   c              ƒ  ó   K  — t           ‚)ah  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.

        Raises:
            NotImplementedError: Implement this method in your custom checkpoint saver.
        rd   rf   s     r-   r‘   zBaseCheckpointSaver.aget_tuple­  s   è è € õ "Ð!r,   úAsyncIterator[CheckpointTuple]c              ó   K  — t           ‚)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.
        rd   rn   s        r-   ÚalistzBaseCheckpointSaver.alist»  s   è è € õ, "Ð!r,   c              ƒ  ó   K  — t           ‚)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.
        rd   rr   s        r-   ÚaputzBaseCheckpointSaver.aputÔ  s   è è € õ* "Ð!r,   c              ƒ  ó   K  — t           ‚)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.
        rd   ry   s        r-   Úaput_writeszBaseCheckpointSaver.aput_writesë  ó   è è € õ$ "Ð!r,   c              ƒ  ó   K  — t           ‚r}   rd   r~   s     r-   Úadelete_threadz"BaseCheckpointSaver.adelete_threadÿ  s   è è € õ "Ð!r,   c              ƒ  ó   K  — t           ‚)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.
        rd   rƒ   s     r-   Úadelete_for_runsz$BaseCheckpointSaver.adelete_for_runs
  s   è è € õ  "Ð!r,   c              ƒ  ó   K  — t           ‚)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.
        rd   rˆ   s      r-   Úacopy_threadz BaseCheckpointSaver.acopy_thread  r›   r,   c             ƒ  ó   K  — t           ‚)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.
        rd   rŽ   s      r-   ÚaprunezBaseCheckpointSaver.aprune0  s   è è € õ( "Ð!r,   Úchannelsú!Mapping[str, DeltaChannelHistory]c               óv  — |si S d„ |D ¦   «         }i }t          |¦  «        }|                      |¦  «        }|r|j        nd}|�¶|r´|                      |¦  «        }|€nœ|j        r>t	          |j        ¦  «        D ])}	|	d         }
|
|v r||
                              |	¦  «         Œ*t          |¦  «        D ]<}
|
|j        d         v r+|j        d         |
         ||
<   |                     |
¦  «         Œ=|j        }|�|°´i }|D ]:}
dt          t	          ||
         ¦  «        ¦  «        i}|
|v r||
         |d<   |||
<   Œ;|S )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.

        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`.
        c                ó   — i | ]}|g “ŒS r+   r+   ©r?   Úcs     r-   rA   zABaseCheckpointSaver.get_delta_channel_history.<locals>.<dictcomp>n  ó   € Ð9RÐ9RÐ9RÀA¸!¸RÐ9RÐ9RÐ9Rr,   Né   r4   rP   rQ   )	Úsetr_   rL   rM   ÚreversedÚappendrZ   r9   Údiscard©rX   rI   r¤   Ú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_historyF  s˜  € ðL ð 	ØˆIØ9RÐ9RÈÐ9RÑ9RÔ9RˆØ%'ˆ
Ý! (™mœmˆ	Ø—~’~ fÑ-Ô-ˆà*6Ð@ˆLÔ&Ð&¸Dð 	ð Ð'¨IÐ'Ø—.’. Ñ/Ô/ˆCØˆ{ØØÔ!ð :Ý% cÔ&8Ñ9Ô9ð :ð :�EØ˜qœ�BØ˜Y��Ø'¨Ô+×2Ò2°5Ñ9Ô9Ð9øÝ˜9‘o”oð *ð *�Ø˜œÐ(8Ô9Ð9Ð9Ø%(¤^Ð4DÔ%EÀbÔ%I�J˜r‘NØ×%Ò% bÑ)Ô)Ð)øØÔ-ˆMð Ð'¨IÐ'ð 24ˆØð 	ð 	ˆBØ*2µD½À/ÐRTÔBUÑ9VÔ9VÑ4WÔ4WÐ)XˆEØ�ZÐÐØ *¨2¤��f‘ØˆF�2‰JˆJØˆr,   c             ƒ  ó’  K  — |si S d„ |D ¦   «         }i }t          |¦  «        }|                      |¦  «        ƒ d{V —†}|r|j        nd}|�¼|rº|                      |¦  «        ƒ d{V —†}|€nœ|j        r>t	          |j        ¦  «        D ])}	|	d         }
|
|v r||
                              |	¦  «         Œ*t          |¦  «        D ]<}
|
|j        d         v r+|j        d         |
         ||
<   |                     |
¦  «         Œ=|j        }|�|°ºi }|D ]:}
dt          t	          ||
         ¦  «        ¦  «        i}|
|v r||
         |d<   |||
<   Œ;|S )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.
        c                ó   — i | ]}|g “ŒS r+   r+   r¨   s     r-   rA   zBBaseCheckpointSaver.aget_delta_channel_history.<locals>.<dictcomp>—  rª   r,   Nr«   r4   rP   rQ   )	r¬   r‘   rL   rM   r­   r®   rZ   r9   r¯   r°   s                r-   Úaget_delta_channel_historyz.BaseCheckpointSaver.aget_delta_channel_history‹  s¿  è è € ð ð 	ØˆIØ9RÐ9RÈÐ9RÑ9RÔ9RˆØ%'ˆ
Ý! (™mœmˆ	Ø!Ÿ_š_¨VÑ4Ô4Ð4Ð4Ð4Ð4Ð4Ð4ˆà*6Ð@ˆLÔ&Ð&¸Dð 	ð Ð'¨IÐ'ØŸš¨Ñ6Ô6Ð6Ð6Ð6Ð6Ð6Ð6ˆCØˆ{ØØÔ!ð :Ý% cÔ&8Ñ9Ô9ð :ð :�EØ˜qœ�BØ˜Y��Ø'¨Ô+×2Ò2°5Ñ9Ô9Ð9øÝ˜9‘o”oð *ð *�Ø˜œÐ(8Ô9Ð9Ð9Ø%(¤^Ð4DÔ%EÀbÔ%I�J˜r‘NØ×%Ò% bÑ)Ô)Ð)øØÔ-ˆMð Ð'¨IÐ'ð 24ˆØð 	ð 	ˆBØ*2µD½À/ÐRTÔBUÑ9VÔ9VÑ4WÔ4WÐ)XˆEØ�ZÐÐØ *¨2¤��f‘ØˆF�2‰JˆJØˆr,   ÚcurrentúV | NoneÚchannelr   c                óL   — t          |t          ¦  «        rt          ‚|€dS |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.
        Nr«   )Ú
isinstancer"   re   )rX   r¿   rÁ   s      r-   Úget_next_versionz$BaseCheckpointSaver.get_next_version´  s0   € õ �g�sÑ#Ô#ð 	Ý%Ð%Øˆ_Ø�1à˜Q‘;Ðr,   Úextra_allowlistúCollection[tuple[str, ...]]úBaseCheckpointSaver[V]c                ó–   — t          | j        |¦  «        }|| j        u r| S t          j        | ¦  «        }t          |¦  «        |_        |S )z8Return a shallow clone with a derived msgpack allowlist.)Ú_with_msgpack_allowlistrT   r=   r   )rX   rÅ   rT   Úclones       r-   Úwith_allowlistz"BaseCheckpointSaver.with_allowlistÉ  sH   € õ (¨¬
°OÑDÔDˆØ�D”JÐÐØˆKÝ”	˜$‘”ˆÝ-¨eÑ4Ô4ˆŒØˆr,   )rT   rU   r:   rV   )r:   rZ   )rI   r   r:   r]   )rI   r   r:   rb   )
rI   rK   rg   rj   rh   rK   ri   rk   r:   rl   )
rI   r   r9   r0   rJ   r   rp   r5   r:   r   )rt   )
rI   r   rP   ru   rv   r"   rw   r"   r:   rV   )r{   r"   r:   rV   )r€   r�   r:   rV   )r…   r"   r†   r"   r:   rV   )rŒ   r�   r‹   r"   r:   rV   )
rI   rK   rg   rj   rh   rK   ri   rk   r:   r”   )rI   r   r¤   r�   r:   r¥   )r¿   rÀ   rÁ   rV   r:   r   )rÅ   rÆ   r:   rÇ   ) r&   r'   r(   r)   r   rT   r*   rY   Úpropertyr\   rE   r_   rZ   rs   rz   r   r„   r‰   r�   r’   r‘   r–   r˜   rš   r�   rŸ   r¡   r£   r»   r¾   rÄ   rË   r+   r,   r-   rS   rS   °   s¡  € € € € € € ðð ð@ !3Ð 2Ñ 4Ô 4€EÐ4Ð4Ð4Ñ4ð
 ,0ðBð Bð Bð Bð Bð Bð ðð ð ñ „Xðð
$ð 
$ð 
$ð 
$ð"ð "ð "ð "ð$ )-Ø(,Ø ð"ð "ð "ð "ð "ð "ð0"ð "ð "ð "ð8 ð"ð "ð "ð "ð "ð(	"ð 	"ð 	"ð 	"ð"ð "ð "ð "ð&"ð "ð "ð "ð8 &ð	)"ð )"ð )"ð )"ð )"ð )"ðV
$ð 
$ð 
$ð 
$ð"ð "ð "ð "ð$ )-Ø(,Ø ðð ð ð ð ð ð2"ð "ð "ð "ð8 ð"ð "ð "ð "ð "ð(	"ð 	"ð 	"ð 	"ð"ð "ð "ð "ð$"ð "ð "ð "ð0 &ð	"ð "ð "ð "ð "ð "ð,Cð Cð Cð CðJ'ð 'ð 'ð 'ðRð ð ð ð*	ð 	ð 	ð 	ð 	ð 	r,   rS   rT   r   rÅ   rÆ   c                óv  — t          | t          ¦  «        r|                      |¦  «        S t          | t          ¦  «        rL| j        }t          |t          ¦  «        r0|                     |¦  «        }||u r| S t          | j        |¦  «        S t                               dt          | ¦  «        j	        ¦  «         | S )NzfSerializer %s does not support msgpack allowlist. Strict msgpack deserialization will not be enforced.)
rÃ   r   Úwith_msgpack_allowlistr   rT   ÚcipherÚloggerÚwarningÚtyper&   )rT   rÅ   ÚinnerÚupdated_inners       r-   rÉ   rÉ   Õ  s½   € õ �%Õ+Ñ,Ô,ð =Ø×+Ò+¨OÑ<Ô<Ð<Ý�%Õ,Ñ-Ô-ð DØ”ˆÝ�eÕ/Ñ0Ô0ð 	DØ!×8Ò8¸ÑIÔIˆMØ Ð%Ð%Ø�Ý& u¤|°]ÑCÔCÐCÝ
‡N‚Nð	?åˆU‰ŒÔñô ð ð
 €Lr,   c                  ó   — e Zd ZdZdS )Ú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   € € € € € ðð ð 	€Dr,   rÖ   rI   r   ú
str | Nonec                ó8   — | d                               d¦  «        S )zGet checkpoint ID.ÚconfigurableÚcheckpoint_id)rE   )rI   s    r-   Úget_checkpoint_idrÛ   ð  s   € à�.Ô!×%Ò% oÑ6Ô6Ð6r,   rJ   c                óÈ  — d„ |                      ¦   «         D ¦   «         }|                      d¦  «        |                      d¦  «        fD ]˜}|sŒ|                      ¦   «         D ]~\  }}||v s|t          v s|                     d¦  «        rŒ(t	          |t
          ¦  «        r|                     dd¦  «        ||<   ŒWt	          |t          t          t          f¦  «        r|||<   ŒŒ™|S )ú9Get checkpoint metadata in a backwards-compatible manner.c                óp   — i | ]3\  }}|t          |t          ¦  «        r|                     d d¦  «        n|“Œ4S )ú rt   )rÃ   r"   Úreplacer>   s      r-   rA   z+get_checkpoint_metadata.<locals>.<dictcomp>ù  sP   € ð ð ð áˆAˆqð 	
¥j°µCÑ&8Ô&8Ð?ˆ1�9Š9�X˜rÑ"Ô"Ð"¸aðð ð r,   rJ   rÙ   Ú__rß   rt   )
rD   rE   ÚEXCLUDED_METADATA_KEYSÚ
startswithrÃ   r"   rà   r   ÚboolÚfloat)rI   rJ   ÚobjÚkeyr1   s        r-   Úget_checkpoint_metadatarè   õ  s  € ðð à—N’NÑ$Ô$ðñ ô €Hð —
’
˜:Ñ&Ô&¨¯
ª
°>Ñ(BÔ(BÐCð 	"ð 	"ˆØð 	ØØ—i’i‘k”kð 	"ð 	"‰FˆC�Ø�hˆˆ #Õ)?Ð"?Ð"?À3Ç>Â>ÐRVÑCWÔCWÐ"?ØÝ˜A�sÑ#Ô#ð "Ø !§	¢	¨(°BÑ 7Ô 7�˜‘�Ý˜A¥¥T­5Ð1Ñ2Ô2ð "Ø !�˜‘øð	"ð €Or,   c                óX   — t          | |¦  «        }d|v r|                     d¦  «         |S )rÝ   rP   )rè   Úpop)rI   rJ   Úcheckpoint_metadatas      r-   Ú$get_serializable_checkpoint_metadatarì   
  s:   € õ 2°&¸(ÑCÔCÐØÐ&Ð&Ð&Ø×Ò Ñ)Ô)Ð)ØÐr,   éÿÿÿÿéþÿÿÿéýÿÿÿéüÿÿÿ>	   r{   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        ¦  «                             ¦   «         i i i g d ¬¦  «        S )Nr   ©ÚdatetimeÚtimezonerî   ©Ú	clock_seq)r1   r2   r3   r4   r6   r7   rB   r8   )	rû   rü   r0   ÚLATEST_VERSIONr"   r   ÚnowÚutcÚ	isoformatrú   s     r-   Úempty_checkpointr  .  sv   € Ø+Ð+Ð+Ð+Ð+Ð+Ð+Ð+åÝ
Ý�u˜rÐ"Ñ"Ô"Ñ#Ô#Ø�<Š<˜œÑ%Ô%×/Ò/Ñ1Ô1ØØØØØð	ñ 	ô 	ð 	r,   )r2   r¤   ú$Mapping[str, ChannelProtocol] | Noner    r   r2   c               óÐ  — ddl m }m} |                     |j        ¦  «                             ¦   «         }|€	| d         }nOi }|                     ¦   «         D ]8\  }}	|| d         vrŒ	 |	                     ¦   «         ||<   Œ)# t          $ r Y Œ5w xY wt          t          ||pt          t          |¬¦  «        ¦  «        || d         | d         |                      dg ¦  «        d¬	¦  «        S )
z+Create a checkpoint for the given channels.r   rú   Nr4   r6   rý   r7   rB   rC   )rû   rü   r   r  r  rD   r9   rÖ   r0   rÿ   r"   r   rE   )
r9   r¤   r    r2   rû   rü   r3   Úvaluesr@   r1   s
             r-   Úcreate_checkpointr  =  s  € ð ,Ð+Ð+Ð+Ð+Ð+Ð+Ð+à	�Š�h”lÑ	#Ô	#×	-Ò	-Ñ	/Ô	/€BØÐØÐ,Ô-ˆˆàˆØ—N’NÑ$Ô$ð 	ð 	‰DˆAˆqØ˜
Ð#5Ô6Ð6Ð6ØðØŸLšL™NœN��q‘	�	øÝ$ð ð ð Ø�ðøøøåÝ
ØØÐ+••U TÐ*Ñ*Ô*Ñ+Ô+ØØ#Ð$6Ô7Ø  Ô1Ø —n’n _°bÑ9Ô9Øð	ñ 	ô 	ð 	s   Á'A?Á?
BÂB)r9   r0   r:   r0   )rT   r   rÅ   rÆ   r:   r   )rI   r   r:   r×   )rI   r   rJ   r   r:   r   )r:   r0   )
r9   r0   r¤   r  r    r   r2   r×   r:   r0   )@Ú
__future__r   r=   ÚloggingÚcollections.abcr   r   r   r   r   Útypingr	   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   Údictr5   r0   rF   rH   rO   rS   rÉ   Ú	ExceptionrÖ   rÛ   rè   rì   ÚWRITES_IDX_MAPrâ   rÿ   r  r  r+   r,   r-   ú<module>r     sŸ  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 4Ð 3Ð 3Ð 3Ð 3Ð 3Ø )Ð )Ð )Ð )Ð )Ð )à .Ð .Ð .Ð .Ð .Ð .Ø WÐ WÐ WÐ WÐ WÐ WÐ WÐ WØ DÐ DÐ DÐ DÐ DÐ DØ BÐ BÐ BÐ BÐ BÐ Bðð ð ð ð ð ð ð ð ð ð ð ð ð ð €GˆC��e˜SÑ!Ô!€Ø�S˜#˜s�]Ô#€ð 
ˆÔ	˜8Ñ	$Ô	$€ð0ð 0ð 0ð 0ð 0˜¨%ð 0ñ 0ô 0ð 0ðf �s˜C #™I¨Ñ-Ð-Ô.€ðð ð ð ð �ñ ô ð ðD
ð 
ð 
ð 
ð5ð 5ð 5ð 5ð 5�jñ 5ô 5ð 5ðð ð ð ð ˜)ñ ô ð ð6bð bð bð bð b˜' !œ*ñ bô bð bðJð ð ð ð(	ð 	ð 	ð 	ð 	˜	ñ 	ô 	ð 	ð7ð 7ð 7ð 7ð
ð ð ð ð*ð ð ð ðð ˜˜Y¨¨I°r¸6À2ÐF€ð
ð 
ð 
Ð ð €ðð ð ð ð( ðð ð ð ð ð ð ð r,   