ó
    ±"³jD  ã                  ó*  • 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Jr  S SKJr  S SKJrJrJr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J r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  S SK)J*r*J+r+J,r,  S SK-J.r.  S SK/J0r0  \" SS9 " S S\\   5      5       r1g)é    )Úannotations)Ú	AwaitableÚCallableÚSequence)ÚKW_ONLYÚ	dataclassÚfield)ÚAnyÚoverload)ÚGenerateJsonSchema)ÚAgentInstructionsÚSourcedInstructionÚnormalize_instructionsÚvalidate_instruction_id_segmentÚvalidate_instruction_name)Ú
AgentDepsTÚ
RunContext)ÚAbstractCapabilityÚCapabilityDescription)ÚCapabilityInstructionSourceÚInstructionId)
ÚArgsValidatorFuncÚDocstringFormatÚGenerateToolJsonSchemaÚSystemPromptFuncÚToolÚToolFuncContextÚToolFuncEitherÚToolFuncPlainÚ
ToolParamsÚToolPrepareFunc)ÚAbstractToolsetÚAgentToolsetÚFunctionToolset)ÚDynamicToolset)ÚCombinedToolsetF)Úinitc                  óÐ  ^ • \ rS rSr% SrS\S'   SrS\S'    SrS\S	'    S
rS\S'    \	" SSS9r
S\S'   \	" SSS S9rS\S'   \	" SSS
S9rS\S'   S
S
SS
S
SS.             S0S jjr\S1S j5       rS2S jrS3S jrS4U 4S jjrS5S jrS6S jr\S7S  j5       r\S
S
S
S
S
S!S\S
SSS
S
SS
S".                               S8S# jj5       r S9S
S
S
S
S
S!S\S
SSS
S
SS
S".                                 S:S$ jjjr\S;S% j5       r\S
S
S
S
S
S!S\S
SSS
S
SS
S".                               S<S& jj5       r S9S
S
S
S
S
S!S\S
SSS
S
SS
S".                                 S=S' jjjr\    S>S( j5       r\    S?S) j5       r\S@S* j5       r\SAS+ j5       r\S
S,.   SBS- jj5       r S9S
S,.     SCS. jjjrS/rU =r$ )DÚ
Capabilityé$   aƒ  Convenience capability for bundling instructions, tools, and toolsets without subclassing.

