
    Cj                        S SK J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  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5      5       r\ " S S5      5       r " S S\5      r " S S\5      r " S S\5      r\ " S S5      5       r\ " S S5      5       r \ " S S\ 5      5       r!\" S\SS9r"\ " S S \\"   5      5       r#\ " S! S"\\"   5      5       r$\\ /\4   r%\\ /\\   4   r&\S,S# j5       r'\S-S$ j5       r'\SS%.   S.S& jj5       r' S/SS%.     S0S' jjjr'\\!/\4   r(\\!/\\   4   r)\S1S( j5       r*\S2S) j5       r*\SS%.   S3S* jj5       r* S/SS%.     S4S+ jjjr*g)5    )annotationsN)	AwaitableCallable)	dataclassfield)TYPE_CHECKINGAnyGenericLiteraloverload)	TypedDictTypeVar   )	UserError)ToolContext)MaybeAwaitable)Agentc                  0    \ rS rSr% SrS\S'    S\S'   Srg)	ToolInputGuardrailResult   z)The result of a tool input guardrail run.ToolInputGuardrail[Any]	guardrailToolGuardrailFunctionOutputoutput N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       h/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/agents/tool_guardrails.pyr   r      s    3&&%''/r$   r   c                  0    \ rS rSr% SrS\S'    S\S'   Srg)	ToolOutputGuardrailResult   z*The result of a tool output guardrail run.ToolOutputGuardrail[Any]r   r   r   r   Nr   r   r$   r%   r'   r'      s    4''%''/r$   r'   c                  .    \ rS rSr% SrS\S'   S\S'   Srg)	RejectContentBehavior(   zQRejects the tool call/output but continues execution with a message to the model.zLiteral['reject_content']typestrmessager   Nr   r   r$   r%   r+   r+   (   s    [
##Lr$   r+   c                  $    \ rS rSr% SrS\S'   Srg)RaiseExceptionBehavior/   z&Raises an exception to halt execution.zLiteral['raise_exception']r-   r   Nr   r   r$   r%   r1   r1   /   s    0
$$r$   r1   c                  $    \ rS rSr% SrS\S'   Srg)AllowBehavior5   z)Allows normal tool execution to continue.zLiteral['allow']r-   r   Nr   r   r$   r%   r4   r4   5   s    3
r$   r4   c                      \ rS rSr% SrS\S'    \" S S9rS\S'    \SSS
 jj5       r	\SSS jj5       r
\SSS jj5       rSrg	)r   ;   z(The output of a tool guardrail function.r	   output_infoc                     [        SS9$ )Nallowr-   r4   r   r$   r%   <lambda>$ToolGuardrailFunctionOutput.<lambda>F   s	    7 ;r$   )default_factoryz>RejectContentBehavior | RaiseExceptionBehavior | AllowBehaviorbehaviorNc                    U " U[        SS9S9$ )zCreate a guardrail output that allows the tool execution to continue normally.

Args:
    output_info: Optional data about checks performed.

Returns:
    ToolGuardrailFunctionOutput configured to allow normal execution.
r:   r;   r8   r@   r<   clsr8   s     r%   r:   !ToolGuardrailFunctionOutput.allowO   s     {]5PQQr$   c                     U " U[        SUS9S9$ )a%  Create a guardrail output that rejects the tool call/output but continues execution.

Args:
    message: Message to send to the model instead of the tool result.
    output_info: Optional data about checks performed.

Returns:
    ToolGuardrailFunctionOutput configured to reject the content.
reject_content)r-   r/   rB   )r+   )rD   r/   r8   s      r%   rG   *ToolGuardrailFunctionOutput.reject_content[   s     #*0@'R
 	
r$   c                    U " U[        SS9S9$ )zCreate a guardrail output that raises an exception to halt execution.

Args:
    output_info: Optional data about checks performed.

Returns:
    ToolGuardrailFunctionOutput configured to raise an exception.
raise_exceptionr;   rB   )r1   rC   s     r%   rJ   +ToolGuardrailFunctionOutput.raise_exceptionk   s     {5KQb5cddr$   r   N)r8   r	   returnr   )r/   r.   r8   r	   rM   r   )r   r   r   r    r!   r"   r   r@   classmethodr:   rG   rJ   r#   r   r$   r%   r   r   ;   so    2
 PU;PHL  	R 	R 
 
 	e 	er$   r   c                  0    \ rS rSr% SrS\S'    S\S'   Srg)	ToolInputGuardrailDatax   z5Input data passed to a tool input guardrail function.zToolContext[Any]contextz
Agent[Any]agentr   Nr   r   r$   r%   rP   rP   x   s    ? r$   rP   c                  $    \ rS rSr% SrS\S'   Srg)ToolOutputGuardrailData   zcInput data passed to a tool output guardrail function.

Extends input data with the tool's output.
r	   r   r   Nr   r   r$   r%   rU   rU      s    
 Kr$   rU   TContext_coT)bound	covariantc                  J    \ rS rSr% SrS\S'    SrS\S'    SS jrSS	 jrS
