@robota-sdk/agent-core 3.0.0-beta.6 → 3.0.0-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +34 -11
- package/dist/browser/index.d.ts +646 -324
- package/dist/browser/index.js +10 -4
- package/dist/node/index.cjs +10 -4
- package/dist/node/index.d.cts +646 -324
- package/dist/node/index.d.ts +646 -324
- package/dist/node/index.js +10 -4
- package/package.json +5 -3
- package/dist/abstracts/abstract-agent.d.ts +0 -56
- package/dist/abstracts/abstract-agent.d.ts.map +0 -1
- package/dist/abstracts/abstract-agent.js +0 -55
- package/dist/abstracts/abstract-agent.js.map +0 -1
- package/dist/abstracts/abstract-ai-provider.d.ts +0 -187
- package/dist/abstracts/abstract-ai-provider.d.ts.map +0 -1
- package/dist/abstracts/abstract-ai-provider.js +0 -252
- package/dist/abstracts/abstract-ai-provider.js.map +0 -1
- package/dist/abstracts/abstract-executor.d.ts +0 -110
- package/dist/abstracts/abstract-executor.d.ts.map +0 -1
- package/dist/abstracts/abstract-executor.js +0 -156
- package/dist/abstracts/abstract-executor.js.map +0 -1
- package/dist/abstracts/abstract-manager.d.ts +0 -42
- package/dist/abstracts/abstract-manager.d.ts.map +0 -1
- package/dist/abstracts/abstract-manager.js +0 -49
- package/dist/abstracts/abstract-manager.js.map +0 -1
- package/dist/abstracts/abstract-module.d.ts +0 -365
- package/dist/abstracts/abstract-module.d.ts.map +0 -1
- package/dist/abstracts/abstract-module.js +0 -474
- package/dist/abstracts/abstract-module.js.map +0 -1
- package/dist/abstracts/abstract-plugin.d.ts +0 -369
- package/dist/abstracts/abstract-plugin.d.ts.map +0 -1
- package/dist/abstracts/abstract-plugin.js +0 -258
- package/dist/abstracts/abstract-plugin.js.map +0 -1
- package/dist/abstracts/abstract-tool.d.ts +0 -175
- package/dist/abstracts/abstract-tool.d.ts.map +0 -1
- package/dist/abstracts/abstract-tool.js +0 -140
- package/dist/abstracts/abstract-tool.js.map +0 -1
- package/dist/abstracts/abstract-workflow-converter.d.ts +0 -136
- package/dist/abstracts/abstract-workflow-converter.d.ts.map +0 -1
- package/dist/abstracts/abstract-workflow-converter.js +0 -252
- package/dist/abstracts/abstract-workflow-converter.js.map +0 -1
- package/dist/abstracts/abstract-workflow-validator.d.ts +0 -203
- package/dist/abstracts/abstract-workflow-validator.d.ts.map +0 -1
- package/dist/abstracts/abstract-workflow-validator.js +0 -447
- package/dist/abstracts/abstract-workflow-validator.js.map +0 -1
- package/dist/abstracts/index.d.ts +0 -6
- package/dist/abstracts/index.d.ts.map +0 -1
- package/dist/abstracts/index.js +0 -9
- package/dist/abstracts/index.js.map +0 -1
- package/dist/agents/constants.d.ts +0 -23
- package/dist/agents/constants.d.ts.map +0 -1
- package/dist/agents/constants.js +0 -22
- package/dist/agents/constants.js.map +0 -1
- package/dist/agents/index.d.ts +0 -1
- package/dist/agents/index.d.ts.map +0 -1
- package/dist/agents/index.js +0 -4
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/robota.test.d.ts +0 -2
- package/dist/agents/robota.test.d.ts.map +0 -1
- package/dist/agents/robota.test.js +0 -416
- package/dist/agents/robota.test.js.map +0 -1
- package/dist/core/robota.d.ts +0 -694
- package/dist/core/robota.d.ts.map +0 -1
- package/dist/core/robota.js +0 -1277
- package/dist/core/robota.js.map +0 -1
- package/dist/executors/local-executor.d.ts +0 -96
- package/dist/executors/local-executor.d.ts.map +0 -1
- package/dist/executors/local-executor.js +0 -197
- package/dist/executors/local-executor.js.map +0 -1
- package/dist/executors/local-executor.test.d.ts +0 -2
- package/dist/executors/local-executor.test.d.ts.map +0 -1
- package/dist/executors/local-executor.test.js +0 -192
- package/dist/executors/local-executor.test.js.map +0 -1
- package/dist/index.d.ts +0 -274
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -235
- package/dist/index.js.map +0 -1
- package/dist/interfaces/agent.d.ts +0 -198
- package/dist/interfaces/agent.d.ts.map +0 -1
- package/dist/interfaces/agent.js +0 -2
- package/dist/interfaces/agent.js.map +0 -1
- package/dist/interfaces/event-service.d.ts +0 -79
- package/dist/interfaces/event-service.d.ts.map +0 -1
- package/dist/interfaces/event-service.js +0 -2
- package/dist/interfaces/event-service.js.map +0 -1
- package/dist/interfaces/executor.d.ts +0 -128
- package/dist/interfaces/executor.d.ts.map +0 -1
- package/dist/interfaces/executor.js +0 -2
- package/dist/interfaces/executor.js.map +0 -1
- package/dist/interfaces/history-module.d.ts +0 -19
- package/dist/interfaces/history-module.d.ts.map +0 -1
- package/dist/interfaces/history-module.js +0 -2
- package/dist/interfaces/history-module.js.map +0 -1
- package/dist/interfaces/index.d.ts +0 -13
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -4
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/manager.d.ts +0 -142
- package/dist/interfaces/manager.d.ts.map +0 -1
- package/dist/interfaces/manager.js +0 -2
- package/dist/interfaces/manager.js.map +0 -1
- package/dist/interfaces/messages.d.ts +0 -75
- package/dist/interfaces/messages.d.ts.map +0 -1
- package/dist/interfaces/messages.js +0 -29
- package/dist/interfaces/messages.js.map +0 -1
- package/dist/interfaces/progress-reporting.d.ts +0 -86
- package/dist/interfaces/progress-reporting.d.ts.map +0 -1
- package/dist/interfaces/progress-reporting.js +0 -37
- package/dist/interfaces/progress-reporting.js.map +0 -1
- package/dist/interfaces/provider.d.ts +0 -217
- package/dist/interfaces/provider.d.ts.map +0 -1
- package/dist/interfaces/provider.js +0 -2
- package/dist/interfaces/provider.js.map +0 -1
- package/dist/interfaces/service.d.ts +0 -205
- package/dist/interfaces/service.d.ts.map +0 -1
- package/dist/interfaces/service.js +0 -6
- package/dist/interfaces/service.js.map +0 -1
- package/dist/interfaces/tool.d.ts +0 -248
- package/dist/interfaces/tool.d.ts.map +0 -1
- package/dist/interfaces/tool.js +0 -2
- package/dist/interfaces/tool.js.map +0 -1
- package/dist/interfaces/types.d.ts +0 -71
- package/dist/interfaces/types.d.ts.map +0 -1
- package/dist/interfaces/types.js +0 -33
- package/dist/interfaces/types.js.map +0 -1
- package/dist/interfaces/workflow-converter.d.ts +0 -193
- package/dist/interfaces/workflow-converter.d.ts.map +0 -1
- package/dist/interfaces/workflow-converter.js +0 -11
- package/dist/interfaces/workflow-converter.js.map +0 -1
- package/dist/interfaces/workflow-validator.d.ts +0 -209
- package/dist/interfaces/workflow-validator.d.ts.map +0 -1
- package/dist/interfaces/workflow-validator.js +0 -16
- package/dist/interfaces/workflow-validator.js.map +0 -1
- package/dist/managers/agent-factory.d.ts +0 -132
- package/dist/managers/agent-factory.d.ts.map +0 -1
- package/dist/managers/agent-factory.js +0 -284
- package/dist/managers/agent-factory.js.map +0 -1
- package/dist/managers/agent-factory.test.d.ts +0 -2
- package/dist/managers/agent-factory.test.d.ts.map +0 -1
- package/dist/managers/agent-factory.test.js +0 -249
- package/dist/managers/agent-factory.test.js.map +0 -1
- package/dist/managers/agent-templates.d.ts +0 -84
- package/dist/managers/agent-templates.d.ts.map +0 -1
- package/dist/managers/agent-templates.js +0 -159
- package/dist/managers/agent-templates.js.map +0 -1
- package/dist/managers/ai-provider-manager.d.ts +0 -80
- package/dist/managers/ai-provider-manager.d.ts.map +0 -1
- package/dist/managers/ai-provider-manager.js +0 -226
- package/dist/managers/ai-provider-manager.js.map +0 -1
- package/dist/managers/conversation-history-manager.d.ts +0 -455
- package/dist/managers/conversation-history-manager.d.ts.map +0 -1
- package/dist/managers/conversation-history-manager.js +0 -578
- package/dist/managers/conversation-history-manager.js.map +0 -1
- package/dist/managers/conversation-history-manager.test.d.ts +0 -2
- package/dist/managers/conversation-history-manager.test.d.ts.map +0 -1
- package/dist/managers/conversation-history-manager.test.js +0 -374
- package/dist/managers/conversation-history-manager.test.js.map +0 -1
- package/dist/managers/index.d.ts +0 -8
- package/dist/managers/index.d.ts.map +0 -1
- package/dist/managers/index.js +0 -8
- package/dist/managers/index.js.map +0 -1
- package/dist/managers/module-registry.d.ts +0 -161
- package/dist/managers/module-registry.d.ts.map +0 -1
- package/dist/managers/module-registry.js +0 -519
- package/dist/managers/module-registry.js.map +0 -1
- package/dist/managers/module-type-registry.d.ts +0 -113
- package/dist/managers/module-type-registry.d.ts.map +0 -1
- package/dist/managers/module-type-registry.js +0 -439
- package/dist/managers/module-type-registry.js.map +0 -1
- package/dist/managers/plugins.d.ts +0 -166
- package/dist/managers/plugins.d.ts.map +0 -1
- package/dist/managers/plugins.js +0 -339
- package/dist/managers/plugins.js.map +0 -1
- package/dist/managers/tool-manager.d.ts +0 -70
- package/dist/managers/tool-manager.d.ts.map +0 -1
- package/dist/managers/tool-manager.js +0 -138
- package/dist/managers/tool-manager.js.map +0 -1
- package/dist/managers/tool-manager.test.d.ts +0 -2
- package/dist/managers/tool-manager.test.d.ts.map +0 -1
- package/dist/managers/tool-manager.test.js +0 -186
- package/dist/managers/tool-manager.test.js.map +0 -1
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts +0 -67
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts.map +0 -1
- package/dist/plugins/conversation-history/conversation-history-plugin.js +0 -270
- package/dist/plugins/conversation-history/conversation-history-plugin.js.map +0 -1
- package/dist/plugins/conversation-history/index.d.ts +0 -3
- package/dist/plugins/conversation-history/index.d.ts.map +0 -1
- package/dist/plugins/conversation-history/index.js +0 -2
- package/dist/plugins/conversation-history/index.js.map +0 -1
- package/dist/plugins/conversation-history/storages/database-storage.d.ts +0 -19
- package/dist/plugins/conversation-history/storages/database-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/database-storage.js +0 -94
- package/dist/plugins/conversation-history/storages/database-storage.js.map +0 -1
- package/dist/plugins/conversation-history/storages/file-storage.d.ts +0 -15
- package/dist/plugins/conversation-history/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/file-storage.js +0 -94
- package/dist/plugins/conversation-history/storages/file-storage.js.map +0 -1
- package/dist/plugins/conversation-history/storages/index.d.ts +0 -4
- package/dist/plugins/conversation-history/storages/index.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/index.js +0 -4
- package/dist/plugins/conversation-history/storages/index.js.map +0 -1
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts +0 -15
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/conversation-history/storages/memory-storage.js +0 -33
- package/dist/plugins/conversation-history/storages/memory-storage.js.map +0 -1
- package/dist/plugins/conversation-history/types.d.ts +0 -61
- package/dist/plugins/conversation-history/types.d.ts.map +0 -1
- package/dist/plugins/conversation-history/types.js +0 -2
- package/dist/plugins/conversation-history/types.js.map +0 -1
- package/dist/plugins/error-handling/context-adapter.d.ts +0 -30
- package/dist/plugins/error-handling/context-adapter.d.ts.map +0 -1
- package/dist/plugins/error-handling/context-adapter.js +0 -41
- package/dist/plugins/error-handling/context-adapter.js.map +0 -1
- package/dist/plugins/error-handling/error-handling-plugin.d.ts +0 -49
- package/dist/plugins/error-handling/error-handling-plugin.d.ts.map +0 -1
- package/dist/plugins/error-handling/error-handling-plugin.js +0 -229
- package/dist/plugins/error-handling/error-handling-plugin.js.map +0 -1
- package/dist/plugins/error-handling/index.d.ts +0 -10
- package/dist/plugins/error-handling/index.d.ts.map +0 -1
- package/dist/plugins/error-handling/index.js +0 -10
- package/dist/plugins/error-handling/index.js.map +0 -1
- package/dist/plugins/error-handling/types.d.ts +0 -73
- package/dist/plugins/error-handling/types.d.ts.map +0 -1
- package/dist/plugins/error-handling/types.js +0 -14
- package/dist/plugins/error-handling/types.js.map +0 -1
- package/dist/plugins/event-emitter/metrics.d.ts +0 -17
- package/dist/plugins/event-emitter/metrics.d.ts.map +0 -1
- package/dist/plugins/event-emitter/metrics.js +0 -17
- package/dist/plugins/event-emitter/metrics.js.map +0 -1
- package/dist/plugins/event-emitter/types.d.ts +0 -112
- package/dist/plugins/event-emitter/types.d.ts.map +0 -1
- package/dist/plugins/event-emitter/types.js +0 -65
- package/dist/plugins/event-emitter/types.js.map +0 -1
- package/dist/plugins/event-emitter-plugin.d.ts +0 -222
- package/dist/plugins/event-emitter-plugin.d.ts.map +0 -1
- package/dist/plugins/event-emitter-plugin.js +0 -432
- package/dist/plugins/event-emitter-plugin.js.map +0 -1
- package/dist/plugins/event-emitter-plugin.test.d.ts +0 -2
- package/dist/plugins/event-emitter-plugin.test.d.ts.map +0 -1
- package/dist/plugins/event-emitter-plugin.test.js +0 -94
- package/dist/plugins/event-emitter-plugin.test.js.map +0 -1
- package/dist/plugins/execution/execution-analytics-plugin.d.ts +0 -129
- package/dist/plugins/execution/execution-analytics-plugin.d.ts.map +0 -1
- package/dist/plugins/execution/execution-analytics-plugin.js +0 -517
- package/dist/plugins/execution/execution-analytics-plugin.js.map +0 -1
- package/dist/plugins/execution/index.d.ts +0 -3
- package/dist/plugins/execution/index.d.ts.map +0 -1
- package/dist/plugins/execution/index.js +0 -2
- package/dist/plugins/execution/index.js.map +0 -1
- package/dist/plugins/execution/types.d.ts +0 -90
- package/dist/plugins/execution/types.d.ts.map +0 -1
- package/dist/plugins/execution/types.js +0 -2
- package/dist/plugins/execution/types.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -11
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/limits/types.d.ts +0 -61
- package/dist/plugins/limits/types.d.ts.map +0 -1
- package/dist/plugins/limits/types.js +0 -2
- package/dist/plugins/limits/types.js.map +0 -1
- package/dist/plugins/limits-plugin.d.ts +0 -113
- package/dist/plugins/limits-plugin.d.ts.map +0 -1
- package/dist/plugins/limits-plugin.js +0 -380
- package/dist/plugins/limits-plugin.js.map +0 -1
- package/dist/plugins/logging/formatters.d.ts +0 -14
- package/dist/plugins/logging/formatters.d.ts.map +0 -1
- package/dist/plugins/logging/formatters.js +0 -24
- package/dist/plugins/logging/formatters.js.map +0 -1
- package/dist/plugins/logging/index.d.ts +0 -3
- package/dist/plugins/logging/index.d.ts.map +0 -1
- package/dist/plugins/logging/index.js +0 -2
- package/dist/plugins/logging/index.js.map +0 -1
- package/dist/plugins/logging/logging-plugin.d.ts +0 -91
- package/dist/plugins/logging/logging-plugin.d.ts.map +0 -1
- package/dist/plugins/logging/logging-plugin.js +0 -335
- package/dist/plugins/logging/logging-plugin.js.map +0 -1
- package/dist/plugins/logging/storages/console-storage.d.ts +0 -14
- package/dist/plugins/logging/storages/console-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/console-storage.js +0 -38
- package/dist/plugins/logging/storages/console-storage.js.map +0 -1
- package/dist/plugins/logging/storages/file-storage.d.ts +0 -14
- package/dist/plugins/logging/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/file-storage.js +0 -41
- package/dist/plugins/logging/storages/file-storage.js.map +0 -1
- package/dist/plugins/logging/storages/index.d.ts +0 -5
- package/dist/plugins/logging/storages/index.d.ts.map +0 -1
- package/dist/plugins/logging/storages/index.js +0 -5
- package/dist/plugins/logging/storages/index.js.map +0 -1
- package/dist/plugins/logging/storages/remote-storage.d.ts +0 -20
- package/dist/plugins/logging/storages/remote-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/remote-storage.js +0 -61
- package/dist/plugins/logging/storages/remote-storage.js.map +0 -1
- package/dist/plugins/logging/storages/silent-storage.d.ts +0 -10
- package/dist/plugins/logging/storages/silent-storage.d.ts.map +0 -1
- package/dist/plugins/logging/storages/silent-storage.js +0 -15
- package/dist/plugins/logging/storages/silent-storage.js.map +0 -1
- package/dist/plugins/logging/types.d.ts +0 -84
- package/dist/plugins/logging/types.d.ts.map +0 -1
- package/dist/plugins/logging/types.js +0 -2
- package/dist/plugins/logging/types.js.map +0 -1
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts +0 -12
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts.map +0 -1
- package/dist/plugins/performance/collectors/system-metrics-collector.js +0 -65
- package/dist/plugins/performance/collectors/system-metrics-collector.js.map +0 -1
- package/dist/plugins/performance/index.d.ts +0 -5
- package/dist/plugins/performance/index.d.ts.map +0 -1
- package/dist/plugins/performance/index.js +0 -4
- package/dist/plugins/performance/index.js.map +0 -1
- package/dist/plugins/performance/performance-plugin.d.ts +0 -49
- package/dist/plugins/performance/performance-plugin.d.ts.map +0 -1
- package/dist/plugins/performance/performance-plugin.js +0 -293
- package/dist/plugins/performance/performance-plugin.js.map +0 -1
- package/dist/plugins/performance/storages/index.d.ts +0 -2
- package/dist/plugins/performance/storages/index.d.ts.map +0 -1
- package/dist/plugins/performance/storages/index.js +0 -4
- package/dist/plugins/performance/storages/index.js.map +0 -1
- package/dist/plugins/performance/storages/memory-storage.d.ts +0 -19
- package/dist/plugins/performance/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/performance/storages/memory-storage.js +0 -69
- package/dist/plugins/performance/storages/memory-storage.js.map +0 -1
- package/dist/plugins/performance/types.d.ts +0 -154
- package/dist/plugins/performance/types.d.ts.map +0 -1
- package/dist/plugins/performance/types.js +0 -2
- package/dist/plugins/performance/types.js.map +0 -1
- package/dist/plugins/usage/aggregate-usage-stats.d.ts +0 -12
- package/dist/plugins/usage/aggregate-usage-stats.d.ts.map +0 -1
- package/dist/plugins/usage/aggregate-usage-stats.js +0 -115
- package/dist/plugins/usage/aggregate-usage-stats.js.map +0 -1
- package/dist/plugins/usage/index.d.ts +0 -5
- package/dist/plugins/usage/index.d.ts.map +0 -1
- package/dist/plugins/usage/index.js +0 -4
- package/dist/plugins/usage/index.js.map +0 -1
- package/dist/plugins/usage/storages/file-storage.d.ts +0 -22
- package/dist/plugins/usage/storages/file-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/file-storage.js +0 -111
- package/dist/plugins/usage/storages/file-storage.js.map +0 -1
- package/dist/plugins/usage/storages/index.d.ts +0 -5
- package/dist/plugins/usage/storages/index.d.ts.map +0 -1
- package/dist/plugins/usage/storages/index.js +0 -5
- package/dist/plugins/usage/storages/index.js.map +0 -1
- package/dist/plugins/usage/storages/memory-storage.d.ts +0 -22
- package/dist/plugins/usage/storages/memory-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/memory-storage.js +0 -42
- package/dist/plugins/usage/storages/memory-storage.js.map +0 -1
- package/dist/plugins/usage/storages/remote-storage.d.ts +0 -26
- package/dist/plugins/usage/storages/remote-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/remote-storage.js +0 -115
- package/dist/plugins/usage/storages/remote-storage.js.map +0 -1
- package/dist/plugins/usage/storages/silent-storage.d.ts +0 -19
- package/dist/plugins/usage/storages/silent-storage.d.ts.map +0 -1
- package/dist/plugins/usage/storages/silent-storage.js +0 -26
- package/dist/plugins/usage/storages/silent-storage.js.map +0 -1
- package/dist/plugins/usage/types.d.ts +0 -127
- package/dist/plugins/usage/types.d.ts.map +0 -1
- package/dist/plugins/usage/types.js +0 -2
- package/dist/plugins/usage/types.js.map +0 -1
- package/dist/plugins/usage/usage-plugin.d.ts +0 -67
- package/dist/plugins/usage/usage-plugin.d.ts.map +0 -1
- package/dist/plugins/usage/usage-plugin.js +0 -309
- package/dist/plugins/usage/usage-plugin.js.map +0 -1
- package/dist/plugins/webhook/http-client.d.ts +0 -30
- package/dist/plugins/webhook/http-client.d.ts.map +0 -1
- package/dist/plugins/webhook/http-client.js +0 -110
- package/dist/plugins/webhook/http-client.js.map +0 -1
- package/dist/plugins/webhook/index.d.ts +0 -9
- package/dist/plugins/webhook/index.d.ts.map +0 -1
- package/dist/plugins/webhook/index.js +0 -9
- package/dist/plugins/webhook/index.js.map +0 -1
- package/dist/plugins/webhook/transformer.d.ts +0 -63
- package/dist/plugins/webhook/transformer.d.ts.map +0 -1
- package/dist/plugins/webhook/transformer.js +0 -157
- package/dist/plugins/webhook/transformer.js.map +0 -1
- package/dist/plugins/webhook/types.d.ts +0 -183
- package/dist/plugins/webhook/types.d.ts.map +0 -1
- package/dist/plugins/webhook/types.js +0 -2
- package/dist/plugins/webhook/types.js.map +0 -1
- package/dist/plugins/webhook/webhook-plugin.d.ts +0 -92
- package/dist/plugins/webhook/webhook-plugin.d.ts.map +0 -1
- package/dist/plugins/webhook/webhook-plugin.js +0 -328
- package/dist/plugins/webhook/webhook-plugin.js.map +0 -1
- package/dist/schemas/agent-template-schema.d.ts +0 -137
- package/dist/schemas/agent-template-schema.d.ts.map +0 -1
- package/dist/schemas/agent-template-schema.js +0 -87
- package/dist/schemas/agent-template-schema.js.map +0 -1
- package/dist/services/conversation-service/index.d.ts +0 -88
- package/dist/services/conversation-service/index.d.ts.map +0 -1
- package/dist/services/conversation-service/index.js +0 -441
- package/dist/services/conversation-service/index.js.map +0 -1
- package/dist/services/conversation-service/types.d.ts +0 -32
- package/dist/services/conversation-service/types.d.ts.map +0 -1
- package/dist/services/conversation-service/types.js +0 -8
- package/dist/services/conversation-service/types.js.map +0 -1
- package/dist/services/event-service.d.ts +0 -61
- package/dist/services/event-service.d.ts.map +0 -1
- package/dist/services/event-service.js +0 -110
- package/dist/services/event-service.js.map +0 -1
- package/dist/services/event-service.test.d.ts +0 -2
- package/dist/services/event-service.test.d.ts.map +0 -1
- package/dist/services/event-service.test.js +0 -86
- package/dist/services/event-service.test.js.map +0 -1
- package/dist/services/execution-service.d.ts +0 -151
- package/dist/services/execution-service.d.ts.map +0 -1
- package/dist/services/execution-service.js +0 -1262
- package/dist/services/execution-service.js.map +0 -1
- package/dist/services/execution-service.test.d.ts +0 -2
- package/dist/services/execution-service.test.d.ts.map +0 -1
- package/dist/services/execution-service.test.js +0 -338
- package/dist/services/execution-service.test.js.map +0 -1
- package/dist/services/history-module.d.ts +0 -15
- package/dist/services/history-module.d.ts.map +0 -1
- package/dist/services/history-module.js +0 -42
- package/dist/services/history-module.js.map +0 -1
- package/dist/services/in-memory-history-store.d.ts +0 -12
- package/dist/services/in-memory-history-store.d.ts.map +0 -1
- package/dist/services/in-memory-history-store.js +0 -41
- package/dist/services/in-memory-history-store.js.map +0 -1
- package/dist/services/index.d.ts +0 -7
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -13
- package/dist/services/index.js.map +0 -1
- package/dist/services/task-events.d.ts +0 -6
- package/dist/services/task-events.d.ts.map +0 -1
- package/dist/services/task-events.js +0 -6
- package/dist/services/task-events.js.map +0 -1
- package/dist/services/tool-execution-service.d.ts +0 -74
- package/dist/services/tool-execution-service.d.ts.map +0 -1
- package/dist/services/tool-execution-service.js +0 -189
- package/dist/services/tool-execution-service.js.map +0 -1
- package/dist/services/user-events.d.ts +0 -7
- package/dist/services/user-events.d.ts.map +0 -1
- package/dist/services/user-events.js +0 -6
- package/dist/services/user-events.js.map +0 -1
- package/dist/tools/implementations/function-tool/index.d.ts +0 -9
- package/dist/tools/implementations/function-tool/index.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/index.js +0 -13
- package/dist/tools/implementations/function-tool/index.js.map +0 -1
- package/dist/tools/implementations/function-tool/schema-converter.d.ts +0 -32
- package/dist/tools/implementations/function-tool/schema-converter.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/schema-converter.js +0 -164
- package/dist/tools/implementations/function-tool/schema-converter.js.map +0 -1
- package/dist/tools/implementations/function-tool/types.d.ts +0 -72
- package/dist/tools/implementations/function-tool/types.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool/types.js +0 -14
- package/dist/tools/implementations/function-tool/types.js.map +0 -1
- package/dist/tools/implementations/function-tool.d.ts +0 -49
- package/dist/tools/implementations/function-tool.d.ts.map +0 -1
- package/dist/tools/implementations/function-tool.js +0 -223
- package/dist/tools/implementations/function-tool.js.map +0 -1
- package/dist/tools/implementations/index.d.ts +0 -4
- package/dist/tools/implementations/index.d.ts.map +0 -1
- package/dist/tools/implementations/index.js +0 -5
- package/dist/tools/implementations/index.js.map +0 -1
- package/dist/tools/implementations/mcp-tool.d.ts +0 -72
- package/dist/tools/implementations/mcp-tool.d.ts.map +0 -1
- package/dist/tools/implementations/mcp-tool.js +0 -246
- package/dist/tools/implementations/mcp-tool.js.map +0 -1
- package/dist/tools/implementations/openapi-tool.d.ts +0 -56
- package/dist/tools/implementations/openapi-tool.d.ts.map +0 -1
- package/dist/tools/implementations/openapi-tool.js +0 -324
- package/dist/tools/implementations/openapi-tool.js.map +0 -1
- package/dist/tools/implementations/relay-mcp-tool.d.ts +0 -38
- package/dist/tools/implementations/relay-mcp-tool.d.ts.map +0 -1
- package/dist/tools/implementations/relay-mcp-tool.js +0 -46
- package/dist/tools/implementations/relay-mcp-tool.js.map +0 -1
- package/dist/tools/index.d.ts +0 -3
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -4
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/registry/index.d.ts +0 -2
- package/dist/tools/registry/index.d.ts.map +0 -1
- package/dist/tools/registry/index.js +0 -3
- package/dist/tools/registry/index.js.map +0 -1
- package/dist/tools/registry/tool-registry.d.ts +0 -54
- package/dist/tools/registry/tool-registry.d.ts.map +0 -1
- package/dist/tools/registry/tool-registry.js +0 -146
- package/dist/tools/registry/tool-registry.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -155
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -203
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/execution-proxy.d.ts +0 -75
- package/dist/utils/execution-proxy.d.ts.map +0 -1
- package/dist/utils/execution-proxy.js +0 -230
- package/dist/utils/execution-proxy.js.map +0 -1
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -7
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -74
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -143
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/message-converter.d.ts +0 -68
- package/dist/utils/message-converter.d.ts.map +0 -1
- package/dist/utils/message-converter.js +0 -87
- package/dist/utils/message-converter.js.map +0 -1
- package/dist/utils/periodic-task.d.ts +0 -14
- package/dist/utils/periodic-task.d.ts.map +0 -1
- package/dist/utils/periodic-task.js +0 -26
- package/dist/utils/periodic-task.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -40
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -162
- package/dist/utils/validation.js.map +0 -1
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { AbstractPlugin, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginErrorContext, type IPluginOptions, type IPluginStats } from '../abstracts/abstract-plugin';
|
|
2
|
-
import type { IToolExecutionContext, TToolParameters, IToolResult } from '../interfaces/tool';
|
|
3
|
-
import { type IEventEmitterEventData, type TEventName, type TEventEmitterListener } from './event-emitter/types';
|
|
4
|
-
import { type IEventEmitterMetrics } from './event-emitter/metrics';
|
|
5
|
-
export type { TEventName };
|
|
6
|
-
/**
|
|
7
|
-
* Basic event execution value types - compatible with IPluginExecutionResult
|
|
8
|
-
*/
|
|
9
|
-
export type TEventExecutionValue = string | number | boolean | Date | string[] | number[] | boolean[] | Record<string, string | number | boolean | null> | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Event execution context data following semantic naming conventions
|
|
12
|
-
* Supports nested structures with proper type safety
|
|
13
|
-
*/
|
|
14
|
-
export interface IEventExecutionContextData {
|
|
15
|
-
messageCount?: number | undefined;
|
|
16
|
-
config?: Record<string, TEventExecutionValue> | undefined;
|
|
17
|
-
result?: IPluginExecutionResult | undefined;
|
|
18
|
-
duration?: number | undefined;
|
|
19
|
-
tokensUsed?: number | undefined;
|
|
20
|
-
toolsExecuted?: number | undefined;
|
|
21
|
-
messages?: Record<string, TEventExecutionValue>[] | undefined;
|
|
22
|
-
response?: string | undefined;
|
|
23
|
-
toolCalls?: Record<string, TEventExecutionValue>[] | undefined;
|
|
24
|
-
[key: string]: TEventExecutionValue | Record<string, TEventExecutionValue> | Record<string, TEventExecutionValue>[] | IPluginExecutionResult | undefined;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Event metadata following semantic naming conventions
|
|
28
|
-
*/
|
|
29
|
-
export type TEventEmitterMetadata = Record<string, string | number | boolean | Date | string[] | number[] | undefined>;
|
|
30
|
-
/**
|
|
31
|
-
* Plugin execution context for event emitter
|
|
32
|
-
*/
|
|
33
|
-
export interface IEventEmitterPluginExecutionContext extends IPluginExecutionContext {
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Plugin execution result for event emitter
|
|
37
|
-
*/
|
|
38
|
-
export interface IEventEmitterPluginExecutionResult {
|
|
39
|
-
content?: string;
|
|
40
|
-
response?: string;
|
|
41
|
-
duration?: number;
|
|
42
|
-
tokensUsed?: number;
|
|
43
|
-
toolsExecuted?: number;
|
|
44
|
-
usage?: Record<string, TEventExecutionValue>;
|
|
45
|
-
toolCalls?: Record<string, TEventExecutionValue>[];
|
|
46
|
-
[key: string]: TEventExecutionValue | Record<string, TEventExecutionValue> | Record<string, TEventExecutionValue>[] | undefined;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Event data structure
|
|
50
|
-
*/
|
|
51
|
-
export type { IEventEmitterEventData };
|
|
52
|
-
/**
|
|
53
|
-
* 🆕 Enhanced event data for hierarchical execution tracking
|
|
54
|
-
* Extends IEventEmitterEventData with additional fields for parent-child relationships and real-time data
|
|
55
|
-
*/
|
|
56
|
-
export interface IEventEmitterHierarchicalEventData extends IEventEmitterEventData {
|
|
57
|
-
/** Parent execution ID for hierarchical tracking */
|
|
58
|
-
parentExecutionId?: string;
|
|
59
|
-
/** Root execution ID (Team/Agent level) */
|
|
60
|
-
rootExecutionId?: string;
|
|
61
|
-
/** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
|
|
62
|
-
executionLevel: number;
|
|
63
|
-
/** Execution path showing complete hierarchy */
|
|
64
|
-
executionPath: string[];
|
|
65
|
-
/** Real-time execution data (no simulation) */
|
|
66
|
-
realTimeData?: {
|
|
67
|
-
/** Actual execution start time */
|
|
68
|
-
startTime: Date;
|
|
69
|
-
/** Actual duration in milliseconds (when completed) */
|
|
70
|
-
actualDuration?: number;
|
|
71
|
-
/** Actual input parameters */
|
|
72
|
-
actualParameters?: TToolParameters;
|
|
73
|
-
/** Actual execution result */
|
|
74
|
-
actualResult?: IToolResult;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Event listener function
|
|
79
|
-
*/
|
|
80
|
-
export type { TEventEmitterListener };
|
|
81
|
-
/**
|
|
82
|
-
* Event emitter configuration
|
|
83
|
-
*/
|
|
84
|
-
export interface IEventEmitterPluginOptions extends IPluginOptions {
|
|
85
|
-
/** Events to listen for */
|
|
86
|
-
events?: TEventName[];
|
|
87
|
-
/** Maximum number of listeners per event type */
|
|
88
|
-
maxListeners?: number;
|
|
89
|
-
/** Whether to emit events asynchronously */
|
|
90
|
-
async?: boolean;
|
|
91
|
-
/** Whether to catch and log listener errors */
|
|
92
|
-
catchErrors?: boolean;
|
|
93
|
-
/** Custom event filters */
|
|
94
|
-
filters?: Record<TEventName, (event: IEventEmitterEventData) => boolean>;
|
|
95
|
-
/** Event buffering options */
|
|
96
|
-
buffer?: {
|
|
97
|
-
enabled: boolean;
|
|
98
|
-
maxSize: number;
|
|
99
|
-
flushInterval: number;
|
|
100
|
-
};
|
|
101
|
-
/** Metrics collector (optional) */
|
|
102
|
-
metrics?: IEventEmitterMetrics;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Event emitter plugin statistics
|
|
106
|
-
*/
|
|
107
|
-
export interface IEventEmitterPluginStats extends IPluginStats {
|
|
108
|
-
eventTypes: TEventName[];
|
|
109
|
-
listenerCounts: Record<TEventName, number>;
|
|
110
|
-
totalListeners: number;
|
|
111
|
-
bufferedEvents: number;
|
|
112
|
-
totalEmitted: number;
|
|
113
|
-
totalErrors: number;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Plugin for event detection and propagation
|
|
117
|
-
* Emits events during agent execution lifecycle
|
|
118
|
-
*/
|
|
119
|
-
export declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptions, IEventEmitterPluginStats> {
|
|
120
|
-
name: string;
|
|
121
|
-
version: string;
|
|
122
|
-
private pluginOptions;
|
|
123
|
-
private logger;
|
|
124
|
-
private handlers;
|
|
125
|
-
private eventBuffer;
|
|
126
|
-
private nextHandlerId;
|
|
127
|
-
private bufferTimer?;
|
|
128
|
-
private metrics;
|
|
129
|
-
constructor(options?: IEventEmitterPluginOptions);
|
|
130
|
-
/**
|
|
131
|
-
* Before execution starts
|
|
132
|
-
*/
|
|
133
|
-
beforeExecution(context: IPluginExecutionContext): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* After execution completes
|
|
136
|
-
*/
|
|
137
|
-
afterExecution(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Before conversation starts
|
|
140
|
-
*/
|
|
141
|
-
beforeConversation(context: IPluginExecutionContext): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* After conversation completes
|
|
144
|
-
*/
|
|
145
|
-
afterConversation(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Before tool execution - emits tool.beforeExecute event
|
|
148
|
-
*/
|
|
149
|
-
beforeToolExecution(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* After tool execution - emits tool.success or tool.error events
|
|
152
|
-
*/
|
|
153
|
-
afterToolExecution(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* On error
|
|
156
|
-
*
|
|
157
|
-
* REASON: Error context structure varies by execution phase and error type, needs flexible handling
|
|
158
|
-
* ALTERNATIVES_CONSIDERED:
|
|
159
|
-
* 1. Strict error context interface (breaks error handling flexibility)
|
|
160
|
-
* 2. Union types (insufficient for dynamic error contexts)
|
|
161
|
-
* 3. Generic constraints (too complex for error handling)
|
|
162
|
-
* 4. Interface definitions (too rigid for varied error contexts)
|
|
163
|
-
* 5. Type assertions (decreases type safety)
|
|
164
|
-
* TODO: Consider standardized error context interface
|
|
165
|
-
*/
|
|
166
|
-
onError(error: Error, context?: IPluginErrorContext): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Register event listener
|
|
169
|
-
*/
|
|
170
|
-
on(eventType: TEventName, listener: TEventEmitterListener, options?: {
|
|
171
|
-
once?: boolean;
|
|
172
|
-
filter?: (event: IEventEmitterEventData) => boolean;
|
|
173
|
-
}): string;
|
|
174
|
-
/**
|
|
175
|
-
* Register one-time event listener
|
|
176
|
-
*/
|
|
177
|
-
once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
|
|
178
|
-
/**
|
|
179
|
-
* Remove event listener
|
|
180
|
-
*/
|
|
181
|
-
off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Emit an event
|
|
184
|
-
*/
|
|
185
|
-
emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* Process a single event
|
|
188
|
-
*/
|
|
189
|
-
private processEvent;
|
|
190
|
-
private executeHandler;
|
|
191
|
-
/**
|
|
192
|
-
* Buffer an event
|
|
193
|
-
*/
|
|
194
|
-
private bufferEvent;
|
|
195
|
-
/**
|
|
196
|
-
* Setup event buffering
|
|
197
|
-
*/
|
|
198
|
-
private setupBuffering;
|
|
199
|
-
/**
|
|
200
|
-
* Flush buffered events
|
|
201
|
-
*/
|
|
202
|
-
flushBuffer(): Promise<void>;
|
|
203
|
-
/**
|
|
204
|
-
* Get event emitter statistics
|
|
205
|
-
*/
|
|
206
|
-
getStats(): IEventEmitterPluginStats;
|
|
207
|
-
/**
|
|
208
|
-
* Clear all listeners
|
|
209
|
-
*/
|
|
210
|
-
clearAllListeners(): void;
|
|
211
|
-
/**
|
|
212
|
-
* Cleanup on plugin destruction
|
|
213
|
-
*/
|
|
214
|
-
destroy(): Promise<void>;
|
|
215
|
-
/**
|
|
216
|
-
* Validates the plugin options.
|
|
217
|
-
* @param options The options to validate.
|
|
218
|
-
* @throws PluginError if options are invalid.
|
|
219
|
-
*/
|
|
220
|
-
private validateOptions;
|
|
221
|
-
}
|
|
222
|
-
//# sourceMappingURL=event-emitter-plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-emitter-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/event-emitter-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,YAAY,EAGpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI9F,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEjG,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC1B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,MAAM,EAAE,GACR,MAAM,EAAE,GACR,OAAO,EAAE,GACT,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,GAChD,IAAI,GACJ,SAAS,CAAC;AAEhB;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAC1D,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC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riority } from '../abstracts/abstract-plugin';
|
|
2
|
-
import { createLogger } from '../utils/logger';
|
|
3
|
-
import { PluginError } from '../utils/errors';
|
|
4
|
-
import { EVENT_EMITTER_EVENTS } from './event-emitter/types';
|
|
5
|
-
import { InMemoryEventEmitterMetrics } from './event-emitter/metrics';
|
|
6
|
-
/**
|
|
7
|
-
* Plugin for event detection and propagation
|
|
8
|
-
* Emits events during agent execution lifecycle
|
|
9
|
-
*/
|
|
10
|
-
export class EventEmitterPlugin extends AbstractPlugin {
|
|
11
|
-
name = 'EventEmitterPlugin';
|
|
12
|
-
version = '1.0.0';
|
|
13
|
-
pluginOptions;
|
|
14
|
-
logger;
|
|
15
|
-
handlers = new Map();
|
|
16
|
-
eventBuffer = [];
|
|
17
|
-
nextHandlerId = 1;
|
|
18
|
-
bufferTimer;
|
|
19
|
-
metrics;
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
super();
|
|
22
|
-
this.logger = createLogger('EventEmitterPlugin');
|
|
23
|
-
this.metrics = options.metrics ?? new InMemoryEventEmitterMetrics();
|
|
24
|
-
// Validate options
|
|
25
|
-
this.validateOptions(options);
|
|
26
|
-
this.pluginOptions = {
|
|
27
|
-
enabled: options.enabled ?? true,
|
|
28
|
-
events: options.events ?? [
|
|
29
|
-
EVENT_EMITTER_EVENTS.AGENT_EXECUTION_START,
|
|
30
|
-
EVENT_EMITTER_EVENTS.AGENT_EXECUTION_COMPLETE,
|
|
31
|
-
EVENT_EMITTER_EVENTS.AGENT_EXECUTION_ERROR,
|
|
32
|
-
EVENT_EMITTER_EVENTS.TOOL_BEFORE_EXECUTE,
|
|
33
|
-
EVENT_EMITTER_EVENTS.TOOL_AFTER_EXECUTE,
|
|
34
|
-
EVENT_EMITTER_EVENTS.TOOL_SUCCESS,
|
|
35
|
-
EVENT_EMITTER_EVENTS.TOOL_ERROR
|
|
36
|
-
],
|
|
37
|
-
maxListeners: options.maxListeners ?? 100,
|
|
38
|
-
async: options.async ?? true,
|
|
39
|
-
catchErrors: options.catchErrors ?? true,
|
|
40
|
-
filters: options.filters ?? {},
|
|
41
|
-
buffer: options.buffer ?? {
|
|
42
|
-
enabled: false,
|
|
43
|
-
maxSize: 1000,
|
|
44
|
-
flushInterval: 5000
|
|
45
|
-
},
|
|
46
|
-
// Add plugin options defaults
|
|
47
|
-
category: options.category ?? PluginCategory.EVENT_PROCESSING,
|
|
48
|
-
priority: options.priority ?? PluginPriority.HIGH,
|
|
49
|
-
moduleEvents: options.moduleEvents ?? [],
|
|
50
|
-
subscribeToAllModuleEvents: options.subscribeToAllModuleEvents ?? false
|
|
51
|
-
};
|
|
52
|
-
if (this.pluginOptions.buffer.enabled) {
|
|
53
|
-
this.setupBuffering();
|
|
54
|
-
}
|
|
55
|
-
this.logger.info('EventEmitterPlugin initialized', {
|
|
56
|
-
events: this.pluginOptions.events,
|
|
57
|
-
maxListeners: this.pluginOptions.maxListeners,
|
|
58
|
-
async: this.pluginOptions.async,
|
|
59
|
-
catchErrors: this.pluginOptions.catchErrors,
|
|
60
|
-
bufferEnabled: this.pluginOptions.buffer.enabled
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Before execution starts
|
|
65
|
-
*/
|
|
66
|
-
async beforeExecution(context) {
|
|
67
|
-
await this.emit(EVENT_EMITTER_EVENTS.AGENT_EXECUTION_START, {
|
|
68
|
-
executionId: context.executionId,
|
|
69
|
-
sessionId: context.sessionId,
|
|
70
|
-
userId: context.userId,
|
|
71
|
-
data: {
|
|
72
|
-
messageCount: context.messages?.length || 0,
|
|
73
|
-
...(context.config && { config: context.config })
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* After execution completes
|
|
79
|
-
*/
|
|
80
|
-
async afterExecution(context, result) {
|
|
81
|
-
await this.emit(EVENT_EMITTER_EVENTS.AGENT_EXECUTION_COMPLETE, {
|
|
82
|
-
executionId: context.executionId,
|
|
83
|
-
sessionId: context.sessionId,
|
|
84
|
-
userId: context.userId,
|
|
85
|
-
data: {
|
|
86
|
-
duration: result?.duration,
|
|
87
|
-
tokensUsed: result?.tokensUsed,
|
|
88
|
-
toolsExecuted: result?.toolsExecuted
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Before conversation starts
|
|
94
|
-
*/
|
|
95
|
-
async beforeConversation(context) {
|
|
96
|
-
await this.emit(EVENT_EMITTER_EVENTS.CONVERSATION_START, {
|
|
97
|
-
executionId: context.executionId,
|
|
98
|
-
sessionId: context.sessionId,
|
|
99
|
-
userId: context.userId,
|
|
100
|
-
data: {
|
|
101
|
-
messages: context.messages?.map(msg => ({
|
|
102
|
-
role: msg.role,
|
|
103
|
-
content: msg.content || '',
|
|
104
|
-
timestamp: msg.timestamp ? msg.timestamp.toISOString() : new Date().toISOString()
|
|
105
|
-
})),
|
|
106
|
-
config: context.config
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* After conversation completes
|
|
112
|
-
*/
|
|
113
|
-
async afterConversation(context, result) {
|
|
114
|
-
await this.emit(EVENT_EMITTER_EVENTS.CONVERSATION_COMPLETE, {
|
|
115
|
-
executionId: context.executionId,
|
|
116
|
-
sessionId: context.sessionId,
|
|
117
|
-
userId: context.userId,
|
|
118
|
-
data: {
|
|
119
|
-
response: result.content || result.response,
|
|
120
|
-
tokensUsed: result.usage?.totalTokens || result.tokensUsed,
|
|
121
|
-
toolCalls: result.toolCalls?.map(call => ({
|
|
122
|
-
id: call.id || '',
|
|
123
|
-
name: call.name || '',
|
|
124
|
-
arguments: JSON.stringify(call.arguments || {}),
|
|
125
|
-
result: String(call.result || '')
|
|
126
|
-
}))
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Before tool execution - emits tool.beforeExecute event
|
|
132
|
-
*/
|
|
133
|
-
async beforeToolExecution(context, toolData) {
|
|
134
|
-
if (!toolData) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const toolCalls = [toolData];
|
|
138
|
-
for (const toolCall of toolCalls) {
|
|
139
|
-
await this.emit(EVENT_EMITTER_EVENTS.TOOL_BEFORE_EXECUTE, {
|
|
140
|
-
executionId: context.executionId,
|
|
141
|
-
sessionId: context.sessionId,
|
|
142
|
-
userId: context.userId,
|
|
143
|
-
data: {
|
|
144
|
-
toolName: toolCall.toolName,
|
|
145
|
-
toolId: toolCall.executionId,
|
|
146
|
-
arguments: JSON.stringify(toolCall.parameters ?? {})
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* After tool execution - emits tool.success or tool.error events
|
|
153
|
-
*/
|
|
154
|
-
async afterToolExecution(context, toolResults) {
|
|
155
|
-
// Handle tool results from IPluginExecutionResult
|
|
156
|
-
if (toolResults.toolCalls && toolResults.toolCalls.length > 0) {
|
|
157
|
-
for (const toolCall of toolResults.toolCalls) {
|
|
158
|
-
const eventType = toolCall.result === null ? EVENT_EMITTER_EVENTS.TOOL_ERROR : EVENT_EMITTER_EVENTS.TOOL_SUCCESS;
|
|
159
|
-
await this.emit(eventType, {
|
|
160
|
-
executionId: context.executionId,
|
|
161
|
-
sessionId: context.sessionId,
|
|
162
|
-
userId: context.userId,
|
|
163
|
-
data: {
|
|
164
|
-
toolName: toolCall.name || '',
|
|
165
|
-
toolId: toolCall.id || '',
|
|
166
|
-
toolResult: toolCall.result !== null ? String(toolCall.result) : undefined,
|
|
167
|
-
duration: toolResults.duration,
|
|
168
|
-
success: toolCall.result !== null
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
// Also emit generic afterExecute event
|
|
172
|
-
await this.emit(EVENT_EMITTER_EVENTS.TOOL_AFTER_EXECUTE, {
|
|
173
|
-
executionId: context.executionId,
|
|
174
|
-
sessionId: context.sessionId,
|
|
175
|
-
userId: context.userId,
|
|
176
|
-
data: {
|
|
177
|
-
toolName: toolCall.name || '',
|
|
178
|
-
toolId: toolCall.id || '',
|
|
179
|
-
toolResult: String(toolCall.result || ''),
|
|
180
|
-
duration: toolResults.duration,
|
|
181
|
-
success: toolCall.result !== null
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* On error
|
|
189
|
-
*
|
|
190
|
-
* REASON: Error context structure varies by execution phase and error type, needs flexible handling
|
|
191
|
-
* ALTERNATIVES_CONSIDERED:
|
|
192
|
-
* 1. Strict error context interface (breaks error handling flexibility)
|
|
193
|
-
* 2. Union types (insufficient for dynamic error contexts)
|
|
194
|
-
* 3. Generic constraints (too complex for error handling)
|
|
195
|
-
* 4. Interface definitions (too rigid for varied error contexts)
|
|
196
|
-
* 5. Type assertions (decreases type safety)
|
|
197
|
-
* TODO: Consider standardized error context interface
|
|
198
|
-
*/
|
|
199
|
-
async onError(error, context) {
|
|
200
|
-
await this.emit(EVENT_EMITTER_EVENTS.AGENT_EXECUTION_ERROR, {
|
|
201
|
-
executionId: context?.executionId,
|
|
202
|
-
sessionId: context?.sessionId,
|
|
203
|
-
userId: context?.userId,
|
|
204
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
205
|
-
data: {
|
|
206
|
-
action: context?.action,
|
|
207
|
-
tool: context?.tool,
|
|
208
|
-
attempt: context?.attempt
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Register event listener
|
|
214
|
-
*/
|
|
215
|
-
on(eventType, listener, options) {
|
|
216
|
-
const handlerId = `handler_${this.nextHandlerId++}`;
|
|
217
|
-
if (!this.handlers.has(eventType)) {
|
|
218
|
-
this.handlers.set(eventType, []);
|
|
219
|
-
}
|
|
220
|
-
const handlers = this.handlers.get(eventType);
|
|
221
|
-
if (handlers.length >= this.pluginOptions.maxListeners) {
|
|
222
|
-
throw new PluginError(`Maximum listeners (${this.pluginOptions.maxListeners}) exceeded for event type: ${eventType}`, this.name, { eventType, currentListeners: handlers.length });
|
|
223
|
-
}
|
|
224
|
-
handlers.push({
|
|
225
|
-
id: handlerId,
|
|
226
|
-
listener,
|
|
227
|
-
once: options?.once ?? false,
|
|
228
|
-
...(options?.filter && { filter: options.filter })
|
|
229
|
-
});
|
|
230
|
-
this.logger.debug('Event listener registered', {
|
|
231
|
-
eventType,
|
|
232
|
-
handlerId,
|
|
233
|
-
once: options?.once ?? false,
|
|
234
|
-
hasFilter: options?.filter ? true : false
|
|
235
|
-
});
|
|
236
|
-
return handlerId;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Register one-time event listener
|
|
240
|
-
*/
|
|
241
|
-
once(eventType, listener, filter) {
|
|
242
|
-
return this.on(eventType, listener, {
|
|
243
|
-
once: true,
|
|
244
|
-
...(filter && { filter })
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Remove event listener
|
|
249
|
-
*/
|
|
250
|
-
off(eventType, handlerIdOrListener) {
|
|
251
|
-
const handlers = this.handlers.get(eventType);
|
|
252
|
-
if (!handlers) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
const index = typeof handlerIdOrListener === 'string'
|
|
256
|
-
? handlers.findIndex(h => h.id === handlerIdOrListener)
|
|
257
|
-
: handlers.findIndex(h => h.listener === handlerIdOrListener);
|
|
258
|
-
if (index !== -1) {
|
|
259
|
-
const removed = handlers.splice(index, 1)[0];
|
|
260
|
-
if (removed) {
|
|
261
|
-
this.logger.debug('Event listener removed', {
|
|
262
|
-
eventType,
|
|
263
|
-
handlerId: removed.id
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Emit an event
|
|
272
|
-
*/
|
|
273
|
-
async emit(eventType, eventData = {}) {
|
|
274
|
-
if (!this.pluginOptions.events.includes(eventType)) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const event = {
|
|
278
|
-
type: eventType,
|
|
279
|
-
timestamp: new Date(),
|
|
280
|
-
...eventData
|
|
281
|
-
};
|
|
282
|
-
// Apply global filter if exists
|
|
283
|
-
const globalFilter = this.pluginOptions.filters[eventType];
|
|
284
|
-
if (globalFilter && !globalFilter(event)) {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
this.metrics.incrementEmitted();
|
|
288
|
-
// Buffer events if enabled
|
|
289
|
-
if (this.pluginOptions.buffer.enabled) {
|
|
290
|
-
this.bufferEvent(event);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
await this.processEvent(event);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Process a single event
|
|
297
|
-
*/
|
|
298
|
-
async processEvent(event) {
|
|
299
|
-
const handlers = this.handlers.get(event.type);
|
|
300
|
-
if (!handlers || handlers.length === 0) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
const handlersToCall = handlers.filter(handler => {
|
|
304
|
-
return !handler.filter || handler.filter(event);
|
|
305
|
-
});
|
|
306
|
-
if (handlersToCall.length === 0) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
this.logger.debug('Emitting event', {
|
|
310
|
-
type: event.type,
|
|
311
|
-
handlersCount: handlersToCall.length,
|
|
312
|
-
executionId: event.executionId || 'undefined'
|
|
313
|
-
});
|
|
314
|
-
// Remove one-time handlers
|
|
315
|
-
const oneTimeHandlers = handlersToCall.filter(h => h.once);
|
|
316
|
-
for (const handler of oneTimeHandlers) {
|
|
317
|
-
this.off(event.type, handler.id);
|
|
318
|
-
}
|
|
319
|
-
// Execute handlers without fallback path.
|
|
320
|
-
if (this.pluginOptions.async) {
|
|
321
|
-
await Promise.all(handlersToCall.map(handler => this.executeHandler(handler, event)));
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
for (const handler of handlersToCall) {
|
|
325
|
-
await this.executeHandler(handler, event);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
async executeHandler(handler, event) {
|
|
329
|
-
try {
|
|
330
|
-
await handler.listener(event);
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
this.metrics.incrementErrors();
|
|
334
|
-
if (this.pluginOptions.catchErrors) {
|
|
335
|
-
this.logger.error('Event handler error', {
|
|
336
|
-
eventType: event.type,
|
|
337
|
-
handlerId: handler.id,
|
|
338
|
-
error: error instanceof Error ? error.message : String(error)
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
throw error instanceof Error ? error : new Error(String(error));
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Buffer an event
|
|
346
|
-
*/
|
|
347
|
-
bufferEvent(event) {
|
|
348
|
-
this.eventBuffer.push(event);
|
|
349
|
-
if (this.eventBuffer.length >= this.pluginOptions.buffer.maxSize) {
|
|
350
|
-
this.flushBuffer();
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Setup event buffering
|
|
355
|
-
*/
|
|
356
|
-
setupBuffering() {
|
|
357
|
-
this.bufferTimer = setInterval(() => {
|
|
358
|
-
this.flushBuffer();
|
|
359
|
-
}, this.pluginOptions.buffer.flushInterval);
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Flush buffered events
|
|
363
|
-
*/
|
|
364
|
-
async flushBuffer() {
|
|
365
|
-
if (this.eventBuffer.length === 0) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const events = [...this.eventBuffer];
|
|
369
|
-
this.eventBuffer = [];
|
|
370
|
-
this.logger.debug('Flushing event buffer', { eventCount: events.length });
|
|
371
|
-
for (const event of events) {
|
|
372
|
-
await this.processEvent(event);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Get event emitter statistics
|
|
377
|
-
*/
|
|
378
|
-
getStats() {
|
|
379
|
-
const base = super.getStats();
|
|
380
|
-
const metrics = this.metrics.getSnapshot();
|
|
381
|
-
const listenerCounts = {};
|
|
382
|
-
let totalListeners = 0;
|
|
383
|
-
for (const [eventType, handlers] of this.handlers) {
|
|
384
|
-
listenerCounts[eventType] = handlers.length;
|
|
385
|
-
totalListeners += handlers.length;
|
|
386
|
-
}
|
|
387
|
-
return {
|
|
388
|
-
...base,
|
|
389
|
-
eventTypes: Array.from(this.handlers.keys()),
|
|
390
|
-
listenerCounts,
|
|
391
|
-
totalListeners,
|
|
392
|
-
bufferedEvents: this.eventBuffer.length,
|
|
393
|
-
totalEmitted: metrics.totalEmitted,
|
|
394
|
-
totalErrors: metrics.totalErrors
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Clear all listeners
|
|
399
|
-
*/
|
|
400
|
-
clearAllListeners() {
|
|
401
|
-
this.handlers.clear();
|
|
402
|
-
this.logger.info('All event listeners cleared');
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Cleanup on plugin destruction
|
|
406
|
-
*/
|
|
407
|
-
async destroy() {
|
|
408
|
-
if (this.bufferTimer) {
|
|
409
|
-
clearInterval(this.bufferTimer);
|
|
410
|
-
}
|
|
411
|
-
await this.flushBuffer();
|
|
412
|
-
this.clearAllListeners();
|
|
413
|
-
this.logger.info('EventEmitterPlugin destroyed');
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Validates the plugin options.
|
|
417
|
-
* @param options The options to validate.
|
|
418
|
-
* @throws PluginError if options are invalid.
|
|
419
|
-
*/
|
|
420
|
-
validateOptions(options) {
|
|
421
|
-
if (options.maxListeners !== undefined && options.maxListeners < 0) {
|
|
422
|
-
throw new PluginError(`Invalid maxListeners option: ${options.maxListeners}. Must be a non-negative number.`, this.name, { maxListeners: options.maxListeners });
|
|
423
|
-
}
|
|
424
|
-
if (options.buffer !== undefined && options.buffer.maxSize !== undefined && options.buffer.maxSize < 0) {
|
|
425
|
-
throw new PluginError(`Invalid buffer.maxSize option: ${options.buffer.maxSize}. Must be a non-negative number.`, this.name, { bufferMaxSize: options.buffer.maxSize });
|
|
426
|
-
}
|
|
427
|
-
if (options.buffer !== undefined && options.buffer.flushInterval !== undefined && options.buffer.flushInterval < 0) {
|
|
428
|
-
throw new PluginError(`Invalid buffer.flushInterval option: ${options.buffer.flushInterval}. Must be a non-negative number.`, this.name, { bufferFlushInterval: options.buffer.flushInterval });
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
//# sourceMappingURL=event-emitter-plugin.js.map
|