ó
    °"³j¬  ã                  ó  • % S 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
JrJrJrJr  SSKrSSKJrJr  SS	KJr  SS
KJrJrJrJrJrJr  \
(       a  SSKJr   " S S\5      r " S S\5      r\" SS9 " S S\5      5       r\" SS9 " S S\5      5       r \RB                  " \\"\S4   5      r#S\$S'   \RB                  " \5      r%S\$S'   S$S jr&S%S jr'\&\S'   \'\S'   S\S'   S\S '   S\\'   S\\ '   S&S! jr(S'S" jr)S&S# jr*g)(z4Typed message parts for deferred capability loading.é    )Úannotations)Ú
CollectionÚSequence)ÚKW_ONLYÚ	dataclass)ÚTYPE_CHECKINGÚ	AnnotatedÚLiteralÚUnionÚcastN)ÚNotRequiredÚ	TypedDicté   )Úcopy_dataclass_fields)Ú_TOOL_CALL_NARROWERSÚ_TOOL_RETURN_NARROWERSÚ_TYPED_PART_TAGSÚ_TYPED_PART_TAGS_BY_TYPEÚToolCallPartÚToolReturnPart)ÚModelMessagec                  ó$   • \ rS rSr% SrS\S'   Srg)ÚLoadCapabilityArgsé   z2Typed arguments for a `load_capability` tool call.zOAnnotated[str, pydantic.Field(description='The id of the capability to load.')]Úid© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_ai/_deferred_capabilities.pyr   r      s   ‡ Ù<ð	ó ò (r%   r   c                  ó$   • \ rS rSr% SrS\S'   Srg)ÚLoadCapabilityReturné(   z2Typed return value for the `load_capability` tool.zNotRequired[str]Úinstructionsr   Nr   r   r%   r&   r(   r(   (   s   ‡ Ù<à"Ó"Ú1r%   r(   F)Úreprc                  ó|   • \ rS rSr% SrS\S'   SrS\S'    SrS	\S
'    SrS\S'    \	SS j5       r
\	SS j5       rSrg)ÚLoadCapabilityCallParté/   z4Typed `ToolCallPart` for the `load_capability` tool.r   Ú_Úload_capabilityúLiteral['load_capability']Ú	tool_nameNzstr | LoadCapabilityArgs | NoneÚargsúcapability-loadúLiteral['capability-load']Ú	tool_kindc                ó~   • U R                   c  g [        SU R                  SS95      $ ! [        [        4 a     gf = f)zJParsed load-capability arguments, or `None` for incomplete streaming args.Nr   T)Úraise_if_invalid)r3   r   Úargs_as_dictÚ
ValueErrorÚAssertionError©Úselfs    r&   Ú
typed_argsÚ!LoadCapabilityCallPart.typed_args>   sJ   € ð �9‰9ÑØð	ÜÐ,¨d×.?Ñ.?ÐQUÐ.?Ð.VÓWÐWøÜœNÐ+ó 	Ùð	ús   �) ©<»<c                óD   • U R                   nUc  gUR                  S5      $ )z1Capability id from the parsed args, if available.Nr   )r>   Úget)r=   Útypeds     r&   Úcapability_idÚ$LoadCapabilityCallPart.capability_idH   s#   € ð —‘ˆØ‰=ØØ�y‰y˜‹Ðr%   r   )ÚreturnzLoadCapabilityArgs | None©rE   z
str | None)r   r   r    r!   r"   r#   r2   r3   r6   Úpropertyr>   rC   r$   r   r%   r&   r-   r-   /   sZ   ‡ á>àƒJà,=€IÐ)Ó=Ø+à,0€DÐ
)Ó0Ø'à,=€IÐ)Ó=Ø/àóó ðð óó ór%   r-   c                  ód   • \ rS rSr% SrS\S'   S\S'    SrS\S	'    S
rS\S'    \SS j5       r	Sr
g)ÚLoadCapabilityReturnPartéQ   z6Typed `ToolReturnPart` for the `load_capability` tool.r   r/   r(   Úcontentr0   r1   r2   r4   r5   r6   c                ó8   • U R                   R                  S5      $ )z'Loaded capability instructions, if any.r*   )rK   rA   r<   s    r&   r*   Ú%LoadCapabilityReturnPart.instructionsc   s   € ð �|‰|×Ñ Ó/Ð/r%   r   NrF   )r   r   r    r!   r"   r#   r2   r6   rG   r*   r$   r   r%   r&   rI   rI   Q   sE   ‡ á@àƒJà!Ó!ðð
 ->€IÐ)Ó=Ø+à,=€IÐ)Ó=Ø/àó0ó ó0r%   rI   z5pydantic.TypeAdapter[str | LoadCapabilityArgs | None]Ú_LOAD_CAPABILITY_CALL_ARGS_TAz*pydantic.TypeAdapter[LoadCapabilityReturn]Ú"_LOAD_CAPABILITY_RETURN_CONTENT_TAc                óŽ   • [        U [        5      (       a  U $ [        R                  U R                  5      n[        U [        USS9$ )Nr4   )r3   r6   )Ú
