+
    ^eòj!@  ã                   óâ  € R t ^ RIHtHtHtHtHtHt ^ RIH	t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt  ^ RIH!t" ^ RIH#t$ ^ RIH%t& ^ RIH't( ^ RIH)t* ^ RIH+t, R R lt-R R lt.R R lt/R R lt0R R lt1R R lt2R  R! lt3R" R# lt4R$ R% lt5R& R' lt6R( R) lt7R* R+ lt8R, R- lt9R. R/ lt:R0 R1 lt;R2 R3 lt<R4 R5 lt=R6 R7 lt>. R9Ot?R8# ):a4  Global guardrail registration for tools and LLMs.

Guardrails can either sanitize data recorded on lifecycle events or reject a
call before it runs.

In managed ``tools.execute()`` and ``llm.execute()`` flows, sanitize
guardrails are observability-only: they change the payload written to emitted
events, not the value passed to the user callback or returned to the caller.

Example::

    import nemo_relay

    def redact(tool_name, args):
        return {**args, "api_key": "***"}

    nemo_relay.guardrails.register_tool_sanitize_request("redact", 10, redact)
)ÚEventSanitizeGuardrailÚ LlmConditionalExecutionGuardrailÚLlmSanitizeRequestGuardrailÚLlmSanitizeResponseGuardrailÚ!ToolConditionalExecutionGuardrailÚToolSanitizeGuardrail)Ú.deregister_llm_conditional_execution_guardrail)Ú)deregister_llm_sanitize_request_guardrail)Ú*deregister_llm_sanitize_response_guardrail)Ú"deregister_mark_sanitize_guardrail)Ú'deregister_scope_sanitize_end_guardrail)Ú)deregister_scope_sanitize_start_guardrail)Ú/deregister_tool_conditional_execution_guardrail)Ú*deregister_tool_sanitize_request_guardrail)Ú+deregister_tool_sanitize_response_guardrail)Ú,register_llm_conditional_execution_guardrail)Ú'register_llm_sanitize_request_guardrail)Ú(register_llm_sanitize_response_guardrail)Ú register_mark_sanitize_guardrail)Ú%register_scope_sanitize_end_guardrail)Ú'register_scope_sanitize_start_guardrail)Ú-register_tool_conditional_execution_guardrail)Ú(register_tool_sanitize_request_guardrail)Ú)register_tool_sanitize_response_guardrailc                ó@   € V ^8„  d   QhR\         R\        R\        RR/# ©é   ÚnameÚpriorityÚ	guardrailÚreturnN©ÚstrÚintr   )Úformats   "ÚŒ/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/nemo_relay/guardrails.pyÚ__annotate__r&   W   s0   € ÷ Eñ E¤ð E´ð EÔ@Vð EÐ[_ñ Eó    c                ó   € \        WV4      # )a  Register a global mark-event sanitizer.

Args:
    name: Unique registration name.
    priority: Execution order; lower values run first.
    guardrail: Callback that sanitizes emitted mark-event fields.

Returns:
    None: The registration is active until deregistered.
)Ú_native_register_mark_sanitize©r   r   r   s   &&&r%   Úregister_mark_sanitizer+   W   s   € ô *¨$¸)ÓDÐDr'   c                ó0   € V ^8„  d   QhR\         R\        /# ©r   r   r    ©r"   Úbool)r$   s   "r%   r&   r&   e   s   € ÷ 	2ñ 	2¤3ð 	2¬4ñ 	2r'   c                ó   € \        V 4      # )zŒRemove a global mark-event sanitizer.

Args:
    name: Registration name to remove.

Returns:
    bool: Whether a registration was removed.
)Ú _native_deregister_mark_sanitize©r   s   &r%   Úderegister_mark_sanitizer3   e   s   € ô ,¨DÓ1Ð1r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   r!   )r$   s   "r%   r&   r&   q   s0   € ÷ Lñ L¬ð L´sð LÔG]ð LÐbfñ Lr'   c                ó   € \        WV4      # )a(  Register a global sanitizer for scope-start event fields.

Args:
    name: Unique registration name.
    priority: Execution order; lower values run first.
    guardrail: Callback that sanitizes emitted scope-start event fields.

Returns:
    None: The registration is active until deregistered.
)Ú%_native_register_scope_sanitize_startr*   s   &&&r%   Úregister_scope_sanitize_startr7   q   s   € ô 1°ÀÓKÐKr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&      s   € ÷ 	9ñ 	9¬#ð 	9´$ñ 	9r'   c                ó   € \        V 4      # )z�Remove a global scope-start sanitizer.

Args:
    name: Registration name to remove.

Returns:
    bool: Whether a registration was removed.
)Ú'_native_deregister_scope_sanitize_startr2   s   &r%   Úderegister_scope_sanitize_startr;      s   € ô 3°4Ó8Ð8r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   r!   )r$   s   "r%   r&   r&   ‹   s0   € ÷ Jñ J¤cð J´Sð JÔE[ð JÐ`dñ Jr'   c                ó   € \        WV4      # )a$  Register a global sanitizer for scope-end event fields.

