ó
    ±"³jbU  ã                  ó¨  • S SK Jr  S SKrS SKJrJr  S SKJr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JrJrJrJr  S SKJr  S S	KJrJr  S S
K J!r!  S SK"J#r#  S SK$J%r%J&r&J'r'  S SK(J)r)  S SK*J+r+J,r,  S SK-J.r.  SSK/J0r0  SSK1J2r2  \" S5      r3\" S5      r4\" S\\   S9r5\6" SS15      r7 Sr80 \8 V s0 s H
  n U SU  S3_M     sn ESSSS.Er9\" S S!9 " S" S#5      5       r:\" S S!9 " S$ S%\\3   5      5       r;S?S& jr<\ " S' S(5      5       r=\" S S!9 " S) S*5      5       r>\" S S!9 " S+ S,5      5       r? " S- S.\0\:   5      r@\" S S!9 " S/ S05      5       rA\ArBS1rCS@S2 jrDSAS3 jrESBS4 jrFSCS5 jrG    SDS6 jrH    SES7 jrI            SFS8 jrJSGS9 jrK          SHS: jrL      SIS; jrMSS<.         SJS= jjrNSKS> jrO\2\:\\4   rPgs  sn f )Lé    )ÚannotationsN)Ú	AwaitableÚCallable)ÚKW_ONLYÚ	dataclassÚreplace)Úupdate_wrapperÚwraps)ÚAnyÚGenericÚ	ParamSpecÚTypeVarÚcastÚget_type_hints)ÚFunctionSchemaÚextract_return_schema_typeÚfind_typed_parameterÚfunction_schemaÚis_call_ctxÚvalidate_schema_signature)Úget_current_run_context)ÚAbstractCapabilityÚleaf_capabilities)Ú	UserError)ÚModelMessage)ÚModelÚModelRequestContextÚModelRequestParameters)ÚModelSettings)ÚGenerateToolJsonSchemaÚ
RunContext)ÚRunUsageé   )ÚCacheIdentity)ÚBoundDurableOperationÚResultTÚPÚA)ÚboundÚget_toolsetÚget_wrapper_toolset)Úwrap_runÚwrap_node_runÚwrap_model_requestÚwrap_tool_validateÚwrap_tool_executeÚwrap_output_validateÚwrap_output_processÚ`zE` receives a handler callable, which cannot cross a durable boundary.zQ`wrap_run_event_stream` receives a live stream and cannot be a durable operation.zG`get_toolset` returns a live toolset and cannot be a durable operation.zO`get_wrapper_toolset` returns a live toolset and cannot be a durable operation.)Úwrap_run_event_streamr*   r+   T)Úfrozenc                  óB   • \ rS rSr% S\S'   S\S'   S\S'   SrS	\S
'   Srg)ÚCapabilityOperationParamsé;   úRunContext[Any]Úrun_contextr   Ú_údict[str, Any]Ú	argumentsNú
str | NoneÚmodel_id© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__r?   Ú__static_attributes__r@   ó    Úk/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_ai/durable_exec/_capability_operation.pyr7   r7   ;   s   ‡ à Ó ØƒJØÓØ€HˆjÖrG   r7   c                  ó4   • \ rS rSr% S\S'   S\S'   S\S'   Srg	)
ÚCapabilityOperationResultéC   r&   Úvaluer   r;   r"   Úusage_deltar@   N)rA   rB   rC   rD   rE   rF   r@   rG   rH   rJ   rJ   C   s   ‡ àƒNØƒJØÖrG   rJ   c                óh   • [        [        [        [              [        [        [        5      U    5      $ )a  Build `CapabilityOperationResult[ResultT]` for the operation's declared result type.

Codecs use the parametrized wrapper to validate both the operation value and its usage delta
when serializing and reconstructing `CapabilityOperationResult[ResultT]` across a durable boundary.
)r   ÚtyperJ   r   )Úresult_types    rH   Ú capability_operation_result_typerQ   J   s*   € ô ”Ô.¬sÑ3Ñ4´d¼3Ô@YÓ6ZÐ[fÑ6gÓhÐhrG   c                  ó‚   • \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   S\S'   \SS j5       rSS jrSSS jjr	Sr
g)ÚModelRequestContextProjectionéS   a5  Serializable projection of a model request context for a durable boundary.

