@mastra/core
Version:
66 lines (46 loc) • 2.51 kB
Markdown
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
# ProcessorProvider
`ProcessorProvider` is the interface a package implements to register a configurable processor with [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor). Processor providers serve two purposes:
1. **Discovery** — the UI uses `info`, `configSchema`, and `availablePhases` to render configuration forms.
2. **Runtime** — the editor calls `createProcessor(config)` during agent hydration to instantiate processors from stored configuration.
Providers are supplied via `MastraEditorConfig.processorProviders`.
## Usage example
```typescript
import { MastraEditor } from '@mastra/editor'
import { moderationProcessorProvider } from '@mastra/processors/moderation'
new MastraEditor({
processorProviders: {
moderation: moderationProcessorProvider,
},
})
```
## Properties
**info** (`ProcessorProviderInfo`): Metadata about the provider.
**info.id** (`string`): Unique identifier (for example, "moderation", "token-limiter").
**info.name** (`string`): Human-readable name.
**info.description** (`string`): Short description of the provider.
**configSchema** (`ZodSchema`): Zod schema describing the configuration this provider accepts. Used by the UI to render a form. The validated config object is passed to createProcessor().
**availablePhases** (`ProcessorPhase[]`): Phases this provider's processors support. One or more of 'processInput', 'processInputStep', 'processOutputStream', 'processOutputResult', 'processOutputStep'.
**createProcessor** (`(config: Record<string, unknown>) => Processor`): Create a Processor instance from the validated configuration. Called during agent hydration to resolve stored processor configs into live instances.
## Implementing a provider
```typescript
import type { ProcessorProvider } from '@mastra/core/processor-provider'
import { z } from 'zod'
import { MyProcessor } from './my-processor-impl'
export const myProcessorProvider: ProcessorProvider = {
info: {
id: 'my-processor',
name: 'My Processor',
description: 'Filters output for sensitive content.',
},
configSchema: z.object({
threshold: z.number().min(0).max(1),
}),
availablePhases: ['processOutputStream', 'processOutputResult'],
createProcessor(config) {
return new MyProcessor(config as { threshold: number })
},
}
```
## Related
- [MastraEditor class](https://mastra.ai/reference/editor/mastra-editor) — provider registry.