Args:
    name: Unique registration name.
    priority: Execution order; lower values run first.
    guardrail: Callback that sanitizes emitted scope-end event fields.

Returns:
    None: The registration is active until deregistered.
)Ú#_native_register_scope_sanitize_endr*   s   &&&r%   Úregister_scope_sanitize_endr?   ‹   s   € ô /¨t¸yÓIÐIr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   ™   s   € ÷ 	7ñ 	7¬ð 	7´ñ 	7r'   c                ó   € \        V 4      # )z‹Remove a global scope-end sanitizer.

Args:
    name: Registration name to remove.

Returns:
    bool: Whether a registration was removed.
)Ú%_native_deregister_scope_sanitize_endr2   s   &r%   Úderegister_scope_sanitize_endrC   ™   s   € ô 1°Ó6Ð6r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   ©r"   r#   r   )r$   s   "r%   r&   r&   ª   s0   € ÷ Mñ M¬ð M¼ð MÔH]ð MÐbfñ Mr'   c                ó   € \        WV4      # )aN  Register a guardrail that sanitizes tool inputs for emitted start events.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(tool_name, args)`` that must
        return the sanitized payload to record on the emitted start event.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    In managed ``nemo_relay.tools.execute()`` flows, sanitize guardrails are
    observability-only. They change the payload written to events, not the
    arguments passed to the tool callback.

Example::

    import nemo_relay

    def redact(tool_name, args):
        return {**args, "api_key": "***"}

    nemo_relay.guardrails.register_tool_sanitize_request("redact", 10, redact)
)Ú&_native_register_tool_sanitize_requestr*   s   &&&r%   Úregister_tool_sanitize_requestrH   ª   s   € ô4 2°$À)ÓLÐLr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   Ç   ó   € ÷ :ñ :¬3ð :´4ñ :r'   c                ó   € \        V 4      # )as  Remove a previously registered tool sanitize-request guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_tool_sanitize_request()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú(_native_deregister_tool_sanitize_requestr2   s   &r%   Ú deregister_tool_sanitize_requestrM   Ç   ó   € ô 4°DÓ9Ð9r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   rE   )r$   s   "r%   r&   r&   Ø   s0   € ÷ Nñ N¬#ð N¼ð NÔI^ð NÐcgñ Nr'   c                ó   € \        WV4      # )a1  Register a guardrail that sanitizes tool outputs for emitted end events.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(tool_name, result)`` that
        must return the sanitized payload to record on emitted end events.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    This guardrail affects event payloads only. The caller still receives
    the original tool result.
)Ú'_native_register_tool_sanitize_responser*   s   &&&r%   Úregister_tool_sanitize_responserR   Ø   s   € ô  3°4À9ÓMÐMr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   ë   s   € ÷ ;ñ ;¬Cð ;´Dñ ;r'   c                ó   € \        V 4      # )au  Remove a previously registered tool sanitize-response guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_tool_sanitize_response()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú)_native_deregister_tool_sanitize_responser2   s   &r%   Ú!deregister_tool_sanitize_responserV   ë   s   € ô 5°TÓ:Ð:r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   )r"   r#   r   )r$   s   "r%   r&   r&   ü   s0   € ÷ Rñ R¬cð R¼Sð RÔMnð RÐswñ Rr'   c                ó   € \        WV4      # )a1  Register a guardrail that can reject a tool call before execution.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(tool_name, args)``. Return
        ``None`` to allow execution or a rejection message to block it.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    Conditional-execution guardrails run before request intercepts and
    before the tool callback is invoked.
)Ú+_native_register_tool_conditional_executionr*   s   &&&r%   Ú#register_tool_conditional_executionrZ   ü   s   € ô  7°tÀyÓQÐQr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&     s   € ÷ ?ñ ?´ð ?¼ñ ?r'   c                ó   € \        V 4      # )a}  Remove a previously registered tool conditional-execution guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_tool_conditional_execution()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú-_native_deregister_tool_conditional_executionr2   s   &r%   Ú%deregister_tool_conditional_executionr^     s   € ô 9¸Ó>Ð>r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   )r"   r#   r   )r$   s   "r%   r&   r&   %  s0   € ÷ !Lñ !L¬ð !L´sð !LÔGbð !LÐgkñ !Lr'   c                ó   € \        WV4      # )aI  Register a guardrail that sanitizes LLM requests for emitted start events.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(request, context)`` that
        returns the sanitized request, or ``None`` to omit the LLM
        observability payload and its annotation. ``context`` contains
        a ``LlmSanitizeRequestContext`` whose ``codec`` is a structured identity
        with ``kind`` of ``none``, ``builtin``, ``runtime``, or ``opaque``.
        ``builtin`` and ``runtime`` identities include ``id``. Use
        ``context.resolve_codec()`` to access the active codec for normalized
        processing.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    In managed ``nemo_relay.llm.execute()`` and
    ``nemo_relay.llm.stream_execute()`` flows, this is observability-only
    and does not mutate the request forwarded to the provider callback.

