Struct Plugin Context
Generated from cargo doc --no-deps -p nemo-relay-builtins -p nemo-relay-diagnostics -p nemo-relay-logging -p nemo-relay-plugin-host -p nemo-relay-codecs -p nemo-relay -p nemo-relay-runtime -p nemo-relay-model-pricing -p nemo-relay-resource-metrics -p nemo-relay-observability -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.
Implementations
impl PluginContext<'_>
impl PluginContext<'_>
runtime
pub fn runtime(&self) -> PluginRuntime
task_spawner
pub fn task_spawner(&self) -> PluginTaskSpawner
Obtain a cloneable task spawner for use inside registered middleware.
spawn
pub fn spawn<F, T>(&self, future: F) -> Result<JoinHandle<Result<T>>>where
F: Future<Output = Result<T>> + Send + 'static,
T: Send + 'static,
Spawn background work whose scope, cancellation, and cleanup belong to this component.
register_subscriber
pub fn register_subscriber<F: Fn(&Event) + Send + Sync + 'static>(
&mut self,
name: &str,
callback: F,
) -> Result<()>
Register a synchronous event subscriber owned by this component.
register_conditional_middleware_guardrail
pub fn register_conditional_middleware_guardrail<F>(
&mut self,
name: &str,
kinds: &BTreeSet<RuntimeRegistrationKind>,
registration_name: &str,
callback: F,
) -> Result<()>where
F: Fn(&BTreeSet<RuntimeRegistrationKind>, &str) -> Option<String> + Send + Sync + 'static,
Register a synchronous gate that can disable selected middleware registrations.
impl PluginContext<'_>
impl PluginContext<'_>
register_event_metadata_injector
pub fn register_event_metadata_injector<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Arc<Event>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<BTreeMap<String, Json>>> + Send + 'static,
Register an async callback that adds metadata to emitted events.
register_mark_sanitize_guardrail
pub fn register_mark_sanitize_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Register an async sanitizer for observable fields on mark events.
register_scope_sanitize_start_guardrail
pub fn register_scope_sanitize_start_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Register an async sanitizer for observable fields on scope-start events.
register_scope_sanitize_end_guardrail
pub fn register_scope_sanitize_end_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Arc<Event>, EventSanitizeFields) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<EventSanitizeFields>> + Send + 'static,
Register an async sanitizer for observable fields on scope-end events.
register_tool_sanitize_request_guardrail
pub fn register_tool_sanitize_request_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Register an async sanitizer for tool request data recorded in events.
register_tool_sanitize_response_guardrail
pub fn register_tool_sanitize_response_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Register an async sanitizer for tool response data recorded in events.
register_tool_conditional_execution_guardrail
pub fn register_tool_conditional_execution_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<String>>> + Send + 'static,
Register an async guardrail that allows or blocks a tool call.
register_tool_request_intercept
pub fn register_tool_request_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
break_chain: bool,
callback: F,
) -> Result<()>where
F: Fn(String, Json) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Register an async intercept that can rewrite a tool’s execution arguments.
register_tool_execution_intercept
pub fn register_tool_execution_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(ToolExecutionContext, ToolNext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<ToolExecutionInterceptOutcome>> + Send + 'static,
Register an async tool execution wrapper with repeatable downstream continuations.
register_llm_conditional_execution_guardrail
pub fn register_llm_conditional_execution_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(LlmRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<String>>> + Send + 'static,
Register an async guardrail that allows or blocks an LLM call.
register_llm_request_intercept
pub fn register_llm_request_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
break_chain: bool,
callback: F,
) -> Result<()>where
F: Fn(String, LlmRequest, Option<AnnotatedLlmRequest>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<LlmRequestInterceptOutcome>> + Send + 'static,
Register an async intercept that can rewrite or complete an LLM request.
register_llm_sanitize_request_guardrail
pub fn register_llm_sanitize_request_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(LlmRequest, LlmSanitizeRequestContext<'static>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<LlmRequest>>> + Send + 'static,
Register an async sanitizer for observable LLM request data with its request codec context.
register_llm_sanitize_response_guardrail
pub fn register_llm_sanitize_response_guardrail<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Json, LlmSanitizeResponseContext<'static>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Option<Json>>> + Send + 'static,
Register an async sanitizer for observable LLM responses with their response codec context.
register_llm_execution_intercept
pub fn register_llm_execution_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(String, LlmRequest, LlmExecutionContext, LlmNext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Json>> + Send + 'static,
Register an async LLM execution wrapper with live codec capabilities and downstream continuation.
register_llm_stream_execution_intercept
pub fn register_llm_stream_execution_intercept<F, Fut>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(String, LlmRequest, LlmExecutionContext, LlmStreamNext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<LlmJsonAsyncStream>> + Send + 'static,
Register an async LLM stream wrapper whose streams close with the owning component.
impl PluginContext<'_>
impl PluginContext<'_>
register_synchronous_callback
pub fn register_synchronous_callback<F>(
&mut self,
name: &str,
surface: Surface,
priority: i32,
break_chain: bool,
callback: F,
) -> Result<()>where
F: Fn(Invocation, Option<ContinuationBox>) -> Result<Json> + Send + Sync + 'static,
Register a synchronous callback using only checked ABI invocation values. The Rust callback and its captured state remain in the originating SDK. Subscribers run inline; synchronous middleware uses blocking offload.
impl PluginContext<'_>
impl PluginContext<'_>
register_synchronous_stream_callback
pub fn register_synchronous_stream_callback<F>(
&mut self,
name: &str,
priority: i32,
callback: F,
) -> Result<()>where
F: Fn(Invocation, ContinuationBox) -> Result<StreamBox> + Send + Sync + 'static,
Register a synchronous stream factory returning a checked stream descriptor. Offload construction; poll returned stream futures under component scope and runtime context.