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 { /* private fields */ }

Registration context passed to WorkerPlugin::register.

Implementations

impl PluginContext

impl PluginContext

new

pub fn new() -> Self

Creates an empty worker registration context.

with_runtime

pub fn with_runtime(runtime: PluginRuntime) -> Self

Creates an empty worker registration context with a host runtime handle.

runtime

pub fn runtime(&self) -> Option<PluginRuntime>

Returns the host runtime handle for event and scope operations.

register_subscriber

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

Registers an event subscriber.

register_tool_sanitize_request_guardrail

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

Registers a 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,
)where
    F: Fn(&str, Json) -> Json + Send + Sync + 'static,

Registers a 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,
)where
    F: Fn(&str, &Json) -> Result<Option<String>> + Send + Sync + 'static,

Registers a 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,
)where
    F: Fn(&str, Json) -> Result<Json> + Send + Sync + 'static,

Registers a tool request intercept.

register_tool_execution_intercept

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

Registers a 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,
)where
    F: Fn(LlmRequest) -> LlmRequest + Send + Sync + 'static,

Registers an 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,
)where
    F: Fn(Json) -> Json + Send + Sync + 'static,

Registers an 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,
)where
    F: Fn(&LlmRequest) -> Result<Option<String>> + Send + Sync + 'static,

Registers an 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,
)where
    F: Fn(&str, LlmRequest, Option<AnnotatedLlmRequest>) -> Result<LlmRequestInterceptOutcome> + Send + Sync + 'static,

Registers an LLM request intercept.

register_llm_execution_intercept

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

Registers an LLM execution intercept.

register_llm_stream_execution_intercept

pub fn register_llm_stream_execution_intercept<F, Fut>(
    &mut self,
    name: &str,
    priority: i32,
    callback: F,
)where
    F: Fn(&str, LlmRequest, LlmStreamNext) -> Fut + Send + Sync + 'static,
    Fut: Future<Output = Result<JsonStream>> + Send + 'static,

Registers an LLM stream execution intercept.

Trait Implementations

impl Default for PluginContext

impl Default for PluginContext

default

fn default() -> Self