`ModelRequestContext` carries a live `Model`, which cannot cross a durable boundary. This
projection carries the serializable request state plus the registered `model_id`, then rebuilds
or updates the live context on the other side.
zlist[ModelMessage]Úmessagesr   r;   zdict[str, Any] | NoneÚmodel_settingsr   Úmodel_request_parametersr>   r?   ÚboolÚ	streamingc                ó¶   • U " UR                   [        [        [        [        4   S -  UR
                  5      UR                  UR                  UR                  S9$ )N)rU   rV   rW   r?   rY   )	rU   r   ÚdictÚstrr   rV   rW   r?   rY   )ÚclsÚcontexts     rH   Úfrom_contextÚ*ModelRequestContextProjection.from_contextc   sP   € áØ×%Ñ%Ü¤¤S¬# X¡°Ñ 5°w×7MÑ7MÓNØ%,×%EÑ%EØ×%Ñ%Ø×'Ñ'ñ
ð 	
rG   c                óÀ   • [        UU R                  [        [        S-  U R                  5      U R
                  S9nU R                  Ul        U R                  Ul        U$ )zFBuild the worker-side live model request context from this projection.N)ÚmodelrU   rV   rW   )r   rU   r   r   rV   rW   r?   rY   )Úselfrb   r^   s      rH   Úbuild_contextÚ+ModelRequestContextProjection.build_contextm   sS   € ä%ØØ—]‘]Ü¤°Ñ 4°d×6IÑ6IÓJØ%)×%BÑ%Bñ	
ˆð  Ÿ=™=ˆÔØ ŸN™NˆÔØˆrG   Nc                óâ   • Ub  X!l         U R                  Ul        [        [        S -  U R                  5      Ul        U R
                  Ul        U R                  Ul        U R                  Ul        g ©N)rb   rU   r   r   rV   rW   r?   rY   )rc   r^   rb   s      rH   ÚapplyÚ#ModelRequestContextProjection.applyy   sY   € ØÑØ!ŒMØŸ=™=ˆÔÜ!%¤m°dÑ&:¸D×<OÑ<OÓ!PˆÔØ+/×+HÑ+HˆÔ(ØŸ=™=ˆÔØ ŸN™NˆÕrG   r@   )r^   r   ÚreturnrS   )rb   r   rj   r   rg   )r^   r   rb   úModel | Nonerj   ÚNone)rA   rB   rC   rD   Ú__doc__rE   Úclassmethodr_   rd   rh   rF   r@   rG   rH   rS   rS   S   sL   ‡ ñð !Ó ØƒJØ)Ó)Ø4Ó4ØÓØƒOàó
ó ð
ô
÷+ñ +rG   rS   c                  ó8   • \ rS rSr% S\S'   S\S'   SrS\S'   S	rg)
Ú_ResolvedModelRequestContextéƒ   rS   Ú
projectionr   r;   Nrk   rb   r@   )rA   rB   rC   rD   rE   rb   rF   r@   rG   rH   rp   rp   ƒ   s   ‡ à-Ó-ØƒJØ€Eˆ<ÖrG   rp   c                  ó~   • \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   S\S'   SrS\S'   \SS j5       rSrg)ÚCapabilityMethodDeclarationéŠ   r\   Únamer   r;   úCallable[..., Awaitable[Any]]Úfunctionúinspect.SignatureÚ	signaturer   ÚschemaÚobjectrP   r>   Úctx_parameterNÚmodel_request_parameterc                ó   • U R                   S L$ rg   )r~   )rc   s    rH   Úmodel_request_hookÚ.CapabilityMethodDeclaration.model_request_hook•   s   € à×+Ñ+°4Ð7Ð7rG   r@   )rj   rX   )	rA   rB   rC   rD   rE   r~   Úpropertyr€   rF   r@   rG   rH   rt   rt   Š   sG   ‡ à
ƒIØƒJØ+Ó+Ø Ó ØÓØÓØÓØ*.Ð˜ZÓ.àó8ó ó8rG   rt   c                  ó"   • \ rS rSrSrSS jrSrg)ÚCapabilityCacheIdentityéš   a[  Project the model, validated arguments, and run context into the cache identity.

