ó
    °"³j%  ã                  óJ  • % S SK Jr  S SKrS SKrS SKrS SKrS SKJrJ	r	  S SK
JrJr  S SKJrJrJrJrJrJr  S SKJrJr  S SKJr  S SKJr  S	S
KJr  \(       a  S SKJr  \" SS9rSr S\!S'    S SKJrJ"r"  S SK#J$r$  \$" 5       r%Sr&\&\%RN                  ;   d   eS$S jr(S%S jr*S&S jr+\" S5      r,S'S jr-S(S jr.S)S jr/S*S jr0 " S S5      r1\1" 5       r2 S SK3J4r4  \(       a  \Rl                  r7O
\S+S" j5       r7S,S# jr8g! \) a    S$S jr( Nof = f! \) a     " S  S!\55      r4 NHf = f)-é    )ÚannotationsN)Ú	AwaitableÚ	Generator)ÚcontextmanagerÚsuppress)ÚTYPE_CHECKINGÚAnyÚ	TypeAliasÚTypeVarÚget_argsÚ
get_origin)ÚLogfireÚLogfireSpan)Útyping_objects)Úis_union_originé   )ÚUnsupportedEventLoopError)ÚSpanzpydantic-graph)Ú
otel_scopezLogfireSpan | Spanr
   ÚAbstractSpan)r   Úset_span_in_context)ÚTraceContextTextMapPropagatorÚtraceparentc                óÌ   • [        U [        5      (       a  U nOU R                  nU(       d   e[        U5      n0 n[        R                  X25        UR                  [        S5      $ )zGGet a string representing the span context to use for annotating spans.Ú )Ú
isinstancer   Ú_spanr   ÚTRACEPARENT_PROPAGATORÚinjectÚgetÚTRACEPARENT_NAME)ÚspanÚ	real_spanÚcontextÚcarriers       ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_graph/_utils.pyÚget_traceparentr'   !   sV   € ô �dœD×!Ñ!Ø‰IàŸ
™
ˆIÞÐ�9Ü% iÓ0ˆØ"$ˆÜ×%Ñ% gÔ7Ø�{‰{Ô+¨RÓ0Ð0ó    c                ó   • g ©N© )r"   s    r&   r'   r'   0   s   € àr(   c                ód   • [        U R                  SS5      [        R                  R                  L$ )aú  Whether `loop` actually implements `run_until_complete()`.

`asyncio.AbstractEventLoop` declares `run_until_complete()` but its body just raises a bare
`NotImplementedError`. Event loops that can only be driven by their own runtime -- like Temporal's
workflow loop -- inherit that method without overriding it, so we check for the inherited method up
front. Catching `NotImplementedError` around the call instead would also swallow one raised by the
coroutine we're running, i.e. by the caller's own code.
Ú__func__N)ÚgetattrÚrun_until_completeÚasyncioÚAbstractEventLoop©Úloops    r&   Ú_implements_run_until_completer4   5   s*   € ô �4×*Ñ*¨J¸Ó=ÄW×E^ÑE^×EqÑEqÐqÐqr(   c                 ó  •  [         R                  " 5       n U b  [        U 5      (       d  U $ U b  U R	                  5       (       a+  [         R
                  " 5       n [         R                  " U 5        U $ ! [         a    S n  Nhf = fr*   )r0   Úget_event_loopÚRuntimeErrorr4   Ú	is_closedÚnew_event_loopÚset_event_loop)Ú
event_loops    r&   r6   r6   A   s|   € ðÜ×+Ò+Ó-ˆ
ð ÑÔ&DÀZ×&PÑ&Pð ÐàÑ˜Z×1Ñ1×3Ñ3Ü×+Ò+Ó-ˆ
Ü×Ò˜zÔ*ØÐøô ó ØŠ
ðús   ‚A1 Á1B Á?B Ú_Tc                óú  • [        5       n[        U5      (       dM  [        R                  " U 5      (       a  U R	                  5         [        S[        U5      R                   S35      e[        R                  " XS9n UR                  U5      $ ! [         ab    UR                  5       (       dK  UR                  5         [        [        5         UR                  U5        SSS5        e ! , (       d  f       e = fe f = f)aP  Run `coro` to completion on the event loop, cleaning up after itself if interrupted.

If the caller interrupts `loop.run_until_complete()` (e.g. by pressing Ctrl-C, raising
`KeyboardInterrupt`) while `coro` is suspended, asyncio leaves its task pending with its
`async with`/`finally` blocks un-run, leaking the task and any open connections. We cancel
*our own* task and drive its cleanup to completion before re-raising, without touching any
other tasks on the (caller-owned) loop.

Raises:
    UnsupportedEventLoopError: If the current event loop doesn't implement `run_until_complete()`.
zThe current event loop (aA  ) does not implement `run_until_complete()`, which synchronous methods need in order to run their asynchronous implementation. This is the case inside a Temporal workflow, whose event loop can only be driven by Temporal itself. Use the asynchronous method instead, e.g. `await agent.run()` rather than `agent.run_sync()`.r2   N)r6   r4   ÚinspectÚiscoroutineÚcloser   ÚtypeÚ__name__r0   Úensure_futurer/   ÚBaseExceptionÚdoneÚcancelr   )Úcoror3   Útasks      r&   r/   r/   X   sÕ   € ô Ó€DÜ)¨$×/Ñ/ô ×Ò˜t×$Ñ$Ø�J‰JŒLÜ'Ø&¤t¨D£z×':Ñ':Ð&;ð <lð ló
ð 	
ô × Ò  Ñ1€DðØ×&Ñ& tÓ,Ð,øÜó Ø�y‰y�{‰{Ø�K‰KŒMÜœ-Õ(Ø×'Ñ'¨Ô-÷ )à÷ )Ô(àúˆðús$   Á=B Â>C:ÃC'Ã	C:Ã'
C5	Ã1	C:c                ó¢   • [         R                  " U 5      (       a  U R                  n [        U 5      n[	        U5      (       a  [        U 5      $ U 4$ )zeExtract the arguments of a Union type if `response_type` is a union, otherwise return an empty tuple.)r   Úis_typealiastypeÚ	__value__r   r   r   )ÚtpÚorigins     r&   Úget_union_argsrN   |   sC   € ô ×&Ò& r×*Ñ*Ø�\‰\ˆä˜‹^€FÜ�v×ÑÜ˜‹|Ðàˆuˆr(   c                ót   • [        U 5      n[        R                  " U5      (       a  [        U 5      tp#X#4$ U / 4$ )zŠStrip `Annotated` from the type if present.

Returns:
    `(tp argument, ())` if not annotated, otherwise `(stripped type, annotations)`.
)r   r   Úis_annotatedr   )rL   rM   Úinner_tpÚargss       r&   Úunpack_annotatedrS   ‰   s:   € ô ˜‹^€FÜ×"Ò" 6×*Ñ*Ü" 2›,ˆˆØˆ~Ðà�2ˆvˆr(   c                óž   • U bJ  U R                   =n(       a6  UR                  R                  S5      S:X  a  [        U5      $ UR                  $ gg)ag  Attempt to get the namespace where the graph was defined.

If the graph is defined with generics `Graph[a, b]` then another frame is inserted, and we have to skip that
to get the correct namespace.

Args:
    frame: The frame to start searching from, or `None`.

Returns:
    The local namespace dict of the defining frame, or `None` if the frame was `None`.
NrB   Útyping)Úf_backÚ	f_globalsr    Úget_parent_namespaceÚf_locals)ÚframeÚbacks     r&   rX   rX   —   sQ   € ð ÑØ—<‘<Ðˆ4ÕØ�~‰~×!Ñ! *Ó-°Ó9ô
 ,¨DÓ1Ð1à—}‘}Ð$ð  ð r(   c                  ó   • \ rS rSrSrSrg)ÚUnseté¯   zMA singleton to represent an unset value.

Copied from pydantic_ai/_utils.py.
r+   N)rB   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r+   r(   r&   r]   r]   ¯   s   † ñò
 	r(   r]   )ÚLogfireNotConfiguredWarningc                  ó   • \ rS rSrSrg)rd   éÁ   r+   N)rB   r_   r`   ra   rc   r+   r(   r&   rd   rd   Á   s   † Úr(   rd   c               /  ó  #   • [         R                  " 5          [         R                  " S[        S9  [        R
                  " U 0 UD6 nUv •  SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f7f)zCCreate a Logfire span without warning if logfire is not configured.Úignore)ÚcategoryN)ÚwarningsÚcatch_warningsÚfilterwarningsrd   Ú_logfirer"   )rR   Úkwargsr"   s      r&   Úlogfire_spanro   É   sX   é € ô
 ×$Ò$Õ&Ü×#Ò# HÔ7RÒSÜ—’ Ð/¨Ò/°4Ø’
÷ 0÷ 'Ð&ç/Õ/ú÷ 'Õ&üs4   ‚B ˜0A/ÁAÁA/Á	B Á
A,	Á(A/Á/
A=Á9B c               ó\  • [         R                  " 5       nUc  g[        U5       H  nUR                  nUb  M    g   UR                  R                  5        H  u  pEXPL d  M  Us  $    UR                  UR                  :w  a+  UR                  R                  5        H  u  pEXPL d  M  Us  $    g)a)  Infer the variable name of an object from the calling frame's scope.

This function examines the call stack to find what variable name was used
for the given object in the calling scope. This is useful for automatic
naming of objects based on their variable names.

Args:
    obj: The object whose variable name to infer.
    depth: Number of stack frames to traverse upward from the current frame.

Returns:
    The inferred variable name if found, None otherwise.

Example:
    Usage should generally look like `infer_name(self, depth=2)` or similar.
N)r>   ÚcurrentframeÚrangerV   rY   ÚitemsrW   )ÚobjÚdepthÚtarget_frameÚ_ÚnameÚitems         r&   Úinfer_obj_namerz   Ô   s¤   € ô" ×'Ò'Ó)€LØÑØÜ�5Ž\ˆØ#×*Ñ*ˆØÓÙñ ð
 #×+Ñ+×1Ñ1Ö3‰
ˆØŒ;ØŠKñ 4ð ×Ñ × 6Ñ 6Ó6à&×0Ñ0×6Ñ6Ö8‰JˆDØŒ{Ø’ñ 9ð r(   )r"   r   Úreturnú
str | None)r3   úasyncio.AbstractEventLoopr{   Úbool)r{   r}   )rG   zAwaitable[_T]r{   r<   )rL   r	   r{   ztuple[Any, ...])rL   r	   r{   ztuple[Any, list[Any]])rZ   ztypes.FrameType | Noner{   zdict[str, Any] | None)rR   r	   rn   r	   r{   z"Generator[LogfireSpan, None, None])rt   r	   ru   Úintr{   r|   )9Ú
__future__r   Ú_annotationsr0   r>   Útypesrj   Úcollections.abcr   r   Ú
contextlibr   r   rU   r   r	   r
   r   r   r   Úlogfire_apir   r   Útyping_inspectionr   Útyping_inspection.introspectionr   Ú
exceptionsr   Úopentelemetry.tracer   rm   r   Ú__annotations__r   Ú,opentelemetry.trace.propagation.tracecontextr   r   r!   Úfieldsr'   ÚImportErrorr4   r6   r<   r/   rN   rS   rX   r]   ÚUNSETÚlogfire._internal.configrd   ÚUserWarningr"   ro   rz   r+   r(   r&   Ú<module>r‘      s  ðÞ 2ã Û Û Û ß 0ß /ß O× Oç ,Ý ,Ý ;å 1æÝ(áÐ.Ñ/€à.€ˆiÓ .ðß=ÝZá:Ó<ÐØ$ÐØÐ5×<Ñ<Ó<Ð<Ð<ô1ô(	rôñ( ˆTƒ]€ô!ôH
ôô%÷0	ñ 	ñ 	‹€ðõö Ø—=‘=�Lð óó ðõ#øðM ó öðûðb ó ô kö ðús$   Á-.C= ÃD Ã=DÄ
DÄD"Ä!D"