
    Cj'                       S SK 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  S SKJr  SSKJr  SS	KJr  SS
KJr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      5       r\ " S S\\   5      5       r\ " S S\\   5      5       r\" S\
SS9r\\\   S\ \!\   -  /\4   r"\\\   S\ \!\   -  /\\   4   r#\    S%S j5       r$\    S&S j5       r$\SSS.     S'S jj5       r$ S(SSS.       S)S jjjr$\\\   S\
/\4   r%\\\   S\
/\\   4   r&\    S*S  j5       r'\    S+S! j5       r'\SS".   S,S# jj5       r' S(SS".     S-S$ jjjr'g).    )annotationsN)	AwaitableCallable)	dataclass)TYPE_CHECKINGAnyGenericoverload)TypeVar   )	UserError)TResponseInputItem)RunContextWrapperTContext)MaybeAwaitable)Agentc                  0    \ rS rSr% SrS\S'    S\S'   Srg)	GuardrailFunctionOutput   z#The output of a guardrail function.r   output_infobooltripwire_triggered N__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       b/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/agents/guardrail.pyr   r      s    -
 r"   r   c                  0    \ rS rSr% SrS\S'    S\S'   Srg)	InputGuardrailResult#   The result of a guardrail run.zInputGuardrail[Any]	guardrailr   outputr   Nr   r   r"   r#   r%   r%   #   s    ("" $#/r"   r%   c                  H    \ rS rSr% SrS\S'    S\S'    S\S'    S	\S
'   Srg)OutputGuardrailResult0   r'   zOutputGuardrail[Any]r(   r   agent_output
Agent[Any]agentr   r)   r   Nr   r   r"   r#   r+   r+   0   s5    (##   $#/r"   r+   c                  j    \ rS rSr% SrS\S'    SrS\S'    SrS	\S
'    SS jr        SS jr	Sr
g)InputGuardrailG   a>  Input guardrails are checks that run either in parallel with the agent or before it starts.
They can be used to do things like:
- Check if input messages are off-topic
- Take over control of the agent's execution if an unexpected input is detected

You can use the `@input_guardrail()` decorator to turn a function into an `InputGuardrail`, or
create an `InputGuardrail` manually.

Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`,
the agent's execution will immediately stop, and
an `InputGuardrailTripwireTriggered` exception will be raised
z|Callable[[RunContextWrapper[TContext], Agent[Any], str | list[TResponseInputItem]], MaybeAwaitable[GuardrailFunctionOutput]]guardrail_functionN
str | NonenameTr   run_in_parallelc                h    U R                   (       a  U R                   $ U R                  R                  $ Nr5   r3   r   selfs    r#   get_nameInputGuardrail.get_namei   %    9999&&///r"   c                  #    [        U R                  5      (       d  [        SU R                   35      eU R                  X1U5      n[        R                  " U5      (       a  [        U UI S h  vN S9$ [        U US9$  N7f)N)Guardrail function must be callable, got )r(   r)   )callabler3   r   inspectisawaitabler%   )r;   r/   inputcontextr)   s        r#   runInputGuardrail.runo   s      //00GH_H_G`abb((?v&&'#| 
 $
 	
 $s   A+B -A>
.B r   returnstr)r/   r.   rD   zstr | list[TResponseInputItem]rE   RunContextWrapper[TContext]rI   r%   )r   r   r   r   r   r    r5   r6   r<   rF   r!   r   r"   r#   r1   r1   G   sh     
 D* !OT 0

 .
 -	

 

r"   r1   c                  Z    \ rS rSr% SrS\S'    SrS\S'    SS jr        SS	 jrS
r	g)OutputGuardrail   a  Output guardrails are checks that run on the final output of an agent.
They can be used to do check if the output passes certain validation criteria

You can use the `@output_guardrail()` decorator to turn a function into an `OutputGuardrail`,
or create an `OutputGuardrail` manually.

Guardrails return a `GuardrailResult`. If `result.tripwire_triggered` is `True`, an
`OutputGuardrailTripwireTriggered` exception will be raised.
zaCallable[[RunContextWrapper[TContext], Agent[Any], Any], MaybeAwaitable[GuardrailFunctionOutput]]r3   Nr4   r5   c                h    U R                   (       a  U R                   $ U R                  R                  $ r8   r9   r:   s    r#   r<   OutputGuardrail.get_name   r>   r"   c                  #    [        U R                  5      (       d  [        SU R                   35      eU R                  XU5      n[        R                  " U5      (       a  [        U UUUI S h  vN S9$ [        U UUUS9$  N7f)Nr@   )r(   r/   r-   r)   )rA   r3   r   rB   rC   r+   )r;   rE   r/   r-   r)   s        r#   rF   OutputGuardrail.run   s      //00GH_H_G`abb((Fv&&()#|	  %%	
 	
 $s   A-B/B0Br   rH   )rE   rK   r/   r.   r-   r   rI   r+   )
r   r   r   r   r   r    r5   r<   rF   r!   r   r"   r#   rM   rM      sQ     
 D*0