Hash-keyed engines consult this projection, while sequence-keyed engines ignore it. The model
separates registered targets, the arguments identify the input, and the run context contributes
durable run and step identity where the engine's cache policy supports it.
c                óH   • UR                   UR                  UR                  4$ rg   )r?   r=   r:   )rc   Úparamss     rH   ÚprojectÚCapabilityCacheIdentity.project¢   s   € Ø—‘ ×!1Ñ!1°6×3EÑ3EÐFÐFrG   r@   N)r‡   r7   rj   ztuple[object, ...])rA   rB   rC   rD   rm   rˆ   rF   r@   rG   rH   r„   r„   š   s   † ñ÷GrG   r„   c                  óB   • \ rS rSr% S\S'   S\S'   S\S'   SrS	\S
'   Srg)Ú_DurableOperationMarkeré¦   r\   rv   r   r;   rw   rx   FrX   Ú	base_hookr@   N)rA   rB   rC   rD   rE   r�   rF   r@   rG   rH   r‹   r‹   ¦   s   ‡ à
ƒIØƒJØ+Ó+Ø€IˆtÖrG   r‹   Ú!__pydantic_ai_durable_operation__c                óF   • [        [        S-  [        U [        S5      5      $ )zBReturn the durable-operation marker attached to `obj`, if present.N)r   ÚMarkerÚgetattrÚ_MARKER_ATTRIBUTE)Úobjs    rH   Úget_durable_operation_markerr”   ²   s   € ä”˜‘œw sÔ,=¸tÓDÓEÐErG   c                ó&   • [        U [        U5        g)z-Attach a durable-operation `marker` to `obj`.N)Úsetattrr’   )r“   Úmarkers     rH   Úset_durable_operation_markerr˜   ·   s   € äˆCÔ" FÕ+rG   c                ó–   • [        U [        5      (       d!  [        S[        U 5      R                   35      eU (       d  [        S5      eU $ )Nz/`durable_operation` name must be a string, got z*`durable_operation` name must not be empty)Ú
isinstancer\   Ú	TypeErrorrO   rA   Ú
ValueError©rv   s    rH   Ú_validate_operation_namerž   ¼   sA   € Ü�dœC× Ñ ÜÐIÌ$ÈtË*×J]ÑJ]ÐI^Ð_Ó`Ð`ÞÜÐEÓFÐFØ€KrG   c                ód   ^ • [        T 5      (       a  [        S5      e[        T 5      m SU 4S jjnU$ )am  Declare an async capability method as a durable operation.

The method keeps its original signature. During a run with a durability capability, calls
dispatch through that engine's activity, step, or task. Without durability, calls await the
original method directly. The required `name` becomes part of persisted durable-unit names
within the capability's required stable `id`, so it must essentially never change. The Python
method itself can be renamed freely as long as `name` stays the same.

```python
from pydantic_ai.capabilities import AbstractCapability, durable_operation
from pydantic_ai.tools import RunContext


class Audit(AbstractCapability[None]):
    id = 'audit'

    @durable_operation(name='record')
    async def record(self, ctx: RunContext[None], message: str) -> bool:
        return bool(message)
```

Args:
    name: The stable operation name. This can be passed positionally or by keyword.

Returns:
    The marked method with its parameter and return types preserved.

Raises:
    TypeError: If used without an explicit name or if the decorated method is synchronous.
    ValueError: If `name` is empty.
zÊ`durable_operation` requires an explicit operation name because it becomes persisted compatibility data and must not change when the function is renamed. Use `@durable_operation(name='operation_name')`.c                ó´  >^ ^• [         R                  " T 5      (       dS  T R                  [        ;   a4  [	        T [        T[        [        S[        [           4   T 5      S95        T $ [        S5      e[        T[        [        S[        [           4   T 5      S9m[        T 5      SUU 4S jj5       n[	        UT5        [        [        [        [        4   U5      $ )N.)rv   rx   z3`durable_operation` can only decorate async methodsc           	   Ÿ  óÎ  >#   • [         R                  " T5      R                  " U /UQ70 UD6n[        5       nUR                  R                  5        H1  n[        U[        5      (       d  M  [        [        [           U5      n  O   Uc2  [        [        S[        [           4   T5      " U /UQ70 UD6I S h  v•N $ [        S UR                  R                  5        5       S 5      nUR                  nUb4  U R                  b'  UR                  U R                  T
R                   45      OS nUc*  TR#                  U [%        U 5      5      " U0 UD6I S h  v•N n	ODU" U[        [&        [(        S4   U5      [        [*        [,        [(        4   U5      5      I S h  v•N n	Ub<  [        U	[.        5      (       a'  U	R0                  R3                  XiR4                  5        U$ U	$  GN' N� NJ7f)N.c              3  óT   #   • U  H  n[        U[        5      (       d  M  Uv •  M      g 7frg   )rš   r   )Ú.0rL   s     rH   Ú	<genexpr>ÚIdurable_operation.<locals>.decorate.<locals>.decorated.<locals>.<genexpr>
  s   é € ÐgÒ$<˜5Ä
È5ÔRe×@f—‘Ò$<ùs   ‚(Ÿ	()Úinspectrz   Úbindr   r=   Úvaluesrš   r!   r   r   r   r   ÚnextÚ_durable_operationsÚidÚgetrv   Ú__get__rO   Útupler|   r[   r\   rp   rr   rh   rb   )rc   ÚargsÚkwargsr)   ÚctxrL   Úrequest_contextÚ
operationsÚ
dispatcherÚresultr—   Útargets             €€rH   Ú	decoratedÚ6durable_operation.<locals>.decorate.<locals>.decoratedù   s²  øé € ô ×%Ò% fÓ-×2Ò2°4ÐI¸$ÒIÀ&ÑIˆEô +BÓ*CˆCØŸ™×/Ñ/Ö1�Ü˜e¤Z×0Ó0Üœz¬#™°Ó6�CÙñ 2ð ‰{ô "¤(¨3´	¼#±Ð+>Ñ"?ÀÔHÈÐ_ÐPTÒ_ÐX^Ñ_×_Ð_ä"Ùg E§O¡O×$:Ñ$:Ô$<ÓgÐimóˆOð ×0Ñ0ˆJà:DÑ:PÐUY×U\ÑU\ÑUh�
—‘ §¡¨¯©Ð5Ô6Ðnrð ð Ñ!Ø%Ÿ~™~¨d´D¸³JÔ?ÀÐPÈÑP×P‘á)ØÜœœv s˜{Ñ+¨TÓ2Üœœc¤6˜kÑ*¨FÓ3ó ÷ �ð Ñ*¬z¸&ÔB^×/_Ñ/_Ø×!Ñ!×'Ñ'¨¿¹ÔFØ&Ð&ØˆMò5 `ñ Qñùs@   ƒA%G%Á,AG%Â7GÂ8BG%ÅG!ÅAG%ÆG#ÆAG%Ç!G%Ç#G%)rc   úAbstractCapability[Any]r¯   r   r°   r   rj   r   )r¦   ÚiscoroutinefunctionrA   Ú_SYNC_NEVER_DURABLE_HOOKSr˜   r�   r   r   r   r   r›   r
   r'   r(   )r¶   r·   r—   rv   s   ` @€rH   ÚdecorateÚ#durable_operation.<locals>.decorateë   s¼   ú€ Ü×*Ò*¨6×2Ñ2Ø�‰Ô";Ó;Ü,ØÜØ!Ü!%¤h¨s´I¼c±NÐ/BÑ&CÀVÓ!Lñôð �ÜÐQÓRÐRÜ˜T¬D´¸#¼yÌ¹~Ð:MÑ1NÐPVÓ,WÑXˆä	ˆv‹÷'	ó 
ð'	ôR 	% Y°Ô7Ü”HœQ¤˜T‘N IÓ.Ð.rG   )r¶   úCallable[P, A]rj   r¾   )Úcallabler›   rž   ©rv   r¼   s   ` rH   Údurable_operationrÁ   Ä   s;   ø€ ô@ �‡~�~Üðqó
ð 	
ô $ DÓ)€D÷9/ðv €OrG   c                ó.   ^ • [        T 5      m SU 4S jjnU$ )zLMark a base hook so every override inherits durable execution automatically.c                ón   >• [        U [        T[        [        S[        [
           4   U 5      SS95        U $ )N.T)rv   rx   r�   )r˜   r�   r   r   r   r   )rx   rv   s    €rH   r¼   Ú-base_hook_durable_operation.<locals>.decorate/  s;   ø€ Ü$ØÜØÜœh s¬I´c©NÐ':Ñ;¸XÓFØñô	
ð ˆrG   )rx   ú!Callable[..., Awaitable[ResultT]]rj   rÅ   )rž   rÀ   s   ` rH   Úbase_hook_durable_operationrÆ   )  s   ø€ ô $ DÓ)€D÷	ð €OrG   c                óŽ  • 0 n[        U 5      R                  SS  H�  n[        U5      R                  5        Hm  u  p4[	        U5      nUb  UR
                  (       d  M&  [        [        U 5      U5      nXdLd  MA  [        [        S[        [           4   U5      XR                  '   Mo     M�     [        R                  " [        U 5      5       HÁ  u  p6[	        U5      nUc  M  UR
                  (       a  XeR                  L a  M6  [        R!                  U5      =n(       a  [#        U5      eUR                  U;   a(  [#        SUR                  < SU R$                  < S35      e[        [        S[        [           4   U5      XR                  '   MÃ     0 nUR                  5        GH  u  pš[	        U
5      nUb  UR                  OU
nUR'                  U [        U 5      5      n[        R(                  " U5      n[+        USS9n[-        XÏ[.        S	S
S9n[-        UUS SS
S9n[1        XÎUU5        Ub?  UR2                  U   R4                  [        R6                  R8                  L a  [#        S5      eUb  U[:        S[:        0O0 n[=        XÞUUUS9nUb  [:        O[?        UR!                  S5      U5      n[A        U	UUUUUUS9X‰'   GM!     U$ )zòCollect durable declarations with a two-phase MRO scan.

The first phase finds overridden base hooks marked durable. The second finds directly marked
methods, validates never-durable hooks and duplicate names, then builds typed declarations.
r#   N.z!Duplicate durable operation name z on capability z<. Use `@durable_operation(name=...)` or change the hook key.T)Úinclude_extrasr!   zDurable operation)Úcallable_kindc                ó   • U [         L $ rg   )r   )Ú
annotations    rH   Ú<lambda>Ú/collect_capability_operations.<locals>.<lambda>k  s
   € ˜zÔ-@Ñ@rG   r   zOModelRequestContext cannot be used as a variadic positional parameter (`*args`)rj   )Úannotation_replacements)rv   rx   rz   r{   rP   r}   r~   )!rO   Ú__mro__ÚvarsÚitemsr”   r�   r‘   r   r   r   r   rv   r¦   Ú
getmembersrx   Ú_NEVER_DURABLE_HOOKSr¬   r   r«   r­   rz   r   r   r   r   Ú
parametersÚkindÚ	ParameterÚVAR_POSITIONALrS   Ú_capability_operation_schemar   rt   )Ú
capabilityÚhandlersÚbaseÚmethod_nameÚbase_memberr—   ÚmemberÚreasonÚdeclarationsÚoperation_nameÚhandlerÚoriginalrx   r)   rz   Ú
type_hintsr}   r~   Úreplacementsr{   rP   s                        rH   Úcollect_capability_operationsræ   =  sÅ  € ð :<€HÜ�ZÓ ×(Ñ(¨¨Ó,ˆÜ(,¨T«
×(8Ñ(8Ö(:Ñ$ˆKÜ1°+Ó>ˆFØ‰~ V×%5×%5ÙÜœT *Ó-¨{Ó;ˆFØÔ(Ü(,¬X°c¼9ÄS¹>Ð6IÑ-JÈFÓ(S�Ÿ™Ó%ó );ñ -ô  '×1Ò1´$°zÓ2BÖCÑˆÜ-¨fÓ5ˆØ‰>ÙØ×× ¯/©/Ò 9ÙÜ)×-Ñ-¨kÓ:Ð:ˆ6Õ:Ü˜FÓ#Ð#Ø�;‰;˜(Ó"ÜØ3°F·K±K±?À/ÐR\×R_ÑR_ÑQbð cMð Móð ô !%¤X¨c´9¼S±>Ð.AÑ%BÀFÓ Kˆ—‘Óñ  Dð <>€LØ#+§>¡>×#3ÑˆÜ/°Ó8ˆØ(0Ñ(<�8×$Ò$À'ˆØ× Ñ  ¬T°*Ó-=Ó>ˆÜ×%Ò% eÓ,ˆ	Ü# E¸$Ñ?ˆ
Ü,Ø¤+¨|ÐK^ñ
ˆô #7ØØÙ@Ø!Ø-ñ#
Ðô 	" (°zÀ=ÔQà#Ñ/Ø×$Ñ$Ð%<Ñ=×BÑBÄg×FWÑFW×FfÑFfÒfäÐmÓnÐnð 'Ñ2ð %Ô&CÀXÔOlÑmàð 	ô
 .Ø˜m¨ZÐQ]ñ
ˆð
 'Ñ2õ *ä+¨J¯N©N¸8Ó,DÀeÓLð 	ô
 (CØØØØØ#Ø'Ø$;ñ(
ˆÔ$ñG $4ðX ÐrG   c          	     ó¼  • Uc  U(       d  [        U [        5      $ [        U 5      nUR                  5        VVs0 s H  u  pgXb:w  d  M  XdR	                  Xg5      _M     snnUl        UR                  UR                  R                  5        Vs/ s H  oˆR                  U:w  d  M  UPM     snS9n	U	[        [        U5      l        [        U[        SS9$ s  snnf s  snf )N)rÔ   F)Ú	takes_ctx)r   r    Ú_schema_targetrÑ   r¬   rE   r   rÔ   r¨   rv   r   r   Ú__signature__)
rx   rz   r}   rä   rÎ   Úschema_targetrv   rË   ÚpÚschema_signatures
             rH   rØ   rØ   Ž  sÙ   € ð ÑÖ%<Ü˜xÔ)?Ó@Ð@ä" 8Ó,€Mð !+× 0Ñ 0Ô 2ô%â 2ÑˆDØÑ ó 	<ˆ×)Ñ)¨$Ó;Ò;Ù 2ò%€MÔ!ð
 !×(Ñ(Ø(×3Ñ3×:Ñ:Ô<ÓXÒ<˜!ÇÁÈ-Ñ@W—AÑ<ÑXð )ð Ðð .>„DŒˆmÓÔ*Ü˜=Ô*@ÈEÑRÐRùó%ùò Ys   ¹CÁCÂCÂ$Cc                ó"   • SS jn[        X5      $ )z[Create a metadata-preserving callable whose signature can be adapted for schema generation.c               ›  ó   #   • U $ 7frg   r@   )r°   s    rH   r¶   Ú_schema_target.<locals>.target©  s
   é € Øˆùs   ‚)r°   r   rj   r   )r	   )rx   r¶   s     rH   ré   ré   ¦  s   € ôô ˜&Ó+Ð+rG   c               ó°  • U R                   R                  " U0 UD6nUR                  5         [        UR                  5      nU R
                  b  UR                  U R
                  5        U R                   R                  R                  5        H†  u  pgUR                  [        R                  R                  L a"  UR                  UR                  U5      5        MN  UR                  [        R                  R                  L d  Mw  [        XV   5      XV'   Mˆ     [!        [        ["        [$        4   U R&                  R(                  R+                  U5      5      $ rg   )rz   r§   Úapply_defaultsr[   r=   r}   ÚpoprÔ   rÑ   rÕ   r¦   rÖ   ÚVAR_KEYWORDÚupdater×   Úlistr   r\   r   r{   Ú	validatorÚvalidate_python)Údeclarationr±   r¯   r°   r)   r=   rv   Ú	parameters           rH   Úbind_argumentsrû   ¯  sü   € ð ×!Ñ!×&Ò&¨Ð7°Ñ7€EØ	×ÑÔÜ�U—_‘_Ó%€IØ× Ñ Ñ,Ø�‰�k×/Ñ/Ô0Ø&×0Ñ0×;Ñ;×AÑAÖC‰ˆØ�>‰>œW×.Ñ.×:Ñ:Ò:Ø×Ñ˜YŸ]™]¨4Ó0Ö1Ø�^‰^œw×0Ñ0×?Ñ?Ô?Ü" 9¡?Ó3ˆI‹Oñ	 Dô
 ””Sœ#�X‘ × 2Ñ 2× <Ñ <× LÑ LÈYÓ WÓXÐXrG   c                óØ   • [        [        U5      U R                  R                  U R                  5      n[	        U5      nUb  UR                  OUnUR                  U[        U5      5      $ )a}  Bind the operation body the run's capability actually implements.

The declaration was collected from the class the engine bound at construction, but a `for_run`
replacement may be a specialized subclass, and its override is the implementation the run asked
for. A decorated override is reached through its marker, which carries the undecorated target so
binding it doesn't re-enter dispatch; an override of a `base_hook_durable_operation` hook carries
no marker of its own and is bound as it stands. A replacement that doesn't carry the method at
all falls back to the declared one, which is also what the lookup's default resolves to.
)r‘   rO   rx   rA   r”   r­   )rù   rÙ   rÞ   r—   rx   s        rH   Úbind_declaration_bodyrý   Ã  s[   € ô ”T˜*Ó% {×';Ñ';×'DÑ'DÀk×FZÑFZÓ[€FÜ)¨&Ó1€FØ"(Ñ"4ˆv�Š¸&€HØ×Ñ˜J¬¨ZÓ(8Ó9Ð9rG   )Úmodel_request_contextc             ƒ  ó´  #   • [        X5      n[        UR                  US9n[        UR                  5      n/ n0 nU R
                  R                  R                  5        GHb  u  pšX�R                  :X  a?  U
R                  [        R                  R                  L a  XXU	'   OUR                  U5        MT  U
R                  [        R                  R                  L a  UR                  U5        MŽ  U
R                  [        R                  R                   L a"  UR#                  UR%                  U	5      5        M×  X�R&                  :X  a  Uc  [)        S5      eUnOUR%                  U	5      nU
R                  [        R                  R*                  [        R                  R,                  4;   a  UR                  U5        GM^  X¸U	'   GMe     U" U0 UD6I S h  v•N $  N7f)N)Ú_capabilityz~A model-request durable declaration was called without its model scope. This is an internal Pydantic AI bug; please report it.)rý   r   r:   r[   r=   rz   rÔ   rÑ   r}   rÕ   r¦   rÖ   ÚKEYWORD_ONLYÚappendrô   rõ   r×   Úextendró   r~   ÚAssertionErrorÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORD)rù   rÙ   r‡   rþ   r)   r:   r=   r¯   r°   rv   rú   rL   s               rH   Úcall_declarationr  Õ  s€  é € ô " +Ó:€Eô ˜&×,Ñ,¸*ÑE€KÜ�V×%Ñ%Ó&€IØ€DØ€FØ&×0Ñ0×;Ñ;×AÑA×C‰ˆØ×,Ñ,Ó,Ø�~‰~¤×!2Ñ!2×!?Ñ!?Ò?Ø*�t’à—‘˜KÔ(ÙØ�>‰>œW×.Ñ.×:Ñ:Ò:Ø�M‰M˜)Ô$ÙØ�>‰>œW×.Ñ.×=Ñ=Ò=Ø�K‰K˜	Ÿ™ dÓ+Ô,ÙØ×6Ñ6Ó6Ø$Ñ,Ü$ðMóð ð *‰Eà—M‘M $Ó'ˆEà�>‰>œg×/Ñ/×?Ñ?Ä×ARÑAR×AhÑAhÐiÓiØ�K‰K˜×à �4ŒLñ5 Dñ6 ˜Ð' Ñ'×'Ð'Ñ'ùs   ‚GGÇGÇGc             ƒ  óø  #   • U R                   =(       d    0 nUR                  U5      =n(       a  U$ U R                  nUc  [        S5      e[	        UR
                  5       Vs/ s H  oUR                  U:X  d  M  UPM     nn[        U5      S:w  a  [        SU< S[        U5       S35      eUS   n[        U5      R                  [        R                  L a  U$ UR                  U 5      I S h  v•N $ s  snf  N	7f)NzIA durable capability operation requires the worker agent on `RunContext`.r#   z&Expected one bound capability with id z, found Ú.r   )Ú_run_capabilities_by_idr¬   ÚagentÚRuntimeErrorr   Úroot_capabilityr«   ÚlenrO   Úfor_runr   )r±   Úcapability_idÚrun_capabilitiesrÙ   r  ÚcapÚmatchess          rH   Úrecover_capabilityr    sñ   é € Ø×2Ñ2×8°bÐØ%×)Ñ)¨-Ó8Ð8€zÕ8ØÐØ�I‰I€EØ�}ÜÐfÓgÐgÜ/°×0EÑ0EÔFÓbÒF�sÏ&É&ÐTaÑJa�sÑF€GÐbÜ
ˆ7ƒ|�qÓÜÐCÀMÑCTÐT\Ô]`ÐahÓ]iÐ\jÐjkÐlÓmÐmØ˜‘€JÜˆJÓ×ÑÔ#5×#=Ñ#=Ò=ØÐØ×#Ñ# CÓ(×(Ð(ùò cñ )ùs%   ‚A!C:Á#C3Á:C3Â A.C:Ã.C8Ã/
C:)rP   r|   rj   z$type[CapabilityOperationResult[Any]])r“   r|   rj   zMarker | None)r“   r|   r—   r�   rj   rl   )rv   r|   rj   r\   )rv   r\   rj   z*Callable[[Callable[P, A]], Callable[P, A]])rv   r\   rj   zPCallable[[Callable[..., Awaitable[ResultT]]], Callable[..., Awaitable[ResultT]]])rÙ   r¹   rj   z&dict[str, CapabilityMethodDeclaration])rx   rw   rz   ry   r}   r>   rä   r<   rÎ   r<   rj   r   )rx   rw   rj   rw   )
rù   rt   r±   r9   r¯   ztuple[Any, ...]r°   r<   rj   r<   )rù   rt   rÙ   r¹   rj   rw   )
rù   rt   rÙ   r¹   r‡   r7   rþ   zModelRequestContext | Nonerj   r   )r±   r9   r  r\   rj   r¹   )QÚ
__future__r   r¦   Úcollections.abcr   r   Údataclassesr   r   r   Ú	functoolsr	   r
   Útypingr   r   r   r   r   r   Úpydantic_ai._function_schemar   r   r   r   r   r   Úpydantic_ai._run_contextr   Ú!pydantic_ai.capabilities.abstractr   r   Úpydantic_ai.exceptionsr   Úpydantic_ai.messagesr   Úpydantic_ai.modelsr   r   r   Úpydantic_ai.settingsr   Úpydantic_ai.toolsr    r!   Úpydantic_ai.usager"   Ú
