Class: BasePlugin<TOptions, TStats>
Base abstract class for all plugins with type parameter support Provides plugin lifecycle management and common functionality
Enhanced with:
- Plugin classification system (categories and priorities)
- EventEmitter integration for module event subscription
- Improved statistics tracking
- Better error handling and recovery
Type parameters
| Name | Type | Description |
|---|---|---|
TOptions | extends BasePluginOptions = BasePluginOptions | Plugin options type that extends BasePluginOptions |
TStats | PluginStats | Plugin statistics type (defaults to PluginStats for type safety) |
Hierarchy
BasePlugin
Implements
TypeSafePluginInterface<TOptions,TStats>PluginHooks
Table of contents
Constructors
Properties
Methods
- initialize
- subscribeToModuleEvents
- unsubscribeFromModuleEvents
- dispose
- enable
- disable
- isEnabled
- getConfig
- updateConfig
- getData
- clearData
- getStatus
- getStats
- beforeRun
- afterRun
- beforeExecution
- afterExecution
- beforeConversation
- afterConversation
- beforeToolCall
- beforeToolExecution
- afterToolCall
- afterToolExecution
- beforeProviderCall
- afterProviderCall
- onStreamingChunk
- onError
- onMessageAdded
- onModuleEvent
Constructors
constructor
• new BasePlugin<TOptions, TStats>(): BasePlugin<TOptions, TStats>
Type parameters
| Name | Type |
|---|---|
TOptions | extends BasePluginOptions = BasePluginOptions |
TStats | PluginStats |
Returns
BasePlugin<TOptions, TStats>
Properties
name
• Readonly Abstract name: string
Plugin name
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:291
version
• Readonly Abstract version: string
Plugin version
Implementation of
TypeSafePluginInterface.version
Defined in
packages/agents/src/abstracts/base-plugin.ts:294
enabled
• enabled: boolean = true
Plugin enabled state
Implementation of
TypeSafePluginInterface.enabled
Defined in
packages/agents/src/abstracts/base-plugin.ts:297
category
• category: PluginCategory = PluginCategory.CUSTOM
Plugin category for classification
Implementation of
TypeSafePluginInterface.category
Defined in
packages/agents/src/abstracts/base-plugin.ts:300
priority
• priority: number = PluginPriority.NORMAL
Plugin priority for execution order
Implementation of
TypeSafePluginInterface.priority
Defined in
packages/agents/src/abstracts/base-plugin.ts:303
Methods
initialize
▸ initialize(options?): Promise<void>
Initialize the plugin with type-safe options
Parameters
| Name | Type |
|---|---|
options? | TOptions |
Returns
Promise<void>
Implementation of
TypeSafePluginInterface.initialize
Defined in
packages/agents/src/abstracts/base-plugin.ts:328
subscribeToModuleEvents
▸ subscribeToModuleEvents(eventEmitter): Promise<void>
Subscribe to module events through EventEmitter
Parameters
| Name | Type |
|---|---|
eventEmitter | EventEmitterPlugin |
Returns
Promise<void>
Implementation of
TypeSafePluginInterface.subscribeToModuleEvents
Defined in
packages/agents/src/abstracts/base-plugin.ts:356
unsubscribeFromModuleEvents
▸ unsubscribeFromModuleEvents(eventEmitter): Promise<void>
Unsubscribe from module events
Parameters
| Name | Type |
|---|---|
eventEmitter | EventEmitterPlugin |
Returns
Promise<void>
Implementation of
TypeSafePluginInterface.unsubscribeFromModuleEvents
Defined in
packages/agents/src/abstracts/base-plugin.ts:415
dispose
▸ dispose(): Promise<void>
Cleanup plugin resources
Returns
Promise<void>
Defined in
packages/agents/src/abstracts/base-plugin.ts:430
enable
▸ enable(): void
Enable the plugin
Returns
void
Defined in
packages/agents/src/abstracts/base-plugin.ts:442
disable
▸ disable(): void
Disable the plugin
Returns
void
Defined in
packages/agents/src/abstracts/base-plugin.ts:449
isEnabled
▸ isEnabled(): boolean
Check if plugin is enabled
Returns
boolean
Defined in
packages/agents/src/abstracts/base-plugin.ts:456
getConfig
▸ getConfig(): PluginConfig
Get plugin configuration
Returns
Defined in
packages/agents/src/abstracts/base-plugin.ts:463
updateConfig
▸ updateConfig(_config): void
Update plugin configuration
Parameters
| Name | Type |
|---|---|
_config | PluginConfig |
Returns
void
Defined in
packages/agents/src/abstracts/base-plugin.ts:470
getData
▸ getData(): PluginData
Get plugin data - enhanced with classification information
Returns
Implementation of
TypeSafePluginInterface.getData
Defined in
packages/agents/src/abstracts/base-plugin.ts:477
clearData
▸ clearData(): void
Clear plugin data - common interface for all plugins This method should be implemented by plugins that store data
Returns
void
Defined in
packages/agents/src/abstracts/base-plugin.ts:497
getStatus
▸ getStatus(): Object
Get plugin status - enhanced with classification information
Returns
Object
| Name | Type |
|---|---|
name | string |
version | string |
enabled | boolean |
initialized | boolean |
category | PluginCategory |
priority | number |
subscribedEventsCount | number |
hasEventEmitter | boolean |
Defined in
packages/agents/src/abstracts/base-plugin.ts:502
getStats
▸ getStats(): TStats
Get plugin statistics - enhanced with module event tracking
Returns
TStats
Implementation of
TypeSafePluginInterface.getStats
Defined in
packages/agents/src/abstracts/base-plugin.ts:527
beforeRun
▸ beforeRun(input, options?): Promise<void>
Called before agent run
Parameters
| Name | Type |
|---|---|
input | string |
options? | RunOptions |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:556
afterRun
▸ afterRun(input, response, options?): Promise<void>
Called after agent run
Parameters
| Name | Type |
|---|---|
input | string |
response | string |
options? | RunOptions |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:557
beforeExecution
▸ beforeExecution(context): Promise<void>
Called before execution with context
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:558
afterExecution
▸ afterExecution(context, result): Promise<void>
Called after execution with context and result
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
result | BaseExecutionResult |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:559
beforeConversation
▸ beforeConversation(context): Promise<void>
Called before conversation with context
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
Returns
Promise<void>
Implementation of
PluginHooks.beforeConversation
Defined in
packages/agents/src/abstracts/base-plugin.ts:560
afterConversation
▸ afterConversation(context, result): Promise<void>
Called after conversation with context and result
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
result | BaseExecutionResult |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:561
beforeToolCall
▸ beforeToolCall(toolName, parameters): Promise<void>
Called before tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | ToolParameters |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:562
beforeToolExecution
▸ beforeToolExecution(context, toolData): Promise<void>
Called before tool execution with context
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
toolData | ToolExecutionContext |
Returns
Promise<void>
Implementation of
PluginHooks.beforeToolExecution
Defined in
packages/agents/src/abstracts/base-plugin.ts:563
afterToolCall
▸ afterToolCall(toolName, parameters, result): Promise<void>
Called after tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | ToolParameters |
result | ToolExecutionResult |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:564
afterToolExecution
▸ afterToolExecution(context, toolResults): Promise<void>
Called after tool execution with context
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
toolResults | BaseExecutionResult |
Returns
Promise<void>
Implementation of
PluginHooks.afterToolExecution
Defined in
packages/agents/src/abstracts/base-plugin.ts:565
beforeProviderCall
▸ beforeProviderCall(messages): Promise<void>
Called before AI provider call
Parameters
| Name | Type |
|---|---|
messages | UniversalMessage[] |
Returns
Promise<void>
Implementation of
PluginHooks.beforeProviderCall
Defined in
packages/agents/src/abstracts/base-plugin.ts:566
afterProviderCall
▸ afterProviderCall(messages, response): Promise<void>
Called after AI provider call
Parameters
| Name | Type |
|---|---|
messages | UniversalMessage[] |
response | UniversalMessage |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:567
onStreamingChunk
▸ onStreamingChunk(chunk): Promise<void>
Called on streaming chunk
Parameters
| Name | Type |
|---|---|
chunk | UniversalMessage |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:568
onError
▸ onError(error, context?): Promise<void>
Called on error
Parameters
| Name | Type |
|---|---|
error | Error |
context? | ErrorContext |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:569
onMessageAdded
▸ onMessageAdded(message): Promise<void>
Called on message added to history
Parameters
| Name | Type |
|---|---|
message | Message |
Returns
Promise<void>
Implementation of
Defined in
packages/agents/src/abstracts/base-plugin.ts:570
onModuleEvent
▸ onModuleEvent(eventType, eventData): Promise<void>
Called when module events are received
Parameters
| Name | Type |
|---|---|
eventType | EventType |
eventData | EventData |
Returns
Promise<void>