@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,4237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Contracts (Single Source of Truth)
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT:
|
|
5
|
+
* - This module is owned by the `interfaces` layer.
|
|
6
|
+
* - All message types used across the SDK must be defined here to avoid drift.
|
|
7
|
+
* - Runtime values (variables/classes/objects) and compile-time types can share the same name in TypeScript.
|
|
8
|
+
* Prefixing type aliases (`T*`) and interfaces (`I*`) reduces value/type name collision risk and review overhead.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Universal message role type - provider-independent neutral role.
|
|
12
|
+
*/
|
|
13
|
+
type TUniversalMessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
14
|
+
/**
|
|
15
|
+
* Message metadata used across conversation history and provider adapters.
|
|
16
|
+
*/
|
|
17
|
+
type TUniversalMessageMetadata = Record<string, string | number | boolean | Date | string[] | number[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Universal multimodal message part contracts.
|
|
20
|
+
*/
|
|
21
|
+
interface ITextMessagePart {
|
|
22
|
+
type: 'text';
|
|
23
|
+
text: string;
|
|
24
|
+
}
|
|
25
|
+
interface IInlineImageMessagePart {
|
|
26
|
+
type: 'image_inline';
|
|
27
|
+
mimeType: string;
|
|
28
|
+
data: string;
|
|
29
|
+
}
|
|
30
|
+
interface IUriImageMessagePart {
|
|
31
|
+
type: 'image_uri';
|
|
32
|
+
uri: string;
|
|
33
|
+
mimeType?: string;
|
|
34
|
+
}
|
|
35
|
+
type TUniversalMessagePart = ITextMessagePart | IInlineImageMessagePart | IUriImageMessagePart;
|
|
36
|
+
/**
|
|
37
|
+
* Tool call (OpenAI tool calling format).
|
|
38
|
+
*/
|
|
39
|
+
interface IToolCall {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'function';
|
|
42
|
+
function: {
|
|
43
|
+
name: string;
|
|
44
|
+
arguments: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Base message contract shared by all message variants.
|
|
49
|
+
*/
|
|
50
|
+
interface IBaseMessage {
|
|
51
|
+
/** Message creation timestamp */
|
|
52
|
+
timestamp: Date;
|
|
53
|
+
/** Additional metadata */
|
|
54
|
+
metadata?: TUniversalMessageMetadata;
|
|
55
|
+
}
|
|
56
|
+
interface IUserMessage extends IBaseMessage {
|
|
57
|
+
role: 'user';
|
|
58
|
+
content: string;
|
|
59
|
+
parts?: TUniversalMessagePart[];
|
|
60
|
+
name?: string;
|
|
61
|
+
}
|
|
62
|
+
interface IAssistantMessage extends IBaseMessage {
|
|
63
|
+
role: 'assistant';
|
|
64
|
+
/** Assistant response content (can be null when making tool calls) */
|
|
65
|
+
content: string | null;
|
|
66
|
+
parts?: TUniversalMessagePart[];
|
|
67
|
+
toolCalls?: IToolCall[];
|
|
68
|
+
}
|
|
69
|
+
interface ISystemMessage extends IBaseMessage {
|
|
70
|
+
role: 'system';
|
|
71
|
+
content: string;
|
|
72
|
+
parts?: TUniversalMessagePart[];
|
|
73
|
+
name?: string;
|
|
74
|
+
}
|
|
75
|
+
interface IToolMessage extends IBaseMessage {
|
|
76
|
+
role: 'tool';
|
|
77
|
+
content: string;
|
|
78
|
+
parts?: TUniversalMessagePart[];
|
|
79
|
+
toolCallId: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Universal message union used across the SDK as the canonical contract.
|
|
84
|
+
*/
|
|
85
|
+
type TUniversalMessage = IUserMessage | IAssistantMessage | ISystemMessage | IToolMessage;
|
|
86
|
+
/**
|
|
87
|
+
* Type guards for the canonical TUniversalMessage union.
|
|
88
|
+
*
|
|
89
|
+
* NOTE:
|
|
90
|
+
* - These guards are owned by the `interfaces` layer and must not depend on managers/services.
|
|
91
|
+
* - Call sites should use these guards instead of importing from manager layers.
|
|
92
|
+
*/
|
|
93
|
+
declare function isUserMessage(message: TUniversalMessage): message is IUserMessage;
|
|
94
|
+
declare function isAssistantMessage(message: TUniversalMessage): message is IAssistantMessage;
|
|
95
|
+
declare function isSystemMessage(message: TUniversalMessage): message is ISystemMessage;
|
|
96
|
+
declare function isToolMessage(message: TUniversalMessage): message is IToolMessage;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Agent-specific type definitions
|
|
100
|
+
* Local types for agent functionality - not forced to use base types unless needed for cross-connections
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Primitive value types - foundation for all other types
|
|
105
|
+
* Extended to include null/undefined for agent contexts
|
|
106
|
+
*/
|
|
107
|
+
type TPrimitiveValue = string | number | boolean | null | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Universal value type axis (recursive, JSON-like + Date).
|
|
110
|
+
*
|
|
111
|
+
* IMPORTANT:
|
|
112
|
+
* - This axis is the single source of truth for payload/context/result values.
|
|
113
|
+
* - It must support nested objects/arrays without `any`/`unknown`.
|
|
114
|
+
*/
|
|
115
|
+
type TUniversalValue = TPrimitiveValue | Date | TUniversalArrayValue | IUniversalObjectValue;
|
|
116
|
+
type TUniversalArrayValue = TUniversalValue[];
|
|
117
|
+
interface IUniversalObjectValue {
|
|
118
|
+
[key: string]: TUniversalValue;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Metadata type - consistent across agent components
|
|
122
|
+
*/
|
|
123
|
+
type TMetadataValue = TPrimitiveValue | TUniversalArrayValue | Date;
|
|
124
|
+
type TMetadata = Record<string, TMetadataValue>;
|
|
125
|
+
/**
|
|
126
|
+
* Context data type - for execution contexts
|
|
127
|
+
*/
|
|
128
|
+
type TContextData = Record<string, TUniversalValue>;
|
|
129
|
+
/**
|
|
130
|
+
* Logger data type - for logging contexts
|
|
131
|
+
*/
|
|
132
|
+
type TLoggerData = Record<string, TUniversalValue | Date | Error>;
|
|
133
|
+
/**
|
|
134
|
+
* Configuration types - for agent configuration
|
|
135
|
+
*/
|
|
136
|
+
type TComplexConfigValue = Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>;
|
|
137
|
+
type TConfigValue = TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue | Array<TComplexConfigValue> | Array<Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>> | Array<TComplexConfigValue> | TComplexConfigValue;
|
|
138
|
+
type TConfigData = Record<string, TConfigValue>;
|
|
139
|
+
/**
|
|
140
|
+
* Tool parameter value type - specific for tool parameters
|
|
141
|
+
*/
|
|
142
|
+
type TToolParameters = Record<string, TUniversalValue>;
|
|
143
|
+
/**
|
|
144
|
+
* Tool result data type - for tool execution results
|
|
145
|
+
*/
|
|
146
|
+
/**
|
|
147
|
+
* Plugin context type - for plugin execution contexts
|
|
148
|
+
*/
|
|
149
|
+
interface IPluginContext {
|
|
150
|
+
input?: string;
|
|
151
|
+
response?: string;
|
|
152
|
+
messages?: TUniversalMessage[];
|
|
153
|
+
responseMessage?: TUniversalMessage;
|
|
154
|
+
metadata?: TMetadata;
|
|
155
|
+
error?: Error;
|
|
156
|
+
executionContext?: TContextData;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Reusable type definitions for provider layer
|
|
161
|
+
*/
|
|
162
|
+
/**
|
|
163
|
+
* Provider configuration value type
|
|
164
|
+
* Used for storing provider-specific configuration values
|
|
165
|
+
*/
|
|
166
|
+
type TProviderConfigValue = string | number | boolean;
|
|
167
|
+
/**
|
|
168
|
+
* JSON Schema parameter default value type
|
|
169
|
+
* Used for default values in parameter schemas
|
|
170
|
+
*/
|
|
171
|
+
type TParameterDefaultValue = string | number | boolean | null;
|
|
172
|
+
/**
|
|
173
|
+
* JSON Schema primitive types
|
|
174
|
+
*/
|
|
175
|
+
type TJSONSchemaKind = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
|
|
176
|
+
/**
|
|
177
|
+
* JSON Schema enum values
|
|
178
|
+
*/
|
|
179
|
+
type TJSONSchemaEnum = string[] | number[] | boolean[] | (string | number | boolean)[];
|
|
180
|
+
/**
|
|
181
|
+
* Tool schema definition
|
|
182
|
+
*/
|
|
183
|
+
interface IToolSchema {
|
|
184
|
+
name: string;
|
|
185
|
+
description: string;
|
|
186
|
+
parameters: {
|
|
187
|
+
type: 'object';
|
|
188
|
+
properties: Record<string, IParameterSchema>;
|
|
189
|
+
required?: string[];
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Parameter schema for tools
|
|
194
|
+
*/
|
|
195
|
+
interface IParameterSchema {
|
|
196
|
+
type: TJSONSchemaKind;
|
|
197
|
+
description?: string;
|
|
198
|
+
enum?: TJSONSchemaEnum;
|
|
199
|
+
items?: IParameterSchema;
|
|
200
|
+
properties?: Record<string, IParameterSchema>;
|
|
201
|
+
minimum?: number;
|
|
202
|
+
maximum?: number;
|
|
203
|
+
pattern?: string;
|
|
204
|
+
format?: string;
|
|
205
|
+
default?: TParameterDefaultValue;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Token usage statistics
|
|
209
|
+
*/
|
|
210
|
+
interface ITokenUsage {
|
|
211
|
+
promptTokens: number;
|
|
212
|
+
completionTokens: number;
|
|
213
|
+
totalTokens: number;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Raw provider response interface
|
|
217
|
+
*/
|
|
218
|
+
interface IRawProviderResponse {
|
|
219
|
+
content: string | null;
|
|
220
|
+
toolCalls?: IToolCall[];
|
|
221
|
+
usage?: ITokenUsage;
|
|
222
|
+
finishReason?: string;
|
|
223
|
+
model?: string;
|
|
224
|
+
metadata?: Record<string, TProviderConfigValue>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Provider request payload
|
|
228
|
+
*/
|
|
229
|
+
interface IProviderRequest {
|
|
230
|
+
messages: TUniversalMessage[];
|
|
231
|
+
model?: string;
|
|
232
|
+
temperature?: number;
|
|
233
|
+
maxTokens?: number;
|
|
234
|
+
tools?: IToolSchema[];
|
|
235
|
+
systemMessage?: string;
|
|
236
|
+
metadata?: Record<string, string | number | boolean>;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Provider-specific configuration options
|
|
240
|
+
*/
|
|
241
|
+
interface IProviderSpecificOptions {
|
|
242
|
+
/** OpenAI specific options */
|
|
243
|
+
openai?: {
|
|
244
|
+
organization?: string;
|
|
245
|
+
user?: string;
|
|
246
|
+
stop?: string | string[];
|
|
247
|
+
presencePenalty?: number;
|
|
248
|
+
frequencyPenalty?: number;
|
|
249
|
+
logitBias?: Record<string, number>;
|
|
250
|
+
topP?: number;
|
|
251
|
+
n?: number;
|
|
252
|
+
stream?: boolean;
|
|
253
|
+
suffix?: string;
|
|
254
|
+
echo?: boolean;
|
|
255
|
+
bestOf?: number;
|
|
256
|
+
logprobs?: number;
|
|
257
|
+
};
|
|
258
|
+
/** Anthropic specific options */
|
|
259
|
+
anthropic?: {
|
|
260
|
+
stopSequences?: string[];
|
|
261
|
+
topP?: number;
|
|
262
|
+
topK?: number;
|
|
263
|
+
metadata?: {
|
|
264
|
+
userId?: string;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
/** Google specific options */
|
|
268
|
+
google?: {
|
|
269
|
+
candidateCount?: number;
|
|
270
|
+
stopSequences?: string[];
|
|
271
|
+
safetySettings?: Array<{
|
|
272
|
+
category: string;
|
|
273
|
+
threshold: string;
|
|
274
|
+
}>;
|
|
275
|
+
responseModalities?: Array<'TEXT' | 'IMAGE'>;
|
|
276
|
+
topP?: number;
|
|
277
|
+
topK?: number;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Callback for receiving text deltas during streaming.
|
|
282
|
+
* Called for each text chunk as the model generates output.
|
|
283
|
+
*/
|
|
284
|
+
type TTextDeltaCallback = (delta: string) => void;
|
|
285
|
+
/**
|
|
286
|
+
* Options for AI provider chat requests
|
|
287
|
+
*/
|
|
288
|
+
interface IChatOptions extends IProviderSpecificOptions {
|
|
289
|
+
/** Tool schemas to provide to the AI provider */
|
|
290
|
+
tools?: IToolSchema[];
|
|
291
|
+
/** Maximum number of tokens to generate */
|
|
292
|
+
maxTokens?: number;
|
|
293
|
+
/** Temperature for response randomness (0-1) */
|
|
294
|
+
temperature?: number;
|
|
295
|
+
/** Model to use for the request */
|
|
296
|
+
model?: string;
|
|
297
|
+
/** Callback for text deltas during streaming. When provided, the provider
|
|
298
|
+
* should use streaming internally and call this for each text chunk,
|
|
299
|
+
* while still returning the complete assembled message. */
|
|
300
|
+
onTextDelta?: TTextDeltaCallback;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Provider-agnostic AI Provider interface
|
|
304
|
+
* This interface uses only TUniversalMessage types and avoids provider-specific types
|
|
305
|
+
*/
|
|
306
|
+
interface IAIProvider {
|
|
307
|
+
/** Provider identifier */
|
|
308
|
+
readonly name: string;
|
|
309
|
+
/** Provider version */
|
|
310
|
+
readonly version: string;
|
|
311
|
+
/**
|
|
312
|
+
* Generate response from AI model using TUniversalMessage
|
|
313
|
+
* @param messages - Array of TUniversalMessage from conversation history
|
|
314
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
315
|
+
* @returns Promise resolving to a TUniversalMessage response
|
|
316
|
+
*/
|
|
317
|
+
chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
318
|
+
/**
|
|
319
|
+
* Generate streaming response from AI model using TUniversalMessage
|
|
320
|
+
* @param messages - Array of TUniversalMessage from conversation history
|
|
321
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
322
|
+
* @returns AsyncIterable of TUniversalMessage chunks
|
|
323
|
+
*/
|
|
324
|
+
chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
325
|
+
/**
|
|
326
|
+
* Generate response from AI model (raw provider response)
|
|
327
|
+
* @param payload - Provider request payload
|
|
328
|
+
* @returns Promise resolving to raw provider response
|
|
329
|
+
*/
|
|
330
|
+
generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
|
|
331
|
+
/**
|
|
332
|
+
* Generate streaming response from AI model (raw provider response)
|
|
333
|
+
* @param payload - Provider request payload
|
|
334
|
+
* @returns AsyncIterable of raw provider response chunks
|
|
335
|
+
*/
|
|
336
|
+
generateStreamingResponse?(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
|
|
337
|
+
/**
|
|
338
|
+
* Check if the provider supports tool calling
|
|
339
|
+
* @returns true if tool calling is supported
|
|
340
|
+
*/
|
|
341
|
+
supportsTools(): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Validate provider configuration
|
|
344
|
+
* @returns true if configuration is valid
|
|
345
|
+
*/
|
|
346
|
+
validateConfig(): boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Clean up resources when provider is no longer needed
|
|
349
|
+
*/
|
|
350
|
+
dispose?(): Promise<void>;
|
|
351
|
+
/**
|
|
352
|
+
* Close provider connections and cleanup resources
|
|
353
|
+
*/
|
|
354
|
+
close?(): Promise<void>;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Provider options interface
|
|
358
|
+
*/
|
|
359
|
+
interface IProviderOptions {
|
|
360
|
+
apiKey?: string;
|
|
361
|
+
baseURL?: string;
|
|
362
|
+
timeout?: number;
|
|
363
|
+
retries?: number;
|
|
364
|
+
maxConcurrentRequests?: number;
|
|
365
|
+
defaultModel?: string;
|
|
366
|
+
organization?: string;
|
|
367
|
+
project?: string;
|
|
368
|
+
/** Additional provider-specific configuration */
|
|
369
|
+
extra?: Record<string, TProviderConfigValue>;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Base union for provider option values.
|
|
373
|
+
*
|
|
374
|
+
* Purpose:
|
|
375
|
+
* - Enable provider packages to compose their own option value unions without redefining the primitives.
|
|
376
|
+
* - Keep the shared axis in @robota-sdk/agent-core (SSOT).
|
|
377
|
+
*
|
|
378
|
+
* Note:
|
|
379
|
+
* - Provider packages may extend this with provider-specific runtime objects (e.g., OpenAI/Anthropic clients).
|
|
380
|
+
*/
|
|
381
|
+
type TProviderOptionValueBase = string | number | boolean | undefined | null | TProviderOptionValueBase[] | {
|
|
382
|
+
[key: string]: TProviderOptionValueBase;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* @fileoverview Event service interface definitions.
|
|
387
|
+
*
|
|
388
|
+
* These interfaces are the single source of truth for event-related contracts
|
|
389
|
+
* within @robota-sdk/agent-core.
|
|
390
|
+
*/
|
|
391
|
+
/**
|
|
392
|
+
* Primitive value types for event payloads.
|
|
393
|
+
*/
|
|
394
|
+
type TEventPrimitiveValue = string | number | boolean | null | undefined;
|
|
395
|
+
/**
|
|
396
|
+
* Recursive universal value type for event payloads (JSON-like + Date).
|
|
397
|
+
*/
|
|
398
|
+
type TEventUniversalValue = TEventPrimitiveValue | Date | TEventUniversalValue[] | IEventObjectValue;
|
|
399
|
+
interface IEventObjectValue {
|
|
400
|
+
[key: string]: TEventUniversalValue;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Logger data type for event metadata.
|
|
404
|
+
*/
|
|
405
|
+
type TEventLoggerData = Record<string, TEventUniversalValue | Date | Error>;
|
|
406
|
+
/**
|
|
407
|
+
* A single segment in an explicit ownerPath.
|
|
408
|
+
*
|
|
409
|
+
* Path-only rule:
|
|
410
|
+
* - Relationships must be derived from these explicit segments, not from parsing IDs.
|
|
411
|
+
*/
|
|
412
|
+
interface IOwnerPathSegment {
|
|
413
|
+
type: string;
|
|
414
|
+
id: string;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Event context that accompanies an emitted event.
|
|
418
|
+
* This is the single source of truth for deterministic linking in subscribers.
|
|
419
|
+
*/
|
|
420
|
+
interface IEventContext {
|
|
421
|
+
ownerType: string;
|
|
422
|
+
ownerId: string;
|
|
423
|
+
ownerPath: IOwnerPathSegment[];
|
|
424
|
+
/** Depth of the current execution in the hierarchy (0 = root) */
|
|
425
|
+
depth?: number;
|
|
426
|
+
/** Unique span identifier for distributed tracing correlation */
|
|
427
|
+
spanId?: string;
|
|
428
|
+
/** Optional structured metadata for debugging/observability */
|
|
429
|
+
metadata?: TEventLoggerData;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Allowed extension values for event payloads.
|
|
433
|
+
*/
|
|
434
|
+
type TEventExtensionValue = TEventUniversalValue | TEventLoggerData | Error | IEventContext | IOwnerPathSegment[];
|
|
435
|
+
/**
|
|
436
|
+
* Base event payload shape.
|
|
437
|
+
* Emitters may add additional fields, but MUST keep linkage information explicit.
|
|
438
|
+
*/
|
|
439
|
+
interface IBaseEventData {
|
|
440
|
+
/** Timestamp when the event was emitted. This is required for deterministic ordering. */
|
|
441
|
+
timestamp: Date;
|
|
442
|
+
/** Optional structured metadata */
|
|
443
|
+
metadata?: TEventLoggerData;
|
|
444
|
+
/** Extensible fields for event-specific payloads */
|
|
445
|
+
[key: string]: TEventExtensionValue | undefined;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Execution-related event payload.
|
|
449
|
+
*/
|
|
450
|
+
interface IExecutionEventData extends IBaseEventData {
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Tool-related event payload.
|
|
454
|
+
*/
|
|
455
|
+
interface IToolEventData extends IBaseEventData {
|
|
456
|
+
toolName?: string;
|
|
457
|
+
parameters?: Record<string, TEventUniversalValue>;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Agent-related event payload.
|
|
461
|
+
*/
|
|
462
|
+
interface IAgentEventData extends IBaseEventData {
|
|
463
|
+
agentId?: string;
|
|
464
|
+
}
|
|
465
|
+
type TEventListener = (eventType: string, data: IBaseEventData, context?: IEventContext) => void;
|
|
466
|
+
/**
|
|
467
|
+
* Minimal EventService contract for emitting events.
|
|
468
|
+
*/
|
|
469
|
+
interface IEventService {
|
|
470
|
+
emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
|
|
471
|
+
subscribe(listener: TEventListener): void;
|
|
472
|
+
unsubscribe(listener: TEventListener): void;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Explicit owner binding information used for scoped event emission.
|
|
476
|
+
*/
|
|
477
|
+
interface IEventServiceOwnerBinding {
|
|
478
|
+
ownerType: string;
|
|
479
|
+
ownerId: string;
|
|
480
|
+
ownerPath: IOwnerPathSegment[];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
type TToolContextExtensionValue = TUniversalValue | Date | Error | TLoggerData | TContextData | TToolParameters | TToolMetadata;
|
|
484
|
+
/**
|
|
485
|
+
* Tool metadata structure - specific type definition
|
|
486
|
+
*/
|
|
487
|
+
type TToolMetadata = Record<string, string | number | boolean | string[] | number[] | boolean[] | TToolParameters>;
|
|
488
|
+
/**
|
|
489
|
+
* Tool execution data - domain payload for tool results.
|
|
490
|
+
*
|
|
491
|
+
* IMPORTANT:
|
|
492
|
+
* - This must support structured tool outputs without resorting to `any`.
|
|
493
|
+
* - Prefer `ToolResultData` (derived from the canonical `UniversalValue` axis).
|
|
494
|
+
*/
|
|
495
|
+
/**
|
|
496
|
+
* Tool execution result - extended for ToolExecutionData compatibility
|
|
497
|
+
*/
|
|
498
|
+
interface IToolResult {
|
|
499
|
+
success: boolean;
|
|
500
|
+
data?: TUniversalValue;
|
|
501
|
+
error?: string;
|
|
502
|
+
metadata?: TToolMetadata;
|
|
503
|
+
[key: string]: TToolContextExtensionValue | undefined;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Enhanced tool execution result with additional metadata
|
|
507
|
+
*/
|
|
508
|
+
interface IToolExecutionResult {
|
|
509
|
+
/** Whether execution was successful */
|
|
510
|
+
success: boolean;
|
|
511
|
+
/** Tool name that was executed */
|
|
512
|
+
toolName?: string;
|
|
513
|
+
/** Execution result or data */
|
|
514
|
+
result?: TUniversalValue;
|
|
515
|
+
/** Error message if execution failed */
|
|
516
|
+
error?: string;
|
|
517
|
+
/** Execution duration in milliseconds */
|
|
518
|
+
duration?: number;
|
|
519
|
+
/** Unique execution ID */
|
|
520
|
+
executionId?: string;
|
|
521
|
+
/** Additional metadata */
|
|
522
|
+
metadata?: TToolMetadata;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Tool execution context - type-safe context for tool execution
|
|
526
|
+
* Enhanced with hierarchical execution tracking support
|
|
527
|
+
*/
|
|
528
|
+
interface IToolExecutionContext {
|
|
529
|
+
toolName: string;
|
|
530
|
+
parameters: TToolParameters;
|
|
531
|
+
executionId?: string;
|
|
532
|
+
userId?: string;
|
|
533
|
+
sessionId?: string;
|
|
534
|
+
metadata?: TToolMetadata;
|
|
535
|
+
/** Parent execution ID for hierarchical tool execution tracking */
|
|
536
|
+
parentExecutionId?: string;
|
|
537
|
+
/** Root execution ID (Team/Agent level) for complete execution tree tracking */
|
|
538
|
+
rootExecutionId?: string;
|
|
539
|
+
/** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
|
|
540
|
+
executionLevel?: number;
|
|
541
|
+
/** Execution path array showing the complete execution hierarchy */
|
|
542
|
+
executionPath?: string[];
|
|
543
|
+
/** Real-time execution data for accurate tracking (no simulation) */
|
|
544
|
+
realTimeData?: {
|
|
545
|
+
/** Actual execution start time */
|
|
546
|
+
startTime: Date;
|
|
547
|
+
/** Actual input parameters passed to the tool */
|
|
548
|
+
actualParameters: TToolParameters;
|
|
549
|
+
/** Tool-provided estimated duration (optional) */
|
|
550
|
+
estimatedDuration?: number;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Additional tool execution context extensions.
|
|
554
|
+
*
|
|
555
|
+
* IMPORTANT:
|
|
556
|
+
* - Avoid ad-hoc top-level fields to keep the contract stable.
|
|
557
|
+
* - Use this map for forward-compatible extra data with constrained value types.
|
|
558
|
+
*/
|
|
559
|
+
extensions?: Record<string, TToolContextExtensionValue>;
|
|
560
|
+
/** Owner context propagated from EventService */
|
|
561
|
+
ownerType?: string;
|
|
562
|
+
ownerId?: string;
|
|
563
|
+
ownerPath?: IOwnerPathSegment[];
|
|
564
|
+
sourceId?: string;
|
|
565
|
+
/**
|
|
566
|
+
* Tool-call scoped EventService instance.
|
|
567
|
+
* Caller (ExecutionService/ToolExecutionService) is responsible for providing
|
|
568
|
+
* an ownerPath-bound EventService for this tool call.
|
|
569
|
+
*/
|
|
570
|
+
eventService?: IEventService;
|
|
571
|
+
/**
|
|
572
|
+
* Unbound base EventService instance.
|
|
573
|
+
*
|
|
574
|
+
* Required when a tool needs to create another owner-bound EventService
|
|
575
|
+
* for a different owner (e.g., creating an agent from a tool call).
|
|
576
|
+
*
|
|
577
|
+
* NOTE: Do not wrap an already owner-bound EventService to bind a different owner.
|
|
578
|
+
* Owner-bound instances must not be layered across different owners.
|
|
579
|
+
*/
|
|
580
|
+
baseEventService?: IEventService;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Parameter validation result
|
|
584
|
+
*/
|
|
585
|
+
interface IParameterValidationResult {
|
|
586
|
+
/** Whether parameters are valid */
|
|
587
|
+
isValid: boolean;
|
|
588
|
+
/** Validation error messages */
|
|
589
|
+
errors: string[];
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Generic tool executor function
|
|
593
|
+
*/
|
|
594
|
+
type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
|
|
595
|
+
/**
|
|
596
|
+
* OpenAPI specification configuration
|
|
597
|
+
*/
|
|
598
|
+
interface IOpenAPIToolConfig {
|
|
599
|
+
/** OpenAPI 3.0 specification */
|
|
600
|
+
spec: {
|
|
601
|
+
openapi: string;
|
|
602
|
+
info: {
|
|
603
|
+
title: string;
|
|
604
|
+
version: string;
|
|
605
|
+
description?: string;
|
|
606
|
+
};
|
|
607
|
+
servers?: Array<{
|
|
608
|
+
url: string;
|
|
609
|
+
description?: string;
|
|
610
|
+
}>;
|
|
611
|
+
paths: Record<string, Record<string, string | number | boolean | Record<string, string | number | boolean>>>;
|
|
612
|
+
components?: Record<string, Record<string, string | number | boolean>>;
|
|
613
|
+
};
|
|
614
|
+
/** Operation ID from the OpenAPI spec */
|
|
615
|
+
operationId: string;
|
|
616
|
+
/** Base URL for API calls */
|
|
617
|
+
baseURL: string;
|
|
618
|
+
/** Authentication configuration */
|
|
619
|
+
auth?: {
|
|
620
|
+
type: 'bearer' | 'apiKey' | 'basic';
|
|
621
|
+
token?: string;
|
|
622
|
+
apiKey?: string;
|
|
623
|
+
header?: string;
|
|
624
|
+
username?: string;
|
|
625
|
+
password?: string;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* MCP (Model Context Protocol) configuration
|
|
630
|
+
*/
|
|
631
|
+
interface IMCPToolConfig {
|
|
632
|
+
/** MCP server endpoint */
|
|
633
|
+
endpoint: string;
|
|
634
|
+
/** Protocol version */
|
|
635
|
+
version?: string;
|
|
636
|
+
/** Authentication configuration */
|
|
637
|
+
auth?: {
|
|
638
|
+
type: 'bearer' | 'apiKey';
|
|
639
|
+
token: string;
|
|
640
|
+
};
|
|
641
|
+
/** Tool-specific configuration */
|
|
642
|
+
toolConfig?: Record<string, string | number | boolean>;
|
|
643
|
+
/** Timeout in milliseconds */
|
|
644
|
+
timeout?: number;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Base tool interface
|
|
648
|
+
*/
|
|
649
|
+
interface ITool {
|
|
650
|
+
/** Tool schema */
|
|
651
|
+
schema: IToolSchema;
|
|
652
|
+
/**
|
|
653
|
+
* Execute the tool with given parameters
|
|
654
|
+
*/
|
|
655
|
+
execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
|
|
656
|
+
/**
|
|
657
|
+
* Validate tool parameters
|
|
658
|
+
*/
|
|
659
|
+
validate(parameters: TToolParameters): boolean;
|
|
660
|
+
/**
|
|
661
|
+
* Validate tool parameters with detailed result
|
|
662
|
+
*/
|
|
663
|
+
validateParameters(parameters: TToolParameters): IParameterValidationResult;
|
|
664
|
+
/**
|
|
665
|
+
* Get tool description
|
|
666
|
+
*/
|
|
667
|
+
getDescription(): string;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Function tool implementation
|
|
671
|
+
*/
|
|
672
|
+
interface IFunctionTool extends ITool {
|
|
673
|
+
/** Function to execute */
|
|
674
|
+
fn: TToolExecutor;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Tool registry interface
|
|
678
|
+
*/
|
|
679
|
+
interface IToolRegistry {
|
|
680
|
+
/**
|
|
681
|
+
* Register a tool
|
|
682
|
+
*/
|
|
683
|
+
register(tool: ITool): void;
|
|
684
|
+
/**
|
|
685
|
+
* Unregister a tool
|
|
686
|
+
*/
|
|
687
|
+
unregister(name: string): void;
|
|
688
|
+
/**
|
|
689
|
+
* Get tool by name
|
|
690
|
+
*/
|
|
691
|
+
get(name: string): ITool | undefined;
|
|
692
|
+
/**
|
|
693
|
+
* Get all registered tools
|
|
694
|
+
*/
|
|
695
|
+
getAll(): ITool[];
|
|
696
|
+
/**
|
|
697
|
+
* Get tool schemas
|
|
698
|
+
*/
|
|
699
|
+
getSchemas(): IToolSchema[];
|
|
700
|
+
/**
|
|
701
|
+
* Check if tool exists
|
|
702
|
+
*/
|
|
703
|
+
has(name: string): boolean;
|
|
704
|
+
/**
|
|
705
|
+
* Clear all tools
|
|
706
|
+
*/
|
|
707
|
+
clear(): void;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Tool factory interface
|
|
711
|
+
*/
|
|
712
|
+
interface IToolFactory {
|
|
713
|
+
/**
|
|
714
|
+
* Create function tool from schema and function
|
|
715
|
+
*/
|
|
716
|
+
createFunctionTool(schema: IToolSchema, fn: TToolExecutor): IFunctionTool;
|
|
717
|
+
/**
|
|
718
|
+
* Create tool from OpenAPI specification
|
|
719
|
+
*/
|
|
720
|
+
createOpenAPITool(config: IOpenAPIToolConfig): ITool;
|
|
721
|
+
/**
|
|
722
|
+
* Create MCP tool
|
|
723
|
+
*/
|
|
724
|
+
createMCPTool(config: IMCPToolConfig): ITool;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
declare const EXECUTION_EVENT_NAMES: {
|
|
728
|
+
readonly START: "execution.start";
|
|
729
|
+
readonly COMPLETE: "execution.complete";
|
|
730
|
+
readonly ERROR: "execution.error";
|
|
731
|
+
};
|
|
732
|
+
declare const TOOL_EVENT_NAMES: {
|
|
733
|
+
readonly CALL_START: "tool.call_start";
|
|
734
|
+
readonly CALL_COMPLETE: "tool.call_complete";
|
|
735
|
+
readonly CALL_ERROR: "tool.call_error";
|
|
736
|
+
};
|
|
737
|
+
declare const AGENT_EVENT_NAMES: {
|
|
738
|
+
readonly EXECUTION_START: "agent.execution_start";
|
|
739
|
+
readonly EXECUTION_COMPLETE: "agent.execution_complete";
|
|
740
|
+
readonly EXECUTION_ERROR: "agent.execution_error";
|
|
741
|
+
readonly CREATED: "agent.created";
|
|
742
|
+
};
|
|
743
|
+
type TExecutionEventName = (typeof EXECUTION_EVENT_NAMES)[keyof typeof EXECUTION_EVENT_NAMES];
|
|
744
|
+
type TToolEventName = (typeof TOOL_EVENT_NAMES)[keyof typeof TOOL_EVENT_NAMES];
|
|
745
|
+
type TAgentEventName = (typeof AGENT_EVENT_NAMES)[keyof typeof AGENT_EVENT_NAMES];
|
|
746
|
+
/**
|
|
747
|
+
* Event types that can be emitted.
|
|
748
|
+
*
|
|
749
|
+
* IMPORTANT:
|
|
750
|
+
* - Do not use string literals for event names outside this module.
|
|
751
|
+
* - Import and use EVENT_EMITTER_EVENTS instead.
|
|
752
|
+
*/
|
|
753
|
+
declare const EVENT_EMITTER_EVENTS: {
|
|
754
|
+
readonly EXECUTION_START: "execution.start";
|
|
755
|
+
readonly EXECUTION_COMPLETE: "execution.complete";
|
|
756
|
+
readonly EXECUTION_ERROR: "execution.error";
|
|
757
|
+
readonly TOOL_BEFORE_EXECUTE: "tool.beforeExecute";
|
|
758
|
+
readonly TOOL_AFTER_EXECUTE: "tool.afterExecute";
|
|
759
|
+
readonly TOOL_SUCCESS: "tool.success";
|
|
760
|
+
readonly TOOL_ERROR: "tool.call_error";
|
|
761
|
+
readonly CONVERSATION_START: "conversation.start";
|
|
762
|
+
readonly CONVERSATION_COMPLETE: "conversation.complete";
|
|
763
|
+
readonly CONVERSATION_ERROR: "conversation.error";
|
|
764
|
+
readonly AGENT_EXECUTION_START: "agent.execution_start";
|
|
765
|
+
readonly AGENT_EXECUTION_COMPLETE: "agent.execution_complete";
|
|
766
|
+
readonly AGENT_EXECUTION_ERROR: "agent.execution_error";
|
|
767
|
+
readonly AGENT_CREATED: "agent.created";
|
|
768
|
+
readonly AGENT_DESTROYED: "agent.destroyed";
|
|
769
|
+
readonly PLUGIN_LOADED: "plugin.loaded";
|
|
770
|
+
readonly PLUGIN_UNLOADED: "plugin.unloaded";
|
|
771
|
+
readonly PLUGIN_ERROR: "plugin.error";
|
|
772
|
+
readonly ERROR_OCCURRED: "error.occurred";
|
|
773
|
+
readonly WARNING_OCCURRED: "warning.occurred";
|
|
774
|
+
readonly MODULE_INITIALIZE_START: "module.initialize.start";
|
|
775
|
+
readonly MODULE_INITIALIZE_COMPLETE: "module.initialize.complete";
|
|
776
|
+
readonly MODULE_INITIALIZE_ERROR: "module.initialize.error";
|
|
777
|
+
readonly MODULE_EXECUTION_START: "module.execution.start";
|
|
778
|
+
readonly MODULE_EXECUTION_COMPLETE: "module.execution.complete";
|
|
779
|
+
readonly MODULE_EXECUTION_ERROR: "module.execution.error";
|
|
780
|
+
readonly MODULE_DISPOSE_START: "module.dispose.start";
|
|
781
|
+
readonly MODULE_DISPOSE_COMPLETE: "module.dispose.complete";
|
|
782
|
+
readonly MODULE_DISPOSE_ERROR: "module.dispose.error";
|
|
783
|
+
readonly MODULE_REGISTERED: "module.registered";
|
|
784
|
+
readonly MODULE_UNREGISTERED: "module.unregistered";
|
|
785
|
+
readonly EXECUTION_HIERARCHY: "execution.hierarchy";
|
|
786
|
+
readonly EXECUTION_REALTIME: "execution.realtime";
|
|
787
|
+
readonly TOOL_REALTIME: "tool.realtime";
|
|
788
|
+
readonly CUSTOM: "custom";
|
|
789
|
+
};
|
|
790
|
+
type TEventName = TExecutionEventName | TToolEventName | TAgentEventName | 'tool.beforeExecute' | 'tool.afterExecute' | 'tool.success' | 'conversation.start' | 'conversation.complete' | 'conversation.error' | 'agent.destroyed' | 'plugin.loaded' | 'plugin.unloaded' | 'plugin.error' | 'error.occurred' | 'warning.occurred' | 'module.initialize.start' | 'module.initialize.complete' | 'module.initialize.error' | 'module.execution.start' | 'module.execution.complete' | 'module.execution.error' | 'module.dispose.start' | 'module.dispose.complete' | 'module.dispose.error' | 'module.registered' | 'module.unregistered' | 'execution.hierarchy' | 'execution.realtime' | 'tool.realtime' | 'custom';
|
|
791
|
+
/**
|
|
792
|
+
* Valid event data value types
|
|
793
|
+
*/
|
|
794
|
+
type TEventDataValue = string | number | boolean | Date | null | undefined | TEventDataValue[] | {
|
|
795
|
+
[key: string]: TEventDataValue;
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* Event data structure
|
|
799
|
+
*/
|
|
800
|
+
interface IEventEmitterEventData {
|
|
801
|
+
type: TEventName;
|
|
802
|
+
timestamp: Date;
|
|
803
|
+
executionId?: string;
|
|
804
|
+
sessionId?: string;
|
|
805
|
+
userId?: string;
|
|
806
|
+
data?: Record<string, TEventDataValue>;
|
|
807
|
+
error?: Error;
|
|
808
|
+
metadata?: Record<string, TEventDataValue>;
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Event listener function
|
|
812
|
+
*/
|
|
813
|
+
type TEventEmitterListener = (event: IEventEmitterEventData) => void | Promise<void>;
|
|
814
|
+
/**
|
|
815
|
+
* Console-like interface for the EventEmitterPlugin.
|
|
816
|
+
*
|
|
817
|
+
* Use this interface for typing instead of the concrete EventEmitterPlugin class.
|
|
818
|
+
*/
|
|
819
|
+
interface IEventEmitterPlugin {
|
|
820
|
+
on(eventType: TEventName, listener: TEventEmitterListener, options?: {
|
|
821
|
+
once?: boolean;
|
|
822
|
+
filter?: (event: IEventEmitterEventData) => boolean;
|
|
823
|
+
}): string;
|
|
824
|
+
once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
|
|
825
|
+
off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
|
|
826
|
+
emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Reusable type definitions for logger utility
|
|
831
|
+
*/
|
|
832
|
+
/**
|
|
833
|
+
* Log levels for the logger
|
|
834
|
+
*/
|
|
835
|
+
type TUtilLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
836
|
+
/**
|
|
837
|
+
* Log entry structure
|
|
838
|
+
*/
|
|
839
|
+
interface IUtilLogEntry {
|
|
840
|
+
timestamp: string;
|
|
841
|
+
level: TUtilLogLevel;
|
|
842
|
+
message: string;
|
|
843
|
+
context?: TLoggerData;
|
|
844
|
+
packageName?: string;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Logger interface
|
|
848
|
+
*/
|
|
849
|
+
interface ILogger {
|
|
850
|
+
debug(...args: Array<TUniversalValue | TLoggerData | Error>): void;
|
|
851
|
+
info(...args: Array<TUniversalValue | TLoggerData | Error>): void;
|
|
852
|
+
warn(...args: Array<TUniversalValue | TLoggerData | Error>): void;
|
|
853
|
+
error(...args: Array<TUniversalValue | TLoggerData | Error>): void;
|
|
854
|
+
log(...args: Array<TUniversalValue | TLoggerData | Error>): void;
|
|
855
|
+
group?(label?: string): void;
|
|
856
|
+
groupEnd?(): void;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Silent logger that does nothing (Null Object Pattern)
|
|
860
|
+
*
|
|
861
|
+
* IMPORTANT:
|
|
862
|
+
* - This library must not write to stdio by default.
|
|
863
|
+
* - Inject a real logger explicitly if you want output.
|
|
864
|
+
*/
|
|
865
|
+
declare const SilentLogger: ILogger;
|
|
866
|
+
/**
|
|
867
|
+
* Create a named logger instance for a package or module.
|
|
868
|
+
* Use this to create loggers with a specific name prefix for easy log filtering.
|
|
869
|
+
*/
|
|
870
|
+
declare function createLogger(packageName: string, logger?: ILogger): ILogger;
|
|
871
|
+
/**
|
|
872
|
+
* Set global log level for all loggers
|
|
873
|
+
*/
|
|
874
|
+
declare function setGlobalLogLevel(level: TUtilLogLevel): void;
|
|
875
|
+
/**
|
|
876
|
+
* Get global log level
|
|
877
|
+
*/
|
|
878
|
+
declare function getGlobalLogLevel(): TUtilLogLevel;
|
|
879
|
+
/**
|
|
880
|
+
* Default logger for the agents package
|
|
881
|
+
*/
|
|
882
|
+
declare const logger: ILogger;
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Type definitions for AbstractPlugin.
|
|
886
|
+
*
|
|
887
|
+
* Extracted from abstract-plugin.ts to keep each file under 300 lines.
|
|
888
|
+
*/
|
|
889
|
+
|
|
890
|
+
/** Plugin categories for classification */
|
|
891
|
+
declare enum PluginCategory {
|
|
892
|
+
MONITORING = "monitoring",
|
|
893
|
+
LOGGING = "logging",
|
|
894
|
+
STORAGE = "storage",
|
|
895
|
+
NOTIFICATION = "notification",
|
|
896
|
+
SECURITY = "security",
|
|
897
|
+
PERFORMANCE = "performance",
|
|
898
|
+
ERROR_HANDLING = "error_handling",
|
|
899
|
+
LIMITS = "limits",
|
|
900
|
+
EVENT_PROCESSING = "event_processing",
|
|
901
|
+
CUSTOM = "custom"
|
|
902
|
+
}
|
|
903
|
+
/** Plugin priority levels */
|
|
904
|
+
declare enum PluginPriority {
|
|
905
|
+
CRITICAL = 1000,
|
|
906
|
+
HIGH = 800,
|
|
907
|
+
NORMAL = 500,
|
|
908
|
+
LOW = 200,
|
|
909
|
+
MINIMAL = 100
|
|
910
|
+
}
|
|
911
|
+
/** Plugin execution context for all plugins */
|
|
912
|
+
interface IPluginExecutionContext {
|
|
913
|
+
executionId?: string;
|
|
914
|
+
sessionId?: string;
|
|
915
|
+
userId?: string;
|
|
916
|
+
messages?: TUniversalMessage[];
|
|
917
|
+
config?: Record<string, string | number | boolean>;
|
|
918
|
+
metadata?: Record<string, string | number | boolean | Date>;
|
|
919
|
+
[key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | TUniversalMessage[] | Record<string, string | number | boolean> | Record<string, string | number | boolean | Date> | undefined;
|
|
920
|
+
}
|
|
921
|
+
/** Plugin execution result for all plugins */
|
|
922
|
+
interface IPluginExecutionResult {
|
|
923
|
+
response?: string;
|
|
924
|
+
content?: string;
|
|
925
|
+
duration?: number;
|
|
926
|
+
tokensUsed?: number;
|
|
927
|
+
toolsExecuted?: number;
|
|
928
|
+
success?: boolean;
|
|
929
|
+
usage?: {
|
|
930
|
+
totalTokens?: number;
|
|
931
|
+
promptTokens?: number;
|
|
932
|
+
completionTokens?: number;
|
|
933
|
+
};
|
|
934
|
+
toolCalls?: Array<{
|
|
935
|
+
id?: string;
|
|
936
|
+
name?: string;
|
|
937
|
+
arguments?: Record<string, string | number | boolean>;
|
|
938
|
+
result?: string | number | boolean | null;
|
|
939
|
+
}>;
|
|
940
|
+
results?: Array<{
|
|
941
|
+
id?: string;
|
|
942
|
+
type?: string;
|
|
943
|
+
data?: string | number | boolean | null;
|
|
944
|
+
success?: boolean;
|
|
945
|
+
}>;
|
|
946
|
+
error?: Error;
|
|
947
|
+
metadata?: Record<string, string | number | boolean | Date>;
|
|
948
|
+
}
|
|
949
|
+
/** Error context for plugin error handling */
|
|
950
|
+
interface IPluginErrorContext {
|
|
951
|
+
action: string;
|
|
952
|
+
tool?: string;
|
|
953
|
+
parameters?: TToolParameters;
|
|
954
|
+
result?: IToolExecutionResult;
|
|
955
|
+
error?: Error;
|
|
956
|
+
executionId?: string;
|
|
957
|
+
sessionId?: string;
|
|
958
|
+
userId?: string;
|
|
959
|
+
timestamp?: Date;
|
|
960
|
+
attempt?: number;
|
|
961
|
+
stack?: string;
|
|
962
|
+
metadata?: Record<string, string | number | boolean>;
|
|
963
|
+
}
|
|
964
|
+
/** Plugin configuration interface */
|
|
965
|
+
interface IPluginConfig extends IPluginOptions {
|
|
966
|
+
options?: Record<string, string | number | boolean>;
|
|
967
|
+
}
|
|
968
|
+
/** Plugin options that all plugin options should extend */
|
|
969
|
+
interface IPluginOptions {
|
|
970
|
+
enabled?: boolean;
|
|
971
|
+
category?: PluginCategory;
|
|
972
|
+
priority?: PluginPriority | number;
|
|
973
|
+
moduleEvents?: TEventName[];
|
|
974
|
+
subscribeToAllModuleEvents?: boolean;
|
|
975
|
+
}
|
|
976
|
+
/** Plugin data interface */
|
|
977
|
+
interface IPluginData {
|
|
978
|
+
name: string;
|
|
979
|
+
version: string;
|
|
980
|
+
enabled: boolean;
|
|
981
|
+
category: PluginCategory;
|
|
982
|
+
priority: number;
|
|
983
|
+
subscribedEvents: TEventName[];
|
|
984
|
+
metadata?: Record<string, string | number | boolean>;
|
|
985
|
+
}
|
|
986
|
+
/** Type-safe plugin interface with specific type parameters */
|
|
987
|
+
interface IPluginContract<TOptions extends IPluginOptions = IPluginOptions, TStats = IPluginStats> {
|
|
988
|
+
name: string;
|
|
989
|
+
version: string;
|
|
990
|
+
enabled: boolean;
|
|
991
|
+
category: PluginCategory;
|
|
992
|
+
priority: number;
|
|
993
|
+
initialize(options?: TOptions): Promise<void>;
|
|
994
|
+
cleanup?(): Promise<void>;
|
|
995
|
+
getData?(): IPluginData;
|
|
996
|
+
getStats?(): TStats;
|
|
997
|
+
subscribeToModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
|
|
998
|
+
unsubscribeFromModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
|
|
999
|
+
onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
|
|
1000
|
+
}
|
|
1001
|
+
/** Plugin statistics base interface with common metrics */
|
|
1002
|
+
interface IPluginStats {
|
|
1003
|
+
enabled: boolean;
|
|
1004
|
+
calls: number;
|
|
1005
|
+
errors: number;
|
|
1006
|
+
lastActivity?: Date;
|
|
1007
|
+
moduleEventsReceived?: number;
|
|
1008
|
+
[key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | Record<string, string | number | boolean | Date> | undefined;
|
|
1009
|
+
}
|
|
1010
|
+
/** Plugin interface extending IPluginContract */
|
|
1011
|
+
interface IPlugin extends IPluginContract<IPluginConfig, IPluginStats> {
|
|
1012
|
+
}
|
|
1013
|
+
/** Plugin lifecycle hooks */
|
|
1014
|
+
interface IPluginHooks {
|
|
1015
|
+
beforeRun?(input: string, options?: IRunOptions): Promise<void> | void;
|
|
1016
|
+
afterRun?(input: string, response: string, options?: IRunOptions): Promise<void> | void;
|
|
1017
|
+
beforeExecution?(context: IPluginExecutionContext): Promise<void> | void;
|
|
1018
|
+
afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
|
|
1019
|
+
beforeConversation?(context: IPluginExecutionContext): Promise<void> | void;
|
|
1020
|
+
afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
|
|
1021
|
+
beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void> | void;
|
|
1022
|
+
beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void> | void;
|
|
1023
|
+
afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void> | void;
|
|
1024
|
+
afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void> | void;
|
|
1025
|
+
beforeProviderCall?(messages: TUniversalMessage[]): Promise<void> | void;
|
|
1026
|
+
afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void> | void;
|
|
1027
|
+
onStreamingChunk?(chunk: TUniversalMessage): Promise<void> | void;
|
|
1028
|
+
onError?(error: Error, context?: IPluginErrorContext): Promise<void> | void;
|
|
1029
|
+
onMessageAdded?(message: TUniversalMessage): Promise<void> | void;
|
|
1030
|
+
onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Abstract class for all plugins with type parameter support.
|
|
1035
|
+
*
|
|
1036
|
+
* Type definitions live in ./abstract-plugin-types.ts.
|
|
1037
|
+
*/
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Abstract class for all plugins with type parameter support.
|
|
1041
|
+
* Provides plugin lifecycle management and common functionality.
|
|
1042
|
+
* @template TOptions - Plugin options type that extends IPluginOptions
|
|
1043
|
+
* @template TStats - Plugin statistics type
|
|
1044
|
+
*/
|
|
1045
|
+
declare abstract class AbstractPlugin<TOptions extends IPluginOptions = IPluginOptions, TStats extends IPluginStats = IPluginStats> implements IPluginContract<TOptions, TStats>, IPluginHooks {
|
|
1046
|
+
abstract readonly name: string;
|
|
1047
|
+
abstract readonly version: string;
|
|
1048
|
+
enabled: boolean;
|
|
1049
|
+
category: PluginCategory;
|
|
1050
|
+
priority: number;
|
|
1051
|
+
protected options: TOptions | undefined;
|
|
1052
|
+
protected eventEmitter: IEventEmitterPlugin | undefined;
|
|
1053
|
+
protected subscribedEvents: TEventName[];
|
|
1054
|
+
protected eventHandlers: Map<TEventName, string[]>;
|
|
1055
|
+
protected readonly pluginLogger: ILogger;
|
|
1056
|
+
protected stats: {
|
|
1057
|
+
calls: number;
|
|
1058
|
+
errors: number;
|
|
1059
|
+
moduleEventsReceived: number;
|
|
1060
|
+
lastActivity: Date | undefined;
|
|
1061
|
+
};
|
|
1062
|
+
initialize(options?: TOptions): Promise<void>;
|
|
1063
|
+
subscribeToModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
|
|
1064
|
+
unsubscribeFromModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
|
|
1065
|
+
dispose(): Promise<void>;
|
|
1066
|
+
enable(): void;
|
|
1067
|
+
disable(): void;
|
|
1068
|
+
isEnabled(): boolean;
|
|
1069
|
+
getConfig(): IPluginConfig;
|
|
1070
|
+
updateConfig(_config: IPluginConfig): void;
|
|
1071
|
+
getData(): IPluginData;
|
|
1072
|
+
clearData?(): void;
|
|
1073
|
+
getStatus(): {
|
|
1074
|
+
name: string;
|
|
1075
|
+
version: string;
|
|
1076
|
+
enabled: boolean;
|
|
1077
|
+
initialized: boolean;
|
|
1078
|
+
category: PluginCategory;
|
|
1079
|
+
priority: number;
|
|
1080
|
+
subscribedEventsCount: number;
|
|
1081
|
+
hasEventEmitter: boolean;
|
|
1082
|
+
};
|
|
1083
|
+
getStats(): TStats;
|
|
1084
|
+
protected updateCallStats(): void;
|
|
1085
|
+
protected updateErrorStats(): void;
|
|
1086
|
+
beforeRun?(input: string, options?: IRunOptions): Promise<void>;
|
|
1087
|
+
afterRun?(input: string, response: string, options?: IRunOptions): Promise<void>;
|
|
1088
|
+
beforeExecution?(context: IPluginExecutionContext): Promise<void>;
|
|
1089
|
+
afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
1090
|
+
beforeConversation?(context: IPluginExecutionContext): Promise<void>;
|
|
1091
|
+
afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
1092
|
+
beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void>;
|
|
1093
|
+
beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
|
|
1094
|
+
afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void>;
|
|
1095
|
+
afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
|
|
1096
|
+
beforeProviderCall?(messages: TUniversalMessage[]): Promise<void>;
|
|
1097
|
+
afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void>;
|
|
1098
|
+
onStreamingChunk?(chunk: TUniversalMessage): Promise<void>;
|
|
1099
|
+
onError?(error: Error, context?: IPluginErrorContext): Promise<void>;
|
|
1100
|
+
onMessageAdded?(message: TUniversalMessage): Promise<void>;
|
|
1101
|
+
onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void>;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Type definitions, interfaces, and enums for the module system.
|
|
1106
|
+
*
|
|
1107
|
+
* Extracted from abstract-module.ts to keep each file under 300 lines.
|
|
1108
|
+
*/
|
|
1109
|
+
|
|
1110
|
+
/** Module execution context */
|
|
1111
|
+
interface IModuleExecutionContext {
|
|
1112
|
+
executionId?: string;
|
|
1113
|
+
sessionId?: string;
|
|
1114
|
+
userId?: string;
|
|
1115
|
+
agentName?: string;
|
|
1116
|
+
metadata?: Record<string, string | number | boolean | Date>;
|
|
1117
|
+
[key: string]: string | number | boolean | Date | Record<string, string | number | boolean | Date> | undefined;
|
|
1118
|
+
}
|
|
1119
|
+
/** Module execution result */
|
|
1120
|
+
interface IModuleExecutionResult {
|
|
1121
|
+
success: boolean;
|
|
1122
|
+
data?: IModuleResultData;
|
|
1123
|
+
error?: Error;
|
|
1124
|
+
duration?: number;
|
|
1125
|
+
metadata?: Record<string, string | number | boolean | Date>;
|
|
1126
|
+
}
|
|
1127
|
+
/** Module result data */
|
|
1128
|
+
interface IModuleResultData {
|
|
1129
|
+
[key: string]: string | number | boolean | Record<string, string | number | boolean> | undefined;
|
|
1130
|
+
}
|
|
1131
|
+
/** Base module options */
|
|
1132
|
+
interface IBaseModuleOptions {
|
|
1133
|
+
enabled?: boolean;
|
|
1134
|
+
config?: Record<string, string | number | boolean>;
|
|
1135
|
+
}
|
|
1136
|
+
/** Module capabilities */
|
|
1137
|
+
interface IModuleCapabilities {
|
|
1138
|
+
capabilities: string[];
|
|
1139
|
+
dependencies?: string[];
|
|
1140
|
+
optionalDependencies?: string[];
|
|
1141
|
+
}
|
|
1142
|
+
/** Module type descriptor */
|
|
1143
|
+
interface IModuleDescriptor {
|
|
1144
|
+
type: string;
|
|
1145
|
+
category: ModuleCategory;
|
|
1146
|
+
layer: ModuleLayer;
|
|
1147
|
+
dependencies?: string[];
|
|
1148
|
+
capabilities?: string[];
|
|
1149
|
+
}
|
|
1150
|
+
/** Module categories */
|
|
1151
|
+
declare enum ModuleCategory {
|
|
1152
|
+
CORE = "core",
|
|
1153
|
+
STORAGE = "storage",
|
|
1154
|
+
PROCESSING = "processing",
|
|
1155
|
+
INTEGRATION = "integration",
|
|
1156
|
+
INTERFACE = "interface",
|
|
1157
|
+
CAPABILITY = "capability"
|
|
1158
|
+
}
|
|
1159
|
+
/** Module layers */
|
|
1160
|
+
declare enum ModuleLayer {
|
|
1161
|
+
INFRASTRUCTURE = "infrastructure",
|
|
1162
|
+
CORE = "core",
|
|
1163
|
+
APPLICATION = "application",
|
|
1164
|
+
DOMAIN = "domain",
|
|
1165
|
+
PRESENTATION = "presentation"
|
|
1166
|
+
}
|
|
1167
|
+
/** Module data for introspection */
|
|
1168
|
+
interface IModuleData {
|
|
1169
|
+
name: string;
|
|
1170
|
+
version: string;
|
|
1171
|
+
type: string;
|
|
1172
|
+
enabled: boolean;
|
|
1173
|
+
initialized: boolean;
|
|
1174
|
+
capabilities: IModuleCapabilities;
|
|
1175
|
+
metadata?: Record<string, string | number | boolean>;
|
|
1176
|
+
}
|
|
1177
|
+
/** Module statistics */
|
|
1178
|
+
interface IModuleStats {
|
|
1179
|
+
enabled: boolean;
|
|
1180
|
+
initialized: boolean;
|
|
1181
|
+
executionCount: number;
|
|
1182
|
+
errorCount: number;
|
|
1183
|
+
lastActivity?: Date;
|
|
1184
|
+
averageExecutionTime?: number;
|
|
1185
|
+
[key: string]: string | number | boolean | Date | undefined;
|
|
1186
|
+
}
|
|
1187
|
+
/** Type-safe module interface */
|
|
1188
|
+
interface IModule<TOptions extends IBaseModuleOptions = IBaseModuleOptions, TStats = IModuleStats> {
|
|
1189
|
+
name: string;
|
|
1190
|
+
version: string;
|
|
1191
|
+
enabled: boolean;
|
|
1192
|
+
initialize(options?: TOptions, eventEmitter?: IEventEmitterPlugin): Promise<void>;
|
|
1193
|
+
dispose?(): Promise<void>;
|
|
1194
|
+
execute?(context: IModuleExecutionContext): Promise<IModuleExecutionResult>;
|
|
1195
|
+
getModuleType(): IModuleDescriptor;
|
|
1196
|
+
getCapabilities(): IModuleCapabilities;
|
|
1197
|
+
getData?(): IModuleData;
|
|
1198
|
+
getStats?(): TStats;
|
|
1199
|
+
isEnabled(): boolean;
|
|
1200
|
+
isInitialized(): boolean;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* @fileoverview Abstract Tool Base Class
|
|
1205
|
+
*
|
|
1206
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
1207
|
+
*
|
|
1208
|
+
* This is a pure abstract base class that defines the interface and common behavior
|
|
1209
|
+
* for all tools. It follows strict architectural principles:
|
|
1210
|
+
*
|
|
1211
|
+
* - Depends ONLY on interfaces (EventService interface, not concrete implementations)
|
|
1212
|
+
* - Does NOT import concrete classes
|
|
1213
|
+
* - Uses Dependency Injection for all dependencies
|
|
1214
|
+
* - Handles undefined dependencies gracefully (Null Object Pattern)
|
|
1215
|
+
*
|
|
1216
|
+
* Concrete implementations should be handled
|
|
1217
|
+
* by the caller who creates the tool instance, not by this abstract class.
|
|
1218
|
+
*
|
|
1219
|
+
* @example
|
|
1220
|
+
* ```typescript
|
|
1221
|
+
* // ✅ CORRECT: Caller prepares an owner-bound EventService and injects it
|
|
1222
|
+
* // (Example: bind to the current tool call identity and ownerPath.)
|
|
1223
|
+
* const toolEventService = bindWithOwnerPath(baseEventService, {
|
|
1224
|
+
* ownerType: 'tool',
|
|
1225
|
+
* ownerId: toolCallId,
|
|
1226
|
+
* ownerPath,
|
|
1227
|
+
* });
|
|
1228
|
+
* const tool = new MyTool({ eventService: toolEventService });
|
|
1229
|
+
*
|
|
1230
|
+
* // ❌ WRONG: AbstractTool creates concrete EventService
|
|
1231
|
+
* // This violates Dependency Inversion Principle
|
|
1232
|
+
* ```
|
|
1233
|
+
*/
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Options for AbstractTool construction
|
|
1237
|
+
*/
|
|
1238
|
+
interface IAbstractToolOptions {
|
|
1239
|
+
/**
|
|
1240
|
+
* Optional logger for tool operations
|
|
1241
|
+
* Defaults to SilentLogger if not provided
|
|
1242
|
+
*/
|
|
1243
|
+
logger?: ILogger;
|
|
1244
|
+
/**
|
|
1245
|
+
* Optional event service for unified event emission
|
|
1246
|
+
* If not provided, tool will operate silently without emitting events
|
|
1247
|
+
*
|
|
1248
|
+
* The caller should provide an EventService configured with appropriate settings
|
|
1249
|
+
* (e.g., ownerPrefix='tool' for tool events)
|
|
1250
|
+
*
|
|
1251
|
+
* @since 2.1.0
|
|
1252
|
+
*/
|
|
1253
|
+
eventService?: IEventService;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Tool execution function type with proper parameter constraints
|
|
1257
|
+
*/
|
|
1258
|
+
type TToolExecutionFunction<TParams = TToolParameters, TResult = IToolResult> = (parameters: TParams) => Promise<TResult> | TResult;
|
|
1259
|
+
/**
|
|
1260
|
+
* Abstract tool interface with type parameters for enhanced type safety
|
|
1261
|
+
*
|
|
1262
|
+
* @template TParams - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
|
|
1263
|
+
* @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
|
|
1264
|
+
*/
|
|
1265
|
+
interface IAbstractTool<TParams = TToolParameters, TResult = IToolResult> {
|
|
1266
|
+
name: string;
|
|
1267
|
+
description: string;
|
|
1268
|
+
parameters: IToolSchema['parameters'];
|
|
1269
|
+
execute: TToolExecutionFunction<TParams, TResult>;
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Type-safe tool interface with type parameters
|
|
1273
|
+
*
|
|
1274
|
+
* @template TParameters - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
|
|
1275
|
+
* @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
|
|
1276
|
+
*/
|
|
1277
|
+
interface IToolContract<TParameters = TToolParameters, TResult = IToolResult> {
|
|
1278
|
+
readonly schema: IToolSchema;
|
|
1279
|
+
execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
|
|
1280
|
+
validate(parameters: TParameters): boolean;
|
|
1281
|
+
validateParameters(parameters: TParameters): IParameterValidationResult;
|
|
1282
|
+
getDescription(): string;
|
|
1283
|
+
getName(): string;
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Runtime tool instance contract used by Robota internals.
|
|
1287
|
+
*
|
|
1288
|
+
* Tools passed into Agent configuration must support EventService injection
|
|
1289
|
+
* so Robota can emit unified tool lifecycle events.
|
|
1290
|
+
*/
|
|
1291
|
+
interface IToolWithEventService<TParameters = TToolParameters, TResult = IToolResult> extends IToolContract<TParameters, TResult> {
|
|
1292
|
+
setEventService(eventService: IEventService | undefined): void;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Abstract base class for tools with type parameter support
|
|
1296
|
+
* Provides type-safe parameter handling and result processing
|
|
1297
|
+
*
|
|
1298
|
+
* 🎯 ARCHITECTURAL PRINCIPLES:
|
|
1299
|
+
* - Pure abstract class - depends only on interfaces
|
|
1300
|
+
* - No concrete class dependencies (EventService interface only)
|
|
1301
|
+
* - Dependency Injection for all external dependencies
|
|
1302
|
+
* - Graceful degradation (undefined dependencies = silent operation)
|
|
1303
|
+
*
|
|
1304
|
+
* @template TParameters - Tool parameters type (defaults to TToolParameters)
|
|
1305
|
+
* @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
|
|
1306
|
+
*/
|
|
1307
|
+
declare abstract class AbstractTool<TParameters = TToolParameters, TResult = IToolResult> implements IToolWithEventService<TParameters, TResult> {
|
|
1308
|
+
abstract readonly schema: IToolSchema;
|
|
1309
|
+
/**
|
|
1310
|
+
* Logger for tool operations
|
|
1311
|
+
*/
|
|
1312
|
+
protected readonly logger: ILogger;
|
|
1313
|
+
/**
|
|
1314
|
+
* EventService for direct event emission (optional)
|
|
1315
|
+
* If undefined, tool operates silently without emitting events
|
|
1316
|
+
*/
|
|
1317
|
+
private eventService;
|
|
1318
|
+
/**
|
|
1319
|
+
* Constructor with simplified options
|
|
1320
|
+
*
|
|
1321
|
+
* 🎯 DEPENDENCY INJECTION:
|
|
1322
|
+
* All dependencies are injected via options parameter
|
|
1323
|
+
* No concrete classes are instantiated within this constructor
|
|
1324
|
+
*
|
|
1325
|
+
* @param options - Configuration options for the tool
|
|
1326
|
+
*/
|
|
1327
|
+
constructor(options?: IAbstractToolOptions);
|
|
1328
|
+
/**
|
|
1329
|
+
* Set EventService for post-construction injection
|
|
1330
|
+
*
|
|
1331
|
+
* 🎯 DEPENDENCY INJECTION:
|
|
1332
|
+
* Accepts EventService as-is without transformation
|
|
1333
|
+
* Caller is responsible for providing properly configured EventService
|
|
1334
|
+
*
|
|
1335
|
+
* @param eventService - EventService instance to use for event emission (or undefined for silent operation)
|
|
1336
|
+
*/
|
|
1337
|
+
setEventService(eventService: IEventService | undefined): void;
|
|
1338
|
+
/**
|
|
1339
|
+
* Get current EventService (for testing/inspection)
|
|
1340
|
+
*/
|
|
1341
|
+
protected getEventService(): IEventService | undefined;
|
|
1342
|
+
/**
|
|
1343
|
+
* Emit event through EventService (if available)
|
|
1344
|
+
* If EventService is not available, silently ignores the event (Null Object Pattern)
|
|
1345
|
+
*
|
|
1346
|
+
* @param eventType - Type of event to emit
|
|
1347
|
+
* @param data - Event data
|
|
1348
|
+
*/
|
|
1349
|
+
protected emitEvent(eventType: string, data: IBaseEventData): void;
|
|
1350
|
+
/**
|
|
1351
|
+
* Execute tool with simplified lifecycle
|
|
1352
|
+
* @param parameters - Tool parameters
|
|
1353
|
+
* @param context - Optional execution context
|
|
1354
|
+
* @returns Promise resolving to tool result
|
|
1355
|
+
*/
|
|
1356
|
+
execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
|
|
1357
|
+
/**
|
|
1358
|
+
* Concrete implementation of tool execution
|
|
1359
|
+
* This method should be implemented by subclasses to provide actual tool logic
|
|
1360
|
+
*
|
|
1361
|
+
* @param parameters - Tool parameters
|
|
1362
|
+
* @param context - Optional execution context
|
|
1363
|
+
* @returns Promise resolving to tool result
|
|
1364
|
+
*/
|
|
1365
|
+
protected abstract executeImpl(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
|
|
1366
|
+
validate(parameters: TParameters): boolean;
|
|
1367
|
+
/**
|
|
1368
|
+
* Validate tool parameters with detailed result (default implementation)
|
|
1369
|
+
*/
|
|
1370
|
+
validateParameters(parameters: TParameters): IParameterValidationResult;
|
|
1371
|
+
getDescription(): string;
|
|
1372
|
+
getName(): string;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Cache key identifying a unique LLM execution request
|
|
1377
|
+
*/
|
|
1378
|
+
interface ICacheKey {
|
|
1379
|
+
/** SHA-256 hash of the serialized request */
|
|
1380
|
+
hash: string;
|
|
1381
|
+
/** Model identifier */
|
|
1382
|
+
model: string;
|
|
1383
|
+
/** Provider name */
|
|
1384
|
+
provider: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Cached LLM response entry
|
|
1388
|
+
*/
|
|
1389
|
+
interface ICacheEntry {
|
|
1390
|
+
/** Cache key that produced this entry */
|
|
1391
|
+
key: ICacheKey;
|
|
1392
|
+
/** Cached response content */
|
|
1393
|
+
response: string;
|
|
1394
|
+
/** When the entry was cached */
|
|
1395
|
+
timestamp: number;
|
|
1396
|
+
/** SHA-256 integrity hash of the response */
|
|
1397
|
+
integrityHash: string;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Cache storage interface for pluggable backends
|
|
1401
|
+
*/
|
|
1402
|
+
interface ICacheStorage {
|
|
1403
|
+
/** Retrieve a cached entry by key hash */
|
|
1404
|
+
get(hash: string): ICacheEntry | undefined;
|
|
1405
|
+
/** Store a cache entry */
|
|
1406
|
+
set(entry: ICacheEntry): void;
|
|
1407
|
+
/** Delete a cached entry by key hash */
|
|
1408
|
+
delete(hash: string): boolean;
|
|
1409
|
+
/** Clear all cached entries */
|
|
1410
|
+
clear(): void;
|
|
1411
|
+
/** Get cache statistics */
|
|
1412
|
+
getStats(): ICacheStats;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Cache performance statistics
|
|
1416
|
+
*/
|
|
1417
|
+
interface ICacheStats {
|
|
1418
|
+
/** Number of cache hits */
|
|
1419
|
+
hits: number;
|
|
1420
|
+
/** Number of cache misses */
|
|
1421
|
+
misses: number;
|
|
1422
|
+
/** Current number of cached entries */
|
|
1423
|
+
entries: number;
|
|
1424
|
+
/** Hit rate (hits / (hits + misses)), 0 if no lookups */
|
|
1425
|
+
hitRate: number;
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Configuration options for execution caching
|
|
1429
|
+
*/
|
|
1430
|
+
interface ICacheOptions {
|
|
1431
|
+
/** Whether caching is enabled */
|
|
1432
|
+
enabled: boolean;
|
|
1433
|
+
/** Maximum number of cached entries */
|
|
1434
|
+
maxEntries: number;
|
|
1435
|
+
/** Time-to-live in milliseconds */
|
|
1436
|
+
ttlMs: number;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* IExecutionContextInjection
|
|
1441
|
+
*
|
|
1442
|
+
* Minimal context payload used to inject an existing ownerPath into a new agent instance
|
|
1443
|
+
* (e.g., when a tool creates an agent and must preserve absolute ownerPath semantics).
|
|
1444
|
+
*
|
|
1445
|
+
* NOTE: This is intentionally NOT ToolExecutionContext. ToolExecutionContext is for tool calls
|
|
1446
|
+
* and requires toolName/parameters; agent creation only needs ownerPath and execution linkage.
|
|
1447
|
+
*/
|
|
1448
|
+
interface IExecutionContextInjection {
|
|
1449
|
+
ownerPath?: IOwnerPathSegment[];
|
|
1450
|
+
parentExecutionId?: string;
|
|
1451
|
+
rootExecutionId?: string;
|
|
1452
|
+
executionLevel?: number;
|
|
1453
|
+
sourceId?: string;
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Provider-specific configuration
|
|
1457
|
+
*/
|
|
1458
|
+
interface IAgentProviderConfig {
|
|
1459
|
+
openai?: {
|
|
1460
|
+
apiKey?: string;
|
|
1461
|
+
baseURL?: string;
|
|
1462
|
+
organization?: string;
|
|
1463
|
+
[key: string]: TProviderConfigValue | undefined;
|
|
1464
|
+
};
|
|
1465
|
+
anthropic?: {
|
|
1466
|
+
apiKey?: string;
|
|
1467
|
+
baseURL?: string;
|
|
1468
|
+
[key: string]: TProviderConfigValue | undefined;
|
|
1469
|
+
};
|
|
1470
|
+
google?: {
|
|
1471
|
+
apiKey?: string;
|
|
1472
|
+
projectId?: string;
|
|
1473
|
+
location?: string;
|
|
1474
|
+
[key: string]: TProviderConfigValue | undefined;
|
|
1475
|
+
};
|
|
1476
|
+
[provider: string]: Record<string, TProviderConfigValue | undefined> | undefined;
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Agent configuration options - New design with aiProviders array and defaultModel
|
|
1480
|
+
*/
|
|
1481
|
+
interface IAgentConfig {
|
|
1482
|
+
id?: string;
|
|
1483
|
+
name: string;
|
|
1484
|
+
aiProviders: IAIProvider[];
|
|
1485
|
+
defaultModel: {
|
|
1486
|
+
provider: string;
|
|
1487
|
+
model: string;
|
|
1488
|
+
temperature?: number;
|
|
1489
|
+
maxTokens?: number;
|
|
1490
|
+
topP?: number;
|
|
1491
|
+
systemMessage?: string;
|
|
1492
|
+
};
|
|
1493
|
+
tools?: Array<IToolWithEventService>;
|
|
1494
|
+
plugins?: Array<IPluginContract<IPluginOptions, IPluginStats>>;
|
|
1495
|
+
modules?: IModule[];
|
|
1496
|
+
systemMessage?: string;
|
|
1497
|
+
systemPrompt?: string;
|
|
1498
|
+
conversationId?: string;
|
|
1499
|
+
sessionId?: string;
|
|
1500
|
+
userId?: string;
|
|
1501
|
+
metadata?: TUniversalMessageMetadata;
|
|
1502
|
+
context?: Record<string, TConfigValue>;
|
|
1503
|
+
logging?: {
|
|
1504
|
+
level?: TUtilLogLevel;
|
|
1505
|
+
enabled?: boolean;
|
|
1506
|
+
format?: string;
|
|
1507
|
+
destination?: string;
|
|
1508
|
+
};
|
|
1509
|
+
providerConfig?: IAgentProviderConfig;
|
|
1510
|
+
stream?: boolean;
|
|
1511
|
+
toolChoice?: 'auto' | 'none' | string;
|
|
1512
|
+
responseFormat?: IResponseFormatConfig;
|
|
1513
|
+
safetySettings?: ISafetySetting[];
|
|
1514
|
+
timeout?: number;
|
|
1515
|
+
retryAttempts?: number;
|
|
1516
|
+
rateLimiting?: {
|
|
1517
|
+
enabled?: boolean;
|
|
1518
|
+
maxRequests?: number;
|
|
1519
|
+
windowMs?: number;
|
|
1520
|
+
};
|
|
1521
|
+
eventService?: IEventService;
|
|
1522
|
+
executionContext?: IExecutionContextInjection;
|
|
1523
|
+
cache?: ICacheOptions;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Agent template interface
|
|
1527
|
+
*/
|
|
1528
|
+
interface IAgentTemplate {
|
|
1529
|
+
id: string;
|
|
1530
|
+
name: string;
|
|
1531
|
+
description?: string;
|
|
1532
|
+
category?: string;
|
|
1533
|
+
tags?: string[];
|
|
1534
|
+
config: IAgentConfig;
|
|
1535
|
+
version?: string;
|
|
1536
|
+
author?: string;
|
|
1537
|
+
createdAt?: Date;
|
|
1538
|
+
updatedAt?: Date;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Agent run options - type-safe interface for all agent execution options
|
|
1542
|
+
*/
|
|
1543
|
+
interface IRunOptions {
|
|
1544
|
+
temperature?: number;
|
|
1545
|
+
maxTokens?: number;
|
|
1546
|
+
stream?: boolean;
|
|
1547
|
+
toolChoice?: 'auto' | 'none' | string;
|
|
1548
|
+
sessionId?: string;
|
|
1549
|
+
userId?: string;
|
|
1550
|
+
metadata?: TMetadata;
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Generic agent interface with type parameters for enhanced type safety
|
|
1554
|
+
*
|
|
1555
|
+
* @template TConfig - Agent configuration type (defaults to IAgentConfig for backward compatibility)
|
|
1556
|
+
* @template TContext - Execution context type (defaults to IRunOptions for backward compatibility)
|
|
1557
|
+
* @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
|
|
1558
|
+
*/
|
|
1559
|
+
interface IAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> {
|
|
1560
|
+
/**
|
|
1561
|
+
* Configure the agent with type-safe configuration
|
|
1562
|
+
*/
|
|
1563
|
+
configure?(config: TConfig): Promise<void>;
|
|
1564
|
+
/**
|
|
1565
|
+
* Run agent with user input and type-safe context
|
|
1566
|
+
*/
|
|
1567
|
+
run(input: string, context?: TContext): Promise<string>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Run agent with streaming response and type-safe context
|
|
1570
|
+
*/
|
|
1571
|
+
runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Get conversation history with type-safe messages
|
|
1574
|
+
*/
|
|
1575
|
+
getHistory(): TMessage[];
|
|
1576
|
+
/**
|
|
1577
|
+
* Clear conversation history
|
|
1578
|
+
*/
|
|
1579
|
+
clearHistory(): void;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Response format configuration
|
|
1583
|
+
*/
|
|
1584
|
+
interface IResponseFormatConfig {
|
|
1585
|
+
type?: 'text' | 'json_object';
|
|
1586
|
+
schema?: Record<string, TConfigValue>;
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Safety setting configuration
|
|
1590
|
+
*/
|
|
1591
|
+
interface ISafetySetting {
|
|
1592
|
+
category: string;
|
|
1593
|
+
threshold: string;
|
|
1594
|
+
[key: string]: TConfigValue;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/**
|
|
1598
|
+
* Provider-agnostic media output reference.
|
|
1599
|
+
* Providers must not return raw binary payloads in this contract.
|
|
1600
|
+
*/
|
|
1601
|
+
interface IMediaOutputRef {
|
|
1602
|
+
kind: 'asset' | 'uri';
|
|
1603
|
+
assetId?: string;
|
|
1604
|
+
uri?: string;
|
|
1605
|
+
mimeType?: string;
|
|
1606
|
+
bytes?: number;
|
|
1607
|
+
}
|
|
1608
|
+
interface IProviderMediaError {
|
|
1609
|
+
code: 'PROVIDER_AUTH_ERROR' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_TIMEOUT' | 'PROVIDER_INVALID_REQUEST' | 'PROVIDER_UPSTREAM_ERROR' | 'PROVIDER_JOB_NOT_FOUND' | 'PROVIDER_JOB_NOT_CANCELLABLE';
|
|
1610
|
+
message: string;
|
|
1611
|
+
details?: Record<string, TUniversalValue>;
|
|
1612
|
+
}
|
|
1613
|
+
type TProviderMediaResult<TValue> = {
|
|
1614
|
+
ok: true;
|
|
1615
|
+
value: TValue;
|
|
1616
|
+
} | {
|
|
1617
|
+
ok: false;
|
|
1618
|
+
error: IProviderMediaError;
|
|
1619
|
+
};
|
|
1620
|
+
interface IInlineImageInputSource {
|
|
1621
|
+
kind: 'inline';
|
|
1622
|
+
mimeType: string;
|
|
1623
|
+
data: string;
|
|
1624
|
+
}
|
|
1625
|
+
interface IUriImageInputSource {
|
|
1626
|
+
kind: 'uri';
|
|
1627
|
+
uri: string;
|
|
1628
|
+
mimeType?: string;
|
|
1629
|
+
}
|
|
1630
|
+
type TImageInputSource = IInlineImageInputSource | IUriImageInputSource;
|
|
1631
|
+
interface IImageGenerationRequest {
|
|
1632
|
+
prompt: string;
|
|
1633
|
+
model: string;
|
|
1634
|
+
}
|
|
1635
|
+
interface IImageEditRequest {
|
|
1636
|
+
image: TImageInputSource;
|
|
1637
|
+
prompt: string;
|
|
1638
|
+
model: string;
|
|
1639
|
+
}
|
|
1640
|
+
interface IImageComposeRequest {
|
|
1641
|
+
images: TImageInputSource[];
|
|
1642
|
+
prompt: string;
|
|
1643
|
+
model: string;
|
|
1644
|
+
}
|
|
1645
|
+
interface IImageGenerationResult {
|
|
1646
|
+
outputs: IMediaOutputRef[];
|
|
1647
|
+
model: string;
|
|
1648
|
+
}
|
|
1649
|
+
interface IImageGenerationProvider {
|
|
1650
|
+
generateImage(request: IImageGenerationRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
1651
|
+
editImage?(request: IImageEditRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
1652
|
+
composeImage?(request: IImageComposeRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
|
|
1653
|
+
}
|
|
1654
|
+
interface IVideoGenerationRequest {
|
|
1655
|
+
prompt: string;
|
|
1656
|
+
model: string;
|
|
1657
|
+
durationSeconds?: number;
|
|
1658
|
+
aspectRatio?: string;
|
|
1659
|
+
seed?: number;
|
|
1660
|
+
inputImages?: TImageInputSource[];
|
|
1661
|
+
}
|
|
1662
|
+
interface IVideoJobAccepted {
|
|
1663
|
+
jobId: string;
|
|
1664
|
+
status: 'queued' | 'running';
|
|
1665
|
+
createdAt: string;
|
|
1666
|
+
}
|
|
1667
|
+
interface IVideoJobSnapshot {
|
|
1668
|
+
jobId: string;
|
|
1669
|
+
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
1670
|
+
output?: IMediaOutputRef;
|
|
1671
|
+
error?: IProviderMediaError;
|
|
1672
|
+
updatedAt: string;
|
|
1673
|
+
}
|
|
1674
|
+
interface IVideoGenerationProvider {
|
|
1675
|
+
createVideo(request: IVideoGenerationRequest): Promise<TProviderMediaResult<IVideoJobAccepted>>;
|
|
1676
|
+
getVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
|
|
1677
|
+
cancelVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
|
|
1678
|
+
}
|
|
1679
|
+
declare function isImageGenerationProvider(provider: object): provider is IImageGenerationProvider;
|
|
1680
|
+
declare function isVideoGenerationProvider(provider: object): provider is IVideoGenerationProvider;
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* Reusable type definitions for manager layer
|
|
1684
|
+
*/
|
|
1685
|
+
/**
|
|
1686
|
+
* Agent creation metadata type
|
|
1687
|
+
* Used for storing additional information about agent creation and configuration
|
|
1688
|
+
*/
|
|
1689
|
+
type TAgentCreationMetadata = Record<string, string | number | boolean | Date>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Tool execution parameters for manager operations
|
|
1692
|
+
* Used for tool parameter validation and execution in manager context
|
|
1693
|
+
*/
|
|
1694
|
+
type TManagerToolParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Configuration validation result
|
|
1697
|
+
*/
|
|
1698
|
+
interface IConfigValidationResult {
|
|
1699
|
+
isValid: boolean;
|
|
1700
|
+
errors: string[];
|
|
1701
|
+
warnings?: string[];
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* AI Provider Manager interface for provider registration and selection
|
|
1705
|
+
*/
|
|
1706
|
+
interface IAIProviderManager {
|
|
1707
|
+
/**
|
|
1708
|
+
* Register an AI provider
|
|
1709
|
+
*/
|
|
1710
|
+
addProvider(name: string, provider: IAIProvider): void;
|
|
1711
|
+
/**
|
|
1712
|
+
* Remove an AI provider
|
|
1713
|
+
*/
|
|
1714
|
+
removeProvider(name: string): void;
|
|
1715
|
+
/**
|
|
1716
|
+
* Get registered provider by name
|
|
1717
|
+
*/
|
|
1718
|
+
getProvider(name: string): IAIProvider | undefined;
|
|
1719
|
+
/**
|
|
1720
|
+
* Get all registered providers
|
|
1721
|
+
*/
|
|
1722
|
+
getProviders(): Record<string, IAIProvider>;
|
|
1723
|
+
/**
|
|
1724
|
+
* Set current provider and model
|
|
1725
|
+
*/
|
|
1726
|
+
setCurrentProvider(name: string, model: string): void;
|
|
1727
|
+
/**
|
|
1728
|
+
* Get current provider and model
|
|
1729
|
+
*/
|
|
1730
|
+
getCurrentProvider(): {
|
|
1731
|
+
provider: string;
|
|
1732
|
+
model: string;
|
|
1733
|
+
} | undefined;
|
|
1734
|
+
/**
|
|
1735
|
+
* Check if provider is configured
|
|
1736
|
+
*/
|
|
1737
|
+
isConfigured(): boolean;
|
|
1738
|
+
/**
|
|
1739
|
+
* Get available models for a provider
|
|
1740
|
+
*/
|
|
1741
|
+
getAvailableModels(providerName: string): string[];
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Tool Manager interface for tool registration and management
|
|
1745
|
+
*/
|
|
1746
|
+
interface IToolManager {
|
|
1747
|
+
/**
|
|
1748
|
+
* Register a tool
|
|
1749
|
+
*/
|
|
1750
|
+
addTool(schema: IToolSchema, executor: TToolExecutor): void;
|
|
1751
|
+
/**
|
|
1752
|
+
* Remove a tool by name
|
|
1753
|
+
*/
|
|
1754
|
+
removeTool(name: string): void;
|
|
1755
|
+
/**
|
|
1756
|
+
* Get tool interface by name
|
|
1757
|
+
*/
|
|
1758
|
+
getTool(name: string): ITool | undefined;
|
|
1759
|
+
/**
|
|
1760
|
+
* Get tool schema by name
|
|
1761
|
+
*/
|
|
1762
|
+
getToolSchema(name: string): IToolSchema | undefined;
|
|
1763
|
+
/**
|
|
1764
|
+
* Get all registered tools
|
|
1765
|
+
*/
|
|
1766
|
+
getTools(): IToolSchema[];
|
|
1767
|
+
/**
|
|
1768
|
+
* Execute a tool
|
|
1769
|
+
*/
|
|
1770
|
+
executeTool(name: string, parameters: TToolParameters, context?: IToolExecutionContext): Promise<TUniversalValue>;
|
|
1771
|
+
/**
|
|
1772
|
+
* Check if tool exists
|
|
1773
|
+
*/
|
|
1774
|
+
hasTool(name: string): boolean;
|
|
1775
|
+
/**
|
|
1776
|
+
* Set allowed tools (for filtering)
|
|
1777
|
+
*/
|
|
1778
|
+
setAllowedTools(tools: string[]): void;
|
|
1779
|
+
/**
|
|
1780
|
+
* Get allowed tools
|
|
1781
|
+
*/
|
|
1782
|
+
getAllowedTools(): string[] | undefined;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Agent creation options
|
|
1786
|
+
*/
|
|
1787
|
+
interface IAgentCreationOptions {
|
|
1788
|
+
/** Override default configuration */
|
|
1789
|
+
overrides?: Partial<IAgentConfig>;
|
|
1790
|
+
/** Validation options */
|
|
1791
|
+
validation?: {
|
|
1792
|
+
strict?: boolean;
|
|
1793
|
+
skipOptional?: boolean;
|
|
1794
|
+
};
|
|
1795
|
+
/** Additional metadata */
|
|
1796
|
+
metadata?: TAgentCreationMetadata;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Agent Factory interface for agent creation and configuration
|
|
1800
|
+
*/
|
|
1801
|
+
interface IAgentFactory {
|
|
1802
|
+
/**
|
|
1803
|
+
* Create agent instance
|
|
1804
|
+
*/
|
|
1805
|
+
createAgent(config: IAgentConfig, options?: IAgentCreationOptions): IAgent<IAgentConfig>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Validate agent configuration
|
|
1808
|
+
*/
|
|
1809
|
+
validateConfig(config: IAgentConfig): IConfigValidationResult;
|
|
1810
|
+
/**
|
|
1811
|
+
* Get default configuration
|
|
1812
|
+
*/
|
|
1813
|
+
getDefaultConfig(): IAgentConfig;
|
|
1814
|
+
/**
|
|
1815
|
+
* Merge configurations
|
|
1816
|
+
*/
|
|
1817
|
+
mergeConfig(base: IAgentConfig, override: Partial<IAgentConfig>): IAgentConfig;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Execution step definition for tools that support step-by-step progress reporting
|
|
1822
|
+
*/
|
|
1823
|
+
interface IToolExecutionStep {
|
|
1824
|
+
/** Unique identifier for this step */
|
|
1825
|
+
id: string;
|
|
1826
|
+
/** Human-readable name of the step */
|
|
1827
|
+
name: string;
|
|
1828
|
+
/** Tool-provided estimated duration for this step in milliseconds */
|
|
1829
|
+
estimatedDuration: number;
|
|
1830
|
+
/** Optional description of what this step does */
|
|
1831
|
+
description?: string;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Progress callback function type for real-time progress updates
|
|
1835
|
+
*/
|
|
1836
|
+
type TToolProgressCallback = (step: string, progress: number) => void;
|
|
1837
|
+
/**
|
|
1838
|
+
* 🆕 IProgressReportingTool - Optional interface for tools that can provide their own progress information
|
|
1839
|
+
*
|
|
1840
|
+
* This interface extends the standard ITool to allow tools to optionally provide:
|
|
1841
|
+
* - Estimated execution duration
|
|
1842
|
+
* - Step-by-step execution plans
|
|
1843
|
+
* - Real-time progress callbacks
|
|
1844
|
+
*
|
|
1845
|
+
* Benefits:
|
|
1846
|
+
* - Tools can provide accurate progress information based on their internal knowledge
|
|
1847
|
+
* - No simulation or fake progress - only real tool-provided estimates
|
|
1848
|
+
* - Completely optional - existing tools work unchanged
|
|
1849
|
+
* - Tools can self-report progress for better user experience
|
|
1850
|
+
*/
|
|
1851
|
+
interface IProgressReportingTool extends ITool {
|
|
1852
|
+
/**
|
|
1853
|
+
* Get estimated execution duration for given parameters (optional)
|
|
1854
|
+
*
|
|
1855
|
+
* Tools can implement this to provide accurate time estimates based on:
|
|
1856
|
+
* - Parameter complexity (e.g., search query length, file size)
|
|
1857
|
+
* - Historical execution data
|
|
1858
|
+
* - Internal optimization knowledge
|
|
1859
|
+
*
|
|
1860
|
+
* @param parameters - The parameters that will be passed to execute()
|
|
1861
|
+
* @returns Estimated duration in milliseconds, or undefined if not available
|
|
1862
|
+
*/
|
|
1863
|
+
getEstimatedDuration?(parameters: TToolParameters): number;
|
|
1864
|
+
/**
|
|
1865
|
+
* Get execution steps for given parameters (optional)
|
|
1866
|
+
*
|
|
1867
|
+
* Tools can implement this to provide step-by-step execution plans:
|
|
1868
|
+
* - webSearch: [query processing, API call, result parsing, filtering]
|
|
1869
|
+
* - fileSearch: [file scanning, content reading, pattern matching, result formatting]
|
|
1870
|
+
* - github-mcp: [authentication, API request, response processing, data transformation]
|
|
1871
|
+
*
|
|
1872
|
+
* @param parameters - The parameters that will be passed to execute()
|
|
1873
|
+
* @returns Array of execution steps, or undefined if not available
|
|
1874
|
+
*/
|
|
1875
|
+
getExecutionSteps?(parameters: TToolParameters): IToolExecutionStep[];
|
|
1876
|
+
/**
|
|
1877
|
+
* Set progress callback for real-time updates (optional)
|
|
1878
|
+
*
|
|
1879
|
+
* Tools can implement this to provide real-time progress updates during execution:
|
|
1880
|
+
* - Called when each step starts/completes
|
|
1881
|
+
* - Progress value between 0-100 representing completion percentage
|
|
1882
|
+
* - Step name helps users understand what's currently happening
|
|
1883
|
+
*
|
|
1884
|
+
* @param callback - Function to call with progress updates
|
|
1885
|
+
*/
|
|
1886
|
+
setProgressCallback?(callback: TToolProgressCallback): void;
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Type guard to check if a tool implements progress reporting
|
|
1890
|
+
*/
|
|
1891
|
+
declare function isProgressReportingTool(tool: ITool): tool is IProgressReportingTool;
|
|
1892
|
+
/**
|
|
1893
|
+
* Helper function to safely get estimated duration from any tool
|
|
1894
|
+
*/
|
|
1895
|
+
declare function getToolEstimatedDuration(tool: ITool, parameters: TToolParameters): number | undefined;
|
|
1896
|
+
/**
|
|
1897
|
+
* Helper function to safely get execution steps from any tool
|
|
1898
|
+
*/
|
|
1899
|
+
declare function getToolExecutionSteps(tool: ITool, parameters: TToolParameters): IToolExecutionStep[] | undefined;
|
|
1900
|
+
/**
|
|
1901
|
+
* Helper function to safely set progress callback on any tool
|
|
1902
|
+
*/
|
|
1903
|
+
declare function setToolProgressCallback(tool: ITool, callback: TToolProgressCallback): boolean;
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* Service layer interfaces for the agents package
|
|
1907
|
+
* Defines contracts for stateless service implementations
|
|
1908
|
+
*/
|
|
1909
|
+
|
|
1910
|
+
/**
|
|
1911
|
+
* Reusable type definitions for service layer
|
|
1912
|
+
*/
|
|
1913
|
+
/**
|
|
1914
|
+
* Metadata type for conversation and execution context
|
|
1915
|
+
* Used for storing additional information about conversations, responses, and execution
|
|
1916
|
+
*/
|
|
1917
|
+
type TConversationContextMetadata = Record<string, string | number | boolean | Date>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Tool execution parameters type
|
|
1920
|
+
* Used for passing parameters to tool execution methods
|
|
1921
|
+
*/
|
|
1922
|
+
type TToolExecutionParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
|
|
1923
|
+
/**
|
|
1924
|
+
* Execution metadata type
|
|
1925
|
+
* Used for storing metadata about execution processes and options
|
|
1926
|
+
*/
|
|
1927
|
+
type TExecutionMetadata = Record<string, string | number | boolean | Date>;
|
|
1928
|
+
/**
|
|
1929
|
+
* Response metadata type
|
|
1930
|
+
* Used for storing metadata about AI provider responses and streaming chunks
|
|
1931
|
+
*/
|
|
1932
|
+
type TResponseMetadata = Record<string, string | number | boolean | Date>;
|
|
1933
|
+
/**
|
|
1934
|
+
* Tool call data structure for function calls
|
|
1935
|
+
*/
|
|
1936
|
+
/**
|
|
1937
|
+
* Tool execution request
|
|
1938
|
+
*/
|
|
1939
|
+
interface IToolExecutionRequest {
|
|
1940
|
+
toolName: string;
|
|
1941
|
+
parameters: TToolParameters;
|
|
1942
|
+
executionId?: string;
|
|
1943
|
+
metadata?: TToolMetadata;
|
|
1944
|
+
ownerType?: string;
|
|
1945
|
+
ownerId?: string;
|
|
1946
|
+
ownerPath?: IOwnerPathSegment[];
|
|
1947
|
+
eventService?: IEventService;
|
|
1948
|
+
baseEventService?: IEventService;
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Conversation context containing messages and metadata
|
|
1952
|
+
*/
|
|
1953
|
+
interface IConversationContext {
|
|
1954
|
+
/** All messages in the conversation */
|
|
1955
|
+
messages: TUniversalMessage[];
|
|
1956
|
+
/** System message for the conversation */
|
|
1957
|
+
systemMessage?: string;
|
|
1958
|
+
/** Model to use for generation */
|
|
1959
|
+
model: string;
|
|
1960
|
+
/** Provider to use for generation */
|
|
1961
|
+
provider: string;
|
|
1962
|
+
/** Temperature for generation */
|
|
1963
|
+
temperature?: number;
|
|
1964
|
+
/** Maximum tokens to generate */
|
|
1965
|
+
maxTokens?: number;
|
|
1966
|
+
/** Available tools */
|
|
1967
|
+
tools?: IToolSchema[];
|
|
1968
|
+
/** Additional metadata */
|
|
1969
|
+
metadata?: TConversationContextMetadata;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Response from AI provider
|
|
1973
|
+
*/
|
|
1974
|
+
interface IConversationResponse {
|
|
1975
|
+
/** Generated content */
|
|
1976
|
+
content: string;
|
|
1977
|
+
/** Tool calls if any */
|
|
1978
|
+
toolCalls?: IToolCall[];
|
|
1979
|
+
/** Usage statistics */
|
|
1980
|
+
usage?: {
|
|
1981
|
+
promptTokens: number;
|
|
1982
|
+
completionTokens: number;
|
|
1983
|
+
totalTokens: number;
|
|
1984
|
+
};
|
|
1985
|
+
/** Response metadata */
|
|
1986
|
+
metadata?: TResponseMetadata;
|
|
1987
|
+
/** Finish reason */
|
|
1988
|
+
finishReason?: string;
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* Streaming response chunk
|
|
1992
|
+
*/
|
|
1993
|
+
interface IStreamingChunk {
|
|
1994
|
+
/** Content delta */
|
|
1995
|
+
delta: string;
|
|
1996
|
+
/** Whether this is the final chunk */
|
|
1997
|
+
done: boolean;
|
|
1998
|
+
/** Tool calls if any */
|
|
1999
|
+
toolCalls?: IToolCall[];
|
|
2000
|
+
/** Usage statistics (only in final chunk) */
|
|
2001
|
+
usage?: {
|
|
2002
|
+
promptTokens: number;
|
|
2003
|
+
completionTokens: number;
|
|
2004
|
+
totalTokens: number;
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Service options for conversation operations
|
|
2009
|
+
*/
|
|
2010
|
+
interface IConversationServiceOptions {
|
|
2011
|
+
/** Maximum conversation history length */
|
|
2012
|
+
maxHistoryLength?: number;
|
|
2013
|
+
/** Whether to automatically retry on failure */
|
|
2014
|
+
enableRetry?: boolean;
|
|
2015
|
+
/** Maximum number of retries */
|
|
2016
|
+
maxRetries?: number;
|
|
2017
|
+
/** Retry delay in milliseconds */
|
|
2018
|
+
retryDelay?: number;
|
|
2019
|
+
/** Request timeout in milliseconds */
|
|
2020
|
+
timeout?: number;
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Context options for conversation preparation
|
|
2024
|
+
*/
|
|
2025
|
+
interface IContextOptions {
|
|
2026
|
+
systemMessage?: string;
|
|
2027
|
+
temperature?: number;
|
|
2028
|
+
maxTokens?: number;
|
|
2029
|
+
tools?: IToolSchema[];
|
|
2030
|
+
metadata?: TConversationContextMetadata;
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Execution service options
|
|
2034
|
+
*/
|
|
2035
|
+
interface IExecutionServiceOptions {
|
|
2036
|
+
/** Maximum number of tool execution rounds */
|
|
2037
|
+
maxToolRounds?: number;
|
|
2038
|
+
/** Tool execution timeout */
|
|
2039
|
+
toolTimeout?: number;
|
|
2040
|
+
/** Whether to enable parallel tool execution */
|
|
2041
|
+
enableParallelExecution?: boolean;
|
|
2042
|
+
/** Additional execution metadata */
|
|
2043
|
+
metadata?: TExecutionMetadata;
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* Interface for conversation service operations
|
|
2047
|
+
* All methods should be stateless and pure functions
|
|
2048
|
+
*/
|
|
2049
|
+
interface IConversationService {
|
|
2050
|
+
/**
|
|
2051
|
+
* Prepare conversation context from messages and configuration
|
|
2052
|
+
* Pure function that transforms inputs to context object
|
|
2053
|
+
*/
|
|
2054
|
+
prepareContext(messages: TUniversalMessage[], model: string, provider: string, contextOptions?: IContextOptions, serviceOptions?: IConversationServiceOptions): IConversationContext;
|
|
2055
|
+
/**
|
|
2056
|
+
* Generate a response using the AI provider
|
|
2057
|
+
* Stateless operation that handles the full request-response cycle
|
|
2058
|
+
*/
|
|
2059
|
+
generateResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): Promise<IConversationResponse>;
|
|
2060
|
+
/**
|
|
2061
|
+
* Generate streaming response using the AI provider
|
|
2062
|
+
* Stateless streaming operation
|
|
2063
|
+
*/
|
|
2064
|
+
generateStreamingResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): AsyncGenerator<IStreamingChunk, void, never>;
|
|
2065
|
+
/**
|
|
2066
|
+
* Validate conversation context
|
|
2067
|
+
* Pure validation function
|
|
2068
|
+
*/
|
|
2069
|
+
validateContext(context: IConversationContext): {
|
|
2070
|
+
isValid: boolean;
|
|
2071
|
+
errors: string[];
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Interface for tool execution service operations
|
|
2076
|
+
*/
|
|
2077
|
+
interface IToolExecutionService {
|
|
2078
|
+
/**
|
|
2079
|
+
* Execute a single tool
|
|
2080
|
+
*/
|
|
2081
|
+
executeTool(toolName: string, parameters: TToolParameters): Promise<TUniversalValue>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Execute multiple tools in parallel
|
|
2084
|
+
*/
|
|
2085
|
+
executeToolsParallel(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
|
|
2086
|
+
/**
|
|
2087
|
+
* Execute multiple tools sequentially
|
|
2088
|
+
*/
|
|
2089
|
+
executeToolsSequential(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Interface for execution service operations
|
|
2093
|
+
*/
|
|
2094
|
+
interface IExecutionService {
|
|
2095
|
+
/**
|
|
2096
|
+
* Execute complete agent pipeline
|
|
2097
|
+
*/
|
|
2098
|
+
execute(input: string, context: IConversationContext, options?: IExecutionServiceOptions): Promise<string>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Execute streaming agent pipeline
|
|
2101
|
+
*/
|
|
2102
|
+
executeStream(input: string, context: IConversationContext, options?: IExecutionServiceOptions): AsyncGenerator<string, void, never>;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
/**
|
|
2106
|
+
* Request for executing a streaming chat completion through an executor
|
|
2107
|
+
*/
|
|
2108
|
+
interface IChatExecutionRequest {
|
|
2109
|
+
/** Array of messages in the conversation */
|
|
2110
|
+
messages: TUniversalMessage[];
|
|
2111
|
+
/** Chat options including model, temperature, etc. */
|
|
2112
|
+
options?: IChatOptions;
|
|
2113
|
+
/** Available tools for the AI to use */
|
|
2114
|
+
tools?: IToolSchema[];
|
|
2115
|
+
/** Target AI provider (e.g., 'openai', 'anthropic', 'google') */
|
|
2116
|
+
provider: string;
|
|
2117
|
+
/** Specific model to use */
|
|
2118
|
+
model: string;
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Request for executing a streaming chat completion through an executor
|
|
2122
|
+
*/
|
|
2123
|
+
interface IStreamExecutionRequest extends IChatExecutionRequest {
|
|
2124
|
+
/** Indicates this is a streaming request */
|
|
2125
|
+
stream: true;
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Interface for executing AI provider operations
|
|
2129
|
+
*
|
|
2130
|
+
* Executors abstract the execution mechanism, allowing providers to work
|
|
2131
|
+
* with either local API calls or remote server calls transparently.
|
|
2132
|
+
*
|
|
2133
|
+
* Implementation patterns:
|
|
2134
|
+
* - LocalExecutor: Direct API calls using provider SDKs
|
|
2135
|
+
* - RemoteExecutor: HTTP/WebSocket calls to remote server
|
|
2136
|
+
* - CacheExecutor: Cached responses with explicit error propagation
|
|
2137
|
+
* - HybridExecutor: Conditional local/remote execution
|
|
2138
|
+
*/
|
|
2139
|
+
interface IExecutor {
|
|
2140
|
+
/**
|
|
2141
|
+
* Execute a chat completion request
|
|
2142
|
+
*
|
|
2143
|
+
* @param request - Chat execution request with messages, options, and tools
|
|
2144
|
+
* @returns Promise resolving to assistant message response
|
|
2145
|
+
*
|
|
2146
|
+
* @example
|
|
2147
|
+
* ```typescript
|
|
2148
|
+
* const response = await executor.executeChat({
|
|
2149
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
2150
|
+
* options: { model: 'gpt-4', temperature: 0.7 },
|
|
2151
|
+
* provider: 'openai',
|
|
2152
|
+
* model: 'gpt-4'
|
|
2153
|
+
* });
|
|
2154
|
+
* ```
|
|
2155
|
+
*/
|
|
2156
|
+
executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
|
|
2157
|
+
/**
|
|
2158
|
+
* Execute a streaming chat completion request
|
|
2159
|
+
*
|
|
2160
|
+
* @param request - Streaming chat execution request
|
|
2161
|
+
* @returns AsyncIterable of message chunks
|
|
2162
|
+
*
|
|
2163
|
+
* @example
|
|
2164
|
+
* ```typescript
|
|
2165
|
+
* for await (const chunk of executor.executeChatStream({
|
|
2166
|
+
* messages: [{ role: 'user', content: 'Tell me a story' }],
|
|
2167
|
+
* options: { model: 'gpt-4' },
|
|
2168
|
+
* provider: 'openai',
|
|
2169
|
+
* model: 'gpt-4',
|
|
2170
|
+
* stream: true
|
|
2171
|
+
* })) {
|
|
2172
|
+
* console.log(chunk.content);
|
|
2173
|
+
* }
|
|
2174
|
+
* ```
|
|
2175
|
+
*/
|
|
2176
|
+
executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
|
|
2177
|
+
/**
|
|
2178
|
+
* Check if the executor supports tool calling
|
|
2179
|
+
* @returns true if tool calling is supported
|
|
2180
|
+
*/
|
|
2181
|
+
supportsTools(): boolean;
|
|
2182
|
+
/**
|
|
2183
|
+
* Validate executor configuration
|
|
2184
|
+
* @returns true if configuration is valid
|
|
2185
|
+
*/
|
|
2186
|
+
validateConfig(): boolean;
|
|
2187
|
+
/**
|
|
2188
|
+
* Clean up resources when executor is no longer needed
|
|
2189
|
+
*/
|
|
2190
|
+
dispose?(): Promise<void>;
|
|
2191
|
+
/**
|
|
2192
|
+
* Get executor name/identifier
|
|
2193
|
+
*/
|
|
2194
|
+
readonly name: string;
|
|
2195
|
+
/**
|
|
2196
|
+
* Get executor version
|
|
2197
|
+
*/
|
|
2198
|
+
readonly version: string;
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Configuration options for local executor
|
|
2202
|
+
*/
|
|
2203
|
+
interface ILocalExecutorConfig {
|
|
2204
|
+
/** Timeout for API requests in milliseconds */
|
|
2205
|
+
timeout?: number;
|
|
2206
|
+
/** Maximum number of retry attempts */
|
|
2207
|
+
maxRetries?: number;
|
|
2208
|
+
/** Base delay between retries in milliseconds */
|
|
2209
|
+
retryDelay?: number;
|
|
2210
|
+
/** Whether to enable request/response logging */
|
|
2211
|
+
enableLogging?: boolean;
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Configuration options for remote executor
|
|
2215
|
+
*/
|
|
2216
|
+
interface IRemoteExecutorConfig {
|
|
2217
|
+
/** Remote server URL */
|
|
2218
|
+
serverUrl: string;
|
|
2219
|
+
/** User authentication token */
|
|
2220
|
+
userApiKey: string;
|
|
2221
|
+
/** Timeout for HTTP requests in milliseconds */
|
|
2222
|
+
timeout?: number;
|
|
2223
|
+
/** Maximum number of retry attempts */
|
|
2224
|
+
maxRetries?: number;
|
|
2225
|
+
/** Whether to enable WebSocket for streaming */
|
|
2226
|
+
enableWebSocket?: boolean;
|
|
2227
|
+
/** Custom headers to include in requests */
|
|
2228
|
+
headers?: Record<string, string>;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
interface IEventHistoryRecord {
|
|
2232
|
+
eventName: string;
|
|
2233
|
+
sequenceId: number;
|
|
2234
|
+
timestamp: Date;
|
|
2235
|
+
eventData: IBaseEventData;
|
|
2236
|
+
context: IEventContext;
|
|
2237
|
+
}
|
|
2238
|
+
interface IEventHistorySnapshot {
|
|
2239
|
+
lastSequenceId: number;
|
|
2240
|
+
createdAt: Date;
|
|
2241
|
+
}
|
|
2242
|
+
interface IEventHistoryModule {
|
|
2243
|
+
append(record: IEventHistoryRecord): void;
|
|
2244
|
+
read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
|
|
2245
|
+
readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
|
|
2246
|
+
getSnapshot?(): IEventHistorySnapshot | undefined;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/**
|
|
2250
|
+
* @fileoverview Abstract Agent Base Class
|
|
2251
|
+
*
|
|
2252
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
2253
|
+
*
|
|
2254
|
+
* This class defines the foundational lifecycle for agent implementations.
|
|
2255
|
+
* Subclasses provide provider/tool-specific behavior while inheriting the
|
|
2256
|
+
* shared guarantees around initialization, history, and disposal.
|
|
2257
|
+
*/
|
|
2258
|
+
|
|
2259
|
+
declare abstract class AbstractAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> implements IAgent<TConfig, TContext, TMessage> {
|
|
2260
|
+
protected history: TMessage[];
|
|
2261
|
+
protected isInitialized: boolean;
|
|
2262
|
+
protected config?: TConfig;
|
|
2263
|
+
/**
|
|
2264
|
+
* Initialize the agent (subclass responsibility)
|
|
2265
|
+
*/
|
|
2266
|
+
protected abstract initialize(): Promise<void>;
|
|
2267
|
+
/**
|
|
2268
|
+
* Configure the agent with type-safe configuration
|
|
2269
|
+
*/
|
|
2270
|
+
configure(config: TConfig): Promise<void>;
|
|
2271
|
+
/**
|
|
2272
|
+
* Run agent with user input and type-safe context
|
|
2273
|
+
*/
|
|
2274
|
+
abstract run(input: string, context?: TContext): Promise<string>;
|
|
2275
|
+
/**
|
|
2276
|
+
* Run agent with streaming response and type-safe context
|
|
2277
|
+
*/
|
|
2278
|
+
abstract runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
|
|
2279
|
+
/**
|
|
2280
|
+
* Get conversation history with type-safe messages
|
|
2281
|
+
*/
|
|
2282
|
+
getHistory(): TMessage[];
|
|
2283
|
+
/**
|
|
2284
|
+
* Clear conversation history
|
|
2285
|
+
*/
|
|
2286
|
+
clearHistory(): void;
|
|
2287
|
+
/**
|
|
2288
|
+
* Add message to history
|
|
2289
|
+
*/
|
|
2290
|
+
protected addMessage(message: TMessage): void;
|
|
2291
|
+
/**
|
|
2292
|
+
* Validate user input
|
|
2293
|
+
*/
|
|
2294
|
+
protected validateInput(input: string): void;
|
|
2295
|
+
/**
|
|
2296
|
+
* Ensure agent is initialized before running
|
|
2297
|
+
*/
|
|
2298
|
+
protected ensureInitialized(): Promise<void>;
|
|
2299
|
+
/**
|
|
2300
|
+
* Cleanup resources
|
|
2301
|
+
*/
|
|
2302
|
+
dispose(): Promise<void>;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
/**
|
|
2306
|
+
* @fileoverview Abstract Manager Base Class
|
|
2307
|
+
*
|
|
2308
|
+
* 🎯 ABSTRACT CLASS - DO NOT IMPORT CONCRETE IMPLEMENTATIONS
|
|
2309
|
+
*
|
|
2310
|
+
* This class defines the common lifecycle contract for all manager implementations.
|
|
2311
|
+
* It enforces explicit initialization/disposal semantics so that subclasses can
|
|
2312
|
+
* provide their own resource management logic while sharing guard rails.
|
|
2313
|
+
*
|
|
2314
|
+
* Architectural rules:
|
|
2315
|
+
* - Depends only on abstractions (no concrete manager implementations)
|
|
2316
|
+
* - Provides finalize hooks (`doInitialize`, `doDispose`) for subclasses
|
|
2317
|
+
* - Guards public APIs via `ensureInitialized`
|
|
2318
|
+
*/
|
|
2319
|
+
declare abstract class AbstractManager {
|
|
2320
|
+
protected initialized: boolean;
|
|
2321
|
+
/**
|
|
2322
|
+
* Initialize the manager (idempotent)
|
|
2323
|
+
*/
|
|
2324
|
+
initialize(): Promise<void>;
|
|
2325
|
+
/**
|
|
2326
|
+
* Subclass-specific initialization logic
|
|
2327
|
+
*/
|
|
2328
|
+
protected abstract doInitialize(): Promise<void>;
|
|
2329
|
+
/**
|
|
2330
|
+
* Dispose manager resources (idempotent)
|
|
2331
|
+
*/
|
|
2332
|
+
dispose(): Promise<void>;
|
|
2333
|
+
/**
|
|
2334
|
+
* Subclass-specific disposal logic
|
|
2335
|
+
*/
|
|
2336
|
+
protected abstract doDispose(): Promise<void>;
|
|
2337
|
+
/**
|
|
2338
|
+
* Whether the manager completed initialization
|
|
2339
|
+
*/
|
|
2340
|
+
isInitialized(): boolean;
|
|
2341
|
+
/**
|
|
2342
|
+
* Ensure manager is initialized before performing operations
|
|
2343
|
+
*/
|
|
2344
|
+
protected ensureInitialized(): void;
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* @fileoverview Abstract AI Provider Base Class
|
|
2349
|
+
*
|
|
2350
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
2351
|
+
*
|
|
2352
|
+
* Defines the shared contract and helper utilities for all AI provider implementations.
|
|
2353
|
+
* Concrete providers should extend this class and inject their own dependencies.
|
|
2354
|
+
*/
|
|
2355
|
+
|
|
2356
|
+
/**
|
|
2357
|
+
* Provider logging data type
|
|
2358
|
+
* Used for storing logging information in provider operations
|
|
2359
|
+
*/
|
|
2360
|
+
type TProviderLoggingData = Record<string, string | number | boolean | Date | string[]>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Provider configuration base interface
|
|
2363
|
+
*/
|
|
2364
|
+
interface IProviderConfig {
|
|
2365
|
+
apiKey?: string;
|
|
2366
|
+
baseUrl?: string;
|
|
2367
|
+
timeout?: number;
|
|
2368
|
+
[key: string]: string | number | boolean | undefined;
|
|
2369
|
+
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Enhanced provider configuration that supports executor injection
|
|
2372
|
+
*/
|
|
2373
|
+
interface IExecutorAwareProviderConfig {
|
|
2374
|
+
apiKey?: string;
|
|
2375
|
+
baseUrl?: string;
|
|
2376
|
+
timeout?: number;
|
|
2377
|
+
/**
|
|
2378
|
+
* Optional executor for handling AI requests
|
|
2379
|
+
* When provided, the provider will delegate all chat operations to this executor
|
|
2380
|
+
* instead of making direct API calls. This enables remote execution capabilities.
|
|
2381
|
+
*/
|
|
2382
|
+
executor?: IExecutor;
|
|
2383
|
+
[key: string]: string | number | boolean | IExecutor | undefined;
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Base AI provider implementation with proper type constraints
|
|
2387
|
+
* All AI providers should extend this class
|
|
2388
|
+
*
|
|
2389
|
+
* ========================================
|
|
2390
|
+
* CRITICAL IMPLEMENTATION GUIDELINES
|
|
2391
|
+
* ========================================
|
|
2392
|
+
*
|
|
2393
|
+
* ALL AI PROVIDER IMPLEMENTATIONS (OpenAI, Anthropic, Google, etc.) MUST:
|
|
2394
|
+
*
|
|
2395
|
+
* 1. EXTEND THIS CLASS:
|
|
2396
|
+
* ```typescript
|
|
2397
|
+
* export class OpenAIProvider extends AbstractAIProvider {
|
|
2398
|
+
* override readonly name = 'openai';
|
|
2399
|
+
* override readonly version = '1.0.0';
|
|
2400
|
+
* ```
|
|
2401
|
+
*
|
|
2402
|
+
* 2. USE IMPORTS FROM @robota-sdk/agent-core:
|
|
2403
|
+
* ```typescript
|
|
2404
|
+
* import { AbstractAIProvider } from '@robota-sdk/agent-core';
|
|
2405
|
+
* import type {
|
|
2406
|
+
* TUniversalMessage,
|
|
2407
|
+
* ChatOptions,
|
|
2408
|
+
* IToolCall,
|
|
2409
|
+
* ToolSchema,
|
|
2410
|
+
* AssistantMessage
|
|
2411
|
+
* } from '@robota-sdk/agent-core';
|
|
2412
|
+
* ```
|
|
2413
|
+
*
|
|
2414
|
+
* 3. USE OVERRIDE KEYWORD FOR ALL INHERITED METHODS:
|
|
2415
|
+
* - override async chat(...)
|
|
2416
|
+
* - override async *chatStream(...)
|
|
2417
|
+
* - override supportsTools()
|
|
2418
|
+
* - override validateConfig()
|
|
2419
|
+
* - override async dispose()
|
|
2420
|
+
*
|
|
2421
|
+
* 4. DO NOT REDEFINE TYPES THAT EXIST IN @robota-sdk/agent-core:
|
|
2422
|
+
* - TUniversalMessage
|
|
2423
|
+
* - ChatOptions
|
|
2424
|
+
* - IToolCall
|
|
2425
|
+
* - ToolSchema
|
|
2426
|
+
* - AssistantMessage
|
|
2427
|
+
* - SystemMessage
|
|
2428
|
+
* - UserMessage
|
|
2429
|
+
* - ToolMessage
|
|
2430
|
+
*
|
|
2431
|
+
* 5. HANDLE MESSAGE CONTENT PROPERLY:
|
|
2432
|
+
* - For tool calls: content should be null (not empty string)
|
|
2433
|
+
* - For regular messages: content can be string or null
|
|
2434
|
+
* - Always preserve null values from API responses
|
|
2435
|
+
*
|
|
2436
|
+
* 6. CALL SUPER() IN CONSTRUCTOR:
|
|
2437
|
+
* ```typescript
|
|
2438
|
+
* constructor(options: IProviderOptions) {
|
|
2439
|
+
* super();
|
|
2440
|
+
* // provider-specific initialization
|
|
2441
|
+
* }
|
|
2442
|
+
* ```
|
|
2443
|
+
*
|
|
2444
|
+
* This ensures ExecutionService can properly identify providers
|
|
2445
|
+
* and prevents type conflicts across the codebase.
|
|
2446
|
+
*
|
|
2447
|
+
* ========================================
|
|
2448
|
+
*
|
|
2449
|
+
* @template TConfig - Provider configuration type (defaults to IProviderConfig for type safety)
|
|
2450
|
+
* @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
|
|
2451
|
+
* @template TResponse - Response type (defaults to TUniversalMessage for backward compatibility)
|
|
2452
|
+
*/
|
|
2453
|
+
declare abstract class AbstractAIProvider<TConfig = IProviderConfig> implements IAIProvider {
|
|
2454
|
+
abstract readonly name: string;
|
|
2455
|
+
abstract readonly version: string;
|
|
2456
|
+
protected config?: TConfig;
|
|
2457
|
+
protected executor?: IExecutor;
|
|
2458
|
+
protected readonly logger: ILogger;
|
|
2459
|
+
constructor(logger?: ILogger);
|
|
2460
|
+
/**
|
|
2461
|
+
* Configure the provider with type-safe configuration
|
|
2462
|
+
*/
|
|
2463
|
+
configure(config: TConfig): Promise<void>;
|
|
2464
|
+
private hasExecutor;
|
|
2465
|
+
/**
|
|
2466
|
+
* Each provider must implement chat using their own native SDK types internally
|
|
2467
|
+
* @param messages - Array of messages from conversation history
|
|
2468
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
2469
|
+
* @returns Promise resolving to a response
|
|
2470
|
+
*/
|
|
2471
|
+
abstract chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
2472
|
+
/**
|
|
2473
|
+
* Each provider must implement streaming chat using their own native SDK types internally
|
|
2474
|
+
* @param messages - Array of messages from conversation history
|
|
2475
|
+
* @param options - Chat options including tools, model settings, etc.
|
|
2476
|
+
* @returns AsyncIterable of response chunks
|
|
2477
|
+
*/
|
|
2478
|
+
chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
2479
|
+
/**
|
|
2480
|
+
* Provider-agnostic raw response API.
|
|
2481
|
+
*
|
|
2482
|
+
* This is the canonical "raw payload" entrypoint required by the AIProvider contract.
|
|
2483
|
+
* The default implementation delegates to `chat()` and adapts the result into a
|
|
2484
|
+
* RawProviderResponse shape.
|
|
2485
|
+
*/
|
|
2486
|
+
generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
|
|
2487
|
+
/**
|
|
2488
|
+
* Provider-agnostic raw streaming API.
|
|
2489
|
+
*
|
|
2490
|
+
* If a provider does not implement chatStream, it does not support streaming.
|
|
2491
|
+
*/
|
|
2492
|
+
generateStreamingResponse(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
|
|
2493
|
+
/**
|
|
2494
|
+
* Default implementation - most modern providers support tools
|
|
2495
|
+
* @returns true if tool calling is supported
|
|
2496
|
+
*/
|
|
2497
|
+
supportsTools(): boolean;
|
|
2498
|
+
/**
|
|
2499
|
+
* Default implementation - providers can override for specific validation
|
|
2500
|
+
* @returns true if configuration is valid
|
|
2501
|
+
*/
|
|
2502
|
+
validateConfig(): boolean;
|
|
2503
|
+
/**
|
|
2504
|
+
* Utility method for validating TUniversalMessage array
|
|
2505
|
+
* @param messages - Messages to validate
|
|
2506
|
+
*/
|
|
2507
|
+
protected validateMessages(messages: TUniversalMessage[]): void;
|
|
2508
|
+
/**
|
|
2509
|
+
* Utility method for validating tool schemas
|
|
2510
|
+
* @param tools - Tool schemas to validate
|
|
2511
|
+
*/
|
|
2512
|
+
protected validateTools(tools?: IToolSchema[]): void;
|
|
2513
|
+
/**
|
|
2514
|
+
* Execute chat via executor.
|
|
2515
|
+
*
|
|
2516
|
+
* Subclasses should call this only when an executor is configured.
|
|
2517
|
+
*/
|
|
2518
|
+
protected executeViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
2519
|
+
/**
|
|
2520
|
+
* Execute streaming chat via executor.
|
|
2521
|
+
*
|
|
2522
|
+
* Subclasses should call this only when an executor is configured.
|
|
2523
|
+
*/
|
|
2524
|
+
protected executeStreamViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
2525
|
+
/**
|
|
2526
|
+
* Clean up resources when provider is no longer needed
|
|
2527
|
+
* Override this method in subclasses for additional cleanup
|
|
2528
|
+
*/
|
|
2529
|
+
dispose(): Promise<void>;
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/**
|
|
2533
|
+
* @fileoverview Abstract Executor Base Class
|
|
2534
|
+
*
|
|
2535
|
+
* 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
|
|
2536
|
+
*
|
|
2537
|
+
* Provides shared execution helpers (retry, timeout, validation, logging) for all
|
|
2538
|
+
* executor implementations. Concrete executors should extend this class and inject
|
|
2539
|
+
* their own logger implementation if they need custom logging behavior.
|
|
2540
|
+
*
|
|
2541
|
+
* @example
|
|
2542
|
+
* ```typescript
|
|
2543
|
+
* export class MyCustomExecutor extends AbstractExecutor {
|
|
2544
|
+
* async executeChat(request: IChatExecutionRequest): Promise<AssistantMessage> {
|
|
2545
|
+
* return this.withRetry(() => this.performChat(request));
|
|
2546
|
+
* }
|
|
2547
|
+
* }
|
|
2548
|
+
* ```
|
|
2549
|
+
*/
|
|
2550
|
+
declare abstract class AbstractExecutor implements IExecutor {
|
|
2551
|
+
/**
|
|
2552
|
+
* Logger injected via constructor (defaults to abstract logger)
|
|
2553
|
+
*/
|
|
2554
|
+
protected readonly logger: ILogger;
|
|
2555
|
+
constructor(logger?: ILogger);
|
|
2556
|
+
abstract readonly name: string;
|
|
2557
|
+
abstract readonly version: string;
|
|
2558
|
+
/**
|
|
2559
|
+
* Execute a chat completion request
|
|
2560
|
+
* Must be implemented by concrete executor classes
|
|
2561
|
+
*/
|
|
2562
|
+
abstract executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
|
|
2563
|
+
/**
|
|
2564
|
+
* Execute a streaming chat completion request
|
|
2565
|
+
* Optional - can be implemented by concrete executor classes
|
|
2566
|
+
*/
|
|
2567
|
+
abstract executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
|
|
2568
|
+
/**
|
|
2569
|
+
* Check if the executor supports tool calling
|
|
2570
|
+
* Default implementation returns false, can be overridden
|
|
2571
|
+
*/
|
|
2572
|
+
supportsTools(): boolean;
|
|
2573
|
+
/**
|
|
2574
|
+
* Validate executor configuration
|
|
2575
|
+
* Default implementation returns true, can be overridden
|
|
2576
|
+
*/
|
|
2577
|
+
validateConfig(): boolean;
|
|
2578
|
+
/**
|
|
2579
|
+
* Clean up resources when executor is no longer needed
|
|
2580
|
+
* Default implementation does nothing, can be overridden
|
|
2581
|
+
*/
|
|
2582
|
+
dispose?(): Promise<void>;
|
|
2583
|
+
/**
|
|
2584
|
+
* Execute function with retry logic
|
|
2585
|
+
*
|
|
2586
|
+
* @param fn - Function to execute with retries
|
|
2587
|
+
* @param maxRetries - Maximum number of retry attempts (default: 3)
|
|
2588
|
+
* @param retryDelay - Delay between retries in milliseconds (default: 1000)
|
|
2589
|
+
* @returns Promise resolving to function result
|
|
2590
|
+
*/
|
|
2591
|
+
protected withRetry<T>(fn: () => Promise<T>, maxRetries?: number, retryDelay?: number): Promise<T>;
|
|
2592
|
+
/**
|
|
2593
|
+
* Execute function with timeout
|
|
2594
|
+
*
|
|
2595
|
+
* @param promise - Promise to execute with timeout
|
|
2596
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
2597
|
+
* @returns Promise resolving to function result
|
|
2598
|
+
*/
|
|
2599
|
+
protected withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
|
|
2600
|
+
/**
|
|
2601
|
+
* Delay execution for specified milliseconds
|
|
2602
|
+
*
|
|
2603
|
+
* @param ms - Milliseconds to delay
|
|
2604
|
+
* @returns Promise that resolves after the delay
|
|
2605
|
+
*/
|
|
2606
|
+
protected delay(ms: number): Promise<void>;
|
|
2607
|
+
/**
|
|
2608
|
+
* Log debug information (only if logging is enabled)
|
|
2609
|
+
*
|
|
2610
|
+
* @param message - Log message
|
|
2611
|
+
* @param data - Optional data to log
|
|
2612
|
+
*/
|
|
2613
|
+
protected logDebug(message: string, data?: TLoggerData): void;
|
|
2614
|
+
/**
|
|
2615
|
+
* Log error information
|
|
2616
|
+
*
|
|
2617
|
+
* @param message - Log message
|
|
2618
|
+
* @param error - Error object
|
|
2619
|
+
* @param data - Optional additional data
|
|
2620
|
+
*/
|
|
2621
|
+
protected logError(message: string, error: Error, data?: TLoggerData): void;
|
|
2622
|
+
/**
|
|
2623
|
+
* Validate that request has required fields
|
|
2624
|
+
*
|
|
2625
|
+
* @param request - Chat execution request to validate
|
|
2626
|
+
* @throws Error if validation fails
|
|
2627
|
+
*/
|
|
2628
|
+
protected validateRequest(request: IChatExecutionRequest): void;
|
|
2629
|
+
/**
|
|
2630
|
+
* Validate that response is properly formatted
|
|
2631
|
+
*
|
|
2632
|
+
* @param response - Response to validate
|
|
2633
|
+
* @throws Error if validation fails
|
|
2634
|
+
*/
|
|
2635
|
+
protected validateResponse(response: TUniversalMessage): void;
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
interface IOpenAIMessage {
|
|
2639
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
2640
|
+
content: string | null;
|
|
2641
|
+
tool_calls?: {
|
|
2642
|
+
id: string;
|
|
2643
|
+
type: 'function';
|
|
2644
|
+
function: {
|
|
2645
|
+
name: string;
|
|
2646
|
+
arguments: string;
|
|
2647
|
+
};
|
|
2648
|
+
}[];
|
|
2649
|
+
tool_call_id?: string;
|
|
2650
|
+
name?: string;
|
|
2651
|
+
}
|
|
2652
|
+
interface IAnthropicProviderMessage {
|
|
2653
|
+
role: 'user' | 'assistant';
|
|
2654
|
+
content: string;
|
|
2655
|
+
}
|
|
2656
|
+
interface IGoogleProviderMessage {
|
|
2657
|
+
role: 'user' | 'model';
|
|
2658
|
+
parts: {
|
|
2659
|
+
text: string;
|
|
2660
|
+
}[];
|
|
2661
|
+
}
|
|
2662
|
+
/**
|
|
2663
|
+
* Provider message format union type
|
|
2664
|
+
*/
|
|
2665
|
+
type TProviderMessage = IOpenAIMessage | IAnthropicProviderMessage | IGoogleProviderMessage | TUniversalMessage;
|
|
2666
|
+
/**
|
|
2667
|
+
* Universal message converter utility
|
|
2668
|
+
* Handles message format conversion between different providers
|
|
2669
|
+
*/
|
|
2670
|
+
declare class MessageConverter {
|
|
2671
|
+
/**
|
|
2672
|
+
* Convert messages to provider-specific format
|
|
2673
|
+
*/
|
|
2674
|
+
static toProviderFormat(messages: TUniversalMessage[], providerName: string): TProviderMessage[];
|
|
2675
|
+
/**
|
|
2676
|
+
* Convert to OpenAI format
|
|
2677
|
+
*/
|
|
2678
|
+
private static toOpenAIFormat;
|
|
2679
|
+
/**
|
|
2680
|
+
* Convert to Anthropic format
|
|
2681
|
+
*/
|
|
2682
|
+
private static toAnthropicFormat;
|
|
2683
|
+
/**
|
|
2684
|
+
* Convert to Google format
|
|
2685
|
+
*/
|
|
2686
|
+
private static toGoogleFormat;
|
|
2687
|
+
/**
|
|
2688
|
+
* Convert to universal format (no conversion)
|
|
2689
|
+
*/
|
|
2690
|
+
private static toUniversalFormat;
|
|
2691
|
+
/**
|
|
2692
|
+
* Extract system message from messages
|
|
2693
|
+
*/
|
|
2694
|
+
static extractSystemMessage(messages: TUniversalMessage[]): string | undefined;
|
|
2695
|
+
/**
|
|
2696
|
+
* Filter non-system messages
|
|
2697
|
+
*/
|
|
2698
|
+
static filterNonSystemMessages(messages: TUniversalMessage[]): TUniversalMessage[];
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
/**
|
|
2702
|
+
* Validation result interface
|
|
2703
|
+
*/
|
|
2704
|
+
interface ISimpleValidationResult {
|
|
2705
|
+
isValid: boolean;
|
|
2706
|
+
errors: string[];
|
|
2707
|
+
warnings?: string[];
|
|
2708
|
+
}
|
|
2709
|
+
/**
|
|
2710
|
+
* Validation utility class
|
|
2711
|
+
*/
|
|
2712
|
+
declare class Validator {
|
|
2713
|
+
/**
|
|
2714
|
+
* Validate agent configuration
|
|
2715
|
+
*/
|
|
2716
|
+
static validateAgentConfig(config: Partial<IAgentConfig>): ISimpleValidationResult;
|
|
2717
|
+
/**
|
|
2718
|
+
* Validate user input string
|
|
2719
|
+
*/
|
|
2720
|
+
static validateUserInput(input: string): ISimpleValidationResult;
|
|
2721
|
+
/**
|
|
2722
|
+
* Validate provider name
|
|
2723
|
+
*/
|
|
2724
|
+
static validateProviderName(name: string): ISimpleValidationResult;
|
|
2725
|
+
/**
|
|
2726
|
+
* Validate model name
|
|
2727
|
+
*/
|
|
2728
|
+
static validateModelName(name: string): ISimpleValidationResult;
|
|
2729
|
+
/**
|
|
2730
|
+
* Validate API key format (basic check)
|
|
2731
|
+
*/
|
|
2732
|
+
static validateApiKey(apiKey: string, provider?: string): ISimpleValidationResult;
|
|
2733
|
+
}
|
|
2734
|
+
declare const validateAgentConfig: typeof Validator.validateAgentConfig;
|
|
2735
|
+
declare const validateUserInput: typeof Validator.validateUserInput;
|
|
2736
|
+
declare const validateProviderName: typeof Validator.validateProviderName;
|
|
2737
|
+
declare const validateModelName: typeof Validator.validateModelName;
|
|
2738
|
+
declare const validateApiKey: typeof Validator.validateApiKey;
|
|
2739
|
+
|
|
2740
|
+
/**
|
|
2741
|
+
* Reusable type definitions for error utilities
|
|
2742
|
+
*/
|
|
2743
|
+
/**
|
|
2744
|
+
* Error context data type
|
|
2745
|
+
* Used for storing contextual information in error instances
|
|
2746
|
+
*/
|
|
2747
|
+
type TErrorContextData = Record<string, string | number | boolean | Date | Error | string[] | undefined>;
|
|
2748
|
+
/**
|
|
2749
|
+
* Error external input type
|
|
2750
|
+
* Used for handling external errors from unknown sources
|
|
2751
|
+
*/
|
|
2752
|
+
type TErrorExternalInput = Error | string | Record<string, string | number | boolean> | null | undefined;
|
|
2753
|
+
/**
|
|
2754
|
+
* Base error class for all Robota errors
|
|
2755
|
+
*/
|
|
2756
|
+
declare abstract class RobotaError extends Error {
|
|
2757
|
+
readonly context?: TErrorContextData | undefined;
|
|
2758
|
+
abstract readonly code: string;
|
|
2759
|
+
abstract readonly category: 'user' | 'system' | 'provider';
|
|
2760
|
+
abstract readonly recoverable: boolean;
|
|
2761
|
+
constructor(message: string, context?: TErrorContextData | undefined);
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Configuration related errors
|
|
2765
|
+
*/
|
|
2766
|
+
declare class ConfigurationError extends RobotaError {
|
|
2767
|
+
readonly code = "CONFIGURATION_ERROR";
|
|
2768
|
+
readonly category: "user";
|
|
2769
|
+
readonly recoverable = false;
|
|
2770
|
+
constructor(message: string, context?: TErrorContextData);
|
|
2771
|
+
}
|
|
2772
|
+
/**
|
|
2773
|
+
* Input validation errors
|
|
2774
|
+
*/
|
|
2775
|
+
declare class ValidationError extends RobotaError {
|
|
2776
|
+
readonly field?: string | undefined;
|
|
2777
|
+
readonly code = "VALIDATION_ERROR";
|
|
2778
|
+
readonly category: "user";
|
|
2779
|
+
readonly recoverable = false;
|
|
2780
|
+
constructor(message: string, field?: string | undefined, context?: TErrorContextData);
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Provider related errors
|
|
2784
|
+
*/
|
|
2785
|
+
declare class ProviderError extends RobotaError {
|
|
2786
|
+
readonly provider: string;
|
|
2787
|
+
readonly originalError?: Error | undefined;
|
|
2788
|
+
readonly code = "PROVIDER_ERROR";
|
|
2789
|
+
readonly category: "provider";
|
|
2790
|
+
readonly recoverable = true;
|
|
2791
|
+
constructor(message: string, provider: string, originalError?: Error | undefined, context?: TErrorContextData);
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Authentication errors
|
|
2795
|
+
*/
|
|
2796
|
+
declare class AuthenticationError extends RobotaError {
|
|
2797
|
+
readonly provider?: string | undefined;
|
|
2798
|
+
readonly code = "AUTHENTICATION_ERROR";
|
|
2799
|
+
readonly category: "user";
|
|
2800
|
+
readonly recoverable = false;
|
|
2801
|
+
constructor(message: string, provider?: string | undefined, context?: TErrorContextData);
|
|
2802
|
+
}
|
|
2803
|
+
/**
|
|
2804
|
+
* Rate limit errors
|
|
2805
|
+
*/
|
|
2806
|
+
declare class RateLimitError extends RobotaError {
|
|
2807
|
+
readonly retryAfter?: number | undefined;
|
|
2808
|
+
readonly provider?: string | undefined;
|
|
2809
|
+
readonly code = "RATE_LIMIT_ERROR";
|
|
2810
|
+
readonly category: "provider";
|
|
2811
|
+
readonly recoverable = true;
|
|
2812
|
+
constructor(message: string, retryAfter?: number | undefined, provider?: string | undefined, context?: TErrorContextData);
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* Network/connectivity errors
|
|
2816
|
+
*/
|
|
2817
|
+
declare class NetworkError extends RobotaError {
|
|
2818
|
+
readonly originalError?: Error | undefined;
|
|
2819
|
+
readonly code = "NETWORK_ERROR";
|
|
2820
|
+
readonly category: "system";
|
|
2821
|
+
readonly recoverable = true;
|
|
2822
|
+
constructor(message: string, originalError?: Error | undefined, context?: TErrorContextData);
|
|
2823
|
+
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Tool execution errors
|
|
2826
|
+
*/
|
|
2827
|
+
declare class ToolExecutionError extends RobotaError {
|
|
2828
|
+
readonly toolName: string;
|
|
2829
|
+
readonly originalError?: Error | undefined;
|
|
2830
|
+
readonly code = "TOOL_EXECUTION_ERROR";
|
|
2831
|
+
readonly category: "system";
|
|
2832
|
+
readonly recoverable = false;
|
|
2833
|
+
constructor(message: string, toolName: string, originalError?: Error | undefined, context?: TErrorContextData);
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2836
|
+
* Model not available errors
|
|
2837
|
+
*/
|
|
2838
|
+
declare class ModelNotAvailableError extends RobotaError {
|
|
2839
|
+
readonly availableModels?: string[] | undefined;
|
|
2840
|
+
readonly code = "MODEL_NOT_AVAILABLE";
|
|
2841
|
+
readonly category: "user";
|
|
2842
|
+
readonly recoverable = false;
|
|
2843
|
+
constructor(model: string, provider: string, availableModels?: string[] | undefined, context?: TErrorContextData);
|
|
2844
|
+
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Circuit breaker open error
|
|
2847
|
+
*/
|
|
2848
|
+
declare class CircuitBreakerOpenError extends RobotaError {
|
|
2849
|
+
readonly code = "CIRCUIT_BREAKER_OPEN";
|
|
2850
|
+
readonly category: "system";
|
|
2851
|
+
readonly recoverable = true;
|
|
2852
|
+
constructor(message?: string, context?: TErrorContextData);
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Plugin errors
|
|
2856
|
+
*/
|
|
2857
|
+
declare class PluginError extends RobotaError {
|
|
2858
|
+
readonly pluginName: string;
|
|
2859
|
+
readonly code = "PLUGIN_ERROR";
|
|
2860
|
+
readonly category: "system";
|
|
2861
|
+
readonly recoverable = false;
|
|
2862
|
+
constructor(message: string, pluginName: string, context?: TErrorContextData);
|
|
2863
|
+
}
|
|
2864
|
+
/**
|
|
2865
|
+
* Storage related errors
|
|
2866
|
+
*/
|
|
2867
|
+
declare class StorageError extends RobotaError {
|
|
2868
|
+
readonly code = "STORAGE_ERROR";
|
|
2869
|
+
readonly category: "system";
|
|
2870
|
+
readonly recoverable = true;
|
|
2871
|
+
constructor(message: string, context?: TErrorContextData);
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Cache integrity validation errors
|
|
2875
|
+
*/
|
|
2876
|
+
declare class CacheIntegrityError extends RobotaError {
|
|
2877
|
+
readonly code = "CACHE_INTEGRITY_ERROR";
|
|
2878
|
+
readonly category: "system";
|
|
2879
|
+
readonly recoverable = false;
|
|
2880
|
+
constructor(message: string, context?: TErrorContextData);
|
|
2881
|
+
}
|
|
2882
|
+
/**
|
|
2883
|
+
* Error utility functions
|
|
2884
|
+
*/
|
|
2885
|
+
declare class ErrorUtils {
|
|
2886
|
+
/**
|
|
2887
|
+
* Check if error is recoverable
|
|
2888
|
+
*/
|
|
2889
|
+
static isRecoverable(error: Error): boolean;
|
|
2890
|
+
/**
|
|
2891
|
+
* Extract error code from any error
|
|
2892
|
+
*/
|
|
2893
|
+
static getErrorCode(error: Error): string;
|
|
2894
|
+
/**
|
|
2895
|
+
* Create error from unknown value
|
|
2896
|
+
*/
|
|
2897
|
+
static fromUnknown(error: TErrorExternalInput, defaultMessage?: string): RobotaError;
|
|
2898
|
+
/**
|
|
2899
|
+
* Wrap external errors
|
|
2900
|
+
*/
|
|
2901
|
+
static wrapProviderError(error: TErrorExternalInput, provider: string, operation: string): ProviderError;
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
interface IPeriodicTaskOptions {
|
|
2905
|
+
name: string;
|
|
2906
|
+
intervalMs: number;
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* Start a periodic async task with consistent error logging.
|
|
2910
|
+
* SSOT helper to avoid duplicating setInterval(async () => ...) patterns.
|
|
2911
|
+
*/
|
|
2912
|
+
declare function startPeriodicTask(logger: ILogger, options: IPeriodicTaskOptions, task: () => Promise<void>): TTimerId;
|
|
2913
|
+
declare function stopPeriodicTask(timer: TTimerId | undefined): void;
|
|
2914
|
+
|
|
2915
|
+
/**
|
|
2916
|
+
* Cross-platform timer identifier type
|
|
2917
|
+
* Works in both Node.js and browser environments
|
|
2918
|
+
*/
|
|
2919
|
+
type TTimerId = ReturnType<typeof setTimeout>;
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* Local executor that directly delegates to AI provider instances
|
|
2923
|
+
*
|
|
2924
|
+
* This executor maintains a registry of AI provider instances and delegates
|
|
2925
|
+
* chat execution requests to the appropriate provider based on the provider
|
|
2926
|
+
* name in the request. This is the "traditional" execution mode where
|
|
2927
|
+
* API calls are made directly from the client.
|
|
2928
|
+
*
|
|
2929
|
+
* @example
|
|
2930
|
+
* ```typescript
|
|
2931
|
+
* import { LocalExecutor } from '@robota-sdk/agent-core';
|
|
2932
|
+
* import { OpenAIProvider } from '@robota-sdk/agent-provider-openai';
|
|
2933
|
+
*
|
|
2934
|
+
* const executor = new LocalExecutor();
|
|
2935
|
+
* executor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
|
|
2936
|
+
*
|
|
2937
|
+
* const response = await executor.executeChat({
|
|
2938
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
2939
|
+
* provider: 'openai',
|
|
2940
|
+
* model: 'gpt-4'
|
|
2941
|
+
* });
|
|
2942
|
+
* ```
|
|
2943
|
+
*/
|
|
2944
|
+
declare class LocalExecutor extends AbstractExecutor {
|
|
2945
|
+
readonly name = "local";
|
|
2946
|
+
readonly version = "1.0.0";
|
|
2947
|
+
private providers;
|
|
2948
|
+
private config;
|
|
2949
|
+
constructor(config?: ILocalExecutorConfig);
|
|
2950
|
+
/**
|
|
2951
|
+
* Register an AI provider instance for use with this executor
|
|
2952
|
+
*
|
|
2953
|
+
* @param name - Provider name (e.g., 'openai', 'anthropic', 'google')
|
|
2954
|
+
* @param provider - Provider instance that implements the required chat methods
|
|
2955
|
+
*/
|
|
2956
|
+
registerProvider(name: string, provider: IAIProviderInstance): void;
|
|
2957
|
+
/**
|
|
2958
|
+
* Unregister an AI provider
|
|
2959
|
+
*
|
|
2960
|
+
* @param name - Provider name to remove
|
|
2961
|
+
*/
|
|
2962
|
+
unregisterProvider(name: string): void;
|
|
2963
|
+
/**
|
|
2964
|
+
* Get registered provider instance
|
|
2965
|
+
*
|
|
2966
|
+
* @param name - Provider name
|
|
2967
|
+
* @returns Provider instance or undefined if not registered
|
|
2968
|
+
*/
|
|
2969
|
+
getProvider(name: string): IAIProviderInstance | undefined;
|
|
2970
|
+
/**
|
|
2971
|
+
* Execute a chat completion request by delegating to the appropriate provider
|
|
2972
|
+
*/
|
|
2973
|
+
executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
|
|
2974
|
+
/**
|
|
2975
|
+
* Execute a streaming chat completion request
|
|
2976
|
+
*/
|
|
2977
|
+
executeChatStream(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
|
|
2978
|
+
/**
|
|
2979
|
+
* Check if any registered providers support tools
|
|
2980
|
+
*/
|
|
2981
|
+
supportsTools(): boolean;
|
|
2982
|
+
/**
|
|
2983
|
+
* Validate executor configuration and all registered providers
|
|
2984
|
+
*/
|
|
2985
|
+
validateConfig(): boolean;
|
|
2986
|
+
/**
|
|
2987
|
+
* Clean up all registered providers
|
|
2988
|
+
*/
|
|
2989
|
+
dispose(): Promise<void>;
|
|
2990
|
+
}
|
|
2991
|
+
/**
|
|
2992
|
+
* Interface that AI provider instances must implement to work with LocalExecutor
|
|
2993
|
+
*
|
|
2994
|
+
* This interface represents the subset of AI provider methods that LocalExecutor
|
|
2995
|
+
* needs to delegate to. It's designed to be compatible with existing BaseAIProvider
|
|
2996
|
+
* implementations from @robota-sdk packages.
|
|
2997
|
+
*/
|
|
2998
|
+
interface IAIProviderInstance {
|
|
2999
|
+
/** Provider name */
|
|
3000
|
+
readonly name?: string;
|
|
3001
|
+
/** Chat completion method */
|
|
3002
|
+
chat?(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
|
|
3003
|
+
/** Streaming chat completion method */
|
|
3004
|
+
chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
|
|
3005
|
+
/** Check if provider supports tools */
|
|
3006
|
+
supportsTools?(): boolean;
|
|
3007
|
+
/** Validate provider configuration */
|
|
3008
|
+
validateConfig?(): boolean;
|
|
3009
|
+
/** Clean up provider resources */
|
|
3010
|
+
dispose?(): Promise<void>;
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
interface IEventEmitterMetricsSnapshot {
|
|
3014
|
+
totalEmitted: number;
|
|
3015
|
+
totalErrors: number;
|
|
3016
|
+
}
|
|
3017
|
+
interface IEventEmitterMetrics {
|
|
3018
|
+
incrementEmitted(): void;
|
|
3019
|
+
incrementErrors(): void;
|
|
3020
|
+
getSnapshot(): IEventEmitterMetricsSnapshot;
|
|
3021
|
+
}
|
|
3022
|
+
declare class InMemoryEventEmitterMetrics implements IEventEmitterMetrics {
|
|
3023
|
+
private totalEmitted;
|
|
3024
|
+
private totalErrors;
|
|
3025
|
+
incrementEmitted(): void;
|
|
3026
|
+
incrementErrors(): void;
|
|
3027
|
+
getSnapshot(): IEventEmitterMetricsSnapshot;
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
/**
|
|
3031
|
+
* Type definitions for EventEmitterPlugin.
|
|
3032
|
+
*
|
|
3033
|
+
* Extracted from event-emitter-plugin.ts to keep each file under 300 lines.
|
|
3034
|
+
*/
|
|
3035
|
+
|
|
3036
|
+
/** Enhanced event data for hierarchical execution tracking */
|
|
3037
|
+
interface IEventEmitterHierarchicalEventData extends IEventEmitterEventData {
|
|
3038
|
+
parentExecutionId?: string;
|
|
3039
|
+
rootExecutionId?: string;
|
|
3040
|
+
executionLevel: number;
|
|
3041
|
+
executionPath: string[];
|
|
3042
|
+
realTimeData?: {
|
|
3043
|
+
startTime: Date;
|
|
3044
|
+
actualDuration?: number;
|
|
3045
|
+
actualParameters?: TToolParameters;
|
|
3046
|
+
actualResult?: IToolResult;
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
/** Event emitter configuration */
|
|
3051
|
+
interface IEventEmitterPluginOptions extends IPluginOptions {
|
|
3052
|
+
events?: TEventName[];
|
|
3053
|
+
maxListeners?: number;
|
|
3054
|
+
async?: boolean;
|
|
3055
|
+
catchErrors?: boolean;
|
|
3056
|
+
filters?: Record<TEventName, (event: IEventEmitterEventData) => boolean>;
|
|
3057
|
+
buffer?: {
|
|
3058
|
+
enabled: boolean;
|
|
3059
|
+
maxSize: number;
|
|
3060
|
+
flushInterval: number;
|
|
3061
|
+
};
|
|
3062
|
+
metrics?: IEventEmitterMetrics;
|
|
3063
|
+
}
|
|
3064
|
+
/** Event emitter plugin statistics */
|
|
3065
|
+
interface IEventEmitterPluginStats extends IPluginStats {
|
|
3066
|
+
eventTypes: TEventName[];
|
|
3067
|
+
listenerCounts: Partial<Record<TEventName, number>>;
|
|
3068
|
+
totalListeners: number;
|
|
3069
|
+
bufferedEvents: number;
|
|
3070
|
+
totalEmitted: number;
|
|
3071
|
+
totalErrors: number;
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
/**
|
|
3075
|
+
* Provides pub/sub event coordination during the agent execution lifecycle.
|
|
3076
|
+
* @extends AbstractPlugin
|
|
3077
|
+
* @see IEventEmitterPluginOptions
|
|
3078
|
+
* @see EVENT_EMITTER_EVENTS
|
|
3079
|
+
*/
|
|
3080
|
+
declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptions, IEventEmitterPluginStats> {
|
|
3081
|
+
name: string;
|
|
3082
|
+
version: string;
|
|
3083
|
+
private pluginOptions;
|
|
3084
|
+
private logger;
|
|
3085
|
+
private handlers;
|
|
3086
|
+
private eventBuffer;
|
|
3087
|
+
private nextHandlerId;
|
|
3088
|
+
private bufferTimer?;
|
|
3089
|
+
private metrics;
|
|
3090
|
+
constructor(options?: IEventEmitterPluginOptions);
|
|
3091
|
+
beforeExecution(context: IPluginExecutionContext): Promise<void>;
|
|
3092
|
+
afterExecution(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
3093
|
+
beforeConversation(context: IPluginExecutionContext): Promise<void>;
|
|
3094
|
+
afterConversation(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
|
|
3095
|
+
beforeToolExecution(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
|
|
3096
|
+
afterToolExecution(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
|
|
3097
|
+
onError(error: Error, context?: IPluginErrorContext): Promise<void>;
|
|
3098
|
+
on(eventType: TEventName, listener: TEventEmitterListener, options?: {
|
|
3099
|
+
once?: boolean;
|
|
3100
|
+
filter?: (event: IEventEmitterEventData) => boolean;
|
|
3101
|
+
}): string;
|
|
3102
|
+
once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
|
|
3103
|
+
off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
|
|
3104
|
+
emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
|
|
3105
|
+
private processEvent;
|
|
3106
|
+
private executeHandler;
|
|
3107
|
+
flushBuffer(): Promise<void>;
|
|
3108
|
+
getStats(): IEventEmitterPluginStats;
|
|
3109
|
+
clearAllListeners(): void;
|
|
3110
|
+
destroy(): Promise<void>;
|
|
3111
|
+
private validateOptions;
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
/** Agent statistics metadata type */
|
|
3115
|
+
type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
|
|
3116
|
+
|
|
3117
|
+
/**
|
|
3118
|
+
* Core AI agent integrating multiple AI providers, tools, and plugins
|
|
3119
|
+
* into a unified conversational interface.
|
|
3120
|
+
* @public
|
|
3121
|
+
*/
|
|
3122
|
+
declare class Robota extends AbstractAgent<IAgentConfig, IRunOptions, TUniversalMessage> implements IAgent<IAgentConfig, IRunOptions, TUniversalMessage> {
|
|
3123
|
+
readonly name: string;
|
|
3124
|
+
readonly version: string;
|
|
3125
|
+
private aiProviders;
|
|
3126
|
+
private tools;
|
|
3127
|
+
private agentFactory;
|
|
3128
|
+
private conversationHistory;
|
|
3129
|
+
private moduleRegistry;
|
|
3130
|
+
private eventEmitter;
|
|
3131
|
+
private executionService;
|
|
3132
|
+
private eventService;
|
|
3133
|
+
private agentEventService;
|
|
3134
|
+
protected config: IAgentConfig;
|
|
3135
|
+
private conversationId;
|
|
3136
|
+
private logger;
|
|
3137
|
+
private initializationPromise?;
|
|
3138
|
+
private isFullyInitialized;
|
|
3139
|
+
private startTime;
|
|
3140
|
+
private configVersion;
|
|
3141
|
+
private configUpdatedAt;
|
|
3142
|
+
private moduleManager;
|
|
3143
|
+
private pluginManager;
|
|
3144
|
+
private configManager;
|
|
3145
|
+
constructor(config: IAgentConfig);
|
|
3146
|
+
private initDelegates;
|
|
3147
|
+
private emitCreatedEvent;
|
|
3148
|
+
run(input: string, options?: IRunOptions): Promise<string>;
|
|
3149
|
+
runStream(input: string, options?: IRunOptions): AsyncGenerator<string, void, undefined>;
|
|
3150
|
+
private executionDeps;
|
|
3151
|
+
getHistory(): TUniversalMessage[];
|
|
3152
|
+
clearHistory(): void;
|
|
3153
|
+
updateTools(next: Array<IToolWithEventService>): Promise<{
|
|
3154
|
+
version: number;
|
|
3155
|
+
}>;
|
|
3156
|
+
updateConfiguration(patch: Partial<IAgentConfig>): Promise<{
|
|
3157
|
+
version: number;
|
|
3158
|
+
}>;
|
|
3159
|
+
getConfiguration(): Promise<{
|
|
3160
|
+
version: number;
|
|
3161
|
+
tools: Array<{
|
|
3162
|
+
name: string;
|
|
3163
|
+
parameters?: string[];
|
|
3164
|
+
}>;
|
|
3165
|
+
updatedAt: number;
|
|
3166
|
+
}>;
|
|
3167
|
+
setModel(mc: {
|
|
3168
|
+
provider: string;
|
|
3169
|
+
model: string;
|
|
3170
|
+
temperature?: number;
|
|
3171
|
+
maxTokens?: number;
|
|
3172
|
+
topP?: number;
|
|
3173
|
+
systemMessage?: string;
|
|
3174
|
+
}): void;
|
|
3175
|
+
getModel(): {
|
|
3176
|
+
provider: string;
|
|
3177
|
+
model: string;
|
|
3178
|
+
temperature?: number;
|
|
3179
|
+
maxTokens?: number;
|
|
3180
|
+
topP?: number;
|
|
3181
|
+
systemMessage?: string;
|
|
3182
|
+
};
|
|
3183
|
+
registerTool(tool: AbstractTool): void;
|
|
3184
|
+
unregisterTool(toolName: string): void;
|
|
3185
|
+
getConfig(): IAgentConfig;
|
|
3186
|
+
addPlugin(plugin: IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks): void;
|
|
3187
|
+
removePlugin(pluginName: string): boolean;
|
|
3188
|
+
getPlugin(pluginName: string): (IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks) | undefined;
|
|
3189
|
+
getPlugins(): Array<IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks>;
|
|
3190
|
+
getPluginNames(): string[];
|
|
3191
|
+
registerModule(module: IModule, options?: {
|
|
3192
|
+
autoInitialize?: boolean;
|
|
3193
|
+
validateDependencies?: boolean;
|
|
3194
|
+
}): Promise<void>;
|
|
3195
|
+
unregisterModule(moduleName: string): Promise<boolean>;
|
|
3196
|
+
getModule(moduleName: string): IModule | undefined;
|
|
3197
|
+
getModulesByType(moduleType: string): IModule[];
|
|
3198
|
+
getModules(): IModule[];
|
|
3199
|
+
getModuleNames(): string[];
|
|
3200
|
+
hasModule(moduleName: string): boolean;
|
|
3201
|
+
executeModule(moduleName: string, context: {
|
|
3202
|
+
executionId?: string;
|
|
3203
|
+
sessionId?: string;
|
|
3204
|
+
userId?: string;
|
|
3205
|
+
metadata?: Record<string, string | number | boolean | Date>;
|
|
3206
|
+
}): Promise<{
|
|
3207
|
+
success: boolean;
|
|
3208
|
+
data?: IModuleResultData;
|
|
3209
|
+
error?: Error;
|
|
3210
|
+
duration?: number;
|
|
3211
|
+
}>;
|
|
3212
|
+
getModuleStats(moduleName: string): {
|
|
3213
|
+
totalExecutions: number;
|
|
3214
|
+
successfulExecutions: number;
|
|
3215
|
+
failedExecutions: number;
|
|
3216
|
+
averageExecutionTime: number;
|
|
3217
|
+
lastExecutionTime?: Date;
|
|
3218
|
+
} | undefined;
|
|
3219
|
+
getStats(): {
|
|
3220
|
+
name: string;
|
|
3221
|
+
version: string;
|
|
3222
|
+
conversationId: string;
|
|
3223
|
+
providers: string[];
|
|
3224
|
+
currentProvider: string | null;
|
|
3225
|
+
tools: string[];
|
|
3226
|
+
plugins: string[];
|
|
3227
|
+
modules: string[];
|
|
3228
|
+
historyLength: number;
|
|
3229
|
+
historyStats: TAgentStatsMetadata;
|
|
3230
|
+
uptime: number;
|
|
3231
|
+
};
|
|
3232
|
+
destroy(): Promise<void>;
|
|
3233
|
+
protected initialize(): Promise<void>;
|
|
3234
|
+
private ensureFullyInitialized;
|
|
3235
|
+
private doAsyncInit;
|
|
3236
|
+
private emitAgentEvent;
|
|
3237
|
+
private buildOwnerPath;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
/**
|
|
3241
|
+
* Template application result
|
|
3242
|
+
*/
|
|
3243
|
+
interface ITemplateApplicationResult {
|
|
3244
|
+
/** Applied configuration */
|
|
3245
|
+
config: IAgentConfig;
|
|
3246
|
+
/** Template that was applied */
|
|
3247
|
+
template: IAgentTemplate;
|
|
3248
|
+
/** Any warnings during application */
|
|
3249
|
+
warnings: string[];
|
|
3250
|
+
/** Whether config was modified during application */
|
|
3251
|
+
modified: boolean;
|
|
3252
|
+
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Agent Templates implementation
|
|
3255
|
+
* Manages agent templates for AgentFactory
|
|
3256
|
+
* Instance-based for isolated template management
|
|
3257
|
+
*/
|
|
3258
|
+
declare class AgentTemplates {
|
|
3259
|
+
private templates;
|
|
3260
|
+
private logger;
|
|
3261
|
+
constructor();
|
|
3262
|
+
/**
|
|
3263
|
+
* Register a template
|
|
3264
|
+
*/
|
|
3265
|
+
registerTemplate(template: IAgentTemplate): void;
|
|
3266
|
+
/**
|
|
3267
|
+
* Unregister a template
|
|
3268
|
+
*/
|
|
3269
|
+
unregisterTemplate(templateId: string): boolean;
|
|
3270
|
+
/**
|
|
3271
|
+
* Get all templates
|
|
3272
|
+
*/
|
|
3273
|
+
getTemplates(): IAgentTemplate[];
|
|
3274
|
+
/**
|
|
3275
|
+
* Get template by ID
|
|
3276
|
+
*/
|
|
3277
|
+
getTemplate(templateId: string): IAgentTemplate | undefined;
|
|
3278
|
+
/**
|
|
3279
|
+
* Find templates by criteria
|
|
3280
|
+
*/
|
|
3281
|
+
findTemplates(criteria: {
|
|
3282
|
+
category?: string;
|
|
3283
|
+
tags?: string[];
|
|
3284
|
+
provider?: string;
|
|
3285
|
+
model?: string;
|
|
3286
|
+
}): IAgentTemplate[];
|
|
3287
|
+
/**
|
|
3288
|
+
* Apply template to configuration
|
|
3289
|
+
*/
|
|
3290
|
+
applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
|
|
3291
|
+
/**
|
|
3292
|
+
* Check if template exists
|
|
3293
|
+
*/
|
|
3294
|
+
hasTemplate(templateId: string): boolean;
|
|
3295
|
+
/**
|
|
3296
|
+
* Get template count
|
|
3297
|
+
*/
|
|
3298
|
+
getTemplateCount(): number;
|
|
3299
|
+
/**
|
|
3300
|
+
* Clear all templates
|
|
3301
|
+
*/
|
|
3302
|
+
clearAll(): void;
|
|
3303
|
+
/**
|
|
3304
|
+
* Get template statistics
|
|
3305
|
+
*/
|
|
3306
|
+
getStats(): {
|
|
3307
|
+
totalTemplates: number;
|
|
3308
|
+
categories: string[];
|
|
3309
|
+
tags: string[];
|
|
3310
|
+
providers: string[];
|
|
3311
|
+
models: string[];
|
|
3312
|
+
};
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
/**
|
|
3316
|
+
* Configuration options for AgentFactory
|
|
3317
|
+
*/
|
|
3318
|
+
interface IAgentFactoryOptions {
|
|
3319
|
+
/** Default model to use if not specified in config */
|
|
3320
|
+
defaultModel?: string;
|
|
3321
|
+
/** Default provider to use if not specified in config */
|
|
3322
|
+
defaultProvider?: string;
|
|
3323
|
+
/** Maximum number of concurrent agents */
|
|
3324
|
+
maxConcurrentAgents?: number;
|
|
3325
|
+
/** Default system message for agents */
|
|
3326
|
+
defaultSystemMessage?: string;
|
|
3327
|
+
/** Enable strict configuration validation */
|
|
3328
|
+
strictValidation?: boolean;
|
|
3329
|
+
}
|
|
3330
|
+
/**
|
|
3331
|
+
* Agent creation statistics
|
|
3332
|
+
*/
|
|
3333
|
+
interface IAgentCreationStats {
|
|
3334
|
+
/** Total number of agents created */
|
|
3335
|
+
totalCreated: number;
|
|
3336
|
+
/** Number of currently active agents */
|
|
3337
|
+
activeCount: number;
|
|
3338
|
+
/** Number of agents created from templates */
|
|
3339
|
+
fromTemplates: number;
|
|
3340
|
+
/** Number of custom configured agents */
|
|
3341
|
+
customConfigured: number;
|
|
3342
|
+
/** Template vs custom creation ratio (fromTemplates / totalCreated) */
|
|
3343
|
+
templateUsageRatio: number;
|
|
3344
|
+
}
|
|
3345
|
+
/**
|
|
3346
|
+
* Agent lifecycle events
|
|
3347
|
+
*/
|
|
3348
|
+
interface IAgentLifecycleEvents {
|
|
3349
|
+
/** Called before agent creation */
|
|
3350
|
+
beforeCreate?: (config: IAgentConfig) => Promise<void> | void;
|
|
3351
|
+
/** Called after successful agent creation */
|
|
3352
|
+
afterCreate?: (agent: IAgent<IAgentConfig>, config: IAgentConfig) => Promise<void> | void;
|
|
3353
|
+
/** Called when agent creation fails */
|
|
3354
|
+
onCreateError?: (error: Error, config: IAgentConfig) => Promise<void> | void;
|
|
3355
|
+
/** Called when agent is destroyed */
|
|
3356
|
+
onDestroy?: (agentId: string) => Promise<void> | void;
|
|
3357
|
+
}
|
|
3358
|
+
/**
|
|
3359
|
+
* Agent Factory for creating and managing agents
|
|
3360
|
+
* Instance-based for isolated agent factory management
|
|
3361
|
+
*/
|
|
3362
|
+
declare class AgentFactory {
|
|
3363
|
+
private agentTemplates;
|
|
3364
|
+
private initialized;
|
|
3365
|
+
private logger;
|
|
3366
|
+
private options;
|
|
3367
|
+
private activeAgents;
|
|
3368
|
+
private creationStats;
|
|
3369
|
+
private lifecycleEvents;
|
|
3370
|
+
constructor(options?: IAgentFactoryOptions, lifecycleEvents?: IAgentLifecycleEvents);
|
|
3371
|
+
/**
|
|
3372
|
+
* Initialize the factory
|
|
3373
|
+
*/
|
|
3374
|
+
initialize(): Promise<void>;
|
|
3375
|
+
/**
|
|
3376
|
+
* Create a new agent instance
|
|
3377
|
+
*/
|
|
3378
|
+
createAgent(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, config: Partial<IAgentConfig>, fromTemplate?: boolean): Promise<IAgent<IAgentConfig>>;
|
|
3379
|
+
/**
|
|
3380
|
+
* Create agent from template
|
|
3381
|
+
*/
|
|
3382
|
+
createFromTemplate(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, templateId: string, overrides?: Partial<IAgentConfig>): Promise<IAgent<IAgentConfig>>;
|
|
3383
|
+
/**
|
|
3384
|
+
* Register a template
|
|
3385
|
+
*/
|
|
3386
|
+
registerTemplate(template: IAgentTemplate): void;
|
|
3387
|
+
/**
|
|
3388
|
+
* Unregister a template
|
|
3389
|
+
*/
|
|
3390
|
+
unregisterTemplate(templateId: string): boolean;
|
|
3391
|
+
/**
|
|
3392
|
+
* Get all templates
|
|
3393
|
+
*/
|
|
3394
|
+
getTemplates(): IAgentTemplate[];
|
|
3395
|
+
/**
|
|
3396
|
+
* Get template by ID
|
|
3397
|
+
*/
|
|
3398
|
+
getTemplate(templateId: string): IAgentTemplate | undefined;
|
|
3399
|
+
/**
|
|
3400
|
+
* Find templates by criteria
|
|
3401
|
+
*/
|
|
3402
|
+
findTemplates(criteria: {
|
|
3403
|
+
category?: string;
|
|
3404
|
+
tags?: string[];
|
|
3405
|
+
provider?: string;
|
|
3406
|
+
model?: string;
|
|
3407
|
+
}): IAgentTemplate[];
|
|
3408
|
+
/**
|
|
3409
|
+
* Apply template to configuration
|
|
3410
|
+
*/
|
|
3411
|
+
applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
|
|
3412
|
+
/**
|
|
3413
|
+
* Destroy an agent
|
|
3414
|
+
*/
|
|
3415
|
+
destroyAgent(agentId: string): Promise<boolean>;
|
|
3416
|
+
/**
|
|
3417
|
+
* Get creation statistics
|
|
3418
|
+
*/
|
|
3419
|
+
getCreationStats(): IAgentCreationStats;
|
|
3420
|
+
/**
|
|
3421
|
+
* Get all active agents
|
|
3422
|
+
*/
|
|
3423
|
+
getActiveAgents(): Map<string, IAgent<IAgentConfig>>;
|
|
3424
|
+
/**
|
|
3425
|
+
* Validate agent configuration
|
|
3426
|
+
*/
|
|
3427
|
+
validateConfiguration(config: Partial<IAgentConfig>): {
|
|
3428
|
+
isValid: boolean;
|
|
3429
|
+
errors: string[];
|
|
3430
|
+
};
|
|
3431
|
+
/**
|
|
3432
|
+
* Apply default configuration values
|
|
3433
|
+
*/
|
|
3434
|
+
private applyDefaults;
|
|
3435
|
+
/**
|
|
3436
|
+
* Generate unique agent ID
|
|
3437
|
+
*/
|
|
3438
|
+
private generateAgentId;
|
|
3439
|
+
/**
|
|
3440
|
+
* Update creation statistics
|
|
3441
|
+
*/
|
|
3442
|
+
private updateCreationStats;
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
/**
|
|
3446
|
+
* Conversation session implementations.
|
|
3447
|
+
*
|
|
3448
|
+
* Extracted from conversation-history-manager.ts.
|
|
3449
|
+
*/
|
|
3450
|
+
|
|
3451
|
+
/** API message format for provider consumption */
|
|
3452
|
+
interface IProviderApiMessage {
|
|
3453
|
+
role: string;
|
|
3454
|
+
content: string | null;
|
|
3455
|
+
tool_calls?: Array<{
|
|
3456
|
+
id: string;
|
|
3457
|
+
type: 'function';
|
|
3458
|
+
function: {
|
|
3459
|
+
name: string;
|
|
3460
|
+
arguments: string;
|
|
3461
|
+
};
|
|
3462
|
+
}>;
|
|
3463
|
+
tool_call_id?: string;
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* Conversation session with duplicate prevention and API format conversion.
|
|
3467
|
+
* @public
|
|
3468
|
+
*/
|
|
3469
|
+
declare class ConversationSession implements IConversationHistory {
|
|
3470
|
+
private history;
|
|
3471
|
+
private toolCallIds;
|
|
3472
|
+
constructor(maxMessages?: number);
|
|
3473
|
+
addMessage(message: TUniversalMessage): void;
|
|
3474
|
+
addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3475
|
+
addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3476
|
+
addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3477
|
+
addToolMessage(content: string, toolCallId: string, toolName?: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3478
|
+
addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3479
|
+
getMessages(): TUniversalMessage[];
|
|
3480
|
+
getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
|
|
3481
|
+
getRecentMessages(count: number): TUniversalMessage[];
|
|
3482
|
+
getMessageCount(): number;
|
|
3483
|
+
getMessagesForAPI(): IProviderApiMessage[];
|
|
3484
|
+
clear(): void;
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
/** Interface for managing conversation history. @public */
|
|
3488
|
+
interface IConversationHistory {
|
|
3489
|
+
addMessage(message: TUniversalMessage): void;
|
|
3490
|
+
addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3491
|
+
addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3492
|
+
addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3493
|
+
addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
|
|
3494
|
+
getMessages(): TUniversalMessage[];
|
|
3495
|
+
getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
|
|
3496
|
+
getRecentMessages(count: number): TUniversalMessage[];
|
|
3497
|
+
clear(): void;
|
|
3498
|
+
getMessageCount(): number;
|
|
3499
|
+
}
|
|
3500
|
+
/** Configuration options for ConversationHistory manager */
|
|
3501
|
+
interface IConversationHistoryOptions {
|
|
3502
|
+
maxMessagesPerConversation?: number;
|
|
3503
|
+
maxConversations?: number;
|
|
3504
|
+
}
|
|
3505
|
+
/** Multi-session conversation history manager. @public */
|
|
3506
|
+
declare class ConversationHistory {
|
|
3507
|
+
private conversations;
|
|
3508
|
+
private logger;
|
|
3509
|
+
private readonly maxMessagesPerConversation;
|
|
3510
|
+
private readonly maxConversations;
|
|
3511
|
+
constructor(options?: IConversationHistoryOptions);
|
|
3512
|
+
getConversationSession(conversationId: string): ConversationSession;
|
|
3513
|
+
hasConversation(conversationId: string): boolean;
|
|
3514
|
+
removeConversation(conversationId: string): boolean;
|
|
3515
|
+
clearAll(): void;
|
|
3516
|
+
getStats(): {
|
|
3517
|
+
totalConversations: number;
|
|
3518
|
+
conversationIds: string[];
|
|
3519
|
+
totalMessages: number;
|
|
3520
|
+
};
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
declare class EventHistoryModule implements IEventHistoryModule {
|
|
3524
|
+
private readonly store;
|
|
3525
|
+
private readonly listener;
|
|
3526
|
+
private sequenceId;
|
|
3527
|
+
constructor(store: IEventHistoryModule, eventService: IEventService);
|
|
3528
|
+
append(record: IEventHistoryRecord): void;
|
|
3529
|
+
read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
|
|
3530
|
+
readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
|
|
3531
|
+
getSnapshot(): IEventHistorySnapshot | undefined;
|
|
3532
|
+
detach(eventService: IEventService): void;
|
|
3533
|
+
private nextSequenceId;
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
/**
|
|
3537
|
+
* ExecutionService owned events.
|
|
3538
|
+
* Local event names only (no dots). Full names are composed at emit time.
|
|
3539
|
+
*/
|
|
3540
|
+
declare const EXECUTION_EVENTS: {
|
|
3541
|
+
readonly START: "start";
|
|
3542
|
+
readonly COMPLETE: "complete";
|
|
3543
|
+
readonly ERROR: "error";
|
|
3544
|
+
readonly ASSISTANT_MESSAGE_START: "assistant_message_start";
|
|
3545
|
+
readonly ASSISTANT_MESSAGE_COMPLETE: "assistant_message_complete";
|
|
3546
|
+
readonly USER_MESSAGE: "user_message";
|
|
3547
|
+
readonly TOOL_RESULTS_TO_LLM: "tool_results_to_llm";
|
|
3548
|
+
readonly TOOL_RESULTS_READY: "tool_results_ready";
|
|
3549
|
+
};
|
|
3550
|
+
declare const EXECUTION_EVENT_PREFIX: "execution";
|
|
3551
|
+
|
|
3552
|
+
/**
|
|
3553
|
+
* ToolExecutionService owned events
|
|
3554
|
+
* Local event names only (no dots). Full names are composed at emit time.
|
|
3555
|
+
*/
|
|
3556
|
+
declare const TOOL_EVENTS: {
|
|
3557
|
+
readonly CALL_START: "call_start";
|
|
3558
|
+
readonly CALL_COMPLETE: "call_complete";
|
|
3559
|
+
readonly CALL_ERROR: "call_error";
|
|
3560
|
+
readonly CALL_RESPONSE_READY: "call_response_ready";
|
|
3561
|
+
};
|
|
3562
|
+
declare const TOOL_EVENT_PREFIX: "tool";
|
|
3563
|
+
|
|
3564
|
+
/**
|
|
3565
|
+
* Agent event constants
|
|
3566
|
+
*
|
|
3567
|
+
* Events emitted by Agent instances themselves.
|
|
3568
|
+
* Event names are local (no dots) and must be used via constants (no string literals).
|
|
3569
|
+
*/
|
|
3570
|
+
declare const AGENT_EVENTS: {
|
|
3571
|
+
/** Agent instance has been created and initialized */
|
|
3572
|
+
readonly CREATED: "created";
|
|
3573
|
+
/** Agent execution lifecycle - start */
|
|
3574
|
+
readonly EXECUTION_START: "execution_start";
|
|
3575
|
+
/** Agent execution lifecycle - complete */
|
|
3576
|
+
readonly EXECUTION_COMPLETE: "execution_complete";
|
|
3577
|
+
/** Agent execution lifecycle - error */
|
|
3578
|
+
readonly EXECUTION_ERROR: "execution_error";
|
|
3579
|
+
/** Agent aggregation process completed */
|
|
3580
|
+
readonly AGGREGATION_COMPLETE: "aggregation_complete";
|
|
3581
|
+
/** Agent configuration (e.g., tools) has been updated by the agent */
|
|
3582
|
+
readonly CONFIG_UPDATED: "config_updated";
|
|
3583
|
+
};
|
|
3584
|
+
declare const AGENT_EVENT_PREFIX: "agent";
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* Workflow Converter Interface
|
|
3588
|
+
*
|
|
3589
|
+
* Defines the contract for all workflow converters in the Robota SDK.
|
|
3590
|
+
* Follows Interface Segregation Principle by providing minimal, focused interface.
|
|
3591
|
+
*
|
|
3592
|
+
* @template TInput - Input workflow data type
|
|
3593
|
+
* @template TOutput - Output workflow data type
|
|
3594
|
+
*/
|
|
3595
|
+
|
|
3596
|
+
/**
|
|
3597
|
+
* Workflow configuration - uses base type for cross-converter compatibility
|
|
3598
|
+
* Step 1: ❌ Can't assign number/boolean to config value type directly (index signature conflict)
|
|
3599
|
+
* Step 2: ✅ TConfigValue already includes primitive types (number, boolean)
|
|
3600
|
+
* Step 3: ✅ Fix index signature to allow optional properties
|
|
3601
|
+
* Step 4: ✅ Use proper intersection type for compatibility
|
|
3602
|
+
*/
|
|
3603
|
+
interface IWorkflowConfig {
|
|
3604
|
+
timeout?: number;
|
|
3605
|
+
retries?: number;
|
|
3606
|
+
validateInput?: boolean;
|
|
3607
|
+
validateOutput?: boolean;
|
|
3608
|
+
[key: string]: TConfigValue | undefined;
|
|
3609
|
+
}
|
|
3610
|
+
/**
|
|
3611
|
+
* Workflow metadata - uses base type for cross-converter compatibility
|
|
3612
|
+
* Step 1: ❌ Can't assign Date/number/string to metadata value type directly (index signature conflict)
|
|
3613
|
+
* Step 2: ✅ TMetadataValue already includes Date, primitive types
|
|
3614
|
+
* Step 3: ✅ Fix index signature to allow optional properties
|
|
3615
|
+
* Step 4: ✅ Use proper intersection type for compatibility
|
|
3616
|
+
*/
|
|
3617
|
+
interface IWorkflowMetadata {
|
|
3618
|
+
convertedAt?: Date;
|
|
3619
|
+
processingTime?: number;
|
|
3620
|
+
executionId?: string;
|
|
3621
|
+
[key: string]: TMetadataValue | undefined;
|
|
3622
|
+
}
|
|
3623
|
+
/**
|
|
3624
|
+
* Base workflow data constraint with flexible typing
|
|
3625
|
+
* All workflow data must extend this interface for type safety
|
|
3626
|
+
*/
|
|
3627
|
+
interface IWorkflowData {
|
|
3628
|
+
readonly __workflowType?: string;
|
|
3629
|
+
[key: string]: TUniversalValue | undefined;
|
|
3630
|
+
}
|
|
3631
|
+
/**
|
|
3632
|
+
* Conversion options for workflow transformations
|
|
3633
|
+
* Step 1: ❌ Can't assign IWorkflowConversionOptions to metadata value type (missing index signature)
|
|
3634
|
+
* Step 2: ✅ Add index signature to make it compatible with MetadataValue
|
|
3635
|
+
* Step 3: ✅ Maintain type safety while allowing metadata storage
|
|
3636
|
+
* Step 4: ✅ Use MetadataValue compatibility for dynamic properties
|
|
3637
|
+
*/
|
|
3638
|
+
interface IWorkflowConversionOptions {
|
|
3639
|
+
/** Include debug information in output */
|
|
3640
|
+
includeDebug?: boolean;
|
|
3641
|
+
/** Validate input before conversion */
|
|
3642
|
+
validateInput?: boolean;
|
|
3643
|
+
/** Validate output after conversion */
|
|
3644
|
+
validateOutput?: boolean;
|
|
3645
|
+
/** Custom logger for conversion process */
|
|
3646
|
+
logger?: ILogger;
|
|
3647
|
+
/** Additional metadata to include */
|
|
3648
|
+
metadata?: IWorkflowMetadata;
|
|
3649
|
+
/** Platform-specific options */
|
|
3650
|
+
platformOptions?: IWorkflowConfig;
|
|
3651
|
+
/** Additional dynamic options compatible with TUniversalValue */
|
|
3652
|
+
[key: string]: TUniversalValue | ILogger | IWorkflowMetadata | IWorkflowConfig | undefined;
|
|
3653
|
+
}
|
|
3654
|
+
/**
|
|
3655
|
+
* Conversion result with metadata and validation info
|
|
3656
|
+
*/
|
|
3657
|
+
interface IWorkflowConversionResult<TOutput> {
|
|
3658
|
+
/** Converted workflow data */
|
|
3659
|
+
data: TOutput;
|
|
3660
|
+
/** Conversion success status */
|
|
3661
|
+
success: boolean;
|
|
3662
|
+
/** Validation errors (if any) */
|
|
3663
|
+
errors: string[];
|
|
3664
|
+
/** Validation warnings (if any) */
|
|
3665
|
+
warnings: string[];
|
|
3666
|
+
/** Conversion metadata */
|
|
3667
|
+
metadata: IWorkflowConversionResultMetadata;
|
|
3668
|
+
}
|
|
3669
|
+
/**
|
|
3670
|
+
* Workflow conversion metadata.
|
|
3671
|
+
*
|
|
3672
|
+
* IMPORTANT:
|
|
3673
|
+
* - Do NOT intersect this object with `TMetadata`.
|
|
3674
|
+
* - `TMetadata` has an index signature with a restricted value axis (`TMetadataValue`),
|
|
3675
|
+
* which would force every property on this object to be assignable to `TMetadataValue`.
|
|
3676
|
+
* - Keep structured fields here, and store additional key/value pairs under `extensions`.
|
|
3677
|
+
*/
|
|
3678
|
+
interface IWorkflowConversionResultMetadata {
|
|
3679
|
+
/** Conversion timestamp */
|
|
3680
|
+
convertedAt: Date;
|
|
3681
|
+
/** Processing time in milliseconds */
|
|
3682
|
+
processingTime: number;
|
|
3683
|
+
/** Input data statistics */
|
|
3684
|
+
inputStats: {
|
|
3685
|
+
nodeCount: number;
|
|
3686
|
+
edgeCount: number;
|
|
3687
|
+
};
|
|
3688
|
+
/** Output data statistics */
|
|
3689
|
+
outputStats: {
|
|
3690
|
+
nodeCount: number;
|
|
3691
|
+
edgeCount: number;
|
|
3692
|
+
};
|
|
3693
|
+
/** Converter name */
|
|
3694
|
+
converter: string;
|
|
3695
|
+
/** Converter version */
|
|
3696
|
+
version: string;
|
|
3697
|
+
/** Conversion options (optional, typically gated by includeDebug) */
|
|
3698
|
+
options?: IWorkflowConversionOptions;
|
|
3699
|
+
/**
|
|
3700
|
+
* Additional key/value metadata (SSOT axis).
|
|
3701
|
+
* Use this for dynamic metadata, not top-level ad-hoc fields.
|
|
3702
|
+
*/
|
|
3703
|
+
extensions?: TMetadata;
|
|
3704
|
+
}
|
|
3705
|
+
/**
|
|
3706
|
+
* Workflow Converter Interface
|
|
3707
|
+
*
|
|
3708
|
+
* Core interface for converting between different workflow representations.
|
|
3709
|
+
* All workflow converters must implement this interface.
|
|
3710
|
+
*
|
|
3711
|
+
* @template TInput - Input workflow data type
|
|
3712
|
+
* @template TOutput - Output workflow data type
|
|
3713
|
+
*/
|
|
3714
|
+
interface IWorkflowConverter<TInput extends IWorkflowData, TOutput extends IWorkflowData> {
|
|
3715
|
+
/** Converter name for identification */
|
|
3716
|
+
readonly name: string;
|
|
3717
|
+
/** Converter version */
|
|
3718
|
+
readonly version: string;
|
|
3719
|
+
/** Source format that this converter accepts */
|
|
3720
|
+
readonly sourceFormat: string;
|
|
3721
|
+
/** Target format that this converter produces */
|
|
3722
|
+
readonly targetFormat: string;
|
|
3723
|
+
/**
|
|
3724
|
+
* Convert workflow data from input format to output format
|
|
3725
|
+
*
|
|
3726
|
+
* @param input - Input workflow data
|
|
3727
|
+
* @param options - Conversion options
|
|
3728
|
+
* @returns Promise resolving to conversion result
|
|
3729
|
+
*/
|
|
3730
|
+
convert(input: TInput, options?: IWorkflowConversionOptions): Promise<IWorkflowConversionResult<TOutput>>;
|
|
3731
|
+
/**
|
|
3732
|
+
* Validate input data before conversion
|
|
3733
|
+
*
|
|
3734
|
+
* @param input - Input workflow data
|
|
3735
|
+
* @returns Promise resolving to validation result
|
|
3736
|
+
*/
|
|
3737
|
+
validateInput(input: TInput): Promise<{
|
|
3738
|
+
isValid: boolean;
|
|
3739
|
+
errors: string[];
|
|
3740
|
+
warnings: string[];
|
|
3741
|
+
}>;
|
|
3742
|
+
/**
|
|
3743
|
+
* Validate output data after conversion
|
|
3744
|
+
*
|
|
3745
|
+
* @param output - Output workflow data
|
|
3746
|
+
* @returns Promise resolving to validation result
|
|
3747
|
+
*/
|
|
3748
|
+
validateOutput(output: TOutput): Promise<{
|
|
3749
|
+
isValid: boolean;
|
|
3750
|
+
errors: string[];
|
|
3751
|
+
warnings: string[];
|
|
3752
|
+
}>;
|
|
3753
|
+
/**
|
|
3754
|
+
* Check if this converter supports the given input format
|
|
3755
|
+
*
|
|
3756
|
+
* @param input - Input data to check
|
|
3757
|
+
* @returns True if converter can handle this input
|
|
3758
|
+
*/
|
|
3759
|
+
canConvert(input: IWorkflowData): input is TInput;
|
|
3760
|
+
/**
|
|
3761
|
+
* Get conversion statistics and metrics
|
|
3762
|
+
*
|
|
3763
|
+
* @returns Converter performance metrics
|
|
3764
|
+
*/
|
|
3765
|
+
getStats(): {
|
|
3766
|
+
totalConversions: number;
|
|
3767
|
+
successfulConversions: number;
|
|
3768
|
+
failedConversions: number;
|
|
3769
|
+
averageProcessingTime: number;
|
|
3770
|
+
lastConversionAt?: Date;
|
|
3771
|
+
};
|
|
3772
|
+
/**
|
|
3773
|
+
* Reset converter statistics
|
|
3774
|
+
*/
|
|
3775
|
+
resetStats(): void;
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
/**
|
|
3779
|
+
* Workflow Validator Interface
|
|
3780
|
+
*
|
|
3781
|
+
* Defines the contract for workflow validation systems in the Robota SDK.
|
|
3782
|
+
* Follows Single Responsibility Principle by focusing only on validation logic.
|
|
3783
|
+
*/
|
|
3784
|
+
|
|
3785
|
+
/**
|
|
3786
|
+
* Validation severity levels
|
|
3787
|
+
*/
|
|
3788
|
+
declare enum ValidationSeverity {
|
|
3789
|
+
ERROR = "error",
|
|
3790
|
+
WARNING = "warning",
|
|
3791
|
+
INFO = "info"
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* Individual validation issue
|
|
3795
|
+
*/
|
|
3796
|
+
interface IValidationIssue {
|
|
3797
|
+
/** Unique identifier for this issue */
|
|
3798
|
+
id: string;
|
|
3799
|
+
/** Issue severity level */
|
|
3800
|
+
severity: ValidationSeverity;
|
|
3801
|
+
/** Human-readable message */
|
|
3802
|
+
message: string;
|
|
3803
|
+
/** Technical details or suggestion */
|
|
3804
|
+
details?: string;
|
|
3805
|
+
/** Location where issue was found */
|
|
3806
|
+
location?: {
|
|
3807
|
+
nodeId?: string;
|
|
3808
|
+
edgeId?: string;
|
|
3809
|
+
field?: string;
|
|
3810
|
+
line?: number;
|
|
3811
|
+
column?: number;
|
|
3812
|
+
};
|
|
3813
|
+
/** Rule that triggered this issue */
|
|
3814
|
+
rule: string;
|
|
3815
|
+
/** Suggested fix (if available) */
|
|
3816
|
+
suggestedFix?: {
|
|
3817
|
+
description: string;
|
|
3818
|
+
action: 'modify' | 'remove' | 'add';
|
|
3819
|
+
target?: IWorkflowConfig;
|
|
3820
|
+
};
|
|
3821
|
+
/** Timestamp when issue was detected */
|
|
3822
|
+
detectedAt: Date;
|
|
3823
|
+
}
|
|
3824
|
+
/**
|
|
3825
|
+
* Validation options
|
|
3826
|
+
*/
|
|
3827
|
+
interface IValidationOptions {
|
|
3828
|
+
/** Validation strictness level */
|
|
3829
|
+
strict?: boolean;
|
|
3830
|
+
/** Skip specific validation rules */
|
|
3831
|
+
skipRules?: string[];
|
|
3832
|
+
/** Include only specific validation rules */
|
|
3833
|
+
includeRules?: string[];
|
|
3834
|
+
/** Maximum number of errors to collect */
|
|
3835
|
+
maxErrors?: number;
|
|
3836
|
+
/** Include warnings in results */
|
|
3837
|
+
includeWarnings?: boolean;
|
|
3838
|
+
/** Include info messages in results */
|
|
3839
|
+
includeInfo?: boolean;
|
|
3840
|
+
/** Custom logger for validation process */
|
|
3841
|
+
logger?: ILogger;
|
|
3842
|
+
/** Additional validation context */
|
|
3843
|
+
context?: IWorkflowMetadata;
|
|
3844
|
+
/** Enable auto-recovery suggestions */
|
|
3845
|
+
enableAutoRecovery?: boolean;
|
|
3846
|
+
}
|
|
3847
|
+
/**
|
|
3848
|
+
* Validation result
|
|
3849
|
+
*/
|
|
3850
|
+
interface IValidationResult {
|
|
3851
|
+
/** Overall validation success status */
|
|
3852
|
+
isValid: boolean;
|
|
3853
|
+
/** All validation issues found */
|
|
3854
|
+
issues: IValidationIssue[];
|
|
3855
|
+
/** Summary by severity */
|
|
3856
|
+
summary: {
|
|
3857
|
+
errorCount: number;
|
|
3858
|
+
warningCount: number;
|
|
3859
|
+
infoCount: number;
|
|
3860
|
+
totalIssues: number;
|
|
3861
|
+
};
|
|
3862
|
+
/** Validation metadata */
|
|
3863
|
+
metadata: {
|
|
3864
|
+
/** Validation timestamp */
|
|
3865
|
+
validatedAt: Date;
|
|
3866
|
+
/** Processing time in milliseconds */
|
|
3867
|
+
processingTime: number;
|
|
3868
|
+
/** Validator used */
|
|
3869
|
+
validator: string;
|
|
3870
|
+
/** Validation rules applied */
|
|
3871
|
+
rulesApplied: string[];
|
|
3872
|
+
/** Data statistics */
|
|
3873
|
+
dataStats: Record<string, string | number | boolean>;
|
|
3874
|
+
/** Version */
|
|
3875
|
+
version?: string;
|
|
3876
|
+
/** Options */
|
|
3877
|
+
options?: string | number | boolean | string[] | Date;
|
|
3878
|
+
/** Additional metrics */
|
|
3879
|
+
[key: string]: string | number | boolean | Date | string[] | Record<string, string | number | boolean> | undefined;
|
|
3880
|
+
};
|
|
3881
|
+
/** Auto-recovery suggestions (if enabled) */
|
|
3882
|
+
recoveryOptions?: Array<{
|
|
3883
|
+
description: string;
|
|
3884
|
+
confidence: number;
|
|
3885
|
+
action: () => Promise<IWorkflowConfig>;
|
|
3886
|
+
}>;
|
|
3887
|
+
}
|
|
3888
|
+
/**
|
|
3889
|
+
* Workflow Validator Interface
|
|
3890
|
+
*
|
|
3891
|
+
* Core interface for validating workflow data structures.
|
|
3892
|
+
* All workflow validators must implement this interface.
|
|
3893
|
+
*
|
|
3894
|
+
* @template TWorkflowData - Type of workflow data to validate
|
|
3895
|
+
*/
|
|
3896
|
+
interface IWorkflowValidator<TWorkflowData extends IWorkflowData> {
|
|
3897
|
+
/** Validator name for identification */
|
|
3898
|
+
readonly name: string;
|
|
3899
|
+
/** Validator version */
|
|
3900
|
+
readonly version: string;
|
|
3901
|
+
/** Data format that this validator handles */
|
|
3902
|
+
readonly dataFormat: string;
|
|
3903
|
+
/** Available validation rules */
|
|
3904
|
+
readonly availableRules: string[];
|
|
3905
|
+
/**
|
|
3906
|
+
* Validate workflow data
|
|
3907
|
+
*
|
|
3908
|
+
* @param data - Workflow data to validate
|
|
3909
|
+
* @param options - Validation options
|
|
3910
|
+
* @returns Promise resolving to validation result
|
|
3911
|
+
*/
|
|
3912
|
+
validate(data: TWorkflowData, options?: IValidationOptions): Promise<IValidationResult>;
|
|
3913
|
+
/**
|
|
3914
|
+
* Validate specific aspect of workflow data
|
|
3915
|
+
*
|
|
3916
|
+
* @param data - Workflow data to validate
|
|
3917
|
+
* @param rule - Specific rule to apply
|
|
3918
|
+
* @param options - Validation options
|
|
3919
|
+
* @returns Promise resolving to validation result for this rule
|
|
3920
|
+
*/
|
|
3921
|
+
validateRule(data: TWorkflowData, rule: string, options?: IValidationOptions): Promise<IValidationResult>;
|
|
3922
|
+
/**
|
|
3923
|
+
* Check if validator can handle the given data format
|
|
3924
|
+
*
|
|
3925
|
+
* @param data - Data to check
|
|
3926
|
+
* @returns True if validator can handle this data
|
|
3927
|
+
*/
|
|
3928
|
+
canValidate(data: IWorkflowData): data is TWorkflowData;
|
|
3929
|
+
/**
|
|
3930
|
+
* Get available validation rules with descriptions
|
|
3931
|
+
*
|
|
3932
|
+
* @returns Map of rule names to descriptions
|
|
3933
|
+
*/
|
|
3934
|
+
getRuleDescriptions(): Map<string, {
|
|
3935
|
+
description: string;
|
|
3936
|
+
severity: ValidationSeverity;
|
|
3937
|
+
category: string;
|
|
3938
|
+
enabled: boolean;
|
|
3939
|
+
}>;
|
|
3940
|
+
/**
|
|
3941
|
+
* Enable or disable specific validation rules
|
|
3942
|
+
*
|
|
3943
|
+
* @param rules - Map of rule names to enabled status
|
|
3944
|
+
*/
|
|
3945
|
+
configureRules(rules: Map<string, boolean>): void;
|
|
3946
|
+
/**
|
|
3947
|
+
* Perform automatic recovery for validation issues
|
|
3948
|
+
*
|
|
3949
|
+
* @param data - Original workflow data
|
|
3950
|
+
* @param issues - Validation issues to recover from
|
|
3951
|
+
* @returns Promise resolving to recovered data and recovery result
|
|
3952
|
+
*/
|
|
3953
|
+
autoRecover(data: TWorkflowData, issues: IValidationIssue[]): Promise<{
|
|
3954
|
+
recoveredData: TWorkflowData;
|
|
3955
|
+
recoveryResult: {
|
|
3956
|
+
success: boolean;
|
|
3957
|
+
issuesFixed: IValidationIssue[];
|
|
3958
|
+
remainingIssues: IValidationIssue[];
|
|
3959
|
+
appliedFixes: string[];
|
|
3960
|
+
};
|
|
3961
|
+
}>;
|
|
3962
|
+
/**
|
|
3963
|
+
* Get validator statistics and metrics
|
|
3964
|
+
*
|
|
3965
|
+
* @returns Validator performance metrics
|
|
3966
|
+
*/
|
|
3967
|
+
getStats(): {
|
|
3968
|
+
totalValidations: number;
|
|
3969
|
+
successfulValidations: number;
|
|
3970
|
+
failedValidations: number;
|
|
3971
|
+
averageProcessingTime: number;
|
|
3972
|
+
averageIssueCount: number;
|
|
3973
|
+
mostCommonIssues: Array<{
|
|
3974
|
+
rule: string;
|
|
3975
|
+
count: number;
|
|
3976
|
+
severity: ValidationSeverity;
|
|
3977
|
+
}>;
|
|
3978
|
+
lastValidationAt?: Date;
|
|
3979
|
+
};
|
|
3980
|
+
/**
|
|
3981
|
+
* Reset validator statistics
|
|
3982
|
+
*/
|
|
3983
|
+
resetStats(): void;
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3986
|
+
/**
|
|
3987
|
+
* Configuration for execution proxy
|
|
3988
|
+
*/
|
|
3989
|
+
interface IExecutionProxyConfig {
|
|
3990
|
+
eventService: IEventService;
|
|
3991
|
+
sourceType: 'agent' | 'team' | 'tool';
|
|
3992
|
+
sourceId: string;
|
|
3993
|
+
enabledEvents?: {
|
|
3994
|
+
execution?: boolean;
|
|
3995
|
+
toolCall?: boolean;
|
|
3996
|
+
task?: boolean;
|
|
3997
|
+
};
|
|
3998
|
+
}
|
|
3999
|
+
/**
|
|
4000
|
+
* Metadata extractor function type
|
|
4001
|
+
*/
|
|
4002
|
+
type TExecutionProxyTarget = Record<string, TUniversalValue>;
|
|
4003
|
+
type TExecutionProxyArgs = TUniversalValue[];
|
|
4004
|
+
type TMetadataExtractor = (target: TExecutionProxyTarget, methodName: string, args: TExecutionProxyArgs) => Record<string, TUniversalValue>;
|
|
4005
|
+
/**
|
|
4006
|
+
* Method configuration for proxy
|
|
4007
|
+
*/
|
|
4008
|
+
interface IMethodConfig {
|
|
4009
|
+
startEvent?: string;
|
|
4010
|
+
completeEvent?: string;
|
|
4011
|
+
errorEvent?: string;
|
|
4012
|
+
extractMetadata?: TMetadataExtractor;
|
|
4013
|
+
extractResult?: (result: TUniversalValue) => Record<string, TUniversalValue>;
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* ExecutionProxy - Automatic event emission using Proxy pattern
|
|
4017
|
+
*
|
|
4018
|
+
* This class wraps target objects and automatically emits events
|
|
4019
|
+
* around method execution without modifying business logic.
|
|
4020
|
+
*
|
|
4021
|
+
* Benefits:
|
|
4022
|
+
* - Zero business logic pollution
|
|
4023
|
+
* - Automatic event emission
|
|
4024
|
+
* - Configurable per method
|
|
4025
|
+
* - AOP (Aspect-Oriented Programming) pattern
|
|
4026
|
+
*/
|
|
4027
|
+
declare class ExecutionProxy<T extends object = object> {
|
|
4028
|
+
private config;
|
|
4029
|
+
private methodConfigs;
|
|
4030
|
+
constructor(config: IExecutionProxyConfig);
|
|
4031
|
+
/**
|
|
4032
|
+
* Configure specific methods for event emission
|
|
4033
|
+
*/
|
|
4034
|
+
configureMethod(methodName: string, config: IMethodConfig): this;
|
|
4035
|
+
/**
|
|
4036
|
+
* Configure multiple methods with standard patterns
|
|
4037
|
+
*/
|
|
4038
|
+
configureStandardMethods(): this;
|
|
4039
|
+
/**
|
|
4040
|
+
* Create a proxy wrapper around the target object
|
|
4041
|
+
*/
|
|
4042
|
+
wrap(target: T): T;
|
|
4043
|
+
/**
|
|
4044
|
+
* Emit event with standard ServiceEventData format
|
|
4045
|
+
*/
|
|
4046
|
+
private emitEvent;
|
|
4047
|
+
/**
|
|
4048
|
+
* Generate unique execution ID
|
|
4049
|
+
*/
|
|
4050
|
+
private generateExecutionId;
|
|
4051
|
+
}
|
|
4052
|
+
/**
|
|
4053
|
+
* Factory function to create execution proxy with standard configuration
|
|
4054
|
+
*/
|
|
4055
|
+
declare function createExecutionProxy<T extends object>(target: T, config: IExecutionProxyConfig): T;
|
|
4056
|
+
/**
|
|
4057
|
+
* Decorator function for automatic event emission
|
|
4058
|
+
* Usage: @withEventEmission(eventService, 'agent', 'agent-id')
|
|
4059
|
+
*/
|
|
4060
|
+
declare function withEventEmission(eventService: IEventService, sourceType: 'agent' | 'team' | 'tool', sourceId: string): <T extends object>(target: T) => T;
|
|
4061
|
+
|
|
4062
|
+
/**
|
|
4063
|
+
* Permission system types — Claude Code compatible permission model.
|
|
4064
|
+
*/
|
|
4065
|
+
/**
|
|
4066
|
+
* Permission modes (Claude Code compatible)
|
|
4067
|
+
* - plan: read-only tools only
|
|
4068
|
+
* - default: reads auto, writes/bash need approval
|
|
4069
|
+
* - acceptEdits: reads + writes auto, bash needs approval
|
|
4070
|
+
* - bypassPermissions: all tools auto
|
|
4071
|
+
*/
|
|
4072
|
+
type TPermissionMode = 'plan' | 'default' | 'acceptEdits' | 'bypassPermissions';
|
|
4073
|
+
/**
|
|
4074
|
+
* Friendly trust level aliases
|
|
4075
|
+
* - safe → plan
|
|
4076
|
+
* - moderate → default
|
|
4077
|
+
* - full → acceptEdits
|
|
4078
|
+
*/
|
|
4079
|
+
type TTrustLevel = 'safe' | 'moderate' | 'full';
|
|
4080
|
+
declare const TRUST_TO_MODE: Record<TTrustLevel, TPermissionMode>;
|
|
4081
|
+
/**
|
|
4082
|
+
* Outcome of a permission evaluation
|
|
4083
|
+
* - auto: proceed without prompting
|
|
4084
|
+
* - approve: prompt user for approval
|
|
4085
|
+
* - deny: block the action
|
|
4086
|
+
*/
|
|
4087
|
+
type TPermissionDecision = 'auto' | 'approve' | 'deny';
|
|
4088
|
+
|
|
4089
|
+
/**
|
|
4090
|
+
* Permission gate — evaluates whether a tool call is auto-approved, needs user approval, or denied.
|
|
4091
|
+
*
|
|
4092
|
+
* Three-step deterministic policy (in order of precedence):
|
|
4093
|
+
* 1. Deny list match → deny
|
|
4094
|
+
* 2. Allow list match → auto
|
|
4095
|
+
* 3. Mode policy lookup
|
|
4096
|
+
*
|
|
4097
|
+
* Pattern syntax (same as Claude Code):
|
|
4098
|
+
* - `Bash(pnpm *)` — Bash tool whose command starts with "pnpm "
|
|
4099
|
+
* - `Read(/src/**)` — Read tool whose filePath is under /src/
|
|
4100
|
+
* - `Write(*)` — Write tool with any argument
|
|
4101
|
+
* - `ToolName` — match any invocation of that tool
|
|
4102
|
+
*/
|
|
4103
|
+
|
|
4104
|
+
/**
|
|
4105
|
+
* Tool arguments passed from the LLM invocation.
|
|
4106
|
+
* The values relevant to permission matching are strings.
|
|
4107
|
+
*/
|
|
4108
|
+
type TToolArgs = Record<string, string | number | boolean | object>;
|
|
4109
|
+
/**
|
|
4110
|
+
* Permission list entries (allow / deny).
|
|
4111
|
+
* Each entry is a pattern string such as "Bash(pnpm *)" or "Read(/src/**)".
|
|
4112
|
+
*/
|
|
4113
|
+
interface IPermissionLists {
|
|
4114
|
+
allow?: string[];
|
|
4115
|
+
deny?: string[];
|
|
4116
|
+
}
|
|
4117
|
+
/**
|
|
4118
|
+
* Evaluate whether a tool invocation should be auto-approved, require user approval, or be denied.
|
|
4119
|
+
*
|
|
4120
|
+
* @param toolName Name of the tool being invoked (e.g. "Bash", "Write")
|
|
4121
|
+
* @param toolArgs Arguments provided by the LLM
|
|
4122
|
+
* @param mode Active permission mode
|
|
4123
|
+
* @param permissions Optional allow/deny lists from config
|
|
4124
|
+
*/
|
|
4125
|
+
declare function evaluatePermission(toolName: string, toolArgs: TToolArgs, mode: TPermissionMode, permissions?: IPermissionLists): TPermissionDecision;
|
|
4126
|
+
|
|
4127
|
+
/**
|
|
4128
|
+
* Permission mode definitions for Robota CLI
|
|
4129
|
+
*
|
|
4130
|
+
* Matches Claude Code-compatible permission modes:
|
|
4131
|
+
* - plan: read-only tools only (Read, Glob, Grep auto; Write, Edit, Bash denied)
|
|
4132
|
+
* - default: safe reads auto, writes and bash need approval
|
|
4133
|
+
* - acceptEdits: reads + writes auto, bash needs approval
|
|
4134
|
+
* - bypassPermissions: all tools auto
|
|
4135
|
+
*/
|
|
4136
|
+
|
|
4137
|
+
/**
|
|
4138
|
+
* Tool names known to the permission system
|
|
4139
|
+
*/
|
|
4140
|
+
type TKnownToolName = 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep';
|
|
4141
|
+
/**
|
|
4142
|
+
* Permission mode → tool policy matrix
|
|
4143
|
+
* Maps each mode to a decision for each known tool.
|
|
4144
|
+
*/
|
|
4145
|
+
declare const MODE_POLICY: Record<TPermissionMode, Record<TKnownToolName, TPermissionDecision>>;
|
|
4146
|
+
/**
|
|
4147
|
+
* Fallback decision when a tool name is not in the policy matrix.
|
|
4148
|
+
* Unknown tools are treated as requiring approval (fail-safe).
|
|
4149
|
+
*/
|
|
4150
|
+
declare const UNKNOWN_TOOL_FALLBACK: Record<TPermissionMode, TPermissionDecision>;
|
|
4151
|
+
|
|
4152
|
+
/**
|
|
4153
|
+
* Context window tracking types.
|
|
4154
|
+
*
|
|
4155
|
+
* These types are used by agent-sessions (and downstream packages) to
|
|
4156
|
+
* track token usage and context window state across conversation turns.
|
|
4157
|
+
*/
|
|
4158
|
+
/** Token usage from a single API call (Anthropic-style granularity) */
|
|
4159
|
+
interface IContextTokenUsage {
|
|
4160
|
+
inputTokens: number;
|
|
4161
|
+
outputTokens: number;
|
|
4162
|
+
cacheCreationTokens?: number;
|
|
4163
|
+
cacheReadTokens?: number;
|
|
4164
|
+
}
|
|
4165
|
+
/** Context window state snapshot */
|
|
4166
|
+
interface IContextWindowState {
|
|
4167
|
+
/** Max tokens for the current model */
|
|
4168
|
+
maxTokens: number;
|
|
4169
|
+
/** Current estimated token usage (input + cache, excludes output) */
|
|
4170
|
+
usedTokens: number;
|
|
4171
|
+
/** Usage percentage (0-100) */
|
|
4172
|
+
usedPercentage: number;
|
|
4173
|
+
/** Remaining percentage (0-100) */
|
|
4174
|
+
remainingPercentage: number;
|
|
4175
|
+
}
|
|
4176
|
+
|
|
4177
|
+
/**
|
|
4178
|
+
* Hook system types — Claude Code compatible event/hook model.
|
|
4179
|
+
*/
|
|
4180
|
+
/** Hook lifecycle events */
|
|
4181
|
+
type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact';
|
|
4182
|
+
/** A single hook definition */
|
|
4183
|
+
interface IHookDefinition {
|
|
4184
|
+
/** Shell command to execute */
|
|
4185
|
+
type: 'command';
|
|
4186
|
+
command: string;
|
|
4187
|
+
}
|
|
4188
|
+
/** A hook group — matcher + array of hook definitions */
|
|
4189
|
+
interface IHookGroup {
|
|
4190
|
+
/** Regex pattern to match tool name (empty string = match all) */
|
|
4191
|
+
matcher: string;
|
|
4192
|
+
hooks: IHookDefinition[];
|
|
4193
|
+
}
|
|
4194
|
+
/** Complete hooks configuration: event → array of hook groups */
|
|
4195
|
+
type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
|
|
4196
|
+
/** Input passed to hook commands via stdin */
|
|
4197
|
+
interface IHookInput {
|
|
4198
|
+
session_id: string;
|
|
4199
|
+
cwd: string;
|
|
4200
|
+
hook_event_name: THookEvent;
|
|
4201
|
+
tool_name?: string;
|
|
4202
|
+
tool_input?: Record<string, string | number | boolean | object>;
|
|
4203
|
+
tool_output?: string;
|
|
4204
|
+
/** Compaction trigger source (PreCompact/PostCompact only) */
|
|
4205
|
+
trigger?: 'auto' | 'manual';
|
|
4206
|
+
/** Compaction summary text (PostCompact only) */
|
|
4207
|
+
compact_summary?: string;
|
|
4208
|
+
}
|
|
4209
|
+
/** Hook execution result */
|
|
4210
|
+
interface IHookResult {
|
|
4211
|
+
/** 0 = allow/proceed, 2 = block/deny, other = proceed with warning */
|
|
4212
|
+
exitCode: number;
|
|
4213
|
+
stdout: string;
|
|
4214
|
+
stderr: string;
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4217
|
+
/**
|
|
4218
|
+
* Hook runner — executes shell command hooks for lifecycle events.
|
|
4219
|
+
*
|
|
4220
|
+
* Hooks receive JSON input on stdin and communicate results via exit codes:
|
|
4221
|
+
* - 0: allow/proceed
|
|
4222
|
+
* - 2: block/deny (stderr contains reason)
|
|
4223
|
+
* - other: proceed (logged as warning)
|
|
4224
|
+
*/
|
|
4225
|
+
|
|
4226
|
+
/**
|
|
4227
|
+
* Run all hooks for a given event.
|
|
4228
|
+
*
|
|
4229
|
+
* For PreToolUse: if any hook returns exit code 2, the tool call is blocked.
|
|
4230
|
+
* Returns { blocked: true, reason: string } if blocked, { blocked: false } otherwise.
|
|
4231
|
+
*/
|
|
4232
|
+
declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput): Promise<{
|
|
4233
|
+
blocked: boolean;
|
|
4234
|
+
reason?: string;
|
|
4235
|
+
}>;
|
|
4236
|
+
|
|
4237
|
+
export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConversationHistory, ConversationSession, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type IConfigValidationResult, type IContextOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, type IExecutorAwareProviderConfig, type IFunctionTool, type IHookDefinition, type IHookGroup, type IHookInput, type IHookResult, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, type ILogger, type IMCPToolConfig, type IMediaOutputRef, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IProviderConfig, type IProviderMediaError, type IProviderOptions, type IProviderRequest, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISimpleValidationResult, type IStreamExecutionRequest, type IStreamingChunk, type ISystemMessage, type ITemplateApplicationResult, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserMessage, type IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, InMemoryEventEmitterMetrics, LocalExecutor, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, type TAgentCreationMetadata, type TComplexConfigValue, type TConfigData, type TConfigValue, type TContextData, type TConversationContextMetadata, type TErrorContextData, type TErrorExternalInput, type TEventEmitterListener, type TEventListener, type TEventName, type TExecutionEventName, type TExecutionMetadata, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, type TLoggerData, type TManagerToolParameters, type TMetadata, type TMetadataValue, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderLoggingData, type TProviderMediaResult, type TProviderOptionValueBase, TRUST_TO_MODE, type TResponseMetadata, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, type TToolParameters, type TToolProgressCallback, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUtilLogLevel, ToolExecutionError, UNKNOWN_TOOL_FALLBACK, ValidationError, ValidationSeverity, Validator, createExecutionProxy, createLogger, evaluatePermission, getGlobalLogLevel, getToolEstimatedDuration, getToolExecutionSteps, isAssistantMessage, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, runHooks, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission };
|