_operationr$   Ú_operation_backendr%   r&   r'   r(   Ú	frozensetr»   Ú_WRAP_NEVER_DURABLE_HOOKSrÓ   r7   rJ   rQ   rS   rp   rt   r„   r‹   r�   r’   r”   r˜   rž   rÁ   rÆ   ræ   rØ   ré   rû   rý   r  r  ÚCapabilityBoundOperationr�   s   0rH   Ú<module>r(     só  ðÝ "ã ß /ß 3Ñ 3ß +ß I× I÷÷ õ =ß SÝ ,Ý -ß QÑ QÝ .ß @Ý &å %Ý 5á
�)Ó
€ÙˆcƒN€ÙˆC�y ‘~Ñ&€á% }Ð6KÐ&LÓMÐ ðð
Ð ðñ .óâ-ˆDð 	��$�Ð\Ð]Ò]Ù-ñðð
 qØ\ØlòÐ ñ �$Ñ÷ ð  ó ð ñ �$Ñô ¨Ñ 0ó ó ðôið ÷,+ð ,+ó ð,+ñ^ �$Ñ÷ð ó ðñ �$Ñ÷8ð 8ó ð8ô	G˜mÐ,EÑFô 	Gñ �$Ñ÷ð ó ðð 
!€Ø7Ð ôFô
,ô
ôbðJØ
ðàUôð(NØ'ðNà+ôNðbSØ+ðSà ðSð ðSð ð	Sð ,ðSð ôSô0,ðYØ,ðYð 
ðYð ð	Yð
 ðYð ôYð(:Ø,ð:Ø:Qð:à"ô:ð. 9=ñ*(Ø,ð*(à'ð*(ð &ð	*(ð
 6ð*(ð 	õ*(ôZ)ð  1Ð1JÈCÐQTÐ1TÑUÑ ùòCs   Â5G