@robota-sdk/agent-core 3.0.0-beta.1
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 +180 -0
- package/LICENSE +21 -0
- package/README.md +230 -0
- package/dist/abstracts/abstract-agent.d.ts +56 -0
- package/dist/abstracts/abstract-agent.d.ts.map +1 -0
- package/dist/abstracts/abstract-agent.js +55 -0
- package/dist/abstracts/abstract-agent.js.map +1 -0
- package/dist/abstracts/abstract-ai-provider.d.ts +187 -0
- package/dist/abstracts/abstract-ai-provider.d.ts.map +1 -0
- package/dist/abstracts/abstract-ai-provider.js +252 -0
- package/dist/abstracts/abstract-ai-provider.js.map +1 -0
- package/dist/abstracts/abstract-executor.d.ts +110 -0
- package/dist/abstracts/abstract-executor.d.ts.map +1 -0
- package/dist/abstracts/abstract-executor.js +156 -0
- package/dist/abstracts/abstract-executor.js.map +1 -0
- package/dist/abstracts/abstract-manager.d.ts +42 -0
- package/dist/abstracts/abstract-manager.d.ts.map +1 -0
- package/dist/abstracts/abstract-manager.js +49 -0
- package/dist/abstracts/abstract-manager.js.map +1 -0
- package/dist/abstracts/abstract-module.d.ts +365 -0
- package/dist/abstracts/abstract-module.d.ts.map +1 -0
- package/dist/abstracts/abstract-module.js +474 -0
- package/dist/abstracts/abstract-module.js.map +1 -0
- package/dist/abstracts/abstract-plugin.d.ts +369 -0
- package/dist/abstracts/abstract-plugin.d.ts.map +1 -0
- package/dist/abstracts/abstract-plugin.js +258 -0
- package/dist/abstracts/abstract-plugin.js.map +1 -0
- package/dist/abstracts/abstract-tool.d.ts +175 -0
- package/dist/abstracts/abstract-tool.d.ts.map +1 -0
- package/dist/abstracts/abstract-tool.js +140 -0
- package/dist/abstracts/abstract-tool.js.map +1 -0
- package/dist/abstracts/abstract-workflow-converter.d.ts +136 -0
- package/dist/abstracts/abstract-workflow-converter.d.ts.map +1 -0
- package/dist/abstracts/abstract-workflow-converter.js +252 -0
- package/dist/abstracts/abstract-workflow-converter.js.map +1 -0
- package/dist/abstracts/abstract-workflow-validator.d.ts +203 -0
- package/dist/abstracts/abstract-workflow-validator.d.ts.map +1 -0
- package/dist/abstracts/abstract-workflow-validator.js +447 -0
- package/dist/abstracts/abstract-workflow-validator.js.map +1 -0
- package/dist/abstracts/index.d.ts +6 -0
- package/dist/abstracts/index.d.ts.map +1 -0
- package/dist/abstracts/index.js +9 -0
- package/dist/abstracts/index.js.map +1 -0
- package/dist/agents/constants.d.ts +23 -0
- package/dist/agents/constants.d.ts.map +1 -0
- package/dist/agents/constants.js +22 -0
- package/dist/agents/constants.js.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +4 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/robota.test.d.ts +2 -0
- package/dist/agents/robota.test.d.ts.map +1 -0
- package/dist/agents/robota.test.js +416 -0
- package/dist/agents/robota.test.js.map +1 -0
- package/dist/browser/builtin-templates.json +107 -0
- package/dist/browser/index.d.ts +4237 -0
- package/dist/browser/index.js +4 -0
- package/dist/core/robota.d.ts +694 -0
- package/dist/core/robota.d.ts.map +1 -0
- package/dist/core/robota.js +1277 -0
- package/dist/core/robota.js.map +1 -0
- package/dist/executors/local-executor.d.ts +96 -0
- package/dist/executors/local-executor.d.ts.map +1 -0
- package/dist/executors/local-executor.js +197 -0
- package/dist/executors/local-executor.js.map +1 -0
- package/dist/executors/local-executor.test.d.ts +2 -0
- package/dist/executors/local-executor.test.d.ts.map +1 -0
- package/dist/executors/local-executor.test.js +192 -0
- package/dist/executors/local-executor.test.js.map +1 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +235 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/agent.d.ts +198 -0
- package/dist/interfaces/agent.d.ts.map +1 -0
- package/dist/interfaces/agent.js +2 -0
- package/dist/interfaces/agent.js.map +1 -0
- package/dist/interfaces/event-service.d.ts +79 -0
- package/dist/interfaces/event-service.d.ts.map +1 -0
- package/dist/interfaces/event-service.js +2 -0
- package/dist/interfaces/event-service.js.map +1 -0
- package/dist/interfaces/executor.d.ts +128 -0
- package/dist/interfaces/executor.d.ts.map +1 -0
- package/dist/interfaces/executor.js +2 -0
- package/dist/interfaces/executor.js.map +1 -0
- package/dist/interfaces/history-module.d.ts +19 -0
- package/dist/interfaces/history-module.d.ts.map +1 -0
- package/dist/interfaces/history-module.js +2 -0
- package/dist/interfaces/history-module.js.map +1 -0
- package/dist/interfaces/index.d.ts +13 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +4 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/manager.d.ts +142 -0
- package/dist/interfaces/manager.d.ts.map +1 -0
- package/dist/interfaces/manager.js +2 -0
- package/dist/interfaces/manager.js.map +1 -0
- package/dist/interfaces/messages.d.ts +75 -0
- package/dist/interfaces/messages.d.ts.map +1 -0
- package/dist/interfaces/messages.js +29 -0
- package/dist/interfaces/messages.js.map +1 -0
- package/dist/interfaces/progress-reporting.d.ts +86 -0
- package/dist/interfaces/progress-reporting.d.ts.map +1 -0
- package/dist/interfaces/progress-reporting.js +37 -0
- package/dist/interfaces/progress-reporting.js.map +1 -0
- package/dist/interfaces/provider.d.ts +217 -0
- package/dist/interfaces/provider.d.ts.map +1 -0
- package/dist/interfaces/provider.js +2 -0
- package/dist/interfaces/provider.js.map +1 -0
- package/dist/interfaces/service.d.ts +205 -0
- package/dist/interfaces/service.d.ts.map +1 -0
- package/dist/interfaces/service.js +6 -0
- package/dist/interfaces/service.js.map +1 -0
- package/dist/interfaces/tool.d.ts +248 -0
- package/dist/interfaces/tool.d.ts.map +1 -0
- package/dist/interfaces/tool.js +2 -0
- package/dist/interfaces/tool.js.map +1 -0
- package/dist/interfaces/types.d.ts +71 -0
- package/dist/interfaces/types.d.ts.map +1 -0
- package/dist/interfaces/types.js +33 -0
- package/dist/interfaces/types.js.map +1 -0
- package/dist/interfaces/workflow-converter.d.ts +193 -0
- package/dist/interfaces/workflow-converter.d.ts.map +1 -0
- package/dist/interfaces/workflow-converter.js +11 -0
- package/dist/interfaces/workflow-converter.js.map +1 -0
- package/dist/interfaces/workflow-validator.d.ts +209 -0
- package/dist/interfaces/workflow-validator.d.ts.map +1 -0
- package/dist/interfaces/workflow-validator.js +16 -0
- package/dist/interfaces/workflow-validator.js.map +1 -0
- package/dist/managers/agent-factory.d.ts +132 -0
- package/dist/managers/agent-factory.d.ts.map +1 -0
- package/dist/managers/agent-factory.js +284 -0
- package/dist/managers/agent-factory.js.map +1 -0
- package/dist/managers/agent-factory.test.d.ts +2 -0
- package/dist/managers/agent-factory.test.d.ts.map +1 -0
- package/dist/managers/agent-factory.test.js +249 -0
- package/dist/managers/agent-factory.test.js.map +1 -0
- package/dist/managers/agent-templates.d.ts +84 -0
- package/dist/managers/agent-templates.d.ts.map +1 -0
- package/dist/managers/agent-templates.js +159 -0
- package/dist/managers/agent-templates.js.map +1 -0
- package/dist/managers/ai-provider-manager.d.ts +80 -0
- package/dist/managers/ai-provider-manager.d.ts.map +1 -0
- package/dist/managers/ai-provider-manager.js +226 -0
- package/dist/managers/ai-provider-manager.js.map +1 -0
- package/dist/managers/conversation-history-manager.d.ts +455 -0
- package/dist/managers/conversation-history-manager.d.ts.map +1 -0
- package/dist/managers/conversation-history-manager.js +578 -0
- package/dist/managers/conversation-history-manager.js.map +1 -0
- package/dist/managers/conversation-history-manager.test.d.ts +2 -0
- package/dist/managers/conversation-history-manager.test.d.ts.map +1 -0
- package/dist/managers/conversation-history-manager.test.js +374 -0
- package/dist/managers/conversation-history-manager.test.js.map +1 -0
- package/dist/managers/index.d.ts +8 -0
- package/dist/managers/index.d.ts.map +1 -0
- package/dist/managers/index.js +8 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/module-registry.d.ts +161 -0
- package/dist/managers/module-registry.d.ts.map +1 -0
- package/dist/managers/module-registry.js +519 -0
- package/dist/managers/module-registry.js.map +1 -0
- package/dist/managers/module-type-registry.d.ts +113 -0
- package/dist/managers/module-type-registry.d.ts.map +1 -0
- package/dist/managers/module-type-registry.js +439 -0
- package/dist/managers/module-type-registry.js.map +1 -0
- package/dist/managers/plugins.d.ts +166 -0
- package/dist/managers/plugins.d.ts.map +1 -0
- package/dist/managers/plugins.js +339 -0
- package/dist/managers/plugins.js.map +1 -0
- package/dist/managers/tool-manager.d.ts +70 -0
- package/dist/managers/tool-manager.d.ts.map +1 -0
- package/dist/managers/tool-manager.js +138 -0
- package/dist/managers/tool-manager.js.map +1 -0
- package/dist/managers/tool-manager.test.d.ts +2 -0
- package/dist/managers/tool-manager.test.d.ts.map +1 -0
- package/dist/managers/tool-manager.test.js +186 -0
- package/dist/managers/tool-manager.test.js.map +1 -0
- package/dist/node/builtin-templates.json +107 -0
- package/dist/node/index.cjs +4 -0
- package/dist/node/index.d.cts +4237 -0
- package/dist/node/index.d.ts +4237 -0
- package/dist/node/index.js +4 -0
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts +67 -0
- package/dist/plugins/conversation-history/conversation-history-plugin.d.ts.map +1 -0
- package/dist/plugins/conversation-history/conversation-history-plugin.js +270 -0
- package/dist/plugins/conversation-history/conversation-history-plugin.js.map +1 -0
- package/dist/plugins/conversation-history/index.d.ts +3 -0
- package/dist/plugins/conversation-history/index.d.ts.map +1 -0
- package/dist/plugins/conversation-history/index.js +2 -0
- package/dist/plugins/conversation-history/index.js.map +1 -0
- package/dist/plugins/conversation-history/storages/database-storage.d.ts +19 -0
- package/dist/plugins/conversation-history/storages/database-storage.d.ts.map +1 -0
- package/dist/plugins/conversation-history/storages/database-storage.js +94 -0
- package/dist/plugins/conversation-history/storages/database-storage.js.map +1 -0
- package/dist/plugins/conversation-history/storages/file-storage.d.ts +15 -0
- package/dist/plugins/conversation-history/storages/file-storage.d.ts.map +1 -0
- package/dist/plugins/conversation-history/storages/file-storage.js +94 -0
- package/dist/plugins/conversation-history/storages/file-storage.js.map +1 -0
- package/dist/plugins/conversation-history/storages/index.d.ts +4 -0
- package/dist/plugins/conversation-history/storages/index.d.ts.map +1 -0
- package/dist/plugins/conversation-history/storages/index.js +4 -0
- package/dist/plugins/conversation-history/storages/index.js.map +1 -0
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts +15 -0
- package/dist/plugins/conversation-history/storages/memory-storage.d.ts.map +1 -0
- package/dist/plugins/conversation-history/storages/memory-storage.js +33 -0
- package/dist/plugins/conversation-history/storages/memory-storage.js.map +1 -0
- package/dist/plugins/conversation-history/types.d.ts +61 -0
- package/dist/plugins/conversation-history/types.d.ts.map +1 -0
- package/dist/plugins/conversation-history/types.js +2 -0
- package/dist/plugins/conversation-history/types.js.map +1 -0
- package/dist/plugins/error-handling/context-adapter.d.ts +30 -0
- package/dist/plugins/error-handling/context-adapter.d.ts.map +1 -0
- package/dist/plugins/error-handling/context-adapter.js +41 -0
- package/dist/plugins/error-handling/context-adapter.js.map +1 -0
- package/dist/plugins/error-handling/error-handling-plugin.d.ts +49 -0
- package/dist/plugins/error-handling/error-handling-plugin.d.ts.map +1 -0
- package/dist/plugins/error-handling/error-handling-plugin.js +229 -0
- package/dist/plugins/error-handling/error-handling-plugin.js.map +1 -0
- package/dist/plugins/error-handling/index.d.ts +10 -0
- package/dist/plugins/error-handling/index.d.ts.map +1 -0
- package/dist/plugins/error-handling/index.js +10 -0
- package/dist/plugins/error-handling/index.js.map +1 -0
- package/dist/plugins/error-handling/types.d.ts +73 -0
- package/dist/plugins/error-handling/types.d.ts.map +1 -0
- package/dist/plugins/error-handling/types.js +14 -0
- package/dist/plugins/error-handling/types.js.map +1 -0
- package/dist/plugins/event-emitter/metrics.d.ts +17 -0
- package/dist/plugins/event-emitter/metrics.d.ts.map +1 -0
- package/dist/plugins/event-emitter/metrics.js +17 -0
- package/dist/plugins/event-emitter/metrics.js.map +1 -0
- package/dist/plugins/event-emitter/types.d.ts +112 -0
- package/dist/plugins/event-emitter/types.d.ts.map +1 -0
- package/dist/plugins/event-emitter/types.js +65 -0
- package/dist/plugins/event-emitter/types.js.map +1 -0
- package/dist/plugins/event-emitter-plugin.d.ts +222 -0
- package/dist/plugins/event-emitter-plugin.d.ts.map +1 -0
- package/dist/plugins/event-emitter-plugin.js +432 -0
- package/dist/plugins/event-emitter-plugin.js.map +1 -0
- package/dist/plugins/event-emitter-plugin.test.d.ts +2 -0
- package/dist/plugins/event-emitter-plugin.test.d.ts.map +1 -0
- package/dist/plugins/event-emitter-plugin.test.js +94 -0
- package/dist/plugins/event-emitter-plugin.test.js.map +1 -0
- package/dist/plugins/execution/execution-analytics-plugin.d.ts +129 -0
- package/dist/plugins/execution/execution-analytics-plugin.d.ts.map +1 -0
- package/dist/plugins/execution/execution-analytics-plugin.js +517 -0
- package/dist/plugins/execution/execution-analytics-plugin.js.map +1 -0
- package/dist/plugins/execution/index.d.ts +3 -0
- package/dist/plugins/execution/index.d.ts.map +1 -0
- package/dist/plugins/execution/index.js +2 -0
- package/dist/plugins/execution/index.js.map +1 -0
- package/dist/plugins/execution/types.d.ts +90 -0
- package/dist/plugins/execution/types.d.ts.map +1 -0
- package/dist/plugins/execution/types.js +2 -0
- package/dist/plugins/execution/types.js.map +1 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +11 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/limits/types.d.ts +61 -0
- package/dist/plugins/limits/types.d.ts.map +1 -0
- package/dist/plugins/limits/types.js +2 -0
- package/dist/plugins/limits/types.js.map +1 -0
- package/dist/plugins/limits-plugin.d.ts +113 -0
- package/dist/plugins/limits-plugin.d.ts.map +1 -0
- package/dist/plugins/limits-plugin.js +380 -0
- package/dist/plugins/limits-plugin.js.map +1 -0
- package/dist/plugins/logging/formatters.d.ts +14 -0
- package/dist/plugins/logging/formatters.d.ts.map +1 -0
- package/dist/plugins/logging/formatters.js +24 -0
- package/dist/plugins/logging/formatters.js.map +1 -0
- package/dist/plugins/logging/index.d.ts +3 -0
- package/dist/plugins/logging/index.d.ts.map +1 -0
- package/dist/plugins/logging/index.js +2 -0
- package/dist/plugins/logging/index.js.map +1 -0
- package/dist/plugins/logging/logging-plugin.d.ts +91 -0
- package/dist/plugins/logging/logging-plugin.d.ts.map +1 -0
- package/dist/plugins/logging/logging-plugin.js +335 -0
- package/dist/plugins/logging/logging-plugin.js.map +1 -0
- package/dist/plugins/logging/storages/console-storage.d.ts +14 -0
- package/dist/plugins/logging/storages/console-storage.d.ts.map +1 -0
- package/dist/plugins/logging/storages/console-storage.js +38 -0
- package/dist/plugins/logging/storages/console-storage.js.map +1 -0
- package/dist/plugins/logging/storages/file-storage.d.ts +14 -0
- package/dist/plugins/logging/storages/file-storage.d.ts.map +1 -0
- package/dist/plugins/logging/storages/file-storage.js +41 -0
- package/dist/plugins/logging/storages/file-storage.js.map +1 -0
- package/dist/plugins/logging/storages/index.d.ts +5 -0
- package/dist/plugins/logging/storages/index.d.ts.map +1 -0
- package/dist/plugins/logging/storages/index.js +5 -0
- package/dist/plugins/logging/storages/index.js.map +1 -0
- package/dist/plugins/logging/storages/remote-storage.d.ts +20 -0
- package/dist/plugins/logging/storages/remote-storage.d.ts.map +1 -0
- package/dist/plugins/logging/storages/remote-storage.js +61 -0
- package/dist/plugins/logging/storages/remote-storage.js.map +1 -0
- package/dist/plugins/logging/storages/silent-storage.d.ts +10 -0
- package/dist/plugins/logging/storages/silent-storage.d.ts.map +1 -0
- package/dist/plugins/logging/storages/silent-storage.js +15 -0
- package/dist/plugins/logging/storages/silent-storage.js.map +1 -0
- package/dist/plugins/logging/types.d.ts +84 -0
- package/dist/plugins/logging/types.d.ts.map +1 -0
- package/dist/plugins/logging/types.js +2 -0
- package/dist/plugins/logging/types.js.map +1 -0
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts +12 -0
- package/dist/plugins/performance/collectors/system-metrics-collector.d.ts.map +1 -0
- package/dist/plugins/performance/collectors/system-metrics-collector.js +65 -0
- package/dist/plugins/performance/collectors/system-metrics-collector.js.map +1 -0
- package/dist/plugins/performance/index.d.ts +5 -0
- package/dist/plugins/performance/index.d.ts.map +1 -0
- package/dist/plugins/performance/index.js +4 -0
- package/dist/plugins/performance/index.js.map +1 -0
- package/dist/plugins/performance/performance-plugin.d.ts +49 -0
- package/dist/plugins/performance/performance-plugin.d.ts.map +1 -0
- package/dist/plugins/performance/performance-plugin.js +293 -0
- package/dist/plugins/performance/performance-plugin.js.map +1 -0
- package/dist/plugins/performance/storages/index.d.ts +2 -0
- package/dist/plugins/performance/storages/index.d.ts.map +1 -0
- package/dist/plugins/performance/storages/index.js +4 -0
- package/dist/plugins/performance/storages/index.js.map +1 -0
- package/dist/plugins/performance/storages/memory-storage.d.ts +19 -0
- package/dist/plugins/performance/storages/memory-storage.d.ts.map +1 -0
- package/dist/plugins/performance/storages/memory-storage.js +69 -0
- package/dist/plugins/performance/storages/memory-storage.js.map +1 -0
- package/dist/plugins/performance/types.d.ts +154 -0
- package/dist/plugins/performance/types.d.ts.map +1 -0
- package/dist/plugins/performance/types.js +2 -0
- package/dist/plugins/performance/types.js.map +1 -0
- package/dist/plugins/usage/aggregate-usage-stats.d.ts +12 -0
- package/dist/plugins/usage/aggregate-usage-stats.d.ts.map +1 -0
- package/dist/plugins/usage/aggregate-usage-stats.js +115 -0
- package/dist/plugins/usage/aggregate-usage-stats.js.map +1 -0
- package/dist/plugins/usage/index.d.ts +5 -0
- package/dist/plugins/usage/index.d.ts.map +1 -0
- package/dist/plugins/usage/index.js +4 -0
- package/dist/plugins/usage/index.js.map +1 -0
- package/dist/plugins/usage/storages/file-storage.d.ts +22 -0
- package/dist/plugins/usage/storages/file-storage.d.ts.map +1 -0
- package/dist/plugins/usage/storages/file-storage.js +111 -0
- package/dist/plugins/usage/storages/file-storage.js.map +1 -0
- package/dist/plugins/usage/storages/index.d.ts +5 -0
- package/dist/plugins/usage/storages/index.d.ts.map +1 -0
- package/dist/plugins/usage/storages/index.js +5 -0
- package/dist/plugins/usage/storages/index.js.map +1 -0
- package/dist/plugins/usage/storages/memory-storage.d.ts +22 -0
- package/dist/plugins/usage/storages/memory-storage.d.ts.map +1 -0
- package/dist/plugins/usage/storages/memory-storage.js +42 -0
- package/dist/plugins/usage/storages/memory-storage.js.map +1 -0
- package/dist/plugins/usage/storages/remote-storage.d.ts +26 -0
- package/dist/plugins/usage/storages/remote-storage.d.ts.map +1 -0
- package/dist/plugins/usage/storages/remote-storage.js +115 -0
- package/dist/plugins/usage/storages/remote-storage.js.map +1 -0
- package/dist/plugins/usage/storages/silent-storage.d.ts +19 -0
- package/dist/plugins/usage/storages/silent-storage.d.ts.map +1 -0
- package/dist/plugins/usage/storages/silent-storage.js +26 -0
- package/dist/plugins/usage/storages/silent-storage.js.map +1 -0
- package/dist/plugins/usage/types.d.ts +127 -0
- package/dist/plugins/usage/types.d.ts.map +1 -0
- package/dist/plugins/usage/types.js +2 -0
- package/dist/plugins/usage/types.js.map +1 -0
- package/dist/plugins/usage/usage-plugin.d.ts +67 -0
- package/dist/plugins/usage/usage-plugin.d.ts.map +1 -0
- package/dist/plugins/usage/usage-plugin.js +309 -0
- package/dist/plugins/usage/usage-plugin.js.map +1 -0
- package/dist/plugins/webhook/http-client.d.ts +30 -0
- package/dist/plugins/webhook/http-client.d.ts.map +1 -0
- package/dist/plugins/webhook/http-client.js +110 -0
- package/dist/plugins/webhook/http-client.js.map +1 -0
- package/dist/plugins/webhook/index.d.ts +9 -0
- package/dist/plugins/webhook/index.d.ts.map +1 -0
- package/dist/plugins/webhook/index.js +9 -0
- package/dist/plugins/webhook/index.js.map +1 -0
- package/dist/plugins/webhook/transformer.d.ts +63 -0
- package/dist/plugins/webhook/transformer.d.ts.map +1 -0
- package/dist/plugins/webhook/transformer.js +157 -0
- package/dist/plugins/webhook/transformer.js.map +1 -0
- package/dist/plugins/webhook/types.d.ts +183 -0
- package/dist/plugins/webhook/types.d.ts.map +1 -0
- package/dist/plugins/webhook/types.js +2 -0
- package/dist/plugins/webhook/types.js.map +1 -0
- package/dist/plugins/webhook/webhook-plugin.d.ts +92 -0
- package/dist/plugins/webhook/webhook-plugin.d.ts.map +1 -0
- package/dist/plugins/webhook/webhook-plugin.js +328 -0
- package/dist/plugins/webhook/webhook-plugin.js.map +1 -0
- package/dist/schemas/agent-template-schema.d.ts +137 -0
- package/dist/schemas/agent-template-schema.d.ts.map +1 -0
- package/dist/schemas/agent-template-schema.js +87 -0
- package/dist/schemas/agent-template-schema.js.map +1 -0
- package/dist/services/conversation-service/index.d.ts +88 -0
- package/dist/services/conversation-service/index.d.ts.map +1 -0
- package/dist/services/conversation-service/index.js +441 -0
- package/dist/services/conversation-service/index.js.map +1 -0
- package/dist/services/conversation-service/types.d.ts +32 -0
- package/dist/services/conversation-service/types.d.ts.map +1 -0
- package/dist/services/conversation-service/types.js +8 -0
- package/dist/services/conversation-service/types.js.map +1 -0
- package/dist/services/event-service.d.ts +61 -0
- package/dist/services/event-service.d.ts.map +1 -0
- package/dist/services/event-service.js +110 -0
- package/dist/services/event-service.js.map +1 -0
- package/dist/services/event-service.test.d.ts +2 -0
- package/dist/services/event-service.test.d.ts.map +1 -0
- package/dist/services/event-service.test.js +86 -0
- package/dist/services/event-service.test.js.map +1 -0
- package/dist/services/execution-service.d.ts +151 -0
- package/dist/services/execution-service.d.ts.map +1 -0
- package/dist/services/execution-service.js +1262 -0
- package/dist/services/execution-service.js.map +1 -0
- package/dist/services/execution-service.test.d.ts +2 -0
- package/dist/services/execution-service.test.d.ts.map +1 -0
- package/dist/services/execution-service.test.js +338 -0
- package/dist/services/execution-service.test.js.map +1 -0
- package/dist/services/history-module.d.ts +15 -0
- package/dist/services/history-module.d.ts.map +1 -0
- package/dist/services/history-module.js +42 -0
- package/dist/services/history-module.js.map +1 -0
- package/dist/services/in-memory-history-store.d.ts +12 -0
- package/dist/services/in-memory-history-store.d.ts.map +1 -0
- package/dist/services/in-memory-history-store.js +41 -0
- package/dist/services/in-memory-history-store.js.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +13 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/task-events.d.ts +6 -0
- package/dist/services/task-events.d.ts.map +1 -0
- package/dist/services/task-events.js +6 -0
- package/dist/services/task-events.js.map +1 -0
- package/dist/services/tool-execution-service.d.ts +74 -0
- package/dist/services/tool-execution-service.d.ts.map +1 -0
- package/dist/services/tool-execution-service.js +189 -0
- package/dist/services/tool-execution-service.js.map +1 -0
- package/dist/services/user-events.d.ts +7 -0
- package/dist/services/user-events.d.ts.map +1 -0
- package/dist/services/user-events.js +6 -0
- package/dist/services/user-events.js.map +1 -0
- package/dist/tools/implementations/function-tool/index.d.ts +9 -0
- package/dist/tools/implementations/function-tool/index.d.ts.map +1 -0
- package/dist/tools/implementations/function-tool/index.js +13 -0
- package/dist/tools/implementations/function-tool/index.js.map +1 -0
- package/dist/tools/implementations/function-tool/schema-converter.d.ts +32 -0
- package/dist/tools/implementations/function-tool/schema-converter.d.ts.map +1 -0
- package/dist/tools/implementations/function-tool/schema-converter.js +164 -0
- package/dist/tools/implementations/function-tool/schema-converter.js.map +1 -0
- package/dist/tools/implementations/function-tool/types.d.ts +72 -0
- package/dist/tools/implementations/function-tool/types.d.ts.map +1 -0
- package/dist/tools/implementations/function-tool/types.js +14 -0
- package/dist/tools/implementations/function-tool/types.js.map +1 -0
- package/dist/tools/implementations/function-tool.d.ts +49 -0
- package/dist/tools/implementations/function-tool.d.ts.map +1 -0
- package/dist/tools/implementations/function-tool.js +223 -0
- package/dist/tools/implementations/function-tool.js.map +1 -0
- package/dist/tools/implementations/index.d.ts +4 -0
- package/dist/tools/implementations/index.d.ts.map +1 -0
- package/dist/tools/implementations/index.js +5 -0
- package/dist/tools/implementations/index.js.map +1 -0
- package/dist/tools/implementations/mcp-tool.d.ts +72 -0
- package/dist/tools/implementations/mcp-tool.d.ts.map +1 -0
- package/dist/tools/implementations/mcp-tool.js +246 -0
- package/dist/tools/implementations/mcp-tool.js.map +1 -0
- package/dist/tools/implementations/openapi-tool.d.ts +56 -0
- package/dist/tools/implementations/openapi-tool.d.ts.map +1 -0
- package/dist/tools/implementations/openapi-tool.js +324 -0
- package/dist/tools/implementations/openapi-tool.js.map +1 -0
- package/dist/tools/implementations/relay-mcp-tool.d.ts +38 -0
- package/dist/tools/implementations/relay-mcp-tool.d.ts.map +1 -0
- package/dist/tools/implementations/relay-mcp-tool.js +46 -0
- package/dist/tools/implementations/relay-mcp-tool.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry/index.d.ts +2 -0
- package/dist/tools/registry/index.d.ts.map +1 -0
- package/dist/tools/registry/index.js +3 -0
- package/dist/tools/registry/index.js.map +1 -0
- package/dist/tools/registry/tool-registry.d.ts +54 -0
- package/dist/tools/registry/tool-registry.d.ts.map +1 -0
- package/dist/tools/registry/tool-registry.js +146 -0
- package/dist/tools/registry/tool-registry.js.map +1 -0
- package/dist/utils/errors.d.ts +155 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +203 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/execution-proxy.d.ts +75 -0
- package/dist/utils/execution-proxy.d.ts.map +1 -0
- package/dist/utils/execution-proxy.js +230 -0
- package/dist/utils/execution-proxy.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +74 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +143 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/message-converter.d.ts +68 -0
- package/dist/utils/message-converter.d.ts.map +1 -0
- package/dist/utils/message-converter.js +87 -0
- package/dist/utils/message-converter.js.map +1 -0
- package/dist/utils/periodic-task.d.ts +14 -0
- package/dist/utils/periodic-task.d.ts.map +1 -0
- package/dist/utils/periodic-task.js +26 -0
- package/dist/utils/periodic-task.js.map +1 -0
- package/dist/utils/validation.d.ts +40 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +162 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { AbstractPlugin, PluginCategory, PluginPriority } from '../abstracts/abstract-plugin';
|
|
2
|
+
import { createLogger } from '../utils/logger';
|
|
3
|
+
import { PluginError } from '../utils/errors';
|
|
4
|
+
/**
|
|
5
|
+
* Plugin for rate limiting and resource control
|
|
6
|
+
* Enforces limits on token usage, request frequency, and costs
|
|
7
|
+
*/
|
|
8
|
+
export class LimitsPlugin extends AbstractPlugin {
|
|
9
|
+
name = 'LimitsPlugin';
|
|
10
|
+
version = '1.0.0';
|
|
11
|
+
pluginOptions;
|
|
12
|
+
logger;
|
|
13
|
+
windows = new Map();
|
|
14
|
+
buckets = new Map();
|
|
15
|
+
requestCounts = new Map();
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super();
|
|
18
|
+
this.logger = createLogger('LimitsPlugin');
|
|
19
|
+
// Validate options
|
|
20
|
+
this.validateOptions(options);
|
|
21
|
+
// Set defaults
|
|
22
|
+
this.pluginOptions = {
|
|
23
|
+
enabled: options.enabled ?? true,
|
|
24
|
+
strategy: options.strategy,
|
|
25
|
+
maxTokens: options.maxTokens ?? 100000,
|
|
26
|
+
maxRequests: options.maxRequests ?? 1000,
|
|
27
|
+
timeWindow: options.timeWindow ?? 3600000, // 1 hour
|
|
28
|
+
maxCost: options.maxCost ?? 10.0, // $10
|
|
29
|
+
tokenCostPer1000: options.tokenCostPer1000 ?? 0.002, // $0.002 per 1K tokens
|
|
30
|
+
refillRate: options.refillRate ?? 100, // tokens per second
|
|
31
|
+
bucketSize: options.bucketSize ?? 10000,
|
|
32
|
+
costCalculator: options.costCalculator ?? this.defaultCostCalculator.bind(this),
|
|
33
|
+
// Add plugin options defaults
|
|
34
|
+
category: options.category ?? PluginCategory.LIMITS,
|
|
35
|
+
priority: options.priority ?? PluginPriority.NORMAL,
|
|
36
|
+
moduleEvents: options.moduleEvents ?? [],
|
|
37
|
+
subscribeToAllModuleEvents: options.subscribeToAllModuleEvents ?? false
|
|
38
|
+
};
|
|
39
|
+
this.logger.info('LimitsPlugin initialized', {
|
|
40
|
+
strategy: this.pluginOptions.strategy,
|
|
41
|
+
maxTokens: this.pluginOptions.maxTokens,
|
|
42
|
+
maxRequests: this.pluginOptions.maxRequests,
|
|
43
|
+
timeWindow: this.pluginOptions.timeWindow
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check limits before execution
|
|
48
|
+
*/
|
|
49
|
+
async beforeExecution(context) {
|
|
50
|
+
if (this.pluginOptions.strategy === 'none') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const key = this.getKey(context);
|
|
54
|
+
try {
|
|
55
|
+
switch (this.pluginOptions.strategy) {
|
|
56
|
+
case 'token-bucket':
|
|
57
|
+
await this.checkTokenBucket(key, context);
|
|
58
|
+
break;
|
|
59
|
+
case 'sliding-window':
|
|
60
|
+
await this.checkSlidingWindow(key, context);
|
|
61
|
+
break;
|
|
62
|
+
case 'fixed-window':
|
|
63
|
+
await this.checkFixedWindow(key, context);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
this.logger.debug('Limits check passed', {
|
|
67
|
+
strategy: this.pluginOptions.strategy,
|
|
68
|
+
key
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.logger.warn('Limits check failed', {
|
|
73
|
+
strategy: this.pluginOptions.strategy,
|
|
74
|
+
key,
|
|
75
|
+
error: error instanceof Error ? error.message : String(error)
|
|
76
|
+
});
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Update limits after execution
|
|
82
|
+
*/
|
|
83
|
+
async afterExecution(context, result) {
|
|
84
|
+
if (this.pluginOptions.strategy === 'none') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const key = this.getKey(context);
|
|
88
|
+
const tokensUsed = result?.tokensUsed || 0;
|
|
89
|
+
const cost = this.pluginOptions.costCalculator(tokensUsed, context.config?.['model'] || 'unknown');
|
|
90
|
+
try {
|
|
91
|
+
switch (this.pluginOptions.strategy) {
|
|
92
|
+
case 'token-bucket':
|
|
93
|
+
this.updateTokenBucket(key, tokensUsed, cost);
|
|
94
|
+
break;
|
|
95
|
+
case 'sliding-window':
|
|
96
|
+
case 'fixed-window':
|
|
97
|
+
this.updateWindow(key, tokensUsed, cost);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
this.logger.debug('Limits updated after execution', {
|
|
101
|
+
strategy: this.pluginOptions.strategy,
|
|
102
|
+
key,
|
|
103
|
+
tokensUsed,
|
|
104
|
+
cost
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.logger.error('Failed to update limits', {
|
|
109
|
+
strategy: this.pluginOptions.strategy,
|
|
110
|
+
key,
|
|
111
|
+
error: error instanceof Error ? error.message : String(error)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Token bucket rate limiting
|
|
117
|
+
*/
|
|
118
|
+
async checkTokenBucket(key, context) {
|
|
119
|
+
const bucket = this.getBucket(key);
|
|
120
|
+
const now = Date.now();
|
|
121
|
+
// Refill bucket
|
|
122
|
+
const timePassed = (now - bucket.lastRefill) / 1000;
|
|
123
|
+
const tokensToAdd = timePassed * this.pluginOptions.refillRate;
|
|
124
|
+
bucket.tokens = Math.min(this.pluginOptions.bucketSize, bucket.tokens + tokensToAdd);
|
|
125
|
+
bucket.lastRefill = now;
|
|
126
|
+
// Check if we can process this request
|
|
127
|
+
const estimatedTokens = this.estimateTokens(context);
|
|
128
|
+
if (bucket.tokens < estimatedTokens) {
|
|
129
|
+
throw new PluginError(`Token bucket depleted. Available: ${Math.floor(bucket.tokens)}, Required: ${estimatedTokens}`, this.name, { availableTokens: bucket.tokens, requiredTokens: estimatedTokens });
|
|
130
|
+
}
|
|
131
|
+
// Check time window limits for requests and cost
|
|
132
|
+
if (now - bucket.windowStart >= this.pluginOptions.timeWindow) {
|
|
133
|
+
bucket.requests = 0;
|
|
134
|
+
bucket.cost = 0;
|
|
135
|
+
bucket.windowStart = now;
|
|
136
|
+
}
|
|
137
|
+
if (bucket.requests >= this.pluginOptions.maxRequests) {
|
|
138
|
+
throw new PluginError(`Request limit exceeded. Max: ${this.pluginOptions.maxRequests}`, this.name, { currentRequests: bucket.requests, maxRequests: this.pluginOptions.maxRequests });
|
|
139
|
+
}
|
|
140
|
+
const estimatedCost = this.pluginOptions.costCalculator(estimatedTokens, context.config?.model || 'unknown');
|
|
141
|
+
if (bucket.cost + estimatedCost > this.pluginOptions.maxCost) {
|
|
142
|
+
throw new PluginError(`Cost limit exceeded. Current: $${bucket.cost.toFixed(4)}, Estimated: $${estimatedCost.toFixed(4)}, Max: $${this.pluginOptions.maxCost}`, this.name, { currentCost: bucket.cost, estimatedCost, maxCost: this.pluginOptions.maxCost });
|
|
143
|
+
}
|
|
144
|
+
// Reserve tokens
|
|
145
|
+
bucket.tokens -= estimatedTokens;
|
|
146
|
+
bucket.requests++;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Sliding window rate limiting
|
|
150
|
+
*/
|
|
151
|
+
async checkSlidingWindow(key, context) {
|
|
152
|
+
const now = Date.now();
|
|
153
|
+
const window = this.getWindow(key);
|
|
154
|
+
// For sliding window, we track usage more granularly
|
|
155
|
+
// This is a simplified implementation
|
|
156
|
+
if (now - window.windowStart < this.pluginOptions.timeWindow) {
|
|
157
|
+
const estimatedTokens = this.estimateTokens(context);
|
|
158
|
+
const estimatedCost = this.pluginOptions.costCalculator(estimatedTokens, context.config?.model || 'unknown');
|
|
159
|
+
if (window.tokens + estimatedTokens > this.pluginOptions.maxTokens) {
|
|
160
|
+
throw new PluginError(`Token limit exceeded in sliding window. Current: ${window.tokens}, Estimated: ${estimatedTokens}, Max: ${this.pluginOptions.maxTokens}`, this.name, { currentTokens: window.tokens, estimatedTokens, maxTokens: this.pluginOptions.maxTokens });
|
|
161
|
+
}
|
|
162
|
+
if (window.count >= this.pluginOptions.maxRequests) {
|
|
163
|
+
throw new PluginError(`Request limit exceeded in sliding window. Current: ${window.count}, Max: ${this.pluginOptions.maxRequests}`, this.name, { currentRequests: window.count, maxRequests: this.pluginOptions.maxRequests });
|
|
164
|
+
}
|
|
165
|
+
if (window.cost + estimatedCost > this.pluginOptions.maxCost) {
|
|
166
|
+
throw new PluginError(`Cost limit exceeded in sliding window. Current: $${window.cost.toFixed(4)}, Estimated: $${estimatedCost.toFixed(4)}, Max: $${this.pluginOptions.maxCost}`, this.name, { currentCost: window.cost, estimatedCost, maxCost: this.pluginOptions.maxCost });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
// Reset window
|
|
171
|
+
window.count = 0;
|
|
172
|
+
window.tokens = 0;
|
|
173
|
+
window.cost = 0;
|
|
174
|
+
window.windowStart = now;
|
|
175
|
+
}
|
|
176
|
+
window.count++;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Fixed window rate limiting
|
|
180
|
+
*/
|
|
181
|
+
async checkFixedWindow(key, context) {
|
|
182
|
+
const now = Date.now();
|
|
183
|
+
const window = this.getWindow(key);
|
|
184
|
+
// Reset window if expired
|
|
185
|
+
if (now - window.windowStart >= this.pluginOptions.timeWindow) {
|
|
186
|
+
window.count = 0;
|
|
187
|
+
window.tokens = 0;
|
|
188
|
+
window.cost = 0;
|
|
189
|
+
window.windowStart = now;
|
|
190
|
+
}
|
|
191
|
+
const estimatedTokens = this.estimateTokens(context);
|
|
192
|
+
const estimatedCost = this.pluginOptions.costCalculator(estimatedTokens, context.config?.model || 'unknown');
|
|
193
|
+
if (window.tokens + estimatedTokens > this.pluginOptions.maxTokens) {
|
|
194
|
+
throw new PluginError(`Token limit exceeded in fixed window. Current: ${window.tokens}, Estimated: ${estimatedTokens}, Max: ${this.pluginOptions.maxTokens}`, this.name, { currentTokens: window.tokens, estimatedTokens, maxTokens: this.pluginOptions.maxTokens });
|
|
195
|
+
}
|
|
196
|
+
if (window.count >= this.pluginOptions.maxRequests) {
|
|
197
|
+
throw new PluginError(`Request limit exceeded in fixed window. Current: ${window.count}, Max: ${this.pluginOptions.maxRequests}`, this.name, { currentRequests: window.count, maxRequests: this.pluginOptions.maxRequests });
|
|
198
|
+
}
|
|
199
|
+
if (window.cost + estimatedCost > this.pluginOptions.maxCost) {
|
|
200
|
+
throw new PluginError(`Cost limit exceeded in fixed window. Current: $${window.cost.toFixed(4)}, Estimated: $${estimatedCost.toFixed(4)}, Max: $${this.pluginOptions.maxCost}`, this.name, { currentCost: window.cost, estimatedCost, maxCost: this.pluginOptions.maxCost });
|
|
201
|
+
}
|
|
202
|
+
window.count++;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Update token bucket after execution
|
|
206
|
+
*/
|
|
207
|
+
updateTokenBucket(key, _tokensUsed, cost) {
|
|
208
|
+
const bucket = this.getBucket(key);
|
|
209
|
+
bucket.cost += cost;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update window after execution
|
|
213
|
+
*/
|
|
214
|
+
updateWindow(key, tokensUsed, cost) {
|
|
215
|
+
const window = this.getWindow(key);
|
|
216
|
+
window.tokens += tokensUsed;
|
|
217
|
+
window.cost += cost;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get or create token bucket for key
|
|
221
|
+
*/
|
|
222
|
+
getBucket(key) {
|
|
223
|
+
if (!this.buckets.has(key)) {
|
|
224
|
+
this.buckets.set(key, {
|
|
225
|
+
tokens: this.pluginOptions.bucketSize,
|
|
226
|
+
lastRefill: Date.now(),
|
|
227
|
+
requests: 0,
|
|
228
|
+
cost: 0,
|
|
229
|
+
windowStart: Date.now()
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return this.buckets.get(key);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get or create window for key
|
|
236
|
+
*/
|
|
237
|
+
getWindow(key) {
|
|
238
|
+
if (!this.windows.has(key)) {
|
|
239
|
+
this.windows.set(key, {
|
|
240
|
+
count: 0,
|
|
241
|
+
tokens: 0,
|
|
242
|
+
cost: 0,
|
|
243
|
+
windowStart: Date.now()
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return this.windows.get(key);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Generate key for rate limiting (user/session based)
|
|
250
|
+
*/
|
|
251
|
+
getKey(context) {
|
|
252
|
+
return context.userId || context.sessionId || context['executionId'] || 'default';
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Estimate tokens needed for request
|
|
256
|
+
*/
|
|
257
|
+
estimateTokens(context) {
|
|
258
|
+
// Simple estimation - in real implementation, this would be more sophisticated
|
|
259
|
+
const messageLength = context.messages?.reduce((total, msg) => total + (msg.content?.length || 0), 0) || 0;
|
|
260
|
+
// Rough estimation: 1 token per 4 characters
|
|
261
|
+
return Math.ceil(messageLength / 4) + 100; // Add some buffer
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Default cost calculator
|
|
265
|
+
*/
|
|
266
|
+
defaultCostCalculator(tokens, model) {
|
|
267
|
+
// Different models have different costs
|
|
268
|
+
const modelCosts = {
|
|
269
|
+
'gpt-4': 0.03,
|
|
270
|
+
'gpt-4-turbo': 0.01,
|
|
271
|
+
'gpt-3.5-turbo': 0.002,
|
|
272
|
+
'claude-3-opus': 0.015,
|
|
273
|
+
'claude-3-sonnet': 0.003,
|
|
274
|
+
'claude-3-haiku': 0.00025
|
|
275
|
+
};
|
|
276
|
+
const costPer1000 = modelCosts[model] || this.pluginOptions.tokenCostPer1000;
|
|
277
|
+
return (tokens / 1000) * costPer1000;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Validate plugin options
|
|
281
|
+
*/
|
|
282
|
+
validateOptions(options) {
|
|
283
|
+
if (options.strategy === 'none') {
|
|
284
|
+
this.logger.info('LimitsPlugin configured with "none" strategy - no rate limiting will be applied');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (!options.strategy) {
|
|
288
|
+
throw new PluginError('Strategy must be specified for limits plugin. Use "none" to disable rate limiting, or choose from: token-bucket, sliding-window, fixed-window', this.name, { availableStrategies: ['none', 'token-bucket', 'sliding-window', 'fixed-window'] });
|
|
289
|
+
}
|
|
290
|
+
const validStrategies = ['none', 'token-bucket', 'sliding-window', 'fixed-window'];
|
|
291
|
+
if (!validStrategies.includes(options.strategy)) {
|
|
292
|
+
throw new PluginError(`Invalid strategy "${options.strategy}". Must be one of: ${validStrategies.join(', ')}`, this.name, { provided: options.strategy, validStrategies });
|
|
293
|
+
}
|
|
294
|
+
// Token bucket strategy validation
|
|
295
|
+
if (options.strategy === 'token-bucket') {
|
|
296
|
+
if (options.bucketSize !== undefined && options.bucketSize <= 0) {
|
|
297
|
+
throw new PluginError('Bucket size must be positive for token-bucket strategy', this.name, { strategy: options.strategy, bucketSize: options.bucketSize });
|
|
298
|
+
}
|
|
299
|
+
if (options.refillRate !== undefined && options.refillRate < 0) {
|
|
300
|
+
throw new PluginError('Refill rate must be non-negative for token-bucket strategy', this.name, { strategy: options.strategy, refillRate: options.refillRate });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Sliding/Fixed window strategy validation
|
|
304
|
+
if (['sliding-window', 'fixed-window'].includes(options.strategy)) {
|
|
305
|
+
if (options.timeWindow !== undefined && options.timeWindow <= 0) {
|
|
306
|
+
throw new PluginError(`Time window must be positive for ${options.strategy} strategy`, this.name, { strategy: options.strategy, timeWindow: options.timeWindow });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Common validations for all strategies
|
|
310
|
+
if (options.maxRequests !== undefined && options.maxRequests < 0) {
|
|
311
|
+
throw new PluginError('Max requests must be non-negative', this.name, { strategy: options.strategy, maxRequests: options.maxRequests });
|
|
312
|
+
}
|
|
313
|
+
if (options.maxTokens !== undefined && options.maxTokens < 0) {
|
|
314
|
+
throw new PluginError('Max tokens must be non-negative', this.name, { strategy: options.strategy, maxTokens: options.maxTokens });
|
|
315
|
+
}
|
|
316
|
+
if (options.maxCost !== undefined && options.maxCost < 0) {
|
|
317
|
+
throw new PluginError('Max cost must be non-negative', this.name, { strategy: options.strategy, maxCost: options.maxCost });
|
|
318
|
+
}
|
|
319
|
+
if (options.tokenCostPer1000 !== undefined && options.tokenCostPer1000 < 0) {
|
|
320
|
+
throw new PluginError('Token cost per 1000 must be non-negative', this.name, { strategy: options.strategy, tokenCostPer1000: options.tokenCostPer1000 });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Get current limits status
|
|
325
|
+
*
|
|
326
|
+
* REASON: Limits status contains mixed data types (numbers, strings, arrays, objects) for comprehensive status reporting
|
|
327
|
+
* ALTERNATIVES_CONSIDERED:
|
|
328
|
+
* 1. Strict interface definitions (too rigid for dynamic status data)
|
|
329
|
+
* 2. Union types (becomes unwieldy for status reporting)
|
|
330
|
+
* 3. Generic constraints (too complex for status methods)
|
|
331
|
+
* 4. Separate status types (breaks existing functionality)
|
|
332
|
+
* 5. Type assertions (decreases type safety)
|
|
333
|
+
* TODO: Consider specific status interface if patterns emerge
|
|
334
|
+
*/
|
|
335
|
+
getLimitsStatus(key) {
|
|
336
|
+
if (key) {
|
|
337
|
+
const bucket = this.buckets.get(key);
|
|
338
|
+
const window = this.windows.get(key);
|
|
339
|
+
return {
|
|
340
|
+
strategy: this.pluginOptions.strategy,
|
|
341
|
+
key,
|
|
342
|
+
bucket: bucket ? {
|
|
343
|
+
availableTokens: Math.floor(bucket.tokens),
|
|
344
|
+
requests: bucket.requests,
|
|
345
|
+
cost: bucket.cost
|
|
346
|
+
} : null,
|
|
347
|
+
window: window ? {
|
|
348
|
+
count: window.count,
|
|
349
|
+
tokens: window.tokens,
|
|
350
|
+
cost: window.cost,
|
|
351
|
+
windowStart: window.windowStart
|
|
352
|
+
} : null
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
strategy: this.pluginOptions.strategy,
|
|
357
|
+
totalKeys: this.buckets.size + this.windows.size,
|
|
358
|
+
bucketKeys: Array.from(this.buckets.keys()),
|
|
359
|
+
windowKeys: Array.from(this.windows.keys())
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Reset limits for a key or all keys
|
|
364
|
+
*/
|
|
365
|
+
resetLimits(key) {
|
|
366
|
+
if (key) {
|
|
367
|
+
this.buckets.delete(key);
|
|
368
|
+
this.windows.delete(key);
|
|
369
|
+
this.requestCounts.delete(key);
|
|
370
|
+
this.logger.info('Limits reset for key', { key });
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.buckets.clear();
|
|
374
|
+
this.windows.clear();
|
|
375
|
+
this.requestCounts.clear();
|
|
376
|
+
this.logger.info('All limits reset');
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
//# sourceMappingURL=limits-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits-plugin.js","sourceRoot":"","sources":["../../src/plugins/limits-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EAGd,cAAc,EACd,cAAc,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA0C9C;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,cAAoC;IAClE,IAAI,GAAG,cAAc,CAAC;IACtB,OAAO,GAAG,OAAO,CAAC;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IAAI,CAAC,sBAAsB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ILogEntry, ILogFormatter } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default console formatter
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConsoleLogFormatter implements ILogFormatter {
|
|
6
|
+
format(entry: ILogEntry): string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* JSON formatter for file/remote logging
|
|
10
|
+
*/
|
|
11
|
+
export declare class JsonLogFormatter implements ILogFormatter {
|
|
12
|
+
format(entry: ILogEntry): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../src/plugins/logging/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD;;GAEG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACrD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;CAOnC;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAClD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;CAMnC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default console formatter
|
|
3
|
+
*/
|
|
4
|
+
export class ConsoleLogFormatter {
|
|
5
|
+
format(entry) {
|
|
6
|
+
const timestamp = entry.timestamp.toISOString();
|
|
7
|
+
const level = entry.level.toUpperCase().padStart(5);
|
|
8
|
+
const contextStr = entry.context ? ` | ${JSON.stringify(entry.context)}` : '';
|
|
9
|
+
const metadataStr = entry.metadata ? ` | ${JSON.stringify(entry.metadata)}` : '';
|
|
10
|
+
return `[${timestamp}] ${level} | ${entry.message}${contextStr}${metadataStr}`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* JSON formatter for file/remote logging
|
|
15
|
+
*/
|
|
16
|
+
export class JsonLogFormatter {
|
|
17
|
+
format(entry) {
|
|
18
|
+
return JSON.stringify({
|
|
19
|
+
...entry,
|
|
20
|
+
timestamp: entry.timestamp.toISOString()
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/plugins/logging/formatters.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC5B,MAAM,CAAC,KAAgB;QACnB,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO,IAAI,SAAS,KAAK,KAAK,MAAM,KAAK,CAAC,OAAO,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC;IACnF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB,MAAM,CAAC,KAAgB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC;YAClB,GAAG,KAAK;YACR,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE;SAC3C,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/logging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EACR,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACtB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/logging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { AbstractPlugin } from '../../abstracts/abstract-plugin';
|
|
2
|
+
import type { IEventEmitterEventData, TEventName } from '../event-emitter-plugin';
|
|
3
|
+
import { TLogLevel, ILogEntry, ILoggingPluginOptions, ILoggingPluginStats } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Logging context data - structured data for log entries
|
|
6
|
+
*/
|
|
7
|
+
export interface ILoggingContextData extends Record<string, string | number | boolean | Date | undefined> {
|
|
8
|
+
userInput?: string;
|
|
9
|
+
duration?: number;
|
|
10
|
+
toolName?: string;
|
|
11
|
+
success?: boolean;
|
|
12
|
+
executionId?: string;
|
|
13
|
+
operation?: string;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
errorStack?: string;
|
|
16
|
+
inputLength?: number;
|
|
17
|
+
responseLength?: number;
|
|
18
|
+
hasOptions?: boolean;
|
|
19
|
+
modelName?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Plugin for logging agent operations
|
|
23
|
+
* Supports multiple logging strategies: console, file, remote, silent
|
|
24
|
+
*/
|
|
25
|
+
export declare class LoggingPlugin extends AbstractPlugin<ILoggingPluginOptions, ILoggingPluginStats> {
|
|
26
|
+
name: string;
|
|
27
|
+
version: string;
|
|
28
|
+
private storage;
|
|
29
|
+
private pluginOptions;
|
|
30
|
+
private logger;
|
|
31
|
+
private simpleLogger;
|
|
32
|
+
private logLevels;
|
|
33
|
+
constructor(options: ILoggingPluginOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Handle module events for logging
|
|
36
|
+
*/
|
|
37
|
+
onModuleEvent(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Log a message
|
|
40
|
+
*/
|
|
41
|
+
log(level: TLogLevel, message: string, context?: ILoggingContextData, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Log debug message
|
|
44
|
+
*/
|
|
45
|
+
debug(message: string, context?: ILoggingContextData, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Log info message
|
|
48
|
+
*/
|
|
49
|
+
info(message: string, context?: ILoggingContextData, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Log warning message
|
|
52
|
+
*/
|
|
53
|
+
warn(message: string, context?: ILoggingContextData, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Log error message
|
|
56
|
+
*/
|
|
57
|
+
error(message: string, error?: Error, context?: ILoggingContextData, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Log execution start
|
|
60
|
+
*/
|
|
61
|
+
logExecutionStart(executionId: string, userInput: string, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Log execution completion
|
|
64
|
+
*/
|
|
65
|
+
logExecutionComplete(executionId: string, duration: number, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Log tool execution
|
|
68
|
+
*/
|
|
69
|
+
logToolExecution(toolName: string, executionId: string, duration?: number, success?: boolean, metadata?: ILogEntry['metadata']): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Flush any pending logs
|
|
72
|
+
*/
|
|
73
|
+
flush(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Cleanup resources
|
|
76
|
+
*/
|
|
77
|
+
destroy(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Check if message should be logged based on level
|
|
80
|
+
*/
|
|
81
|
+
private shouldLog;
|
|
82
|
+
/**
|
|
83
|
+
* Validate plugin options
|
|
84
|
+
*/
|
|
85
|
+
private validateOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Create storage instance based on strategy
|
|
88
|
+
*/
|
|
89
|
+
private createStorage;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=logging-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/logging/logging-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkC,MAAM,iCAAiC,CAAC;AAIjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,EACH,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EAGtB,MAAM,SAAS,CAAC;AAQjB;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IACrG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MA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