This groups related instructions, descriptions, function tools, and toolsets under
a capability identity. Instructions passed via `instructions=` are available through
`get_instructions()`;
[`instructions`][pydantic_ai.capabilities.Capability.instructions] is the decorator
for registering instruction functions. The constructor accepts static or callable
`description=` values. For model settings, lifecycle hooks, native tools, wrapper
toolsets, or custom per-run logic, subclass
[`AbstractCapability`][pydantic_ai.capabilities.AbstractCapability].
r   Ú_© z"Sequence[AgentToolset[AgentDepsT]]Útoolsetsú<Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]]ÚtoolsNú
str | NoneÚdescriptionF)r'   ÚreprzFunctionToolset[AgentDepsT]Ú_function_toolsetc                 ó   • / $ ©Nr,   r,   ó    Ú`/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_ai/capabilities/capability.pyÚ<lambda>ÚCapability.<lambda>B   s   € Ñprr6   )r'   r2   Údefault_factoryú$list[SourcedInstruction[AgentDepsT]]Ú_instructions)r'   r2   Údefaultú(CapabilityDescription[AgentDepsT] | NoneÚ_description)Úinstructionsr-   r/   Úidr1   Údefer_loadingc               óL  • Ub  [        U5      nOSnUb
  [        USS9  X@l        [        U[        5      (       a  UOSU l        XPl        X`l        Xpl        X0l	        [        [           " X4S9U l        [        U5       Vs/ s H  o€R                  U5      PM     snU l        gs  snf )a~  Build a capability from instructions, tools, toolsets, and an optional description.

Args:
    instructions: Static instructions and/or instruction function(s), available via
        `get_instructions()`. Pass an [`InstructionPart`][pydantic_ai.messages.InstructionPart]
        to declare a part's [`name`][pydantic_ai.messages.InstructionPart.name] or mark it
        [`dynamic`][pydantic_ai.messages.InstructionPart.dynamic]. Register more with the
        [`instructions`][pydantic_ai.capabilities.Capability.instructions] decorator.
    toolsets: Toolsets to register with the agent.
    tools: Function tools to register with the agent.
    id: Stable identifier for the capability. Required when `defer_loading=True`, so the
        model's `load_capability` call can reference it.
    description: Static string or callable description, returned from `get_description()`.
        For a deferred capability it is shown to the model so it can decide whether to load it.
    defer_loading: When `True`, the capability's tools and instructions stay hidden until the
        model loads it on demand via the `load_capability` tool; requires `id`.
Nr,   zCapability id)Úkind©rA   )Útupler   rA   Ú
isinstanceÚstrr1   r?   rB   r-   r/   r$   r   r3   r   Ú_attribute_instructionr<   )	Úselfr@   r-   r/   rA   r1   rB   Úresolved_toolsetsÚinstructions	            r7   Ú__init__ÚCapability.__init__E   sŸ   € ð8 ÑÜ % h£Ñà "ÐØ‰>Ü+¨B°_ÒEØŒÜ*4°[Ä#×*FÑ*F™;ÈDˆÔØ'ÔØ*ÔØ)ŒØŒ
ô "1´Ò!<¸UÑ!JˆÔäH^Ð_kÔHló
ÚHl¸×'Ñ'¨Ö4ÑHlñ
ˆÕùò 
s   Á>B!c                ó   • g r5   r,   )Úclss    r7   Úget_serialization_nameÚ!Capability.get_serialization_nameu   s   € ð
 r6   c                ó   • U R                   $ r5   )r?   )rJ   s    r7   Úget_descriptionÚCapability.get_description|   s   € Ø× Ñ Ð r6   c                ój   • U R                    Vs/ s H  oR                  PM     sn=(       d    S $ s  snf r5   )r<   rL   )rJ   Úsourceds     r7   Úget_instructionsÚCapability.get_instructions   s+   € Ø37×3EÒ3EÓFÒ3E¨×#Ô#Ñ3EÑF×NÈ$ÐNùÒFs   �0c                ó–   >• [        U 5      R                  [        R                  La  [        TU ]  5       $ [        U R                  5      $ r5   )ÚtyperX   r)   ÚsuperÚ_collect_instructionsÚlistr<   )rJ   Ú	__class__s    €r7   r]   Ú Capability._collect_instructions‚   s:   ø€ Ü�‹:×&Ñ&¬j×.IÑ.IÒIä‘7Ñ0Ó2Ð2Ü�D×&Ñ&Ó'Ð'r6   c           
     ó–  • [        U R                  5       VVs/ s H<  u  p[        U[        5      (       a  UO[        [
           " X R                  U5      S9PM>     nnnU R                  R                  (       a  U R                  /UQOUnU(       d  U R                  $ [        U5      S:X  a  US   $ [        [
           " U5      $ s  snnf )N)Útoolset_funcrA   é   r   )Ú	enumerater-   rG   r"   r%   r   Ú_toolset_idr3   r/   Úlenr&   )rJ   ÚindexÚtsÚleavesÚmaterializeds        r7   Úget_toolsetÚCapability.get_toolsetˆ   sÉ   € ô ' t§}¡}Ô5ô	5
ò 6‘	�ô ˜"œo×.Ñ.ñ ä¤
Ò+¸×@PÑ@PÐQVÓ@WÑXòYñ 6ð	 	ñ 5
ð 26×1GÑ1G×1M×1MˆT×#Ñ#Ð- fÑ-ÐSYð 	ö ð ×)Ñ)Ð)Üˆ|Ó Ó!Ø ‘?Ð"ÜœzÒ*¨<Ó8Ð8ùó#5
s   ™ACc                óB   • U R                   c  S$ U R                    SU 3$ )aê  The `id` for the leaf toolset this capability builds around the callable at `index`.

Durable execution identifies a leaf toolset by `id`, so a capability the user named has to
pass that name down or the toolset it contributes stays anonymous and unusable there
(#7274). One capability can contribute several leaves, though -- `tools=` builds a
`FunctionToolset` that already took the bare `id` -- so the position within this
capability's own arguments distinguishes them. That position is stable because it is the
order the user wrote in `toolsets=`, not an order the run happened to compose, and not one
that shifts when a `@tool` is registered later.

Pass a `DynamicToolset` with its own `id` instead of a bare callable to name one yourself.
Nr+   rE   )rJ   rg   s     r7   re   ÚCapability._toolset_idž   s&   € ð —w‘w‘ˆtÐ@¨t¯w©w¨i°q¸¸Ð,@Ð@r6   c               ó   • g r5   r,   ©rJ   Úfuncs     r7   Ú
tool_plainÚCapability.tool_plain­   ó   € Ø[^r6   Úauto©Únamer1   ÚretriesÚprepareÚargs_validatorÚdocstring_formatÚrequire_parameter_descriptionsÚschema_generatorÚstrictÚ
sequentialÚrequires_approvalÚmetadataÚtimeoutrB   Úinclude_return_schemac              ó   • g r5   r,   ©rJ   rw   r1   rx   ry   rz   r{   r|   r}   r~   r   r€   r�   r‚   rB   rƒ   s                   r7   rr   rs   °   s	   € ð( LOr6   c              ój   • U R                   R                  UUUUUUUU	U
UUUUUUS9nUc  U$ U" U5      $ )a.  Decorator to register a plain (no-[`RunContext`][pydantic_ai.tools.RunContext]) function tool on this capability.

Mirrors [`Agent.tool_plain`][pydantic_ai.agent.Agent.tool_plain]: the tool is added to this
capability's function toolset and registered with the agent whenever the capability is active.
rv   )r3   rr   ©rJ   rq   rw   r1   rx   ry   rz   r{   r|   r}   r~   r   r€   r�   r‚   rB   rƒ   Ú	decorators                     r7   rr   rs   Æ   sa   € ð4 ×*Ñ*×5Ñ5ØØ#ØØØ)Ø-Ø+IØ-ØØ!Ø/ØØØ'Ø"7ð 6ð 
ˆ	ð" !™LˆyÐ=©i¸«oÐ=r6   c               ó   • g r5   r,   rp   s     r7   ÚtoolÚCapability.tooló   ó   € Øqtr6   c              ó   • g r5   r,   r…   s                   r7   rŠ   r‹   ö   s	   € ð( hkr6   c              ój   • U R                   R                  UUUUUUUU	U
UUUUUUS9nUc  U$ U" U5      $ )a   Decorator to register a function tool (taking [`RunContext`][pydantic_ai.tools.RunContext]) on this capability.

Mirrors [`Agent.tool`][pydantic_ai.agent.Agent.tool]: the tool is added to this capability's
function toolset and registered with the agent whenever the capability is active.
rv   )r3   rŠ   r‡   s                     r7   rŠ   r‹     sa   € ð4 ×*Ñ*×/Ñ/ØØ#ØØØ)Ø-Ø+IØ-ØØ!Ø/ØØØ'Ø"7ð 0ð 
ˆ	ð" !™LˆyÐ=©i¸«oÐ=r6   c               ó   • g r5   r,   rp   s     r7   r@   ÚCapability.instructions9  s   € ð :=r6   c               ó   • g r5   r,   rp   s     r7   r@   r�   >  s	   € ð EHr6   c               ó   • g r5   r,   rp   s     r7   r@   r�   C  rt   r6   c               ó   • g r5   r,   rp   s     r7   r@   r�   F  rŒ   r6   ©rw   c              ó   • g r5   r,   )rJ   rw   s     r7   r@   r�   I  s	   € ð RUr6   c              óV   ^ ^• Tb  [        T5            SUU 4S jjnUc  U$ U" U5      $ )uÀ  Decorator to register an instructions function on this capability.

Mirrors `Agent.instructions`: the function may take
[`RunContext`][pydantic_ai.tools.RunContext] (or no arguments), may be sync or async, and is
appended to any instructions provided via the `instructions=` field.

Example:
```python
from pydantic_ai import RunContext
from pydantic_ai.capabilities import Capability

cap = Capability[str](instructions='base instructions')

@cap.instructions
async def dynamic(ctx: RunContext[str]) -> str:
    return f'extra: {ctx.deps}'
```

Args:
    func: The instructions function to register.
    name: An optional name for the instruction part this function produces, keyed as
        `'capability:<capability id>:<name>'` on
        [`InstructionPart.id`][pydantic_ai.messages.InstructionPart.id] so an application can
        address this part specifically, where the capability's own key addresses everything it
        contributes. Requires the capability to have an
        [`id`][pydantic_ai.capabilities.AbstractCapability.id] â€” without one there is no source
        key to qualify the name against, so the part stays unaddressable. See
        [instruction parts](../agent.md#instruction-parts).
c                ó´   >• TR                   b  [        TR                   5      OS nTR                  R                  [	        U TUb
  [        UTS9OS SS95        U $ )Nr”   T)rw   rA   Údynamic)rA   r   r<   Úappendr   r   )Úfunc_Úsourcerw   rJ   s     €€r7   rˆ   Ú*Capability.instructions.<locals>.decoratoru  s_   ø€ ð >B¿W¹WÑ=PÔ0°·±Ô9ÐVZˆFØ×Ñ×%Ñ%Ü"ØØØ;AÑ;M”} V°$Ò7ÐSWØ ñ	ôð ˆLr6   )rš   úSystemPromptFunc[AgentDepsT]Úreturnr�   )r   )rJ   rq   rw   rˆ   s   ` ` r7   r@   r�   N  sC   ù€ ðH ÑÜ% dÔ+ð	Ø/ð	à)÷	ð 	ð !™LˆyÐ=©i¸«oÐ=r6   )r?   r3   r<   rB   r1   rA   r/   r-   )r@   ú$AgentInstructions[AgentDepsT] | Noner-   z)Sequence[AgentToolset[AgentDepsT]] | Noner/   r.   rA   r0   r1   r>   rB   Úboolrž   ÚNone)rž   r0   )rž   r>   )rž   rŸ   )rž   r;   )rž   zAgentToolset[AgentDepsT] | None)rg   Úintrž   r0   )rq   úToolFuncPlain[ToolParams]rž   r£   ) rw   r0   r1   r0   rx   ú
int | Nonery   ú"ToolPrepareFunc[AgentDepsT] | Nonerz   ú0ArgsValidatorFunc[AgentDepsT, ToolParams] | Noner{   r   r|   r    r}   útype[GenerateJsonSchema]r~   úbool | Noner   r    r€   r    r�   údict[str, Any] | Noner‚   úfloat | NonerB   r    rƒ   r¨   rž   z@Callable[[ToolFuncPlain[ToolParams]], ToolFuncPlain[ToolParams]]r5   )"rq   z ToolFuncPlain[ToolParams] | Nonerw   r0   r1   r0   rx   r¤   ry   r¥   rz   r¦   r{   r   r|   r    r}   r§   r~   r¨   r   r    r€   r    r�   r©   r‚   rª   rB   r    rƒ   r¨   rž   r
   )rq   ú'ToolFuncContext[AgentDepsT, ToolParams]rž   r«   ) rw   r0   r1   r0   rx   r¤   ry   r¥   rz   r¦   r{   r   r|   r    r}   r§   r~   r¨   r   r    r€   r    r�   r©   r‚   rª   rB   r    rƒ   r¨   rž   z\Callable[[ToolFuncContext[AgentDepsT, ToolParams]], ToolFuncContext[AgentDepsT, ToolParams]])"rq   z.ToolFuncContext[AgentDepsT, ToolParams] | Nonerw   r0   r1   r0   rx   r¤   ry   r¥   rz   r¦   r{   r   r|   r    r}   r§   r~   r¨   r   r    r€   r    r�   r©   r‚   rª   rB   r    rƒ   r¨   rž   r
   )rq   ú.Callable[[RunContext[AgentDepsT]], str | None]rž   r¬   )rq   ú9Callable[[RunContext[AgentDepsT]], Awaitable[str | None]]rž   r­   )rq   úCallable[[], str | None]rž   r®   )rq   ú#Callable[[], Awaitable[str | None]]rž   r¯   )rw   r0   rž   zFCallable[[SystemPromptFunc[AgentDepsT]], SystemPromptFunc[AgentDepsT]])rq   z#SystemPromptFunc[AgentDepsT] | Nonerw   r0   rž   zeCallable[[SystemPromptFunc[AgentDepsT]], SystemPromptFunc[AgentDepsT]] | SystemPromptFunc[AgentDepsT])Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r-   r/   r1   r	   r3   r<   r?   rM   ÚclassmethodrQ   rT   rX   r]   rk   re   r   rr   r   rŠ   r@   Ú__static_attributes__Ú__classcell__)r_   s   @r7   r)   r)   $   s´  ø‡ ñ
ð ƒJà35€HÐ0Ó5ð VàJL€EÐGÓLØ4à"€K�Ó"ðñ 6;ÀÈEÑ5RÐÐ2ÓRÙ:?ÀUÐQVÑhrÑ:s€MÐ7ÓsÙ=BÈÐTYÐcgÑ=h€LÐ:Óhð
 >BØ>BØNPØØ@DØ#ñ.
ð ;ð.
ð <ð	.
ð
 Lð.
ð ð.
ð >ð.
ð ð.
ð 
õ.
ð` óó ðô!ôO÷(ô9ô,Að Û^ó Ø^àð
  Ø"&Ø"Ø6:ØKOØ,2Ø/4Ø5KØ"Ø Ø"'Ø*.Ø $Ø#Ø-1ñ%Oð ð	Oð
  ðOð ðOð 4ðOð IðOð *ðOð )-ðOð 3ðOð ðOð ðOð  ðOð (ðOð  ð!Oð" ð#Oð$  +ð%Oð& 
Jô'Oó ðOð. 26ð+>ð
  Ø"&Ø"Ø6:ØKOØ,2Ø/4Ø5KØ"Ø Ø"'Ø*.Ø $Ø#Ø-1ñ'+>à.ð+>ð
 ð+>ð  ð+>ð ð+>ð 4ð+>ð Ið+>ð *ð+>ð )-ð+>ð 3ð+>ð ð+>ð ð+>ð  ð+>ð  (ð!+>ð" ð#+>ð$ ð%+>ð&  +ð'+>ð( 
ö)+>ðZ Ûtó Øtàð
  Ø"&Ø"Ø6:ØKOØ,2Ø/4Ø5KØ"Ø Ø"'Ø*.Ø $Ø#Ø-1ñ%kð ð	kð
  ðkð ðkð 4ðkð Iðkð *ðkð )-ðkð 3ðkð ðkð ðkð  ðkð (ðkð  ð!kð" ð#kð$  +ð%kð& 
fô'kó ðkð. @Dð+>ð
  Ø"&Ø"Ø6:ØKOØ,2Ø/4Ø5KØ"Ø Ø"'Ø*.Ø $Ø#Ø-1ñ'+>à<ð+>ð
 ð+>ð  ð+>ð ð+>ð 4ð+>ð Ið+>ð *ð+>ð )-ð+>ð 3ð+>ð ð+>ð ð+>ð  ð+>ð  (ð!+>ð" ð#+>ð$ ð%+>ð&  +ð'+>ð( 
ö)+>ðZ ð=ØBð=à	7ó=ó ð=ð ðHØMðHà	BóHó ðHð Û^ó Ø^àÛtó Øtàà'+ñUØ$ðUà	OôUó ðUð 59ð5>ð
  ñ5>à1ð5>ð
 ð5>ð 
o÷5>ô 5>r6   r)   N)2Ú
__future__r   Úcollections.abcr   r   r   Údataclassesr   r   r	   Útypingr
   r   Úpydantic.json_schemar   Úpydantic_ai._instructionsr   r   r   r   r   Úpydantic_ai._run_contextr   r   Ú!pydantic_ai.capabilities.abstractr   r   Úpydantic_ai.messagesr   r   Úpydantic_ai.toolsr   r   r   r   r   r   r   r   r    r!   Úpydantic_ai.toolsetsr"   r#   r$   Úpydantic_ai.toolsets._dynamicr%   Úpydantic_ai.toolsets.combinedr&   r)   r,   r6   r7   Ú<module>rÆ      sv   ðÝ "ç 9Ñ 9ß 1Ñ 1ß  å 3÷õ ÷ <ß Wß K÷÷ ÷ ÷ PÑ OÝ 8Ý 9ñ �Ñô^>Ð# JÑ/ó ^>ó ñ^>r6   