ó
    ýÞ jO(  ã            
      ó”  • S SK Jr  S SKJr  S SKJrJrJr  S SKJ	r	J
r
Jr  S SKJr  S SKJr  S SKJrJr  S SKJrJr  S S	KJr  S S
KJrJr  S SKJr  Sr\" SSS9 " S S5      5       r\" SSS9 " S S5      5       r " S S5      r S S jr!S!S jr" " S S\\
\   SS9r#\" S"0 \D6 " S S\
\   5      5       r$\$" SS\!\"SSSS9r%S#S$S jjr&g)%é    )Úannotations)ÚCallable)Ú	dataclassÚfieldÚreplace)ÚAnyÚGenericÚcast)Ú	BaseStore)ÚBaseUser)Ú	TypedDictÚUnpack)ÚCONFÚCONFIG_KEY_RUNTIME)Ú
get_config)Ú
_DC_KWARGSÚStreamWriter)ÚContextT)r   ÚExecutionInfoÚ
RunControlÚRuntimeÚ
ServerInfoÚget_runtimeT)ÚfrozenÚslotsc                  óˆ   • \ rS rSr% SrS\S'    S\S'    S\S'    SrS\S	'    SrS\S
'    SrS\S'    Sr	S\S'    SS jr
Srg)r   é   zORead-only execution info/metadata for the execution of current thread/run/node.ÚstrÚcheckpoint_idÚcheckpoint_nsÚtask_idNú
str | NoneÚ	thread_idÚrun_idé   ÚintÚnode_attemptzfloat | NoneÚnode_first_attempt_timec                ó   • [        U 40 UD6$ )zAReturn a new execution info object with selected fields replaced.©r   ©ÚselfÚ	overridess     ÚK/var/www/html/gaurav/venv/lib/python3.13/site-packages/langgraph/runtime.pyÚpatchÚExecutionInfo.patch7   s   € ä�tÑ)˜yÑ)Ð)ó    © )r-   r   Úreturnr   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r#   r$   r'   r(   r/   Ú__static_attributes__r2   r1   r.   r   r      sc   ‡ áYàÓØ6àÓØ=àƒLØ0à €IˆzÓ ðHð €FˆJÓðAð €L�#ÓØ<à,0Ð˜\Ó0ØF÷*r1   r   c                  ó@   • \ rS rSr% SrS\S'    S\S'    SrS\S'   S	rg)
r   é<   zmMetadata injected by LangGraph Server. None when running open-source LangGraph without LangSmith deployments.r   Úassistant_idÚgraph_idNzBaseUser | NoneÚuserr2   )r4   r5   r6   r7   r8   r9   r?   r:   r2   r1   r.   r   r   <   s%   ‡ áwàÓØ5àƒMØ1à €Dˆ/Ó òr1   r   c                  ó\   • \ rS rSrSrSrS	S jrS
SS jjr\SS j5       r	\SS j5       r
Srg)r   éO   av  Run-scoped control surface for cooperative draining.

Intended for a single graph run. Create a fresh `RunControl` per run;
reusing a control after `request_drain()` leaves it drained.

Safe to call from any thread: the drain request is represented by a
single attribute write, so no lock is needed for this signal.
If more mutable state is added here, add synchronization.
©Ú_drain_reasonc                ó   • S U l         g ©NrB   ©r,   s    r.   Ú__init__ÚRunControl.__init__\   s
   € Ø)-ˆÕr1   c                ó   • Xl         g rE   rB   )r,   Úreasons     r.   Úrequest_drainÚRunControl.request_drain_   s   € Ø#Õr1   c                ó   • U R                   S L$ rE   rB   rF   s    r.   Údrain_requestedÚRunControl.drain_requestedb   s   € à×!Ñ!¨Ð-Ð-r1   c                ó   • U R                   $ rE   rB   rF   s    r.   Údrain_reasonÚRunControl.drain_reasonf   s   € à×!Ñ!Ð!r1   N©r3   ÚNone)Úshutdown)rJ   r   r3   rT   ©r3   Úbool©r3   r"   )r4   r5   r6   r7   r8   Ú	__slots__rG   rK   ÚpropertyrN   rQ   r:   r2   r1   r.   r   r   O   s@   † ñð #€Iô.ö$ð ó.ó ð.ð ó"ó ó"r1   r   c                ó   • g rE   r2   )Ú_s    r.   Ú_no_op_stream_writerr]   k   s   € ¨#r1   c                 ó   • g rE   r2   r2   r1   r.   Ú_no_op_heartbeatr_   n   s   €  r1   c                  óf   • \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   S\S'   S\S'   Srg)Ú_RuntimeOverrideséq   r   ÚcontextúBaseStore | NoneÚstorer   Ústream_writerúCallable[[], None]Ú	heartbeatr   Úpreviousr   Úexecution_infoúServerInfo | NoneÚserver_infoúRunControl | NoneÚcontrolr2   N)r4   r5   r6   r7   r9   r:   r2   r1   r.   ra   ra   q   s1   ‡ ØÓØÓØÓØ!Ó!ØƒMØ!Ó!Ø"Ó"ØÖr1   ra   F)Útotalc                  ó(  • \ rS rSr% Sr\" SS9rS\S'    \" SS9rS\S'    \" \	S9r