2
;E
UX
	
r"   rM   TContext_coT)bound	covariantr.   c                    g r8   r   funcs    r#   input_guardrailrY           #&r"   c                    g r8   r   rW   s    r#   rY   rY      rZ   r"   r5   r6   c                    g r8   r   r\   s     r#   rY   rY      s     r"   c               :   ^^     SUU4S jjnU b  U" U 5      $ U$ )aM  
Decorator that transforms a sync or async function into an `InputGuardrail`.
It can be used directly (no parentheses) or with keyword args, e.g.:

    @input_guardrail
    def my_sync_guardrail(...): ...

    @input_guardrail(name="guardrail_name", run_in_parallel=False)
    async def my_async_guardrail(...): ...

Args:
    func: The guardrail function to wrap.
    name: Optional name for the guardrail. If not provided, uses the function's name.
    run_in_parallel: Whether to run the guardrail concurrently with the agent (True, default)
        or before the agent starts (False).
c                F   > [        U T(       a  TTS9$ U R                  TS9$ )N)r3   r5   r6   )r1   r   )fr5   r6   s    r#   	decorator"input_guardrail.<locals>.decorator   s3      +	
 	
 $%::+	
 	
r"   )r`   zL_InputGuardrailFuncSync[TContext_co] | _InputGuardrailFuncAsync[TContext_co]rI   InputGuardrail[TContext_co]r   )rX   r5   r6   ra   s    `` r#   rY   rY      s7    >
W
	$
 
  r"   c                    g r8   r   rW   s    r#   output_guardrailre          $'r"   c                    g r8   r   rW   s    r#   re   re   !  rf   r"   r5   c                    g r8   r   rh   s    r#   re   re   '  s     r"   c               6   ^     SU4S jjnU b  U" U 5      $ U$ )a(  
Decorator that transforms a sync or async function into an `OutputGuardrail`.
It can be used directly (no parentheses) or with keyword args, e.g.:

    @output_guardrail
    def my_sync_guardrail(...): ...

    @output_guardrail(name="guardrail_name")
    async def my_async_guardrail(...): ...
c                B   > [        U T(       a  TS9$ U R                  S9$ )N)r3   r5   )rM   r   )r`   r5   s    r#   ra   #output_guardrail.<locals>.decoratorI  s-      
 	
 $%::
 	
r"   )r`   zN_OutputGuardrailFuncSync[TContext_co] | _OutputGuardrailFuncAsync[TContext_co]rI   OutputGuardrail[TContext_co]r   )rX   r5   ra   s    ` r#   re   re   1  s2    0
Y
	%
  r"   )rX   z$_InputGuardrailFuncSync[TContext_co]rI   rc   )rX   z%_InputGuardrailFuncAsync[TContext_co]rI   rc   )r5   r4   r6   r   rI   zuCallable[[_InputGuardrailFuncSync[TContext_co] | _InputGuardrailFuncAsync[TContext_co]], InputGuardrail[TContext_co]]r8   )rX   zS_InputGuardrailFuncSync[TContext_co] | _InputGuardrailFuncAsync[TContext_co] | Noner5   r4   r6   r   rI   zInputGuardrail[TContext_co] | Callable[[_InputGuardrailFuncSync[TContext_co] | _InputGuardrailFuncAsync[TContext_co]], InputGuardrail[TContext_co]])rX   z%_OutputGuardrailFuncSync[TContext_co]rI   rm   )rX   z&_OutputGuardrailFuncAsync[TContext_co]rI   rm   )r5   r4   rI   zxCallable[[_OutputGuardrailFuncSync[TContext_co] | _OutputGuardrailFuncAsync[TContext_co]], OutputGuardrail[TContext_co]])rX   zU_OutputGuardrailFuncSync[TContext_co] | _OutputGuardrailFuncAsync[TContext_co] | Noner5   r4   rI   zOutputGuardrail[TContext_co] | Callable[[_OutputGuardrailFuncSync[TContext_co] | _OutputGuardrailFuncAsync[TContext_co]], OutputGuardrail[TContext_co]])(
__future__r   rB   collections.abcr   r   dataclassesr   typingr   r   r	   r
   typing_extensionsr   
exceptionsr   itemsr   run_contextr   r   util._typesr   r/   r   r   r%   r+   r1   rM   rS   rJ   list_InputGuardrailFuncSync_InputGuardrailFuncAsyncrY   _OutputGuardrailFuncSync_OutputGuardrailFuncAsyncre   r   r"   r#   <module>r|      s   "  / ! 8 8 % ! % 4 '    	0 	0 	0 0 0 0, :
WX& :
 :
z 3
gh' 3
 3
l m3$? #{#\3>P9Q3QR  ${#\3>P9Q3QR%&(  
&
.& & 
&
 
&
/& & 
&
 
  
 	 
 .
  ..
 . ..b ${#\37  %{#\37%&(  
'
/'!' 
'
 
'
0'!' 
'
 
 
 
 &
 &&
 &&r"   