r	g)ToolInputGuardrail   z8A guardrail that runs before a function tool is invoked.zOCallable[[ToolInputGuardrailData], MaybeAwaitable[ToolGuardrailFunctionOutput]]guardrail_functionN
str | Nonenamec                T    U R                   =(       d    U R                  R                  $ rL   r_   r]   r   selfs    r%   get_nameToolInputGuardrail.get_name       yy<D33<<<r$   c                   #    [        U R                  5      (       d  [        SU R                   35      eU R                  U5      n[        R                  " U5      (       a
  UI S h  vN $ U$  N7fNz)Guardrail function must be callable, got callabler]   r   inspectisawaitablerc   dataresults      r%   runToolInputGuardrail.run   c     //00GH_H_G`abb((.v&&<     A$A/&A-'A/r   rM   r.   )rn   rP   rM   r   
r   r   r   r    r!   r"   r_   rd   rp   r#   r   r$   r%   r[   r[      s/    B  D*=r$   r[   c                  J    \ rS rSr% SrS\S'    SrS\S'    SS jrSS	 jrS
r	g)ToolOutputGuardrail   z7A guardrail that runs after a function tool is invoked.zPCallable[[ToolOutputGuardrailData], MaybeAwaitable[ToolGuardrailFunctionOutput]]r]   Nr^   r_   c                T    U R                   =(       d    U R                  R                  $ rL   ra   rb   s    r%   rd   ToolOutputGuardrail.get_name   rf   r$   c                   #    [        U R                  5      (       d  [        SU R                   35      eU R                  U5      n[        R                  " U5      (       a
  UI S h  vN $ U$  N7frh   ri   rm   s      r%   rp   ToolOutputGuardrail.run   rr   rs   r   rt   )rn   rU   rM   r   ru   r   r$   r%   rw   rw      s/    A  D*=r$   rw   c                    g rL   r   funcs    r%   tool_input_guardrailr      s    47r$   c                    g rL   r   r~   s    r%   r   r      s    58r$   r_   c                    g rL   r   r   s    r%   r   r      s	     UXr$   c               .   ^ SU4S jjnU b  U" U 5      $ U$ )z9Decorator to create a ToolInputGuardrail from a function.c                >   > [        U T=(       d    U R                  S9$ N)r]   r_   )r[   r   fr_   s    r%   	decorator'tool_input_guardrail.<locals>.decorator   s    !QT=OQZZPPr$   )r   z(_ToolInputFuncSync | _ToolInputFuncAsyncrM   r   r   r   r_   r   s    ` r%   r   r      s!    Q r$   c                    g rL   r   r~   s    r%   tool_output_guardrailr      s    69r$   c                    g rL   r   r~   s    r%   r   r      s    7:r$   c                    g rL   r   r   s    r%   r   r     s	     X[r$   c               .   ^ SU4S jjnU b  U" U 5      $ U$ )z:Decorator to create a ToolOutputGuardrail from a function.c                >   > [        U T=(       d    U R                  S9$ r   )rw   r   r   s    r%   r   (tool_output_guardrail.<locals>.decorator  s    "ad>PajjQQr$   )r   z*_ToolOutputFuncSync | _ToolOutputFuncAsyncrM   r)   r   r   s    ` r%   r   r     s!    R r$   )r   _ToolInputFuncSync)r   _ToolInputFuncAsync)r_   r^   rM   zMCallable[[_ToolInputFuncSync | _ToolInputFuncAsync], ToolInputGuardrail[Any]]rL   )r   z/_ToolInputFuncSync | _ToolInputFuncAsync | Noner_   r^   rM   zgToolInputGuardrail[Any] | Callable[[_ToolInputFuncSync | _ToolInputFuncAsync], ToolInputGuardrail[Any]])r   _ToolOutputFuncSync)r   _ToolOutputFuncAsync)r_   r^   rM   zPCallable[[_ToolOutputFuncSync | _ToolOutputFuncAsync], ToolOutputGuardrail[Any]])r   z1_ToolOutputFuncSync | _ToolOutputFuncAsync | Noner_   r^   rM   zkToolOutputGuardrail[Any] | Callable[[_ToolOutputFuncSync | _ToolOutputFuncAsync], ToolOutputGuardrail[Any]])+
__future__r   rk   collections.abcr   r   dataclassesr   r   typingr   r	   r
   r   r   typing_extensionsr   r   
exceptionsr   tool_contextr   util._typesr   rS   r   r   r'   r+   r1   r4   r   rP   rU   rW   r[   rw   r   r   r   r   r   r   r   r$   r%   <module>r      s}   "  / ( A A 0 ! % ' 0 0 0 0 0 0I %Y %I  9e 9e 9ex    	4 	 	 m3$? -  8 '+.  : 568SST  67C^9__`  
 7 
 7 
 8 
 8 
XXRX 
X =A 
9 
T$  78:UUV !8 99E`;a ab  
 9 
 9 
 : 
 : 
[[U[ 
[ ?C 
; 
Wr$   