@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,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Abstract AI Provider Base Class
|
|
3
|
+
*
|
|
4
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
5
|
+
*
|
|
6
|
+
* Defines the shared contract and helper utilities for all AI provider implementations.
|
|
7
|
+
* Concrete providers should extend this class and inject their own dependencies.
|
|
8
|
+
*/
|
|
9
|
+
import type { IAIProvider, IToolSchema, IChatOptions, IProviderRequest, IRawProviderResponse } from '../interfaces/provider';
|
|
10
|
+
import type { IExecutor } from '../interfaces/executor';
|
|
11
|
+
import type { TUniversalMessage } from '../interfaces/messages';
|
|
12
|
+
import type { ILogger } from '../utils/logger';
|
|
13
|
+
/**
|
|
14
|
+
* Provider logging data type
|
|
15
|
+
* Used for storing logging information in provider operations
|
|
16
|
+
*/
|
|
17
|
+
export type TProviderLoggingData = Record<string, string | number | boolean | Date | string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Provider configuration base interface
|
|
20
|
+
*/
|
|
21
|
+
export interface IProviderConfig {
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
[key: string]: string | number | boolean | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enhanced provider configuration that supports executor injection
|
|
29
|
+
*/
|
|
30
|
+
export interface IExecutorAwareProviderConfig {
|
|
31
|
+
apiKey?: string;
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Optional executor for handling AI requests
|
|
36
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
37
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
38
|
+
*/
|
|
39
|
+
executor?: IExecutor;
|
|
40
|
+
[key: string]: string | number | boolean | IExecutor | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Base AI provider implementation with proper type constraints
|
|
44
|
+
* All AI providers should extend this class
|
|
45
|
+
*
|
|
46
|
+
* ========================================
|
|
47
|
+
* CRITICAL IMPLEMENTATION GUIDELINES
|
|
48
|
+
* ========================================
|
|
49
|
+
*
|
|
50
|
+
* ALL AI PROVIDER IMPLEMENTATIONS (OpenAI, Anthropic, Google, etc.) MUST:
|
|
51
|
+
*
|
|
52
|
+
* 1. EXTEND THIS CLASS:
|
|
53
|
+
* ```typescript
|
|
54
|
+
* export class OpenAIProvider extends AbstractAIProvider {
|
|
55
|
+
* override readonly name = 'openai';
|
|
56
|
+
* override readonly version = '1.0.0';
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* 2. USE IMPORTS FROM @robota-sdk/agents:
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { AbstractAIProvider } from '@robota-sdk/agents';
|
|
62
|
+
* import type {
|
|
63
|
+
* TUniversalMessage,
|
|
64
|
+
* ChatOptions,
|
|
65
|
+
* IToolCall,
|
|
66
|
+
* ToolSchema,
|
|
67
|
+
* AssistantMessage
|
|
68
|
+
* } from '@robota-sdk/agents';
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* 3. USE OVERRIDE KEYWORD FOR ALL INHERITED METHODS:
|
|
72
|
+
* - override async chat(...)
|
|
73
|
+
* - override async *chatStream(...)
|
|
74
|
+
* - override supportsTools()
|
|
75
|
+
* - override validateConfig()
|
|
76
|
+
* - override async dispose()
|
|
77
|
+
*
|
|
78
|
+
* 4. DO NOT REDEFINE TYPES THAT EXIST IN @robota-sdk/agents:
|
|
79
|
+
* - TUniversalMessage
|
|
80
|
+
* - ChatOptions
|
|
81
|
+
* - IToolCall
|
|
82
|
+
* - ToolSchema
|
|
83
|
+
* - AssistantMessage
|
|
84
|
+
* - SystemMessage
|
|
85
|
+
* - UserMessage
|
|
86
|
+
* - ToolMessage
|
|
87
|
+
*
|
|
88
|
+
* 5. HANDLE MESSAGE CONTENT PROPERLY:
|
|
89
|
+
* - For tool calls: content should be null (not empty string)
|
|
90
|
+
* - For regular messages: content can be string or null
|
|
91
|
+
* - Always preserve null values from API responses
|
|
92
|
+
*
|
|
93
|
+
* 6. CALL SUPER() IN CONSTRUCTOR:
|
|
94
|
+
* ```typescript
|
|
95
|
+
* constructor(options: IProviderOptions) {
|
|
96
|
+
* super();
|
|
97
|
+
* // provider-specific initialization
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* This ensures ExecutionService can properly identify providers
|
|
102
|
+
* and prevents type conflicts across the codebase.
|
|
103
|
+
*
|
|
104
|
+
* ========================================
|
|
105
|
+
*
|
|
106
|
+
* @template TConfig - Provider configuration type (defaults to IProviderConfig for type safety)
|
|
107
|
+
* @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
|
|
108
|
+
* @template TResponse - Response type (defaults to TUniversalMessage for backward compatibility)
|
|
109
|
+
*/
|
|
110
|
+
export declare abstract class AbstractAIProvider<TConfig = IProviderConfig> implements IAIProvider {
|
|
111
|
+
abstract readonly name: string;
|
|
112
|
+
abstract readonly version: string;
|
|
113
|
+
protected config?: TConfig;
|
|
114
|
+
protected executor?: IExecutor;
|
|
115
|
+
protected readonly logger: ILogger;
|
|
116
|
+
constructor(logger?: ILogger);
|
|
117
|
+
/**
|
|
118
|
+
* Configure the provider with type-safe configuration
|
|
119
|
+
*/
|
|
120
|
+
configure(config: TConfig): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Each provider must implement chat using their own native SDK types internally
|
|
123
|
+
* @param messages - Array of messages from conversation history
|
|
124
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
125
|
+
* @returns Promise resolving to a response
|
|
126
|
+
*/
|
|
127
|
+
abstract chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
128
|
+
/**
|
|
129
|
+
* Each provider must implement streaming chat using their own native SDK types internally
|
|
130
|
+
* @param messages - Array of messages from conversation history
|
|
131
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
132
|
+
* @returns AsyncIterable of response chunks
|
|
133
|
+
*/
|
|
134
|
+
abstract chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
135
|
+
/**
|
|
136
|
+
* Provider-agnostic raw response API.
|
|
137
|
+
*
|
|
138
|
+
* This is the canonical "raw payload" entrypoint required by the AIProvider contract.
|
|
139
|
+
* The default implementation delegates to `chat()` and adapts the result into a
|
|
140
|
+
* RawProviderResponse shape.
|
|
141
|
+
*/
|
|
142
|
+
generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* Provider-agnostic raw streaming API.
|
|
145
|
+
*
|
|
146
|
+
* If a provider does not implement chatStream, it does not support streaming.
|
|
147
|
+
*/
|
|
148
|
+
generateStreamingResponse(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
|
|
149
|
+
/**
|
|
150
|
+
* Default implementation - most modern providers support tools
|
|
151
|
+
* @returns true if tool calling is supported
|
|
152
|
+
*/
|
|
153
|
+
supportsTools(): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Default implementation - providers can override for specific validation
|
|
156
|
+
* @returns true if configuration is valid
|
|
157
|
+
*/
|
|
158
|
+
validateConfig(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Utility method for validating TUniversalMessage array
|
|
161
|
+
* @param messages - Messages to validate
|
|
162
|
+
*/
|
|
163
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
164
|
+
/**
|
|
165
|
+
* Utility method for validating tool schemas
|
|
166
|
+
* @param tools - Tool schemas to validate
|
|
167
|
+
*/
|
|
168
|
+
protected validateTools(tools?: IToolSchema[]): void;
|
|
169
|
+
/**
|
|
170
|
+
* Execute chat via executor.
|
|
171
|
+
*
|
|
172
|
+
* Subclasses should call this only when an executor is configured.
|
|
173
|
+
*/
|
|
174
|
+
protected executeViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
175
|
+
/**
|
|
176
|
+
* Execute streaming chat via executor.
|
|
177
|
+
*
|
|
178
|
+
* Subclasses should call this only when an executor is configured.
|
|
179
|
+
*/
|
|
180
|
+
protected executeStreamViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
181
|
+
/**
|
|
182
|
+
* Clean up resources when provider is no longer needed
|
|
183
|
+
* Override this method in subclasses for additional cleanup
|
|
184
|
+
*/
|
|
185
|
+
dispose(): Promise<void>;
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=abstract-ai-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-ai-provider.d.ts","sourceRoot":"","sources":["../../src/abstracts/abstract-ai-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC7H,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,MAAM,CAAC,EAAE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,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,iBAAiB,CAAC;IAE7G;;;;;;OAMG;IACG,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgBhF;;;;OAIG;IACI,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAAC,oBAAoB,CAAC;IAoBhG;;;OAGG;IACH,aAAa,IAAI,OAAO;IAIxB;;;OAGG;IACH,cAAc,IAAI,OAAO;IAMzB;;;OAGG;IACH,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAgB/D;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI;IAoBpD;;;;OAIG;cACa,0BAA0B,CACtC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,iBAAiB,CAAC;IAmB7B;;;;OAIG;cACc,gCAAgC,CAC7C,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,OAAO,CAAC,EAAE,YAAY,GACvB,aAAa,CAAC,iBAAiB,CAAC;IAmCnC;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAQjC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { isAssistantMessage } from '../interfaces/messages';
|
|
2
|
+
import { SilentLogger } from '../utils/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Base AI provider implementation with proper type constraints
|
|
5
|
+
* All AI providers should extend this class
|
|
6
|
+
*
|
|
7
|
+
* ========================================
|
|
8
|
+
* CRITICAL IMPLEMENTATION GUIDELINES
|
|
9
|
+
* ========================================
|
|
10
|
+
*
|
|
11
|
+
* ALL AI PROVIDER IMPLEMENTATIONS (OpenAI, Anthropic, Google, etc.) MUST:
|
|
12
|
+
*
|
|
13
|
+
* 1. EXTEND THIS CLASS:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* export class OpenAIProvider extends AbstractAIProvider {
|
|
16
|
+
* override readonly name = 'openai';
|
|
17
|
+
* override readonly version = '1.0.0';
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* 2. USE IMPORTS FROM @robota-sdk/agents:
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { AbstractAIProvider } from '@robota-sdk/agents';
|
|
23
|
+
* import type {
|
|
24
|
+
* TUniversalMessage,
|
|
25
|
+
* ChatOptions,
|
|
26
|
+
* IToolCall,
|
|
27
|
+
* ToolSchema,
|
|
28
|
+
* AssistantMessage
|
|
29
|
+
* } from '@robota-sdk/agents';
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* 3. USE OVERRIDE KEYWORD FOR ALL INHERITED METHODS:
|
|
33
|
+
* - override async chat(...)
|
|
34
|
+
* - override async *chatStream(...)
|
|
35
|
+
* - override supportsTools()
|
|
36
|
+
* - override validateConfig()
|
|
37
|
+
* - override async dispose()
|
|
38
|
+
*
|
|
39
|
+
* 4. DO NOT REDEFINE TYPES THAT EXIST IN @robota-sdk/agents:
|
|
40
|
+
* - TUniversalMessage
|
|
41
|
+
* - ChatOptions
|
|
42
|
+
* - IToolCall
|
|
43
|
+
* - ToolSchema
|
|
44
|
+
* - AssistantMessage
|
|
45
|
+
* - SystemMessage
|
|
46
|
+
* - UserMessage
|
|
47
|
+
* - ToolMessage
|
|
48
|
+
*
|
|
49
|
+
* 5. HANDLE MESSAGE CONTENT PROPERLY:
|
|
50
|
+
* - For tool calls: content should be null (not empty string)
|
|
51
|
+
* - For regular messages: content can be string or null
|
|
52
|
+
* - Always preserve null values from API responses
|
|
53
|
+
*
|
|
54
|
+
* 6. CALL SUPER() IN CONSTRUCTOR:
|
|
55
|
+
* ```typescript
|
|
56
|
+
* constructor(options: IProviderOptions) {
|
|
57
|
+
* super();
|
|
58
|
+
* // provider-specific initialization
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* This ensures ExecutionService can properly identify providers
|
|
63
|
+
* and prevents type conflicts across the codebase.
|
|
64
|
+
*
|
|
65
|
+
* ========================================
|
|
66
|
+
*
|
|
67
|
+
* @template TConfig - Provider configuration type (defaults to IProviderConfig for type safety)
|
|
68
|
+
* @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
|
|
69
|
+
* @template TResponse - Response type (defaults to TUniversalMessage for backward compatibility)
|
|
70
|
+
*/
|
|
71
|
+
export class AbstractAIProvider {
|
|
72
|
+
config;
|
|
73
|
+
executor;
|
|
74
|
+
logger;
|
|
75
|
+
constructor(logger = SilentLogger) {
|
|
76
|
+
this.logger = logger;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Configure the provider with type-safe configuration
|
|
80
|
+
*/
|
|
81
|
+
async configure(config) {
|
|
82
|
+
this.config = config;
|
|
83
|
+
// Check if config includes executor and set it
|
|
84
|
+
if (config && typeof config === 'object' && 'executor' in config && config.executor) {
|
|
85
|
+
this.executor = config.executor;
|
|
86
|
+
}
|
|
87
|
+
// Subclasses can override for additional setup
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Provider-agnostic raw response API.
|
|
91
|
+
*
|
|
92
|
+
* This is the canonical "raw payload" entrypoint required by the AIProvider contract.
|
|
93
|
+
* The default implementation delegates to `chat()` and adapts the result into a
|
|
94
|
+
* RawProviderResponse shape.
|
|
95
|
+
*/
|
|
96
|
+
async generateResponse(payload) {
|
|
97
|
+
const response = await this.chat(payload.messages, {
|
|
98
|
+
...(payload.model !== undefined && { model: payload.model }),
|
|
99
|
+
...(payload.temperature !== undefined && { temperature: payload.temperature }),
|
|
100
|
+
...(payload.maxTokens !== undefined && { maxTokens: payload.maxTokens }),
|
|
101
|
+
...(payload.tools !== undefined && { tools: payload.tools })
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
content: response.content ?? null,
|
|
105
|
+
toolCalls: isAssistantMessage(response) ? response.toolCalls : undefined,
|
|
106
|
+
model: payload.model,
|
|
107
|
+
metadata: payload.metadata
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Provider-agnostic raw streaming API.
|
|
112
|
+
*
|
|
113
|
+
* If a provider does not implement chatStream, it does not support streaming.
|
|
114
|
+
*/
|
|
115
|
+
async *generateStreamingResponse(payload) {
|
|
116
|
+
if (!this.chatStream) {
|
|
117
|
+
throw new Error(`[AI-PROVIDER] Streaming is not supported by provider "${this.name}"`);
|
|
118
|
+
}
|
|
119
|
+
for await (const chunk of this.chatStream(payload.messages, {
|
|
120
|
+
...(payload.model !== undefined && { model: payload.model }),
|
|
121
|
+
...(payload.temperature !== undefined && { temperature: payload.temperature }),
|
|
122
|
+
...(payload.maxTokens !== undefined && { maxTokens: payload.maxTokens }),
|
|
123
|
+
...(payload.tools !== undefined && { tools: payload.tools })
|
|
124
|
+
})) {
|
|
125
|
+
yield {
|
|
126
|
+
content: chunk.content ?? null,
|
|
127
|
+
toolCalls: isAssistantMessage(chunk) ? chunk.toolCalls : undefined,
|
|
128
|
+
model: payload.model,
|
|
129
|
+
metadata: payload.metadata
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Default implementation - most modern providers support tools
|
|
135
|
+
* @returns true if tool calling is supported
|
|
136
|
+
*/
|
|
137
|
+
supportsTools() {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Default implementation - providers can override for specific validation
|
|
142
|
+
* @returns true if configuration is valid
|
|
143
|
+
*/
|
|
144
|
+
validateConfig() {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Utility method for validating TUniversalMessage array
|
|
149
|
+
* @param messages - Messages to validate
|
|
150
|
+
*/
|
|
151
|
+
validateMessages(messages) {
|
|
152
|
+
if (!Array.isArray(messages)) {
|
|
153
|
+
throw new Error('Messages must be an array');
|
|
154
|
+
}
|
|
155
|
+
if (messages.length === 0) {
|
|
156
|
+
throw new Error('Messages array cannot be empty');
|
|
157
|
+
}
|
|
158
|
+
for (const message of messages) {
|
|
159
|
+
if (!message.role || !['user', 'assistant', 'system', 'tool'].includes(message.role)) {
|
|
160
|
+
throw new Error(`Invalid message role: ${message.role}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Utility method for validating tool schemas
|
|
166
|
+
* @param tools - Tool schemas to validate
|
|
167
|
+
*/
|
|
168
|
+
validateTools(tools) {
|
|
169
|
+
if (!tools)
|
|
170
|
+
return;
|
|
171
|
+
if (!Array.isArray(tools)) {
|
|
172
|
+
throw new Error('Tools must be an array');
|
|
173
|
+
}
|
|
174
|
+
for (const tool of tools) {
|
|
175
|
+
if (!tool.name || typeof tool.name !== 'string') {
|
|
176
|
+
throw new Error('Tool must have a valid name');
|
|
177
|
+
}
|
|
178
|
+
if (!tool.description || typeof tool.description !== 'string') {
|
|
179
|
+
throw new Error('Tool must have a valid description');
|
|
180
|
+
}
|
|
181
|
+
if (!tool.parameters || typeof tool.parameters !== 'object' || tool.parameters === null || Array.isArray(tool.parameters)) {
|
|
182
|
+
throw new Error('Tool must have valid parameters');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Execute chat via executor.
|
|
188
|
+
*
|
|
189
|
+
* Subclasses should call this only when an executor is configured.
|
|
190
|
+
*/
|
|
191
|
+
async executeViaExecutorOrDirect(messages, options) {
|
|
192
|
+
if (!this.executor) {
|
|
193
|
+
throw new Error(`Executor is required for ${this.name} provider. Configure an executor or use direct execution path.`);
|
|
194
|
+
}
|
|
195
|
+
if (!options?.model) {
|
|
196
|
+
throw new Error(`Model is required for executor execution in ${this.name} provider.`);
|
|
197
|
+
}
|
|
198
|
+
const result = await this.executor.executeChat({
|
|
199
|
+
messages,
|
|
200
|
+
options,
|
|
201
|
+
provider: this.name,
|
|
202
|
+
model: options.model,
|
|
203
|
+
...(options.tools && { tools: options.tools })
|
|
204
|
+
});
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Execute streaming chat via executor.
|
|
209
|
+
*
|
|
210
|
+
* Subclasses should call this only when an executor is configured.
|
|
211
|
+
*/
|
|
212
|
+
async *executeStreamViaExecutorOrDirect(messages, options) {
|
|
213
|
+
if (!this.executor || !this.executor.executeChatStream) {
|
|
214
|
+
throw new Error(`Streaming executor is required for ${this.name} provider.`);
|
|
215
|
+
}
|
|
216
|
+
if (!options?.model) {
|
|
217
|
+
throw new Error(`Model is required for executor streaming in ${this.name} provider.`);
|
|
218
|
+
}
|
|
219
|
+
// 🔍 [TOOL-FLOW] AbstractAIProvider.executeStreamViaExecutorOrDirect() - Preparing executor request
|
|
220
|
+
this.logger.debug?.('🔍 [TOOL-FLOW] AbstractAIProvider.executeStreamViaExecutorOrDirect() - Executor request', {
|
|
221
|
+
provider: this.name,
|
|
222
|
+
model: options.model,
|
|
223
|
+
hasTools: !!options.tools,
|
|
224
|
+
toolsCount: options.tools?.length || 0,
|
|
225
|
+
toolNames: options.tools?.map((t) => t.name) || []
|
|
226
|
+
});
|
|
227
|
+
const stream = this.executor.executeChatStream({
|
|
228
|
+
messages,
|
|
229
|
+
options,
|
|
230
|
+
provider: this.name,
|
|
231
|
+
model: options.model,
|
|
232
|
+
stream: true,
|
|
233
|
+
...(options.tools && { tools: options.tools })
|
|
234
|
+
});
|
|
235
|
+
for await (const chunk of stream) {
|
|
236
|
+
yield chunk;
|
|
237
|
+
}
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Clean up resources when provider is no longer needed
|
|
242
|
+
* Override this method in subclasses for additional cleanup
|
|
243
|
+
*/
|
|
244
|
+
async dispose() {
|
|
245
|
+
// Clean up executor if present
|
|
246
|
+
if (this.executor?.dispose) {
|
|
247
|
+
await this.executor.dispose();
|
|
248
|
+
}
|
|
249
|
+
// Subclasses can override for additional cleanup
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=abstract-ai-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-ai-provider.js","sourceRoot":"","sources":["../../src/abstracts/abstract-ai-provider.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAkC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,OAAgB,kBAAkB;IAI1B,MAAM,CAAW;IACjB,QAAQ,CAAa;IACZ,MAAM,CAAU;IAEnC,YAAY,SAAkB,YAAY;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;GAED;IACC,KAAK,CAAC,SAAS,CAAC,MAAe;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,+CAA+C;QAC/C,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,UAAU,IAAI,MAAM,IAAK,MAAc,CAAC,QAAQ,EAAE,CAAC;YAC3F,IAAI,CAAC,QAAQ,GAAI,MAAc,CAAC,QAAqB,CAAC;QAC1D,CAAC;QAED,+CAA+C;IACnD,CAAC;IAkBD;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB,CAAC,OAAyB;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAC/C,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;YAC5D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,WA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,KAAK,CAAC,OAAO;QACT,+BAA+B;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QAED,iDAAiD;IACrD,CAAC;CACJ"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { IExecutor, IChatExecutionRequest, IStreamExecutionRequest } from '../interfaces/executor';
|
|
2
|
+
import type { TUniversalMessage, IAssistantMessage } from '../interfaces/messages';
|
|
3
|
+
import type { TLoggerData } from '../interfaces/types';
|
|
4
|
+
import type { ILogger } from '../utils/logger';
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview Abstract Executor Base Class
|
|
7
|
+
*
|
|
8
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
9
|
+
*
|
|
10
|
+
* Provides shared execution helpers (retry, timeout, validation, logging) for all
|
|
11
|
+
* executor implementations. Concrete executors should extend this class and inject
|
|
12
|
+
* their own logger implementation if they need custom logging behavior.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* export class MyCustomExecutor extends AbstractExecutor {
|
|
17
|
+
* async executeChat(request: IChatExecutionRequest): Promise<AssistantMessage> {
|
|
18
|
+
* return this.withRetry(() => this.performChat(request));
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare abstract class AbstractExecutor implements IExecutor {
|
|
24
|
+
/**
|
|
25
|
+
* Logger injected via constructor (defaults to abstract logger)
|
|
26
|
+
*/
|
|
27
|
+
protected readonly logger: ILogger;
|
|
28
|
+
constructor(logger?: ILogger);
|
|
29
|
+
abstract readonly name: string;
|
|
30
|
+
abstract readonly version: string;
|
|
31
|
+
/**
|
|
32
|
+
* Execute a chat completion request
|
|
33
|
+
* Must be implemented by concrete executor classes
|
|
34
|
+
*/
|
|
35
|
+
abstract executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
|
|
36
|
+
/**
|
|
37
|
+
* Execute a streaming chat completion request
|
|
38
|
+
* Optional - can be implemented by concrete executor classes
|
|
39
|
+
*/
|
|
40
|
+
abstract executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the executor supports tool calling
|
|
43
|
+
* Default implementation returns false, can be overridden
|
|
44
|
+
*/
|
|
45
|
+
supportsTools(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Validate executor configuration
|
|
48
|
+
* Default implementation returns true, can be overridden
|
|
49
|
+
*/
|
|
50
|
+
validateConfig(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Clean up resources when executor is no longer needed
|
|
53
|
+
* Default implementation does nothing, can be overridden
|
|
54
|
+
*/
|
|
55
|
+
dispose?(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Execute function with retry logic
|
|
58
|
+
*
|
|
59
|
+
* @param fn - Function to execute with retries
|
|
60
|
+
* @param maxRetries - Maximum number of retry attempts (default: 3)
|
|
61
|
+
* @param retryDelay - Delay between retries in milliseconds (default: 1000)
|
|
62
|
+
* @returns Promise resolving to function result
|
|
63
|
+
*/
|
|
64
|
+
protected withRetry<T>(fn: () => Promise<T>, maxRetries?: number, retryDelay?: number): Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute function with timeout
|
|
67
|
+
*
|
|
68
|
+
* @param promise - Promise to execute with timeout
|
|
69
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
70
|
+
* @returns Promise resolving to function result
|
|
71
|
+
*/
|
|
72
|
+
protected withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Delay execution for specified milliseconds
|
|
75
|
+
*
|
|
76
|
+
* @param ms - Milliseconds to delay
|
|
77
|
+
* @returns Promise that resolves after the delay
|
|
78
|
+
*/
|
|
79
|
+
protected delay(ms: number): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Log debug information (only if logging is enabled)
|
|
82
|
+
*
|
|
83
|
+
* @param message - Log message
|
|
84
|
+
* @param data - Optional data to log
|
|
85
|
+
*/
|
|
86
|
+
protected logDebug(message: string, data?: TLoggerData): void;
|
|
87
|
+
/**
|
|
88
|
+
* Log error information
|
|
89
|
+
*
|
|
90
|
+
* @param message - Log message
|
|
91
|
+
* @param error - Error object
|
|
92
|
+
* @param data - Optional additional data
|
|
93
|
+
*/
|
|
94
|
+
protected logError(message: string, error: Error, data?: TLoggerData): void;
|
|
95
|
+
/**
|
|
96
|
+
* Validate that request has required fields
|
|
97
|
+
*
|
|
98
|
+
* @param request - Chat execution request to validate
|
|
99
|
+
* @throws Error if validation fails
|
|
100
|
+
*/
|
|
101
|
+
protected validateRequest(request: IChatExecutionRequest): void;
|
|
102
|
+
/**
|
|
103
|
+
* Validate that response is properly formatted
|
|
104
|
+
*
|
|
105
|
+
* @param response - Response to validate
|
|
106
|
+
* @throws Error if validation fails
|
|
107
|
+
*/
|
|
108
|
+
protected validateResponse(response: TUniversalMessage): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=abstract-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-executor.d.ts","sourceRoot":"","sources":["../../src/abstracts/abstract-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;;;;;;;;;;;;;;;;GAiBG;AACH,8BAAsB,gBAAiB,YAAW,SAAS;IACvD;;OAEG;IAC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