Struct Plugin Context
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.
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_mark_sanitize_guardrail
pub fn register_mark_sanitize_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(&Event, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Registers a mark event sanitizer.
register_scope_sanitize_start_guardrail
pub fn register_scope_sanitize_start_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(&Event, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Registers a scope-start event sanitizer.
register_scope_sanitize_end_guardrail
pub fn register_scope_sanitize_end_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(&Event, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Registers a scope-end event sanitizer.
register_tool_sanitize_request_guardrail
pub fn register_tool_sanitize_request_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(&str, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Registers a tool sanitize-request guardrail.
register_tool_sanitize_response_guardrail
pub fn register_tool_sanitize_response_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(&str, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Registers a tool sanitize-response guardrail.
register_tool_conditional_execution_guardrail
pub fn register_tool_conditional_execution_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<String>>> + Send + 'static,
Registers a tool conditional-execution guardrail.
register_tool_request_intercept
pub fn register_tool_request_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
break_chain: bool,
callback: F,
)where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + '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. ToolNext may be called repeatedly or concurrently while the callback is active. Each call snapshots its visible worker scope stack, and Relay rejects late calls or cancels unfinished calls when the callback settles.
register_llm_sanitize_request_guardrail
pub fn register_llm_sanitize_request_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(LlmRequest, LlmSanitizeRequestContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<LlmRequest>>> + Send + 'static,
Registers an LLM sanitize-request guardrail.
register_llm_sanitize_response_guardrail
pub fn register_llm_sanitize_response_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(Json, LlmSanitizeResponseContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<Json>>> + Send + 'static,
Registers an LLM sanitize-response guardrail.
register_llm_conditional_execution_guardrail
pub fn register_llm_conditional_execution_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
)where
F: Fn(LlmRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<String>>> + Send + 'static,
Registers an LLM conditional-execution guardrail.
register_llm_request_intercept
pub fn register_llm_request_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
break_chain: bool,
callback: F,
)where
F: Fn(String, LlmRequest, Option<AnnotatedLlmRequest>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<LlmRequestInterceptOutcome>> + Send + '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.
LlmNext::call may run repeatedly or concurrently while the callback is active. Each call snapshots its visible worker scope stack, and Relay rejects late calls or cancels unfinished calls when the callback settles.
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.
LlmStreamNext::call may run repeatedly or concurrently. Each call snapshots its visible worker scope stack. The interceptor’s returned stream keeps the callback active until it closes; Relay then rejects late calls and cancels unfinished calls.
Trait Implementations
impl Default for PluginContext
impl Default for PluginContext
default
fn default() -> Self