Plugin Helpers
Generated from crates/node/plugin.d.ts.
Import from nemo-relay-node/plugin.
Plugin configuration, validation, activation, and registration helpers.
Interfaces
LlmSanitizeRequestContext
Codec context available while an LLM request is sanitized.
LlmSanitizeResponseContext
Codec context available while an LLM response is sanitized.
ConfigPolicy
Plugin-level policy for unknown or unsupported plugin configuration.
ConfigDiagnostic
One validation or compatibility diagnostic produced by the plugin system.
ConfigReport
Validation or activation report for a plugin configuration.
RuntimeDiagnostic
One bounded aggregate of a runtime plugin failure.
ComponentSpec interface
One top-level plugin component.
PluginConfig
Canonical plugin configuration document.
PluginHostActivation
PluginHostReport
DynamicPluginValidationStatus
DynamicPluginFailure
DynamicPluginValidationReport
PendingMarkSpec
A mark Relay materializes under a managed lifecycle.
LlmOptimizationDataSchema
Schema tag attached to an opaque optimization contribution payload.
LlmOptimizationModel
Model identity retained for counterfactual pricing and downstream repricing.
LlmOptimizationModelTransition
Baseline and effective model identities for a routing optimization.
LlmOptimizationTokens
Explicit token evidence, independent from a pricing catalog.
LlmOptimizationTokenImpact
Baseline, effective, and saved token evidence for one optimization.
LlmOptimizationContribution
One plugin’s optimization evidence.
kind is deliberately an open string so new optimizer categories round-trip without a Relay release. Unknown top-level fields are retained by the wire contract and represented by this interface’s JSON extension surface.
LlmRequestInterceptOutcome
Canonical result returned by an LLM request intercept.
ToolExecutionInterceptOutcome
Canonical result returned by a tool execution intercept.
result is passed to the remaining middleware and application. pendingMarks are Relay-owned lifecycle metadata emitted after the tool-end event and are not included in the application-visible result.
PluginContext
Component-scoped registration context passed to plugin handlers.
Plugin
Plugin callback contract.
Functions
defaultConfig
Create an empty plugin configuration.
Returns the canonical top-level config shape with version = 1 and no configured components so callers can build a document incrementally before validating or activating it.
Returns
A new PluginConfig object ready for mutation or validation.
Remarks
Mutating the returned object does not affect runtime state until it is passed to initialize.
ComponentSpec function
Create a plugin component entry for a plugin config document.
Packages a plugin kind, component-local config, and enablement flag into the object shape expected by PluginConfig.components.
Parameters
kind: Registered plugin kind to reference.config: Component-local config passed to plugin hooks.options: Optional component-level flags.
Returns
A ComponentSpec ready to insert into a plugin config.
Remarks
Setting options.enabled = false preserves the component for validation while skipping runtime registration during initialize.
initialize
Initialize the core-owned static and dynamic plugin host.
Resolves programmatic config with either an explicit or discovered user file, then the system configuration, and activates one owned lifetime.
Parameters
config: Lowest-precedence programmatic configuration.additionalPluginsToml: Optional explicitplugins.tomllayer.
Returns
An owned activation with the unified host report.
Remarks
Keep the returned activation alive while callbacks may run and call close() or use await using for deterministic teardown.
validate
Validate the plugin host without loading plugin code.
Resolves the same layered configuration and trust policy used by activation while leaving the process-wide host lease untouched.
Parameters
config: Lowest-precedence programmatic configuration.additionalPluginsToml: Optional explicitplugins.tomllayer.
Returns
Structured static and dynamic validation report.
Remarks
Validation performs no activation and does not acquire the host lease.
validateExact
Validate only the supplied static plugin configuration.
Unlike validate, this does not discover or merge plugins.toml files. Use it for component-specific validation when config is the complete document to check.
Parameters
config: Complete static plugin configuration.
Returns
Static validation results with no dynamic plugins.
listKinds
List registered plugin kinds.
Returns the plugin kind identifiers currently known to the global registry so callers can inspect what can be referenced from plugin configs.
Returns
The registered plugin kind names.
Remarks
The list reflects registry state only; it does not indicate whether a plugin kind is currently active in the runtime configuration.
register
Register a plugin kind with JavaScript validation and registration hooks.
Adapts the higher-level Plugin object contract to the native callback shape expected by the Node binding.
Parameters
pluginKind: Unique plugin kind identifier to register.plugin: Plugin implementation withvalidateandregisterhooks.
Returns
Nothing.
Remarks
Omitting plugin.validate makes the plugin permissive during validation; plugin.register still runs later during initialize.
deregister
Remove a previously registered plugin kind.
Deletes the plugin kind from the registry so future config validation and initialization calls can no longer reference it.
Parameters
pluginKind: Registered plugin kind identifier to remove.
Returns
true when a plugin kind was removed, otherwise false.
Remarks
Active runtime registrations remain until the owning plugin-host activation closes.
Type Aliases
LlmCodecIdentity
Codec identity available while a managed LLM event is sanitized.
UnsupportedBehavior
Policy behavior for unsupported configuration.
DynamicPluginKind
Execution lane for a dynamically loaded Relay plugin.
DynamicPluginCheckState
EventMetadataScalar
Scalar value accepted in event metadata additions.
EventMetadataValue
Flat value accepted in event metadata additions. After JSON conversion, numeric arrays must contain only integer values or only floating-point values.
EventMetadata
Metadata additions returned by an event metadata injector.