ó
    ±"³j  ã                  óö   • 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
  S SKJrJr  S SKJr  S SKJrJrJr  \(       a  SS	KJr  \" S
S9 " S S\\   5      5       r      SS jr      SS jr    SS jrg)é    )Úannotations)Ú	dataclassÚreplace)ÚTYPE_CHECKINGÚGeneric)Úvalidate_instruction_id_segmentÚvalidate_instruction_name)Ú
AgentDepsTÚ
RunContext)Ú	UserError)ÚInstructionIdÚInstructionPartÚToolsetInstructionSourceé   )ÚAbstractToolsetT)Úfrozenc                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)ÚInstructionContributioné   zCOne source's instruction parts, with the key they are addressed by.úAbstractToolset[AgentDepsT]ÚsourcezToolsetInstructionSource | NoneÚ	source_idztuple[InstructionPart, ...]Úparts© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    Úi/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_ai/toolsets/_instruction_collection.pyr   r      s   ‡ áMà'Ó'Ø.Ó.Ø&Ö&r"   r   c                ó„  • SnUnUR                   b  [        UR                   5        U R                  bl  [        U R                  SS9  [	        U R                  5      nUR                  b  UR                  R
                  U:w  a  [        U[        X!R                   S9S9nOUR                  b
  [        USS9n[        XU4S9$ )an  Attribute one surviving part to the source that authored it, minting that source's key.

Takes a part rather than a `get_instructions` result because minting validates the source's
`id`, and a source that says nothing to the model must never be the reason that fails. Callers
normalize first and never reach here with nothing, so there is no empty case to mint for.
Nz
Toolset id)Úkind)Úname)Úid)r   r   r   )	r&   r	   r'   r   r   r   r   r   r   )r   Úpartr   Úresolved_parts       r#   Úmake_contributionr*      s    € ð €IØ€MØ‡y�yÑÜ! $§)¡)Ô,Ø‡y�yÑÜ'¨¯	©	¸ÒEÜ,¨V¯Y©YÓ7ˆ	Ø�7‰7‰?˜dŸg™gŸn™n°	Ó9ô $ D¬]¸9Ï9É9Ñ-UÑVˆMøØ	�‰Ñ	Ü ¨Ñ.ˆÜ"¨&ÈmÐM]Ñ^Ð^r"   c              ƒ  óV   #   • U R                  U5      I Sh  v•N n[        U5      $  N7f)zACollect instruction parts once at the authoring toolset boundary.N)Ú"_collect_instruction_contributionsÚ!flatten_instruction_contributions)ÚtoolsetÚctxÚcontributionss      r#   Úcollect_toolset_instructionsr1   1   s+   é € ð "×DÑDÀSÓI×I€MÜ,¨]Ó;Ð;ñ Jùs   ‚)—'˜)c           	     ó&  • 0 n/ nU  H†  nUR                   b[  UR                   nUR                  XCR                  5      UR                  La'  [        SUR                  < S[        U5      < S35      eUR                  UR                  5        Mˆ     U$ )zîFlatten collected contributions, rejecting two sources that would claim one key.

Separate from the collection itself so a toolset that has already gathered its children can
apply the rule without re-entering the walk that produced them.
z Two toolsets have the same `id` z& and both contribute instructions, so zo would address parts from each. Toolset `id`s must be unique among all toolsets registered with the same agent.)r   Ú
setdefaultr   r   r'   ÚstrÚextendr   )r0   Úownersr   Úcontributionr   s        r#   r-   r-   9   s    € ð KM€FØ#%€EÛ%ˆØ×!Ñ!Ñ-Ø$×.Ñ.ˆIØ× Ñ  ×,?Ñ,?Ó@È×H[ÑH[Ò[ÜØ6°y·|±|Ñ6Fð G(Ü(+¨I«Ñ'9ð :fðfóð ð
 	�‰�\×'Ñ'Ö(ñ &ð €Lr"   N)r   r   r(   r   Úreturnz#InstructionContribution[AgentDepsT])r.   r   r/   zRunContext[AgentDepsT]r8   úlist[InstructionPart])r0   z)list[InstructionContribution[AgentDepsT]]r8   r9   )Ú
__future__r   Údataclassesr   r   Útypingr   r   Úpydantic_ai._instructionsr   r	   Úpydantic_ai._run_contextr
   r   Úpydantic_ai.exceptionsr   Úpydantic_ai.messagesr   r   r   Úabstractr   r   r*   r1   r-   r   r"   r#   Ú<module>rB      s›   ðÝ "ç *ß )ç `ß ;Ý ,ß YÑ YæÝ)ñ �$Ñô'˜g jÑ1ó 'ó ð'ð_Ø'ð_Ø/>ð_à(ô_ð2<Ø(ð<Ø/Eð<àô<ðØ<ðàõr"   