isinstancer-   rN   Úvalidate_pythonr3   r   )ÚpartÚvalidated_argss     r&   Ú_narrow_load_capability_callrU   q   s<   € Ü�$Ô.×/Ñ/ØˆÜ2×BÑBÀ4Ç9Á9ÓM€NÜ  Ô'=ÀNÐ^oÑpÐpr%   c                óŽ   • [        U [        5      (       a  U $ [        R                  U R                  5      n[        U [        USS9$ )Nr4   )rK   r6   )rQ   rI   rO   rR   rK   r   )rS   Úvalidated_contents     r&   Ú_narrow_load_capability_returnrX   x   s>   € Ü�$Ô0×1Ñ1ØˆÜ:×JÑJÈ4Ï<É<ÓXÐÜ  Ô'?ÐIZÐfwÑxÐxr%   r4   zcapability-load-call)z	tool-callr4   zcapability-load-return)ztool-returnr4   c                ó0   • SSK Jn  [        U" U 5      5      $ )u  Parse visible history to find capabilities loaded via `load_capability`.

Every [`CompactionPart`][pydantic_ai.messages.CompactionPart] resets the derived
state at its exact position in a response. This is deliberately provider-agnostic:
over-counting can expose tools whose load evidence is no longer visible, while
under-counting once only permitted a redundant, idempotent load. Now that availability
gates execution, an under-count also *refuses* the call â€” see
[`post_compaction_window`][pydantic_ai.messages.post_compaction_window] for when that
is wrong and what is tracked to fix it.

Only the [`post_compaction_window`][pydantic_ai.messages.post_compaction_window] is scanned â€”
the one definition of the boundary â€” so only pairs entirely after the boundary count.
r   )Úpost_compaction_window)ÚmessagesrZ   Ú_parse_loaded_capabilities)r[   rZ   s     r&   Úparse_loaded_capabilitiesr]   Š   s   € õ  1ä%Ñ&<¸XÓ&FÓGÐGr%   c                ó0   • [        U 5      [        U5      -  $ )u  `parse_loaded_capabilities`, narrowed to capabilities this run actually registered.

History outlives configuration: a conversation resumed against a smaller capability set still
carries the load records of capabilities that are no longer configured, and without this
`RunContext.loaded_capability_ids` â€” and the `active_capability_ids` that unions it â€” would
name a capability the run has no way to act on. Every consumer today starts from a real
capability or a real `ToolDefinition`, so nothing observes the difference yet; the sets are
public, though, and should not promise something that isn't there.

Leans on the registry being seeded once at run start. Capabilities registered mid-run would make
this a moving target and would need the narrowing reapplied wherever they land.
)r]   Úset)r[   Úcapability_idss     r&   Ú registered_loaded_capability_idsra   Ÿ   s   € ô % XÓ.´°^Ó1DÑDÐDr%   c                ób  • 0 n[        5       nU  Hœ  nUR                   H‰  n[        U[        5      (       a)  UR                  b  UR                  XR
                  '   M?  MA  [        U[        5      (       d  MX  UR                  UR
                  5      nUc  Mx  UR                  U5        M‹     Mž     U$ )zGParse capability-load evidence from an already-selected message window.)	r_   ÚpartsrQ   r-   rC   Útool_call_idrI   rA   Úadd)r[   Úcall_id_by_tool_call_idÚloadedÚmsgrS   Úcap_ids         r&   r\   r\   ¯   s˜   € à.0ÐÜ“u€FÛˆØ—I”IˆDÜ˜$Ô 6×7Ñ7Ø×%Ñ%Ñ1ØAE×ASÑASÐ+×,=Ñ,=Ó>ñ 2ä˜DÔ":×;Ó;Ø0×4Ñ4°T×5FÑ5FÓG�ØÓ%Ø—J‘J˜vÖ&ó ñ ð €Mr%   )rS   r   rE   r-   )rS   r   rE   rI   )r[   úSequence[ModelMessage]rE   úset[str])r[   rj   r`   zCollection[str]rE   rk   )+r"   Ú
__future__r   Úcollections.abcr   r   Údataclassesr   r   Útypingr   r	   r
   r   r   ÚpydanticÚtyping_extensionsr   r   Ú_utilsr   r[   r   r   r   r   r   r   r   r   r(   r-   rI   ÚTypeAdapterÚstrrN   r#   rO   rU   rX   r]   ra   r\   r   r%   r&   Ú<module>ru      sB  ðÚ :å "ç 0ß *ß AÕ Aã ß 4å )÷÷ ö Ý&ô	(˜ô 	(ô2˜9ô 2ñ �Ñô˜\ó ó ðñB �Ñô0˜~ó 0ó ð0ð. X`×WkÒWkØ	ˆ#Ð! 4Ð
'Ñ(óXÐ ÐTó ð RZ×QeÒQeØóRÐ "Ð$Nó ô
qôyð +GÐ Ð&Ñ 'Ø,JÐ Ð(Ñ )à5KÐ Ð1Ñ 2Ø7OÐ Ð3Ñ 4à3IÐ Ð/Ñ 0Ø5MÐ Ð1Ñ 2ôHô*Eõ r%   