Struct Plugin Context

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

1pub struct PluginContext<'a> { /* private fields */ }

Borrowed safe wrapper around a host plugin registration context.

Implementations

impl<'a> PluginContext<'a>

impl<'a> PluginContext<'a>

from_raw

pub unsafe fn from_raw(
    host: &'a NemoRelayNativeHostApiV1,
    raw: *mut NemoRelayNativePluginContext,
) -> Self

Creates a plugin context wrapper from raw ABI parts.

Safety

host and raw must remain valid for the lifetime of this wrapper.

host_api

pub fn host_api(&self) -> &'a NemoRelayNativeHostApiV1

Returns the host ABI table backing this registration context.

runtime

pub fn runtime(&self) -> PluginRuntime

Returns a cloneable high-level runtime handle.

register_subscriber

pub fn register_subscriber<F>(&mut self, name: &str, callback: F) -> Result<()>where
    F: Fn(&Event) + Send + Sync + 'static,

Registers a typed event subscriber callback.

register_tool_sanitize_request_guardrail

pub fn register_tool_sanitize_request_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(&str, Json) -> Json + Send + Sync + 'static,

Registers a typed tool sanitize-request guardrail.

register_tool_sanitize_response_guardrail

pub fn register_tool_sanitize_response_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(&str, Json) -> Json + Send + Sync + 'static,

Registers a typed tool sanitize-response guardrail.

register_tool_conditional_execution_guardrail

pub fn register_tool_conditional_execution_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(&str, &Json) -> Result<Option<String>> + Send + Sync + 'static,

Registers a typed tool conditional-execution guardrail.

register_tool_request_intercept

pub fn register_tool_request_intercept<F>(
    &mut self,
    name: &str,
    priority: i32,
    break_chain: bool,
    callback: F,
) -> Result<()>where
    F: Fn(&str, Json) -> Result<Json> + Send + Sync + 'static,

Registers a typed tool request intercept.

register_tool_execution_intercept

pub fn register_tool_execution_intercept<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: for<'next> Fn(&str, Json, ToolNext<'next>) -> Result<ToolExecutionInterceptOutcome> + Send + Sync + 'static,

Registers a typed tool execution intercept.

The callback returns a ToolExecutionInterceptOutcome. Calling ToolNext::call continues the chain and returns only the raw downstream result JSON; Relay retains downstream pending marks.

register_llm_sanitize_request_guardrail

pub fn register_llm_sanitize_request_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(LlmRequest) -> LlmRequest + Send + Sync + 'static,

Registers a typed LLM sanitize-request guardrail.

register_llm_sanitize_response_guardrail

pub fn register_llm_sanitize_response_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(Json) -> Json + Send + Sync + 'static,

Registers a typed LLM sanitize-response guardrail.

register_llm_conditional_execution_guardrail

pub fn register_llm_conditional_execution_guardrail<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: Fn(&LlmRequest) -> Result<Option<String>> + Send + Sync + 'static,

Registers a typed LLM conditional-execution guardrail.

register_llm_request_intercept

pub fn register_llm_request_intercept<F>(
    &mut self,
    name: &str,
    priority: i32,
    break_chain: bool,
    callback: F,
) -> Result<()>where
    F: Fn(&str, LlmRequest, Option<AnnotatedLlmRequest>) -> Result<LlmRequestInterceptOutcome> + Send + Sync + 'static,

Registers a typed LLM request intercept.

register_llm_execution_intercept

pub fn register_llm_execution_intercept<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: for<'next> Fn(&str, LlmRequest, LlmNext<'next>) -> Result<Json> + Send + Sync + 'static,

Registers a typed LLM execution intercept.

register_llm_stream_execution_intercept

pub fn register_llm_stream_execution_intercept<F>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
) -> Result<()>where
    F: for<'next> Fn(&str, LlmRequest, LlmStreamNext<'next>) -> Result<LlmJsonStream> + Send + Sync + 'static,

Registers a typed LLM stream execution intercept.

Native ABI v1 represents stream execution as one JSON result. The host wraps that result as a one-chunk stream.

register_subscriber_raw

pub unsafe fn register_subscriber_raw(
    &mut self,
    name: &str,
    cb: NemoRelayNativeEventSubscriberCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw event subscriber callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_tool_sanitize_request_guardrail_raw

pub unsafe fn register_tool_sanitize_request_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeToolJsonCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw tool sanitize-request guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_tool_sanitize_response_guardrail_raw

pub unsafe fn register_tool_sanitize_response_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeToolJsonCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw tool sanitize-response guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_tool_conditional_execution_guardrail_raw

pub unsafe fn register_tool_conditional_execution_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeToolConditionalCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw tool conditional-execution guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_tool_request_intercept_raw

pub unsafe fn register_tool_request_intercept_raw(
    &mut self,
    name: &str,
    priority: i32,
    break_chain: bool,
    cb: NemoRelayNativeToolJsonCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw tool request intercept callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_tool_execution_intercept_raw

pub unsafe fn register_tool_execution_intercept_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeToolExecutionCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw tool execution intercept callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_sanitize_request_guardrail_raw

pub unsafe fn register_llm_sanitize_request_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeLlmRequestCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM sanitize-request guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_sanitize_response_guardrail_raw

pub unsafe fn register_llm_sanitize_response_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeJsonCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM sanitize-response guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_conditional_execution_guardrail_raw

pub unsafe fn register_llm_conditional_execution_guardrail_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeLlmConditionalCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM conditional-execution guardrail callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_request_intercept_raw

pub unsafe fn register_llm_request_intercept_raw(
    &mut self,
    name: &str,
    priority: i32,
    break_chain: bool,
    cb: NemoRelayNativeLlmRequestInterceptCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM request intercept callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_execution_intercept_raw

pub unsafe fn register_llm_execution_intercept_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeLlmExecutionCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM execution intercept callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.

register_llm_stream_execution_intercept_raw

pub unsafe fn register_llm_stream_execution_intercept_raw(
    &mut self,
    name: &str,
    priority: i32,
    cb: NemoRelayNativeLlmStreamExecutionCb,
    user_data: *mut c_void,
    free_fn: NemoRelayNativeFreeFn,
) -> NemoRelayStatus

Registers a raw LLM stream execution intercept callback.

Safety

cb, user_data, and free_fn must remain valid for every host callback invocation until the host deregisters the callback or calls free_fn. free_fn must match the allocation behind user_data.