agents / Exports / EventEmitterPlugin
Class: EventEmitterPlugin
Plugin for event detection and propagation Emits events during agent execution lifecycle
Hierarchy
BasePlugin<EventEmitterPluginOptions,EventEmitterPluginStats>↳
EventEmitterPlugin
Table of contents
Constructors
Properties
Methods
- initialize
- subscribeToModuleEvents
- unsubscribeFromModuleEvents
- dispose
- enable
- disable
- isEnabled
- getConfig
- updateConfig
- getData
- clearData
- getStatus
- beforeRun
- afterRun
- beforeToolCall
- afterToolCall
- beforeProviderCall
- afterProviderCall
- onStreamingChunk
- onMessageAdded
- onModuleEvent
- beforeExecution
- afterExecution
- beforeConversation
- afterConversation
- beforeToolExecution
- afterToolExecution
- onError
- on
- once
- off
- emit
- flushBuffer
- getStats
- clearAllListeners
- destroy
Constructors
constructor
• new EventEmitterPlugin(options?): EventEmitterPlugin
Parameters
| Name | Type |
|---|---|
options | EventEmitterPluginOptions |
Returns
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:176
Properties
enabled
• enabled: boolean = true
Plugin enabled state
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:297
category
• category: PluginCategory = PluginCategory.CUSTOM
Plugin category for classification
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:300
priority
• priority: number = PluginPriority.NORMAL
Plugin priority for execution order
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:303
name
• name: string = 'EventEmitterPlugin'
Plugin name
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:165
version
• version: string = '1.0.0'
Plugin version
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:166
Methods
initialize
▸ initialize(options?): Promise<void>
Initialize the plugin with type-safe options
Parameters
| Name | Type |
|---|---|
options? | EventEmitterPluginOptions |
Returns
Promise<void>
Inherited from
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>
Inherited from
BasePlugin.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>
Inherited from
BasePlugin.unsubscribeFromModuleEvents
Defined in
packages/agents/src/abstracts/base-plugin.ts:415
dispose
▸ dispose(): Promise<void>
Cleanup plugin resources
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:430
enable
▸ enable(): void
Enable the plugin
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:442
disable
▸ disable(): void
Disable the plugin
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:449
isEnabled
▸ isEnabled(): boolean
Check if plugin is enabled
Returns
boolean
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:456
getConfig
▸ getConfig(): PluginConfig
Get plugin configuration
Returns
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:463
updateConfig
▸ updateConfig(_config): void
Update plugin configuration
Parameters
| Name | Type |
|---|---|
_config | PluginConfig |
Returns
void
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:470
getData
▸ getData(): PluginData
Get plugin data - enhanced with classification information
Returns
Inherited from
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
Inherited from
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 |
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:502
beforeRun
▸ beforeRun(input, options?): Promise<void>
Called before agent run
Parameters
| Name | Type |
|---|---|
input | string |
options? | RunOptions |
Returns
Promise<void>
Inherited from
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>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:557
beforeToolCall
▸ beforeToolCall(toolName, parameters): Promise<void>
Called before tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | ToolParameters |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:562
afterToolCall
▸ afterToolCall(toolName, parameters, result): Promise<void>
Called after tool execution
Parameters
| Name | Type |
|---|---|
toolName | string |
parameters | ToolParameters |
result | ToolExecutionResult |
Returns
Promise<void>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:564
beforeProviderCall
▸ beforeProviderCall(messages): Promise<void>
Called before AI provider call
Parameters
| Name | Type |
|---|---|
messages | UniversalMessage[] |
Returns
Promise<void>
Inherited from
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>
Inherited from
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>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:568
onMessageAdded
▸ onMessageAdded(message): Promise<void>
Called on message added to history
Parameters
| Name | Type |
|---|---|
message | Message |
Returns
Promise<void>
Inherited from
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>
Inherited from
Defined in
packages/agents/src/abstracts/base-plugin.ts:571
beforeExecution
▸ beforeExecution(context): Promise<void>
Before execution starts
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:226
afterExecution
▸ afterExecution(context, result): Promise<void>
After execution completes
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
result | BaseExecutionResult |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:241
beforeConversation
▸ beforeConversation(context): Promise<void>
Before conversation starts
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:258
afterConversation
▸ afterConversation(context, result): Promise<void>
After conversation completes
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
result | BaseExecutionResult |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:277
beforeToolExecution
▸ beforeToolExecution(context, toolData): Promise<void>
Before tool execution - emits tool.beforeExecute event
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
toolData | ToolExecutionContext |
Returns
Promise<void>
Overrides
BasePlugin.beforeToolExecution
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:298
afterToolExecution
▸ afterToolExecution(context, toolResults): Promise<void>
After tool execution - emits tool.success or tool.error events
Parameters
| Name | Type |
|---|---|
context | BaseExecutionContext |
toolResults | BaseExecutionResult |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:319
onError
▸ onError(error, context?): Promise<void>
On error
REASON: Error context structure varies by execution phase and error type, needs flexible handling ALTERNATIVES_CONSIDERED:
- Strict error context interface (breaks error handling flexibility)
- Union types (insufficient for dynamic error contexts)
- Generic constraints (too complex for error handling)
- Interface definitions (too rigid for varied error contexts)
- Type assertions (decreases type safety) TODO: Consider standardized error context interface
Parameters
| Name | Type |
|---|---|
error | Error |
context? | ErrorContext |
Returns
Promise<void>
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:367
on
▸ on(eventType, listener, options?): string
Register event listener
Parameters
| Name | Type |
|---|---|
eventType | EventType |
listener | EventListener |
options? | Object |
options.once? | boolean |
options.filter? | (event: EventData) => boolean |
Returns
string
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:382
once
▸ once(eventType, listener, filter?): string
Register one-time event listener
Parameters
| Name | Type |
|---|---|
eventType | EventType |
listener | EventListener |
filter? | (event: EventData) => boolean |
Returns
string
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:422
off
▸ off(eventType, handlerIdOrListener): boolean
Remove event listener
Parameters
| Name | Type |
|---|---|
eventType | EventType |
handlerIdOrListener | string | EventListener |
Returns
boolean
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:432
emit
▸ emit(eventType, eventData?): Promise<void>
Emit an event
Parameters
| Name | Type |
|---|---|
eventType | EventType |
eventData | Partial<EventData> |
Returns
Promise<void>
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:459
flushBuffer
▸ flushBuffer(): Promise<void>
Flush buffered events
Returns
Promise<void>
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:573
getStats
▸ getStats(): EventEmitterPluginStats
Get event emitter statistics
Returns
EventEmitterPluginStats
Overrides
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:591
clearAllListeners
▸ clearAllListeners(): void
Clear all listeners
Returns
void
Defined in
packages/agents/src/plugins/event-emitter-plugin.ts:613
destroy
▸ destroy(): Promise<void>
Cleanup on plugin destruction
Returns
Promise<void>