Example::

    import nemo_relay

    def strip_auth(request, context):
        headers = {k: v for k, v in request.headers.items() if k.lower() != "authorization"}
        return nemo_relay.LLMRequest(headers, request.content)

    nemo_relay.guardrails.register_llm_sanitize_request("strip-auth", 10, strip_auth)
)Ú%_native_register_llm_sanitize_requestr*   s   &&&r%   Úregister_llm_sanitize_requestrb   %  s   € ôB 1°ÀÓKÐKr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   I  s   € ÷ 9ñ 9¬#ð 9´$ñ 9r'   c                ó   € \        V 4      # )aq  Remove a previously registered LLM sanitize-request guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_llm_sanitize_request()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú'_native_deregister_llm_sanitize_requestr2   s   &r%   Úderegister_llm_sanitize_requestrf   I  s   € ô 3°4Ó8Ð8r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   )r"   r#   r   )r$   s   "r%   r&   r&   Z  s0   € ÷ Mñ M¬ð M¼ð MÔHdð MÐimñ Mr'   c                ó   € \        WV4      # )aÂ  Register a guardrail that sanitizes LLM outputs for emitted end events.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(response, context)`` that
        returns the sanitized payload, or ``None`` to omit the LLM
        observability payload and its annotation. ``context`` contains
        a ``LlmSanitizeResponseContext`` whose ``codec`` is a structured identity
        with ``kind`` of ``none``, ``builtin``, ``runtime``, or ``opaque``.
        ``builtin`` and ``runtime`` identities include ``id``. Use
        ``context.resolve_codec()`` to access the active codec for normalized
        processing.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    This guardrail changes only event payloads. The raw provider response
    returned to the caller is left unchanged.
)Ú&_native_register_llm_sanitize_responser*   s   &&&r%   Úregister_llm_sanitize_responserj   Z  s   € ô, 2°$À)ÓLÐLr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   s  rJ   r'   c                ó   € \        V 4      # )as  Remove a previously registered LLM sanitize-response guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_llm_sanitize_response()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú(_native_deregister_llm_sanitize_responser2   s   &r%   Ú deregister_llm_sanitize_responsern   s  rN   r'   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# r   )r"   r#   r   )r$   s   "r%   r&   r&   „  s0   € ÷ Qñ Q¬Sð Q¼Cð QÔLlð QÐquñ Qr'   c                ó   € \        WV4      # )a'  Register a guardrail that can reject an LLM call before execution.

Args:
    name: Unique guardrail name used for later replacement or removal.
    priority: Execution order for the guardrail. Lower values run first.
    guardrail: Callable invoked as ``guardrail(request)``. Return ``None``
        to allow execution or a rejection message to block the call.

Returns:
    None: This function returns after the guardrail is registered.

Notes:
    Conditional-execution guardrails run before request intercepts, codecs,
    and provider execution.
)Ú*_native_register_llm_conditional_executionr*   s   &&&r%   Ú"register_llm_conditional_executionrr   „  s   € ô  6°dÀiÓPÐPr'   c                ó0   € V ^8„  d   QhR\         R\        /# r-   r.   )r$   s   "r%   r&   r&   —  s   € ÷ >ñ >¬sð >´tñ >r'   c                ó   € \        V 4      # )a{  Remove a previously registered LLM conditional-execution guardrail.

Args:
    name: Guardrail name previously passed to
        ``register_llm_conditional_execution()``.

Returns:
    bool: ``True`` if a guardrail was removed, otherwise ``False``.

Notes:
    Removal affects only future executions. In-flight calls continue using
    the guardrail chain they already resolved.
)Ú,_native_deregister_llm_conditional_executionr2   s   &r%   Ú$deregister_llm_conditional_executionrv   —  s   € ô 8¸Ó=Ð=r'   N)r+   r3   r7   r;   r?   rC   rH   rM   rR   rV   rZ   r^   rb   rf   rj   rn   rr   rv   )@Ú__doc__Ú
nemo_relayr   r   r   r   r   r   Únemo_relay._nativer   ru   r	   re   r
   rm   r   r1   r   rB   r   r:   r   r]   r   rL   r   rU   r   rq   r   ra   r   ri   r   r)   r   r>   r   r6   r   rY   r   rG   r   rQ   r+   r3   r7   r;   r?   rC   rH   rM   rR   rV   rZ   r^   rb   rf   rj   rn   rr   rv   Ú__all__© r'   r%   Ú<module>r|      sÛ   ðñ÷&÷ õõõõ fõõõõõõõõõ bõõõõõõEõ	2õLõ	9õJõ	7õ"Mõ::õ"Nõ&;õ"Rõ&?õ,!LõH9õ"Mõ2:õ"Qõ&>ò"‚r'   