S	\S
'    \" \S9rS\S'    \" SS9rS\S'    \" SS9rS\S'    \" SS9rS\S'    \" SS9rS\S'    SS jr    SS jrSS jr\SS j5       r\SS j5       rSrg) r   é|   a¾  Convenience class that bundles run-scoped context and other runtime utilities.

This class is injected into graph nodes and middleware. It provides access to
`context`, `store`, `stream_writer`, `previous`, and `execution_info`.

!!! note "Accessing `config`"

    `Runtime` does not include `config`. To access `RunnableConfig`, you can inject
    it directly by adding a `config: RunnableConfig` parameter to your node function
    (recommended), or use `get_config()` from `langgraph.config`.

!!! note
    `ToolRuntime` (from `langgraph.prebuilt`) is a subclass that provides similar
    functionality but is designed specifically for tools. It shares `context`, `store`,
    and `stream_writer` with `Runtime`, and adds tool-specific attributes like `config`,
    `state`, and `tool_call_id`.

!!! version-added "Added in version v0.6.0"

Example:

```python
from typing import TypedDict
from langgraph.graph import StateGraph
from dataclasses import dataclass
from langgraph.runtime import Runtime
from langgraph.store.memory import InMemoryStore


@dataclass
class Context:  # (1)!
    user_id: str


class State(TypedDict, total=False):
    response: str


store = InMemoryStore()  # (2)!
store.put(("users",), "user_123", {"name": "Alice"})


def personalized_greeting(state: State, runtime: Runtime[Context]) -> State:
    '''Generate personalized greeting using runtime context and store.'''
    user_id = runtime.context.user_id  # (3)!
    name = "unknown_user"
    if runtime.store:
        if memory := runtime.store.get(("users",), user_id):
            name = memory.value["name"]

    response = f"Hello {name}! Nice to see you again."
    return {"response": response}


graph = (
    StateGraph(state_schema=State, context_schema=Context)
    .add_node("personalized_greeting", personalized_greeting)
    .set_entry_point("personalized_greeting")
    .set_finish_point("personalized_greeting")
    .compile(store=store)
)

result = graph.invoke({}, context=Context(user_id="user_123"))
print(result)
# > {'response': 'Hello Alice! Nice to see you again.'}
```

