@robota-sdk/agent-core 3.0.0-beta.7 → 3.0.0-beta.71
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 +122 -0
- package/README.md +41 -12
- package/dist/browser/index.d.ts +3736 -3090
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +12 -5
- package/dist/browser/index.js.map +1 -0
- package/dist/node/index.cjs +11 -5
- package/dist/node/index.d.ts +3736 -3090
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +12 -5
- package/dist/node/index.js.map +1 -0
- package/package.json +8 -5
- 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/browser/builtin-templates.json +0 -107
- 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/node/builtin-templates.json +0 -107
- package/dist/node/index.d.cts +0 -4238
- 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,309 +0,0 @@
|
|
|
1
|
-
import { AbstractPlugin, PluginCategory, PluginPriority } from '../../abstracts/abstract-plugin';
|
|
2
|
-
import { createLogger } from '../../utils/logger';
|
|
3
|
-
import { PluginError, ConfigurationError } from '../../utils/errors';
|
|
4
|
-
import { EVENT_EMITTER_EVENTS } from '../event-emitter/types';
|
|
5
|
-
import { startPeriodicTask } from '../../utils/periodic-task';
|
|
6
|
-
import { MemoryUsageStorage, FileUsageStorage, RemoteUsageStorage, SilentUsageStorage } from './storages/index';
|
|
7
|
-
/**
|
|
8
|
-
* Plugin for tracking usage statistics
|
|
9
|
-
* Collects and stores usage data including tokens, costs, performance metrics
|
|
10
|
-
*/
|
|
11
|
-
export class UsagePlugin extends AbstractPlugin {
|
|
12
|
-
name = 'UsagePlugin';
|
|
13
|
-
version = '1.0.0';
|
|
14
|
-
storage;
|
|
15
|
-
pluginOptions;
|
|
16
|
-
logger;
|
|
17
|
-
aggregationTimer;
|
|
18
|
-
constructor(options) {
|
|
19
|
-
super();
|
|
20
|
-
this.logger = createLogger('UsagePlugin');
|
|
21
|
-
// Set plugin classification
|
|
22
|
-
this.category = PluginCategory.MONITORING;
|
|
23
|
-
this.priority = PluginPriority.NORMAL;
|
|
24
|
-
// Validate options
|
|
25
|
-
this.validateOptions(options);
|
|
26
|
-
// Set defaults
|
|
27
|
-
this.pluginOptions = {
|
|
28
|
-
enabled: options.enabled ?? true,
|
|
29
|
-
strategy: options.strategy,
|
|
30
|
-
filePath: options.filePath ?? './usage-stats.json',
|
|
31
|
-
remoteEndpoint: options.remoteEndpoint ?? '',
|
|
32
|
-
remoteHeaders: options.remoteHeaders ?? {},
|
|
33
|
-
maxEntries: options.maxEntries ?? 10000,
|
|
34
|
-
trackCosts: options.trackCosts ?? true,
|
|
35
|
-
...(options.costRates && { costRates: options.costRates }),
|
|
36
|
-
batchSize: options.batchSize ?? 50,
|
|
37
|
-
flushInterval: options.flushInterval ?? 60000, // 1 minute
|
|
38
|
-
aggregateStats: options.aggregateStats ?? true,
|
|
39
|
-
aggregationInterval: options.aggregationInterval ?? 300000, // 5 minutes
|
|
40
|
-
// Add plugin options defaults
|
|
41
|
-
category: options.category ?? PluginCategory.MONITORING,
|
|
42
|
-
priority: options.priority ?? PluginPriority.NORMAL,
|
|
43
|
-
moduleEvents: options.moduleEvents ?? [],
|
|
44
|
-
subscribeToAllModuleEvents: options.subscribeToAllModuleEvents ?? false,
|
|
45
|
-
};
|
|
46
|
-
// Initialize storage
|
|
47
|
-
this.storage = this.createStorage();
|
|
48
|
-
// Setup aggregation if enabled
|
|
49
|
-
if (this.pluginOptions.aggregateStats) {
|
|
50
|
-
this.setupAggregation();
|
|
51
|
-
}
|
|
52
|
-
this.logger.info('UsagePlugin initialized', {
|
|
53
|
-
strategy: this.pluginOptions.strategy,
|
|
54
|
-
trackCosts: this.pluginOptions.trackCosts,
|
|
55
|
-
maxEntries: this.pluginOptions.maxEntries
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Handle module events for usage tracking
|
|
60
|
-
*/
|
|
61
|
-
async onModuleEvent(eventName, eventData) {
|
|
62
|
-
try {
|
|
63
|
-
// Extract module event data from eventData.data
|
|
64
|
-
const moduleData = eventData.data;
|
|
65
|
-
switch (eventName) {
|
|
66
|
-
case EVENT_EMITTER_EVENTS.MODULE_INITIALIZE_COMPLETE:
|
|
67
|
-
case EVENT_EMITTER_EVENTS.MODULE_EXECUTION_COMPLETE:
|
|
68
|
-
case EVENT_EMITTER_EVENTS.MODULE_DISPOSE_COMPLETE:
|
|
69
|
-
// Track module usage statistics
|
|
70
|
-
if (moduleData && 'duration' in moduleData && typeof moduleData.duration === 'number') {
|
|
71
|
-
await this.recordUsage({
|
|
72
|
-
provider: 'module',
|
|
73
|
-
model: ('moduleType' in moduleData && typeof moduleData['moduleType'] === 'string') ? moduleData['moduleType'] : 'unknown',
|
|
74
|
-
tokensUsed: {
|
|
75
|
-
input: 0,
|
|
76
|
-
output: 0,
|
|
77
|
-
total: 0
|
|
78
|
-
},
|
|
79
|
-
requestCount: 1,
|
|
80
|
-
duration: moduleData.duration,
|
|
81
|
-
success: true,
|
|
82
|
-
...(eventData.executionId && { executionId: eventData.executionId }),
|
|
83
|
-
...(eventData.sessionId && { conversationId: eventData.sessionId }),
|
|
84
|
-
metadata: {
|
|
85
|
-
moduleName: ('moduleName' in moduleData && typeof moduleData['moduleName'] === 'string') ? moduleData['moduleName'] : 'unknown',
|
|
86
|
-
moduleType: ('moduleType' in moduleData && typeof moduleData['moduleType'] === 'string') ? moduleData['moduleType'] : 'unknown',
|
|
87
|
-
operation: eventName.includes('initialize') ? 'initialization' :
|
|
88
|
-
eventName.includes('execution') ? 'execution' : 'disposal'
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
case EVENT_EMITTER_EVENTS.MODULE_INITIALIZE_ERROR:
|
|
94
|
-
case EVENT_EMITTER_EVENTS.MODULE_EXECUTION_ERROR:
|
|
95
|
-
case EVENT_EMITTER_EVENTS.MODULE_DISPOSE_ERROR:
|
|
96
|
-
// Track module error statistics
|
|
97
|
-
if (moduleData && 'duration' in moduleData && typeof moduleData.duration === 'number') {
|
|
98
|
-
await this.recordUsage({
|
|
99
|
-
provider: 'module',
|
|
100
|
-
model: ('moduleType' in moduleData && typeof moduleData['moduleType'] === 'string') ? moduleData['moduleType'] : 'unknown',
|
|
101
|
-
tokensUsed: {
|
|
102
|
-
input: 0,
|
|
103
|
-
output: 0,
|
|
104
|
-
total: 0
|
|
105
|
-
},
|
|
106
|
-
requestCount: 1,
|
|
107
|
-
duration: moduleData.duration,
|
|
108
|
-
success: false,
|
|
109
|
-
...(eventData.executionId && { executionId: eventData.executionId }),
|
|
110
|
-
...(eventData.sessionId && { conversationId: eventData.sessionId }),
|
|
111
|
-
metadata: {
|
|
112
|
-
moduleName: ('moduleName' in moduleData && typeof moduleData['moduleName'] === 'string') ? moduleData['moduleName'] : 'unknown',
|
|
113
|
-
moduleType: ('moduleType' in moduleData && typeof moduleData['moduleType'] === 'string') ? moduleData['moduleType'] : 'unknown',
|
|
114
|
-
operation: eventName.includes('initialize') ? 'initialization' :
|
|
115
|
-
eventName.includes('execution') ? 'execution' : 'disposal',
|
|
116
|
-
error: eventData.error?.message || 'unknown error'
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
// Log the error but don't throw to avoid breaking module event processing
|
|
125
|
-
// UsagePlugin failed to handle module event
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Record usage statistics
|
|
130
|
-
*/
|
|
131
|
-
async recordUsage(usage) {
|
|
132
|
-
try {
|
|
133
|
-
const cost = this.pluginOptions.trackCosts ? this.calculateCost(usage.model, usage.tokensUsed) : undefined;
|
|
134
|
-
const entry = {
|
|
135
|
-
...usage,
|
|
136
|
-
timestamp: new Date(),
|
|
137
|
-
...(cost && { cost })
|
|
138
|
-
};
|
|
139
|
-
await this.storage.save(entry);
|
|
140
|
-
this.logger.debug('Usage recorded', {
|
|
141
|
-
provider: entry.provider,
|
|
142
|
-
model: entry.model,
|
|
143
|
-
tokens: entry.tokensUsed.total,
|
|
144
|
-
cost: entry.cost?.total,
|
|
145
|
-
success: entry.success
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
throw new PluginError('Failed to record usage', this.name, {
|
|
150
|
-
error: error instanceof Error ? error.message : String(error)
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Get usage statistics
|
|
156
|
-
*/
|
|
157
|
-
async getUsageStats(conversationId, timeRange) {
|
|
158
|
-
try {
|
|
159
|
-
return await this.storage.getStats(conversationId, timeRange);
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
throw new PluginError('Failed to get usage stats', this.name, {
|
|
163
|
-
conversationId: conversationId || 'all',
|
|
164
|
-
timeRange: timeRange ? `${timeRange.start.toISOString()}-${timeRange.end.toISOString()}` : 'all',
|
|
165
|
-
error: error instanceof Error ? error.message : String(error)
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get aggregated usage statistics
|
|
171
|
-
*/
|
|
172
|
-
async getAggregatedStats(timeRange) {
|
|
173
|
-
try {
|
|
174
|
-
return await this.storage.getAggregatedStats(timeRange);
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
throw new PluginError('Failed to get aggregated usage stats', this.name, {
|
|
178
|
-
timeRange: timeRange ? `${timeRange.start.toISOString()}-${timeRange.end.toISOString()}` : 'all',
|
|
179
|
-
error: error instanceof Error ? error.message : String(error)
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Clear all usage statistics
|
|
185
|
-
*/
|
|
186
|
-
async clearStats() {
|
|
187
|
-
try {
|
|
188
|
-
await this.storage.clear();
|
|
189
|
-
this.logger.info('Usage statistics cleared');
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
throw new PluginError('Failed to clear usage stats', this.name, {
|
|
193
|
-
error: error instanceof Error ? error.message : String(error)
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Flush pending statistics
|
|
199
|
-
*/
|
|
200
|
-
async flush() {
|
|
201
|
-
try {
|
|
202
|
-
await this.storage.flush();
|
|
203
|
-
}
|
|
204
|
-
catch (error) {
|
|
205
|
-
throw new PluginError('Failed to flush usage stats', this.name, {
|
|
206
|
-
error: error instanceof Error ? error.message : String(error)
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Cleanup resources
|
|
212
|
-
*/
|
|
213
|
-
async destroy() {
|
|
214
|
-
try {
|
|
215
|
-
if (this.aggregationTimer) {
|
|
216
|
-
clearInterval(this.aggregationTimer);
|
|
217
|
-
}
|
|
218
|
-
await this.storage.close();
|
|
219
|
-
this.logger.info('UsagePlugin destroyed');
|
|
220
|
-
}
|
|
221
|
-
catch (error) {
|
|
222
|
-
this.logger.error('Error during plugin cleanup', {
|
|
223
|
-
error: error instanceof Error ? error.message : String(error)
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Calculate cost based on token usage and model rates
|
|
229
|
-
*/
|
|
230
|
-
calculateCost(model, tokens) {
|
|
231
|
-
if (!this.pluginOptions.costRates || !this.pluginOptions.costRates[model]) {
|
|
232
|
-
return undefined;
|
|
233
|
-
}
|
|
234
|
-
const rates = this.pluginOptions.costRates[model];
|
|
235
|
-
const inputCost = tokens.input * rates.input;
|
|
236
|
-
const outputCost = tokens.output * rates.output;
|
|
237
|
-
return {
|
|
238
|
-
input: inputCost,
|
|
239
|
-
output: outputCost,
|
|
240
|
-
total: inputCost + outputCost
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Validate plugin options
|
|
245
|
-
*/
|
|
246
|
-
validateOptions(options) {
|
|
247
|
-
if (!options.strategy) {
|
|
248
|
-
throw new ConfigurationError('Usage tracking strategy is required');
|
|
249
|
-
}
|
|
250
|
-
if (!['memory', 'file', 'remote', 'silent'].includes(options.strategy)) {
|
|
251
|
-
throw new ConfigurationError('Invalid usage tracking strategy', {
|
|
252
|
-
validStrategies: ['memory', 'file', 'remote', 'silent'],
|
|
253
|
-
provided: options.strategy
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
if (options.strategy === 'file' && !options.filePath) {
|
|
257
|
-
throw new ConfigurationError('File path is required for file usage tracking strategy');
|
|
258
|
-
}
|
|
259
|
-
if (options.strategy === 'remote' && !options.remoteEndpoint) {
|
|
260
|
-
throw new ConfigurationError('Remote endpoint is required for remote usage tracking strategy');
|
|
261
|
-
}
|
|
262
|
-
if (options.maxEntries !== undefined && options.maxEntries <= 0) {
|
|
263
|
-
throw new ConfigurationError('Max entries must be positive');
|
|
264
|
-
}
|
|
265
|
-
if (options.batchSize !== undefined && options.batchSize <= 0) {
|
|
266
|
-
throw new ConfigurationError('Batch size must be positive');
|
|
267
|
-
}
|
|
268
|
-
if (options.flushInterval !== undefined && options.flushInterval <= 0) {
|
|
269
|
-
throw new ConfigurationError('Flush interval must be positive');
|
|
270
|
-
}
|
|
271
|
-
if (options.aggregationInterval !== undefined && options.aggregationInterval <= 0) {
|
|
272
|
-
throw new ConfigurationError('Aggregation interval must be positive');
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Create storage instance based on strategy
|
|
277
|
-
*/
|
|
278
|
-
createStorage() {
|
|
279
|
-
switch (this.pluginOptions.strategy) {
|
|
280
|
-
case 'memory':
|
|
281
|
-
return new MemoryUsageStorage(this.pluginOptions.maxEntries);
|
|
282
|
-
case 'file':
|
|
283
|
-
return new FileUsageStorage(this.pluginOptions.filePath);
|
|
284
|
-
case 'remote':
|
|
285
|
-
return new RemoteUsageStorage(this.pluginOptions.remoteEndpoint, '', // apiKey - not in options
|
|
286
|
-
30000, // timeout - not in options
|
|
287
|
-
this.pluginOptions.remoteHeaders || {}, this.pluginOptions.batchSize, this.pluginOptions.flushInterval);
|
|
288
|
-
case 'silent':
|
|
289
|
-
return new SilentUsageStorage();
|
|
290
|
-
default:
|
|
291
|
-
throw new ConfigurationError('Unknown usage tracking strategy', { strategy: this.pluginOptions.strategy });
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Setup periodic aggregation
|
|
296
|
-
*/
|
|
297
|
-
setupAggregation() {
|
|
298
|
-
this.aggregationTimer = startPeriodicTask(this.logger, { name: 'UsagePlugin.aggregate', intervalMs: this.pluginOptions.aggregationInterval }, async () => {
|
|
299
|
-
const stats = await this.getAggregatedStats();
|
|
300
|
-
this.logger.debug('Periodic usage aggregation', {
|
|
301
|
-
totalRequests: stats.totalRequests,
|
|
302
|
-
totalTokens: stats.totalTokens,
|
|
303
|
-
totalCost: stats.totalCost,
|
|
304
|
-
successRate: stats.successRate
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
//# sourceMappingURL=usage-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage-plugin.js","sourceRoot":"","sources":["../../../src/plugins/usage/usage-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAQ9D,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACrB,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,cAAsD;IACnF,IAAI,GAAG,aAAa,CAAC;IACrB,OAAO,GAAG,OAAO,CAAC;IAEV,OAAO,CAAgB;IACvB,aAAa,CAAuH;IACpI,MA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,QAAQ,EAAE,CAAC,CAAC;QACnH,CAAC;IACL,CAAC;IAED;;OAEG;IACK,gBAAgB;QACpB,IAAI,CAAC,gBAAgB,GAAG,iBAAiB,CACrC,IAAI,CAAC,MAAM,EACX,EAAE,IAAI,EAAE,uBAAuB,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,mBAAmB,EAAE,EACrF,KAAK,IAAI,EAAE;YACP,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE;gBAC5C,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;aACjC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webhook HTTP client for sending webhook requests
|
|
3
|
-
* Handles retries, timeouts, and error scenarios
|
|
4
|
-
*/
|
|
5
|
-
import type { IWebhookRequest } from './types';
|
|
6
|
-
import type { ILogger } from '../../utils/logger';
|
|
7
|
-
/**
|
|
8
|
-
* HTTP client for webhook requests
|
|
9
|
-
*/
|
|
10
|
-
export declare class WebhookHttpClient {
|
|
11
|
-
private logger;
|
|
12
|
-
constructor(logger: ILogger);
|
|
13
|
-
/**
|
|
14
|
-
* Send a single webhook request with retries
|
|
15
|
-
*/
|
|
16
|
-
sendRequest(request: IWebhookRequest): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Generate HMAC signature for webhook security using jsSHA (browser compatible)
|
|
19
|
-
*/
|
|
20
|
-
private generateSignature;
|
|
21
|
-
/**
|
|
22
|
-
* Make HTTP request with timeout support
|
|
23
|
-
*/
|
|
24
|
-
private makeHttpRequest;
|
|
25
|
-
/**
|
|
26
|
-
* Delay utility for retry backoff
|
|
27
|
-
*/
|
|
28
|
-
private delay;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/plugins/webhook/http-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,MAAM,CAAU;gBAEZ,MAAM,EAAE,OAAO;IAI3B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAoE1D;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;YACW,eAAe;IAuB7B;;OAEG;IACH,OAAO,CAAC,KAAK;CAGhB"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webhook HTTP client for sending webhook requests
|
|
3
|
-
* Handles retries, timeouts, and error scenarios
|
|
4
|
-
*/
|
|
5
|
-
import jsSHA from 'jssha';
|
|
6
|
-
/**
|
|
7
|
-
* HTTP client for webhook requests
|
|
8
|
-
*/
|
|
9
|
-
export class WebhookHttpClient {
|
|
10
|
-
logger;
|
|
11
|
-
constructor(logger) {
|
|
12
|
-
this.logger = logger;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Send a single webhook request with retries
|
|
16
|
-
*/
|
|
17
|
-
async sendRequest(request) {
|
|
18
|
-
const { endpoint, payload, attempt } = request;
|
|
19
|
-
const timeout = endpoint.timeout ?? 5000;
|
|
20
|
-
const maxRetries = endpoint.retries ?? 3;
|
|
21
|
-
try {
|
|
22
|
-
// Prepare request body
|
|
23
|
-
const body = JSON.stringify(payload);
|
|
24
|
-
// Prepare headers
|
|
25
|
-
const headers = {
|
|
26
|
-
'Content-Type': 'application/json',
|
|
27
|
-
'User-Agent': 'robota-webhook/1.0.0',
|
|
28
|
-
...endpoint.headers
|
|
29
|
-
};
|
|
30
|
-
// Add signature if secret is provided
|
|
31
|
-
if (endpoint.secret) {
|
|
32
|
-
const signature = this.generateSignature(body, endpoint.secret);
|
|
33
|
-
headers['X-Webhook-Signature'] = signature;
|
|
34
|
-
}
|
|
35
|
-
// Make HTTP request
|
|
36
|
-
const response = await this.makeHttpRequest(endpoint.url, {
|
|
37
|
-
method: 'POST',
|
|
38
|
-
headers,
|
|
39
|
-
body,
|
|
40
|
-
timeout
|
|
41
|
-
});
|
|
42
|
-
if (!response.ok) {
|
|
43
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
44
|
-
}
|
|
45
|
-
this.logger.debug('Webhook sent successfully', {
|
|
46
|
-
url: endpoint.url,
|
|
47
|
-
event: payload.event,
|
|
48
|
-
attempt,
|
|
49
|
-
status: response.status
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
this.logger.error('Webhook request failed', {
|
|
54
|
-
url: endpoint.url,
|
|
55
|
-
event: payload.event,
|
|
56
|
-
attempt,
|
|
57
|
-
error: error instanceof Error ? error.message : String(error)
|
|
58
|
-
});
|
|
59
|
-
// Retry if we haven't exceeded max attempts
|
|
60
|
-
if (attempt < maxRetries) {
|
|
61
|
-
const retryRequest = {
|
|
62
|
-
...request,
|
|
63
|
-
attempt: attempt + 1
|
|
64
|
-
};
|
|
65
|
-
// Exponential backoff
|
|
66
|
-
const delay = Math.min(1000 * Math.pow(2, attempt - 1), 10000);
|
|
67
|
-
await this.delay(delay);
|
|
68
|
-
return this.sendRequest(retryRequest);
|
|
69
|
-
}
|
|
70
|
-
// Max retries exceeded
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Generate HMAC signature for webhook security using jsSHA (browser compatible)
|
|
76
|
-
*/
|
|
77
|
-
generateSignature(body, secret) {
|
|
78
|
-
const shaObj = new jsSHA("SHA-256", "TEXT", {
|
|
79
|
-
hmacKey: { value: secret, format: "TEXT" }
|
|
80
|
-
});
|
|
81
|
-
shaObj.update(body);
|
|
82
|
-
return shaObj.getHash("HEX").toLowerCase();
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Make HTTP request with timeout support
|
|
86
|
-
*/
|
|
87
|
-
async makeHttpRequest(url, options) {
|
|
88
|
-
const controller = new AbortController();
|
|
89
|
-
const timeoutId = setTimeout(() => controller.abort(), options.timeout);
|
|
90
|
-
try {
|
|
91
|
-
const response = await fetch(url, {
|
|
92
|
-
method: options.method,
|
|
93
|
-
headers: options.headers,
|
|
94
|
-
body: options.body,
|
|
95
|
-
signal: controller.signal
|
|
96
|
-
});
|
|
97
|
-
return response;
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
clearTimeout(timeoutId);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Delay utility for retry backoff
|
|
105
|
-
*/
|
|
106
|
-
delay(ms) {
|
|
107
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=http-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../src/plugins/webhook/http-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAClB,MAAM,CAAU;IAExB,YAAY,MAAe;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,OAAwB;QACtC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAC/C,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CAAC,OAAO,CAAC,CAAC;QAExE,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,UAAU,CAAC,MAAM;aAC5B,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QACpB,CAAC;gBAAS,CAAC;YACP,YAAY,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACpB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webhook plugin exports
|
|
3
|
-
* Centralized export point for all webhook plugin components
|
|
4
|
-
*/
|
|
5
|
-
export * from './types';
|
|
6
|
-
export * from './transformer';
|
|
7
|
-
export * from './http-client';
|
|
8
|
-
export { WebhookPlugin } from './webhook-plugin';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/webhook/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webhook plugin exports
|
|
3
|
-
* Centralized export point for all webhook plugin components
|
|
4
|
-
*/
|
|
5
|
-
export * from './types';
|
|
6
|
-
export * from './transformer';
|
|
7
|
-
export * from './http-client';
|
|
8
|
-
export { WebhookPlugin } from './webhook-plugin';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/webhook/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Webhook data transformation utilities
|
|
3
|
-
* Converts base plugin types to webhook-specific types safely
|
|
4
|
-
*/
|
|
5
|
-
import type { IPluginExecutionContext, IPluginExecutionResult } from '../../abstracts/abstract-plugin';
|
|
6
|
-
import type { TLoggerData } from '../../interfaces/types';
|
|
7
|
-
import type { IWebhookExecutionContext, IWebhookExecutionResult, IWebhookEventData, TWebhookEventName } from './types';
|
|
8
|
-
/**
|
|
9
|
-
* Webhook data transformer utility class
|
|
10
|
-
*/
|
|
11
|
-
export declare class WebhookTransformer {
|
|
12
|
-
/**
|
|
13
|
-
* Convert IPluginExecutionContext to WebhookExecutionContext
|
|
14
|
-
*/
|
|
15
|
-
static contextToWebhook(context: IPluginExecutionContext): IWebhookExecutionContext;
|
|
16
|
-
/**
|
|
17
|
-
* Convert IPluginExecutionResult to WebhookExecutionResult
|
|
18
|
-
*/
|
|
19
|
-
static resultToWebhook(result: IPluginExecutionResult): IWebhookExecutionResult;
|
|
20
|
-
/**
|
|
21
|
-
* Create execution event data
|
|
22
|
-
*/
|
|
23
|
-
static createExecutionData(context: IWebhookExecutionContext, result: IWebhookExecutionResult): IWebhookEventData;
|
|
24
|
-
/**
|
|
25
|
-
* Create conversation event data
|
|
26
|
-
*/
|
|
27
|
-
static createConversationData(context: IWebhookExecutionContext, result: IWebhookExecutionResult): IWebhookEventData;
|
|
28
|
-
/**
|
|
29
|
-
* Create tool execution event data
|
|
30
|
-
*
|
|
31
|
-
* REASON: Tool result structure varies by tool type and provider, needs flexible handling for webhook processing
|
|
32
|
-
* ALTERNATIVES_CONSIDERED:
|
|
33
|
-
* 1. Strict tool result interfaces (breaks tool compatibility)
|
|
34
|
-
* 2. Union types (insufficient for dynamic tool results)
|
|
35
|
-
* 3. Generic constraints (too complex for webhook processing)
|
|
36
|
-
* 4. Interface definitions (too rigid for varied tool results)
|
|
37
|
-
* 5. Type assertions (decreases type safety)
|
|
38
|
-
* TODO: Consider standardized tool result interface across tools
|
|
39
|
-
*/
|
|
40
|
-
static createToolData(context: IWebhookExecutionContext, toolResult: TLoggerData): IWebhookEventData;
|
|
41
|
-
/**
|
|
42
|
-
* Create error event data
|
|
43
|
-
*/
|
|
44
|
-
static createErrorData(context: IWebhookExecutionContext, error: Error): IWebhookEventData;
|
|
45
|
-
/**
|
|
46
|
-
* Safely get property from object (handles index signature issues)
|
|
47
|
-
*
|
|
48
|
-
* REASON: Safe property access for webhook data transformation needs flexible input/output types
|
|
49
|
-
* ALTERNATIVES_CONSIDERED:
|
|
50
|
-
* 1. Strict object types (breaks dynamic property access)
|
|
51
|
-
* 2. Union types (insufficient for property extraction)
|
|
52
|
-
* 3. Generic constraints (too complex for simple property access)
|
|
53
|
-
* 4. Interface definitions (too rigid for dynamic objects)
|
|
54
|
-
* 5. Type assertions (decreases type safety)
|
|
55
|
-
* TODO: Consider typed property access if patterns emerge
|
|
56
|
-
*/
|
|
57
|
-
private static safeGetProperty;
|
|
58
|
-
/**
|
|
59
|
-
* Default payload transformer for webhook events
|
|
60
|
-
*/
|
|
61
|
-
static defaultPayloadTransformer(_event: TWebhookEventName, data: IWebhookEventData): IWebhookEventData;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=transformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../../src/plugins/webhook/transformer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACvG,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EACR,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EAMjB,iBAAiB,EACpB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,kBAAkB;IAC3B;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,wBAAwB;IAQnF;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,sBAAsB,GAAG,uBAAuB;IAc/E;;OAEG;IACH,MAAM,CAAC,mBAAmB,CACtB,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,uBAAuB,GAChC,iBAAiB;IAiBpB;;OAEG;IACH,MAAM,CAAC,sBAAsB,CACzB,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,uBAAuB,GAChC,iBAAiB;IAsBpB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,cAAc,CACjB,OAAO,EAAE,wBAAwB,EACjC,UAAU,EAAE,WAAW,GACxB,iBAAiB;IA0BpB;;OAEG;IACH,MAAM,CAAC,eAAe,CAClB,OAAO,EAAE,wBAAwB,EACjC,KAAK,EAAE,KAAK,GACb,iBAAiB;IAoBpB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAO9B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAC5B,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,iBAAiB,GACxB,iBAAiB;CAIvB"}
|