1. Define a schema for the runtime context.
2. Create a store to persist memories and other information.
3. Use the runtime context to access the `user_id`.
N)Údefaultr   rc   rd   re   r   rf   rg   rh   r   ri   zExecutionInfo | Nonerj   rk   rl   rm   rn   c                ó.  • [        UR                  =(       d    U R                  UR                  =(       d    U R                  UR                  [        La  UR                  OU R                  UR
                  [        La  UR
                  OU R
                  UR                  c  U R                  OUR                  UR                  =(       d    U R                  UR                  =(       d    U R                  UR                  =(       d    U R                  S9$ )z{Merge two runtimes together.

If a value is not provided in the other runtime, the value from the current runtime is used.
)rc   re   rf   rh   ri   rj   rl   rn   )r   rc   re   rf   r]   rh   r_   ri   rj   rl   rn   )r,   Úothers     r.   ÚmergeÚRuntime.mergeð   s¿   € ô
 Ø—M‘M×1 T§\¡\Ø—+‘+×+ §¡à×"Ñ"Ô*>Ò>ð  ×-Ò-à×#Ñ#à�‰Ô&6Ò6ð —o’oà—‘Ø&+§n¡nÑ&<�T—]’]À%Ç.Á.Ø ×/Ñ/×F°4×3FÑ3FØ×)Ñ)×=¨T×-=Ñ-=Ø—M‘M×1 T§\¡\ñ
ð 	
r1   c                ó   • [        U 40 UD6$ )z@Replace the runtime with a new runtime with the given overrides.r*   r+   s     r.   ÚoverrideÚRuntime.override  s   € ô �tÑ)˜yÑ)Ð)r1   c                ó~   • U R                   c  Sn[        U5      e[        U U R                   R                  " S0 UD6S9$ )zBReturn a new runtime with selected execution_info fields replaced.z2Cannot patch execution_info before it has been set)rj   r2   )rj   ÚRuntimeErrorr   r/   )r,   r-   Úmsgs      r.   Úpatch_execution_infoÚRuntime.patch_execution_info
  sE   € à×ÑÑ&ØFˆCÜ˜sÓ#Ð#ÜØØ×.Ñ.×4Ò4ÑA°yÑAñ
ð 	
r1   c                óL   • U R                   b  U R                   R                  $ S$ )NF)rn   rN   rF   s    r.   rN   ÚRuntime.drain_requested  s    € à/3¯|©|Ñ/Gˆt�|‰|×+Ñ+ÐRÈUÐRr1   c                óL   • U R                   b  U R                   R                  $ S $ rE   )rn   rQ   rF   s    r.   rQ   ÚRuntime.drain_reason  s    € à,0¯L©LÑ,Dˆt�|‰|×(Ñ(ÐNÈ$ÐNr1   r2   )rt   úRuntime[ContextT]r3   rƒ   )r-   z#Unpack[_RuntimeOverrides[ContextT]]r3   rƒ   )r-   r   r3   rƒ   rV   rX   )r4   r5   r6   r7   r8   r   rc   r9   re   r]   rf   r_   rh   ri   rj   rl   rn   ru   rx   r}   rZ   rN   rQ   r:   r2   r1   r.   r   r   |   sÿ   ‡ ñFñP  dÑ+€GˆXÓ+ð5ñ $¨DÑ1€EÐÓ1ØCá"'Ð0DÑ"E€M�<ÓEØ4á$)Ð2BÑ$C€IÐ!ÓCðñ  $Ñ'€HˆcÓ'ðñ
 ,1¸Ñ+>€NÐ(Ó>ð2ñ &+°4Ñ%8€KÐ"Ó8Øwá!&¨tÑ!4€GÐÓ4ðô
ð(*Ø>ð*à	ô*ô
ð óSó ðSð óOó óOr1   r   N)rc   re   rf   rh   ri   rj   rn   c                óx   • [        [        [           [        5       [           R                  [        5      5      nU$ )zÁGet the runtime for the current graph run.

Args:
    context_schema: Optional schema used for type hinting the return type of the runtime.

Returns:
    The runtime for the current graph run.
)r
   r   r   r   r   Úgetr   )Úcontext_schemaÚruntimes     r.   r   r   (  s-   € ô ”7œ8Ñ$¤j£l´4Ñ&8×&<Ñ&<Ô=OÓ&PÓQ€GØ€Nr1   )r\   r   r3   rT   rS   r2   rE   )r†   ztype[ContextT] | Noner3   rƒ   )'Ú
__future__r   Úcollections.abcr   Údataclassesr   r   r   Útypingr   r	   r
   Úlanggraph.store.baser   Úlanggraph_sdk.auth.typesr   Útyping_extensionsr   r   Úlanggraph._internal._constantsr   r   Úlanggraph.configr   Úlanggraph.typesr   r   Úlanggraph.typingr   Ú__all__r   r   r   r]   r_   ra   r   ÚDEFAULT_RUNTIMEr   r2   r1   r.   Ú<module>r•      sò   ðÝ "å $ß 1Ñ 1ß %Ñ %å *Ý -ß /ç CÝ 'ß 4Ý %ð€ñ �$˜dÑ#÷*ð *ó $ð*ñB �$˜dÑ#÷ð ó $ð÷$"ñ "ô8 .ô $ô˜	 7¨8Ñ#4¸Eò ñ ÑˆZÑô]Oˆg�hÑó ]Oó ð]Oñ@ ØØ
Ø&ØØØØñ€÷r1   