@mxf-dev/core 2.0.5 → 3.0.0
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/dist/config/ModelContextLimits.d.ts.map +1 -1
- package/dist/config/ModelContextLimits.js +7 -1
- package/dist/config/ModelContextLimits.js.map +1 -1
- package/dist/constants/CoreTools.d.ts +6 -5
- package/dist/constants/CoreTools.d.ts.map +1 -1
- package/dist/constants/CoreTools.js +6 -5
- package/dist/constants/CoreTools.js.map +1 -1
- package/dist/constants/DefaultPhaseProfiles.d.ts.map +1 -1
- package/dist/constants/DefaultPhaseProfiles.js +29 -0
- package/dist/constants/DefaultPhaseProfiles.js.map +1 -1
- package/dist/constants/ReservedIdentities.d.ts +14 -0
- package/dist/constants/ReservedIdentities.d.ts.map +1 -0
- package/dist/constants/ReservedIdentities.js +42 -0
- package/dist/constants/ReservedIdentities.js.map +1 -0
- package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.d.ts +16 -16
- package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.d.ts.map +1 -1
- package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.js +98 -36
- package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.js.map +1 -1
- package/dist/events/ClientEventBus.d.ts +28 -0
- package/dist/events/ClientEventBus.d.ts.map +1 -1
- package/dist/events/ClientEventBus.js +87 -40
- package/dist/events/ClientEventBus.js.map +1 -1
- package/dist/events/EventBus.d.ts +19 -1
- package/dist/events/EventBus.d.ts.map +1 -1
- package/dist/events/EventBus.js +23 -0
- package/dist/events/EventBus.js.map +1 -1
- package/dist/events/EventBusBase.d.ts +37 -6
- package/dist/events/EventBusBase.d.ts.map +1 -1
- package/dist/events/EventBusBase.js +75 -27
- package/dist/events/EventBusBase.js.map +1 -1
- package/dist/events/EventNames.d.ts +49 -36
- package/dist/events/EventNames.d.ts.map +1 -1
- package/dist/events/EventNames.js +38 -36
- package/dist/events/EventNames.js.map +1 -1
- package/dist/events/PublicEvents.d.ts +5 -1
- package/dist/events/PublicEvents.d.ts.map +1 -1
- package/dist/events/PublicEvents.js +7 -0
- package/dist/events/PublicEvents.js.map +1 -1
- package/dist/events/ServerEventBus.d.ts +7 -54
- package/dist/events/ServerEventBus.d.ts.map +1 -1
- package/dist/events/ServerEventBus.js +10 -96
- package/dist/events/ServerEventBus.js.map +1 -1
- package/dist/events/event-definitions/ControlLoopEvents.d.ts +35 -0
- package/dist/events/event-definitions/ControlLoopEvents.d.ts.map +1 -1
- package/dist/events/event-definitions/ControlLoopEvents.js +6 -0
- package/dist/events/event-definitions/ControlLoopEvents.js.map +1 -1
- package/dist/events/event-definitions/SdkEvents.d.ts +55 -0
- package/dist/events/event-definitions/SdkEvents.d.ts.map +1 -0
- package/dist/events/event-definitions/SdkEvents.js +36 -0
- package/dist/events/event-definitions/SdkEvents.js.map +1 -0
- package/dist/events/event-definitions/TaskEvents.d.ts +2 -7
- package/dist/events/event-definitions/TaskEvents.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/AgentInterfaces.d.ts +5 -0
- package/dist/interfaces/AgentInterfaces.d.ts.map +1 -1
- package/dist/interfaces/ChannelConfig.d.ts +2 -2
- package/dist/interfaces/ChannelConfig.d.ts.map +1 -1
- package/dist/interfaces/ConversationMessage.d.ts +1 -1
- package/dist/interfaces/ConversationMessage.d.ts.map +1 -1
- package/dist/interfaces/IMemoryPersistence.d.ts +47 -1
- package/dist/interfaces/IMemoryPersistence.d.ts.map +1 -1
- package/dist/interfaces/SocketServiceInterface.d.ts +3 -2
- package/dist/interfaces/SocketServiceInterface.d.ts.map +1 -1
- package/dist/interfaces/TaskInterfaces.d.ts +14 -1
- package/dist/interfaces/TaskInterfaces.d.ts.map +1 -1
- package/dist/models/agent.d.ts +0 -1
- package/dist/models/agent.d.ts.map +1 -1
- package/dist/models/agent.js +0 -5
- package/dist/models/agent.js.map +1 -1
- package/dist/models/agentIdentityReservation.d.ts +42 -0
- package/dist/models/agentIdentityReservation.d.ts.map +1 -0
- package/dist/models/agentIdentityReservation.js +52 -0
- package/dist/models/agentIdentityReservation.js.map +1 -0
- package/dist/models/channel.d.ts +2 -0
- package/dist/models/channel.d.ts.map +1 -1
- package/dist/models/channel.js.map +1 -1
- package/dist/models/channelKey.d.ts +1 -0
- package/dist/models/channelKey.d.ts.map +1 -1
- package/dist/models/channelKey.js +5 -0
- package/dist/models/channelKey.js.map +1 -1
- package/dist/models/memory.d.ts +1 -1
- package/dist/models/memory.d.ts.map +1 -1
- package/dist/models/memory.js +9 -12
- package/dist/models/memory.js.map +1 -1
- package/dist/models/memoryStrata.d.ts +3 -16
- package/dist/models/memoryStrata.d.ts.map +1 -1
- package/dist/models/memoryStrata.js +3 -5
- package/dist/models/memoryStrata.js.map +1 -1
- package/dist/models/plan.d.ts +2 -2
- package/dist/models/plan.d.ts.map +1 -1
- package/dist/models/plan.js +1 -1
- package/dist/models/plan.js.map +1 -1
- package/dist/models/taskEffectiveness.d.ts +1 -0
- package/dist/models/taskEffectiveness.d.ts.map +1 -1
- package/dist/models/taskEffectiveness.js +7 -1
- package/dist/models/taskEffectiveness.js.map +1 -1
- package/dist/models/user.d.ts +4 -0
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/user.js +8 -0
- package/dist/models/user.js.map +1 -1
- package/dist/protocols/mcp/LlmTestEnvironmentGuard.d.ts +16 -0
- package/dist/protocols/mcp/LlmTestEnvironmentGuard.d.ts.map +1 -0
- package/dist/protocols/mcp/LlmTestEnvironmentGuard.js +25 -0
- package/dist/protocols/mcp/LlmTestEnvironmentGuard.js.map +1 -0
- package/dist/protocols/mcp/McpServerTypes.d.ts +9 -0
- package/dist/protocols/mcp/McpServerTypes.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/AnthropicMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/AnthropicMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/AnthropicMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/BaseMcpClient.d.ts +4 -0
- package/dist/protocols/mcp/providers/BaseMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/BaseMcpClient.js +10 -0
- package/dist/protocols/mcp/providers/BaseMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/CustomMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/CustomMcpClient.js +7 -0
- package/dist/protocols/mcp/providers/CustomMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/GeminiMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/GeminiMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/GeminiMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/OllamaMcpClient.d.ts +1 -0
- package/dist/protocols/mcp/providers/OllamaMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/OllamaMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/OllamaMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/OpenAiMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/OpenAiMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/OpenAiMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/OpenRouterMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/OpenRouterMcpClient.js +2 -0
- package/dist/protocols/mcp/providers/OpenRouterMcpClient.js.map +1 -1
- package/dist/protocols/mcp/providers/XaiMcpClient.d.ts.map +1 -1
- package/dist/protocols/mcp/providers/XaiMcpClient.js +1 -0
- package/dist/protocols/mcp/providers/XaiMcpClient.js.map +1 -1
- package/dist/protocols/mcp/security/BrowserTargetGuard.d.ts +14 -0
- package/dist/protocols/mcp/security/BrowserTargetGuard.d.ts.map +1 -0
- package/dist/protocols/mcp/security/BrowserTargetGuard.js +55 -0
- package/dist/protocols/mcp/security/BrowserTargetGuard.js.map +1 -0
- package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.d.ts +24 -0
- package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.d.ts.map +1 -0
- package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.js +33 -0
- package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.js.map +1 -0
- package/dist/protocols/mcp/security/HttpTargetGuard.d.ts.map +1 -1
- package/dist/protocols/mcp/security/HttpTargetGuard.js +68 -6
- package/dist/protocols/mcp/security/HttpTargetGuard.js.map +1 -1
- package/dist/protocols/mcp/security/McpSecurityGuard.d.ts.map +1 -1
- package/dist/protocols/mcp/security/McpSecurityGuard.js +7 -5
- package/dist/protocols/mcp/security/McpSecurityGuard.js.map +1 -1
- package/dist/protocols/mcp/security/McpToolPolicy.d.ts +18 -0
- package/dist/protocols/mcp/security/McpToolPolicy.d.ts.map +1 -1
- package/dist/protocols/mcp/security/McpToolPolicy.js +60 -0
- package/dist/protocols/mcp/security/McpToolPolicy.js.map +1 -1
- package/dist/protocols/mcp/services/ExternalMcpServerManager.d.ts +25 -0
- package/dist/protocols/mcp/services/ExternalMcpServerManager.d.ts.map +1 -1
- package/dist/protocols/mcp/services/ExternalMcpServerManager.js +93 -17
- package/dist/protocols/mcp/services/ExternalMcpServerManager.js.map +1 -1
- package/dist/protocols/mcp/services/ExternalServerConfigs.d.ts +2 -2
- package/dist/protocols/mcp/services/ExternalServerConfigs.d.ts.map +1 -1
- package/dist/protocols/mcp/services/ExternalServerConfigs.js +25 -8
- package/dist/protocols/mcp/services/ExternalServerConfigs.js.map +1 -1
- package/dist/protocols/mcp/tools/AnalyticsTools.d.ts +3 -37
- package/dist/protocols/mcp/tools/AnalyticsTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/AnalyticsTools.js +134 -614
- package/dist/protocols/mcp/tools/AnalyticsTools.js.map +1 -1
- package/dist/protocols/mcp/tools/CodeAnalysisTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/CodeAnalysisTools.js +16 -13
- package/dist/protocols/mcp/tools/CodeAnalysisTools.js.map +1 -1
- package/dist/protocols/mcp/tools/EffectivenessTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/EffectivenessTools.js +94 -30
- package/dist/protocols/mcp/tools/EffectivenessTools.js.map +1 -1
- package/dist/protocols/mcp/tools/GitTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/GitTools.js +9 -5
- package/dist/protocols/mcp/tools/GitTools.js.map +1 -1
- package/dist/protocols/mcp/tools/InfrastructureTools.d.ts +10 -40
- package/dist/protocols/mcp/tools/InfrastructureTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/InfrastructureTools.js +29 -70
- package/dist/protocols/mcp/tools/InfrastructureTools.js.map +1 -1
- package/dist/protocols/mcp/tools/JsonTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/JsonTools.js +4 -4
- package/dist/protocols/mcp/tools/JsonTools.js.map +1 -1
- package/dist/protocols/mcp/tools/KnowledgeGraphTools.d.ts +55 -592
- package/dist/protocols/mcp/tools/KnowledgeGraphTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/KnowledgeGraphTools.js +169 -119
- package/dist/protocols/mcp/tools/KnowledgeGraphTools.js.map +1 -1
- package/dist/protocols/mcp/tools/MemorySearchTools.d.ts +6 -6
- package/dist/protocols/mcp/tools/MemorySearchTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/MemorySearchTools.js +107 -39
- package/dist/protocols/mcp/tools/MemorySearchTools.js.map +1 -1
- package/dist/protocols/mcp/tools/MemoryUtilityTools.d.ts +4 -5
- package/dist/protocols/mcp/tools/MemoryUtilityTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/MemoryUtilityTools.js +59 -208
- package/dist/protocols/mcp/tools/MemoryUtilityTools.js.map +1 -1
- package/dist/protocols/mcp/tools/PlanningTools.d.ts +2 -1
- package/dist/protocols/mcp/tools/PlanningTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/PlanningTools.js +111 -49
- package/dist/protocols/mcp/tools/PlanningTools.js.map +1 -1
- package/dist/protocols/mcp/tools/ProjectContextTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/ProjectContextTools.js +18 -12
- package/dist/protocols/mcp/tools/ProjectContextTools.js.map +1 -1
- package/dist/protocols/mcp/tools/SafetyTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/SafetyTools.js +16 -13
- package/dist/protocols/mcp/tools/SafetyTools.js.map +1 -1
- package/dist/protocols/mcp/tools/SearchProjectTools.d.ts +24 -7
- package/dist/protocols/mcp/tools/SearchProjectTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/SearchProjectTools.js +226 -126
- package/dist/protocols/mcp/tools/SearchProjectTools.js.map +1 -1
- package/dist/protocols/mcp/tools/TaskPlanningTools.d.ts +0 -32
- package/dist/protocols/mcp/tools/TaskPlanningTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/TaskPlanningTools.js +363 -450
- package/dist/protocols/mcp/tools/TaskPlanningTools.js.map +1 -1
- package/dist/protocols/mcp/tools/TestTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/TestTools.js +18 -11
- package/dist/protocols/mcp/tools/TestTools.js.map +1 -1
- package/dist/protocols/mcp/tools/TypeScriptTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/TypeScriptTools.js +22 -12
- package/dist/protocols/mcp/tools/TypeScriptTools.js.map +1 -1
- package/dist/protocols/mcp/tools/UserInputTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/UserInputTools.js +14 -1
- package/dist/protocols/mcp/tools/UserInputTools.js.map +1 -1
- package/dist/protocols/mcp/tools/UserMemoryTools.d.ts +3 -1
- package/dist/protocols/mcp/tools/UserMemoryTools.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/UserMemoryTools.js +27 -62
- package/dist/protocols/mcp/tools/UserMemoryTools.js.map +1 -1
- package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.js +14 -60
- package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.js.map +1 -1
- package/dist/protocols/mcp/tools/shell/ShellSandbox.d.ts.map +1 -1
- package/dist/protocols/mcp/tools/shell/ShellSandbox.js +9 -27
- package/dist/protocols/mcp/tools/shell/ShellSandbox.js.map +1 -1
- package/dist/repositories/interfaces/IKnowledgeGraphRepository.d.ts +40 -30
- package/dist/repositories/interfaces/IKnowledgeGraphRepository.d.ts.map +1 -1
- package/dist/schemas/EventPayloadSchema.d.ts +28 -0
- package/dist/schemas/EventPayloadSchema.d.ts.map +1 -1
- package/dist/schemas/EventPayloadSchema.js +30 -1
- package/dist/schemas/EventPayloadSchema.js.map +1 -1
- package/dist/schemas/MxpProtocolSchemas.d.ts +6 -6
- package/dist/services/AgentPerformanceService.d.ts +11 -0
- package/dist/services/AgentPerformanceService.d.ts.map +1 -1
- package/dist/services/AgentPerformanceService.js +59 -33
- package/dist/services/AgentPerformanceService.js.map +1 -1
- package/dist/services/AutoCorrectionService.d.ts +3 -0
- package/dist/services/AutoCorrectionService.d.ts.map +1 -1
- package/dist/services/AutoCorrectionService.js +19 -2
- package/dist/services/AutoCorrectionService.js.map +1 -1
- package/dist/services/BackgroundTaskManager.d.ts +23 -7
- package/dist/services/BackgroundTaskManager.d.ts.map +1 -1
- package/dist/services/BackgroundTaskManager.js +137 -57
- package/dist/services/BackgroundTaskManager.js.map +1 -1
- package/dist/services/BrowserManager.d.ts +2 -0
- package/dist/services/BrowserManager.d.ts.map +1 -1
- package/dist/services/BrowserManager.js +18 -15
- package/dist/services/BrowserManager.js.map +1 -1
- package/dist/services/ChannelContextMemoryOperations.d.ts +8 -1
- package/dist/services/ChannelContextMemoryOperations.d.ts.map +1 -1
- package/dist/services/ChannelContextMemoryOperations.js +89 -165
- package/dist/services/ChannelContextMemoryOperations.js.map +1 -1
- package/dist/services/ChannelContextMessageOperations.d.ts +4 -3
- package/dist/services/ChannelContextMessageOperations.d.ts.map +1 -1
- package/dist/services/ChannelContextMessageOperations.js +72 -212
- package/dist/services/ChannelContextMessageOperations.js.map +1 -1
- package/dist/services/MemoryService.d.ts +52 -21
- package/dist/services/MemoryService.d.ts.map +1 -1
- package/dist/services/MemoryService.js +775 -548
- package/dist/services/MemoryService.js.map +1 -1
- package/dist/services/PatternLearningService.d.ts +5 -0
- package/dist/services/PatternLearningService.d.ts.map +1 -1
- package/dist/services/PatternLearningService.js +26 -3
- package/dist/services/PatternLearningService.js.map +1 -1
- package/dist/services/PerformanceOptimizationService.d.ts +2 -1
- package/dist/services/PerformanceOptimizationService.d.ts.map +1 -1
- package/dist/services/PerformanceOptimizationService.js +21 -6
- package/dist/services/PerformanceOptimizationService.js.map +1 -1
- package/dist/services/PredictiveAnalyticsService.d.ts +1 -0
- package/dist/services/PredictiveAnalyticsService.d.ts.map +1 -1
- package/dist/services/PredictiveAnalyticsService.js +18 -6
- package/dist/services/PredictiveAnalyticsService.js.map +1 -1
- package/dist/services/ProactiveValidationService.d.ts +6 -0
- package/dist/services/ProactiveValidationService.d.ts.map +1 -1
- package/dist/services/ProactiveValidationService.js +58 -39
- package/dist/services/ProactiveValidationService.js.map +1 -1
- package/dist/services/TaskEffectivenessService.d.ts +55 -31
- package/dist/services/TaskEffectivenessService.d.ts.map +1 -1
- package/dist/services/TaskEffectivenessService.js +243 -125
- package/dist/services/TaskEffectivenessService.js.map +1 -1
- package/dist/services/ToolExecutionInterceptor.d.ts +4 -0
- package/dist/services/ToolExecutionInterceptor.d.ts.map +1 -1
- package/dist/services/ToolExecutionInterceptor.js +31 -5
- package/dist/services/ToolExecutionInterceptor.js.map +1 -1
- package/dist/services/UserInputRequestManager.d.ts +13 -3
- package/dist/services/UserInputRequestManager.d.ts.map +1 -1
- package/dist/services/UserInputRequestManager.js +42 -6
- package/dist/services/UserInputRequestManager.js.map +1 -1
- package/dist/services/UserMemoryService.d.ts +2 -0
- package/dist/services/UserMemoryService.d.ts.map +1 -1
- package/dist/services/UserMemoryService.js +9 -4
- package/dist/services/UserMemoryService.js.map +1 -1
- package/dist/services/ValidationAnalyticsService.d.ts +4 -0
- package/dist/services/ValidationAnalyticsService.d.ts.map +1 -1
- package/dist/services/ValidationAnalyticsService.js +30 -8
- package/dist/services/ValidationAnalyticsService.js.map +1 -1
- package/dist/services/ValidationCacheService.d.ts +3 -1
- package/dist/services/ValidationCacheService.d.ts.map +1 -1
- package/dist/services/ValidationCacheService.js +25 -4
- package/dist/services/ValidationCacheService.js.map +1 -1
- package/dist/services/ValidationMiddleware.d.ts +7 -0
- package/dist/services/ValidationMiddleware.d.ts.map +1 -1
- package/dist/services/ValidationMiddleware.js +53 -10
- package/dist/services/ValidationMiddleware.js.map +1 -1
- package/dist/services/ValidationPerformanceService.d.ts +3 -0
- package/dist/services/ValidationPerformanceService.d.ts.map +1 -1
- package/dist/services/ValidationPerformanceService.js +28 -11
- package/dist/services/ValidationPerformanceService.js.map +1 -1
- package/dist/services/WebSearchService.d.ts.map +1 -1
- package/dist/services/WebSearchService.js +9 -0
- package/dist/services/WebSearchService.js.map +1 -1
- package/dist/services/dag/TaskDagService.d.ts +3 -0
- package/dist/services/dag/TaskDagService.d.ts.map +1 -1
- package/dist/services/dag/TaskDagService.js +18 -0
- package/dist/services/dag/TaskDagService.js.map +1 -1
- package/dist/services/kg/EntityQValueManager.d.ts +3 -1
- package/dist/services/kg/EntityQValueManager.d.ts.map +1 -1
- package/dist/services/kg/EntityQValueManager.js +10 -10
- package/dist/services/kg/EntityQValueManager.js.map +1 -1
- package/dist/services/kg/GraphSurpriseCalculator.d.ts +0 -4
- package/dist/services/kg/GraphSurpriseCalculator.d.ts.map +1 -1
- package/dist/services/kg/GraphSurpriseCalculator.js +0 -9
- package/dist/services/kg/GraphSurpriseCalculator.js.map +1 -1
- package/dist/services/kg/KnowledgeGraphService.d.ts +12 -12
- package/dist/services/kg/KnowledgeGraphService.d.ts.map +1 -1
- package/dist/services/kg/KnowledgeGraphService.js +43 -51
- package/dist/services/kg/KnowledgeGraphService.js.map +1 -1
- package/dist/services/kg/OrparGraphIntegration.d.ts.map +1 -1
- package/dist/services/kg/OrparGraphIntegration.js +6 -5
- package/dist/services/kg/OrparGraphIntegration.js.map +1 -1
- package/dist/services/orpar-memory/CycleConsolidationTrigger.d.ts +1 -0
- package/dist/services/orpar-memory/CycleConsolidationTrigger.d.ts.map +1 -1
- package/dist/services/orpar-memory/CycleConsolidationTrigger.js +8 -1
- package/dist/services/orpar-memory/CycleConsolidationTrigger.js.map +1 -1
- package/dist/services/orpar-memory/OrparMemoryCoordinator.d.ts +8 -1
- package/dist/services/orpar-memory/OrparMemoryCoordinator.d.ts.map +1 -1
- package/dist/services/orpar-memory/OrparMemoryCoordinator.js +93 -45
- package/dist/services/orpar-memory/OrparMemoryCoordinator.js.map +1 -1
- package/dist/services/orpar-memory/SurpriseOrparAdapter.d.ts +1 -0
- package/dist/services/orpar-memory/SurpriseOrparAdapter.d.ts.map +1 -1
- package/dist/services/orpar-memory/SurpriseOrparAdapter.js +8 -1
- package/dist/services/orpar-memory/SurpriseOrparAdapter.js.map +1 -1
- package/dist/types/ChannelContext.d.ts +2 -1
- package/dist/types/ChannelContext.d.ts.map +1 -1
- package/dist/types/EffectivenessTypes.d.ts +4 -1
- package/dist/types/EffectivenessTypes.d.ts.map +1 -1
- package/dist/types/TaskCompletionTypes.d.ts +7 -5
- package/dist/types/TaskCompletionTypes.d.ts.map +1 -1
- package/dist/types/TaskTypes.d.ts +8 -1
- package/dist/types/TaskTypes.d.ts.map +1 -1
- package/dist/utils/GlobMatcher.d.ts +37 -0
- package/dist/utils/GlobMatcher.d.ts.map +1 -0
- package/dist/utils/GlobMatcher.js +131 -0
- package/dist/utils/GlobMatcher.js.map +1 -0
- package/package.json +1 -1
- package/src/config/ModelContextLimits.ts +7 -1
- package/src/constants/CoreTools.ts +6 -5
- package/src/constants/DefaultPhaseProfiles.ts +29 -0
- package/src/constants/ReservedIdentities.ts +51 -0
- package/src/database/adapters/mongodb/MongoKnowledgeGraphRepository.ts +115 -36
- package/src/events/ClientEventBus.ts +117 -48
- package/src/events/EventBus.ts +32 -2
- package/src/events/EventBusBase.ts +132 -39
- package/src/events/EventNames.ts +43 -36
- package/src/events/PublicEvents.ts +8 -0
- package/src/events/ServerEventBus.ts +9 -128
- package/src/events/event-definitions/ControlLoopEvents.ts +12 -0
- package/src/events/event-definitions/SdkEvents.ts +58 -0
- package/src/events/event-definitions/TaskEvents.ts +2 -2
- package/src/index.ts +15 -0
- package/src/interfaces/AgentInterfaces.ts +5 -0
- package/src/interfaces/ChannelConfig.ts +2 -2
- package/src/interfaces/ConversationMessage.ts +5 -0
- package/src/interfaces/IMemoryPersistence.ts +55 -1
- package/src/interfaces/SocketServiceInterface.ts +3 -2
- package/src/interfaces/TaskInterfaces.ts +16 -1
- package/src/models/agent.ts +0 -6
- package/src/models/agentIdentityReservation.ts +77 -0
- package/src/models/channel.ts +2 -0
- package/src/models/channelKey.ts +10 -0
- package/src/models/memory.ts +18 -19
- package/src/models/memoryStrata.ts +9 -23
- package/src/models/plan.ts +3 -3
- package/src/models/taskEffectiveness.ts +9 -2
- package/src/models/user.ts +12 -0
- package/src/protocols/mcp/LlmTestEnvironmentGuard.ts +30 -0
- package/src/protocols/mcp/McpServerTypes.ts +9 -0
- package/src/protocols/mcp/providers/AnthropicMcpClient.ts +2 -0
- package/src/protocols/mcp/providers/AzureOpenAiMcpClient.ts +1 -0
- package/src/protocols/mcp/providers/BaseMcpClient.ts +13 -0
- package/src/protocols/mcp/providers/CustomMcpClient.ts +7 -0
- package/src/protocols/mcp/providers/GeminiMcpClient.ts +2 -0
- package/src/protocols/mcp/providers/OllamaMcpClient.ts +3 -1
- package/src/protocols/mcp/providers/OpenAiMcpClient.ts +2 -0
- package/src/protocols/mcp/providers/OpenRouterMcpClient.ts +3 -0
- package/src/protocols/mcp/providers/XaiMcpClient.ts +2 -0
- package/src/protocols/mcp/security/BrowserTargetGuard.ts +64 -0
- package/src/protocols/mcp/security/ExternalMcpRegistrationPolicy.ts +38 -0
- package/src/protocols/mcp/security/HttpTargetGuard.ts +77 -6
- package/src/protocols/mcp/security/McpSecurityGuard.ts +7 -5
- package/src/protocols/mcp/security/McpToolPolicy.ts +74 -0
- package/src/protocols/mcp/services/ExternalMcpServerManager.ts +146 -17
- package/src/protocols/mcp/services/ExternalServerConfigs.ts +26 -8
- package/src/protocols/mcp/tools/AnalyticsTools.ts +167 -641
- package/src/protocols/mcp/tools/CodeAnalysisTools.ts +44 -14
- package/src/protocols/mcp/tools/EffectivenessTools.ts +185 -45
- package/src/protocols/mcp/tools/GitTools.ts +15 -5
- package/src/protocols/mcp/tools/InfrastructureTools.ts +42 -90
- package/src/protocols/mcp/tools/JsonTools.ts +7 -4
- package/src/protocols/mcp/tools/KnowledgeGraphTools.ts +313 -164
- package/src/protocols/mcp/tools/MemorySearchTools.ts +158 -46
- package/src/protocols/mcp/tools/MemoryUtilityTools.ts +85 -232
- package/src/protocols/mcp/tools/PlanningTools.ts +137 -59
- package/src/protocols/mcp/tools/ProjectContextTools.ts +33 -12
- package/src/protocols/mcp/tools/SafetyTools.ts +49 -13
- package/src/protocols/mcp/tools/SearchProjectTools.ts +294 -153
- package/src/protocols/mcp/tools/TaskPlanningTools.ts +437 -514
- package/src/protocols/mcp/tools/TestTools.ts +41 -11
- package/src/protocols/mcp/tools/TypeScriptTools.ts +61 -12
- package/src/protocols/mcp/tools/UserInputTools.ts +15 -1
- package/src/protocols/mcp/tools/UserMemoryTools.ts +27 -62
- package/src/protocols/mcp/tools/shell/ShellExecuteHandler.ts +26 -84
- package/src/protocols/mcp/tools/shell/ShellSandbox.ts +13 -31
- package/src/repositories/interfaces/IKnowledgeGraphRepository.ts +45 -27
- package/src/schemas/EventPayloadSchema.ts +45 -1
- package/src/services/AgentPerformanceService.ts +85 -36
- package/src/services/AutoCorrectionService.ts +25 -6
- package/src/services/BackgroundTaskManager.ts +183 -76
- package/src/services/BrowserManager.ts +20 -16
- package/src/services/ChannelContextMemoryOperations.ts +169 -202
- package/src/services/ChannelContextMessageOperations.ts +112 -274
- package/src/services/MemoryService.ts +1053 -760
- package/src/services/PatternLearningService.ts +32 -7
- package/src/services/PerformanceOptimizationService.ts +26 -9
- package/src/services/PredictiveAnalyticsService.ts +23 -10
- package/src/services/ProactiveValidationService.ts +66 -40
- package/src/services/TaskEffectivenessService.ts +421 -206
- package/src/services/ToolExecutionInterceptor.ts +40 -9
- package/src/services/UserInputRequestManager.ts +51 -6
- package/src/services/UserMemoryService.ts +12 -3
- package/src/services/ValidationAnalyticsService.ts +36 -11
- package/src/services/ValidationCacheService.ts +30 -7
- package/src/services/ValidationMiddleware.ts +62 -14
- package/src/services/ValidationPerformanceService.ts +47 -25
- package/src/services/WebSearchService.ts +16 -4
- package/src/services/dag/TaskDagService.ts +20 -1
- package/src/services/kg/EntityQValueManager.ts +21 -10
- package/src/services/kg/GraphSurpriseCalculator.ts +0 -14
- package/src/services/kg/KnowledgeGraphService.ts +56 -48
- package/src/services/kg/OrparGraphIntegration.ts +11 -5
- package/src/services/orpar-memory/CycleConsolidationTrigger.ts +10 -1
- package/src/services/orpar-memory/OrparMemoryCoordinator.ts +142 -71
- package/src/services/orpar-memory/SurpriseOrparAdapter.ts +10 -1
- package/src/types/ChannelContext.ts +3 -1
- package/src/types/EffectivenessTypes.ts +6 -2
- package/src/types/TaskCompletionTypes.ts +9 -9
- package/src/types/TaskTypes.ts +12 -1
- package/src/utils/GlobMatcher.ts +157 -0
|
@@ -6,82 +6,176 @@
|
|
|
6
6
|
* You may obtain a copy of the License at
|
|
7
7
|
*
|
|
8
8
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
* @author Brad Anderson <BradA1878@pm.me>
|
|
17
|
-
* @repository https://github.com/BradA1878/model-exchange-framework
|
|
18
|
-
* @documentation https://mxf-dev.github.io/mxf/
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Task Planning Tools
|
|
23
|
-
*
|
|
24
|
-
* Enhanced task creation tools that integrate with planning and completion monitoring
|
|
25
9
|
*/
|
|
26
10
|
|
|
11
|
+
import type { Subscription } from 'rxjs';
|
|
27
12
|
import type { ChannelTask } from '../../../types/TaskTypes.js';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
13
|
+
import type { TaskCompletionConfig } from '../../../types/TaskCompletionTypes.js';
|
|
14
|
+
import {
|
|
15
|
+
McpToolDefinition,
|
|
16
|
+
McpToolHandlerContext,
|
|
17
|
+
McpToolHandlerResult,
|
|
18
|
+
McpToolResultContent
|
|
19
|
+
} from '../McpServerTypes.js';
|
|
20
|
+
import type { McpToolInput } from '../IMcpClient.js';
|
|
30
21
|
import { Logger } from '../../../utils/Logger.js';
|
|
31
22
|
import { EventBus } from '../../../events/EventBus.js';
|
|
32
23
|
import { Events } from '../../../events/EventNames.js';
|
|
33
24
|
import { TaskEvents } from '../../../events/event-definitions/TaskEvents.js';
|
|
34
25
|
import { createTaskEventPayload } from '../../../schemas/EventPayloadSchema.js';
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
37
|
-
import { firstValueFrom } from 'rxjs';
|
|
26
|
+
import PlanModel from '../../../models/plan.js';
|
|
27
|
+
import { Task } from '../../../models/task.js';
|
|
38
28
|
import { v4 as uuidv4 } from 'uuid';
|
|
39
29
|
|
|
40
30
|
const logger = new Logger('debug', 'TaskPlanningTools', 'server');
|
|
31
|
+
const planUpdateLocks = new Set<string>();
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
interface PlanningIdentity {
|
|
34
|
+
agentId: string;
|
|
35
|
+
channelId: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface CorrelatedTaskEventData {
|
|
39
|
+
requestId?: string;
|
|
40
|
+
taskId?: string;
|
|
41
|
+
task?: ChannelTask;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface CompletionPlanStepInput {
|
|
46
|
+
title: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
critical?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const requireIdentity = (context: McpToolHandlerContext): PlanningIdentity => {
|
|
52
|
+
if (typeof context.agentId !== 'string' || context.agentId.trim().length === 0 ||
|
|
53
|
+
typeof context.channelId !== 'string' || context.channelId.trim().length === 0) {
|
|
54
|
+
throw new Error('Authenticated agentId and channelId are required');
|
|
55
|
+
}
|
|
56
|
+
return { agentId: context.agentId.trim(), channelId: context.channelId.trim() };
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const readCorrelatedEvent = (payload: unknown): {
|
|
60
|
+
channelId?: string;
|
|
61
|
+
data: CorrelatedTaskEventData;
|
|
62
|
+
} | null => {
|
|
63
|
+
if (!payload || typeof payload !== 'object' || !('data' in payload)) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const candidate = payload as { channelId?: unknown; data?: unknown };
|
|
67
|
+
if (!candidate.data || typeof candidate.data !== 'object') {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
channelId: typeof candidate.channelId === 'string' ? candidate.channelId : undefined,
|
|
72
|
+
data: candidate.data as CorrelatedTaskEventData
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const awaitTaskEvent = (
|
|
77
|
+
requestId: string,
|
|
78
|
+
channelId: string,
|
|
79
|
+
successEvent: typeof TaskEvents.CREATED | typeof TaskEvents.PROGRESS_UPDATED,
|
|
80
|
+
emitRequest: () => void
|
|
81
|
+
): Promise<ChannelTask> => {
|
|
82
|
+
let successSubscription: Subscription | undefined;
|
|
83
|
+
let errorSubscription: Subscription | undefined;
|
|
84
|
+
const result = new Promise<ChannelTask>((resolve, reject) => {
|
|
85
|
+
const cleanup = (): void => {
|
|
86
|
+
successSubscription?.unsubscribe();
|
|
87
|
+
errorSubscription?.unsubscribe();
|
|
88
|
+
};
|
|
89
|
+
successSubscription = EventBus.server.on(successEvent, payload => {
|
|
90
|
+
const event = readCorrelatedEvent(payload);
|
|
91
|
+
if (event?.channelId !== channelId || event.data.requestId !== requestId) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!event.data.task?.id) {
|
|
95
|
+
cleanup();
|
|
96
|
+
reject(new Error(`${successEvent} ${requestId} returned no persisted task`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
cleanup();
|
|
100
|
+
resolve(event.data.task);
|
|
101
|
+
});
|
|
102
|
+
errorSubscription = EventBus.server.on(TaskEvents.ERROR, payload => {
|
|
103
|
+
const event = readCorrelatedEvent(payload);
|
|
104
|
+
if (event?.channelId !== channelId || event.data.requestId !== requestId) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
cleanup();
|
|
108
|
+
reject(new Error(event.data.error ?? `Task operation ${requestId} failed`));
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
emitRequest();
|
|
113
|
+
} catch (error) {
|
|
114
|
+
successSubscription?.unsubscribe();
|
|
115
|
+
errorSubscription?.unsubscribe();
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const requireString = (value: unknown, field: string): string => {
|
|
122
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
123
|
+
throw new Error(`${field} is required`);
|
|
124
|
+
}
|
|
125
|
+
return value.trim();
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const requireAssignees = (value: unknown, defaultAgentId: string): string[] => {
|
|
129
|
+
if (value === undefined) {
|
|
130
|
+
return [defaultAgentId];
|
|
131
|
+
}
|
|
132
|
+
if (!Array.isArray(value) || value.length === 0 ||
|
|
133
|
+
value.some(agentId => typeof agentId !== 'string' || agentId.trim().length === 0)) {
|
|
134
|
+
throw new Error('assignTo must be a non-empty array of agent ids');
|
|
135
|
+
}
|
|
136
|
+
return Array.from(new Set(value.map(agentId => (agentId as string).trim())));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const emitCreateRequest = (
|
|
140
|
+
identity: PlanningIdentity,
|
|
141
|
+
requestId: string,
|
|
142
|
+
task: Partial<ChannelTask> & Pick<ChannelTask, 'title'>
|
|
143
|
+
): Promise<ChannelTask> => awaitTaskEvent(
|
|
144
|
+
requestId,
|
|
145
|
+
identity.channelId,
|
|
146
|
+
TaskEvents.CREATED,
|
|
147
|
+
() => EventBus.server.emit(
|
|
148
|
+
TaskEvents.CREATE_REQUEST,
|
|
149
|
+
createTaskEventPayload(TaskEvents.CREATE_REQUEST, identity.agentId, identity.channelId, {
|
|
150
|
+
taskId: requestId,
|
|
151
|
+
requestId,
|
|
152
|
+
fromAgentId: identity.agentId,
|
|
153
|
+
toAgentId: task.assignedAgentIds?.[0] ?? identity.agentId,
|
|
154
|
+
task
|
|
155
|
+
})
|
|
156
|
+
)
|
|
157
|
+
);
|
|
44
158
|
|
|
45
|
-
/**
|
|
46
|
-
* Create a task with a completion plan
|
|
47
|
-
*/
|
|
48
159
|
export const task_create_with_plan: McpToolDefinition = {
|
|
49
160
|
name: 'task_create_with_plan',
|
|
50
|
-
description: '
|
|
161
|
+
description: 'Persist a task and completion plan, then monitor the task until its configured plan criteria are met.',
|
|
51
162
|
inputSchema: {
|
|
52
163
|
type: 'object',
|
|
53
164
|
properties: {
|
|
54
|
-
title: {
|
|
55
|
-
|
|
56
|
-
description: 'Title of the task'
|
|
57
|
-
},
|
|
58
|
-
description: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
description: 'Detailed description of what needs to be done'
|
|
61
|
-
},
|
|
165
|
+
title: { type: 'string', description: 'Title of the task' },
|
|
166
|
+
description: { type: 'string', description: 'Detailed task description' },
|
|
62
167
|
completionPlan: {
|
|
63
168
|
type: 'object',
|
|
64
|
-
description: 'Plan-based completion criteria',
|
|
65
169
|
properties: {
|
|
66
170
|
steps: {
|
|
67
171
|
type: 'array',
|
|
68
|
-
|
|
172
|
+
minItems: 1,
|
|
69
173
|
items: {
|
|
70
174
|
type: 'object',
|
|
71
175
|
properties: {
|
|
72
|
-
title: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
description: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
description: 'Step description'
|
|
79
|
-
},
|
|
80
|
-
critical: {
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
description: 'Is this step critical for completion?',
|
|
83
|
-
default: false
|
|
84
|
-
}
|
|
176
|
+
title: { type: 'string' },
|
|
177
|
+
description: { type: 'string' },
|
|
178
|
+
critical: { type: 'boolean', default: false }
|
|
85
179
|
},
|
|
86
180
|
required: ['title']
|
|
87
181
|
}
|
|
@@ -89,583 +183,412 @@ export const task_create_with_plan: McpToolDefinition = {
|
|
|
89
183
|
completionType: {
|
|
90
184
|
type: 'string',
|
|
91
185
|
enum: ['all_steps', 'critical_steps', 'percentage'],
|
|
92
|
-
description: 'How to determine completion',
|
|
93
186
|
default: 'all_steps'
|
|
94
187
|
},
|
|
95
|
-
percentage: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
minimum: 0,
|
|
99
|
-
maximum: 100
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
assignTo: {
|
|
104
|
-
type: 'array',
|
|
105
|
-
items: { type: 'string' },
|
|
106
|
-
description: 'Agent IDs to assign this task to. REQUIRED for delegation — without this, the task stays assigned to the calling agent and nobody else picks it up. Example: ["mxf-planner"]'
|
|
107
|
-
},
|
|
108
|
-
priority: {
|
|
109
|
-
type: 'string',
|
|
110
|
-
enum: ['low', 'medium', 'high'],
|
|
111
|
-
default: 'medium'
|
|
188
|
+
percentage: { type: 'number', minimum: 0, maximum: 100 }
|
|
189
|
+
},
|
|
190
|
+
required: ['steps']
|
|
112
191
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
192
|
+
assignTo: { type: 'array', minItems: 1, items: { type: 'string' } },
|
|
193
|
+
priority: { type: 'string', enum: ['low', 'medium', 'high'], default: 'medium' },
|
|
194
|
+
absoluteTimeout: { type: 'number', minimum: 1 }
|
|
117
195
|
},
|
|
118
196
|
required: ['title', 'description', 'completionPlan']
|
|
119
197
|
},
|
|
120
198
|
enabled: true,
|
|
121
199
|
handler: async (input: McpToolInput, context: McpToolHandlerContext): Promise<McpToolHandlerResult> => {
|
|
200
|
+
const startedAt = Date.now();
|
|
201
|
+
const identity = requireIdentity(context);
|
|
202
|
+
const title = requireString(input.title, 'title');
|
|
203
|
+
const description = requireString(input.description, 'description');
|
|
204
|
+
const completionPlan = input.completionPlan as {
|
|
205
|
+
steps?: CompletionPlanStepInput[];
|
|
206
|
+
completionType?: 'all_steps' | 'critical_steps' | 'percentage';
|
|
207
|
+
percentage?: number;
|
|
208
|
+
};
|
|
209
|
+
if (!completionPlan || !Array.isArray(completionPlan.steps) || completionPlan.steps.length === 0) {
|
|
210
|
+
throw new Error('completionPlan.steps must contain at least one step');
|
|
211
|
+
}
|
|
212
|
+
for (const step of completionPlan.steps) {
|
|
213
|
+
requireString(step.title, 'completionPlan step title');
|
|
214
|
+
}
|
|
215
|
+
const completionType = completionPlan.completionType ?? 'all_steps';
|
|
216
|
+
if (completionType === 'percentage' &&
|
|
217
|
+
(typeof completionPlan.percentage !== 'number' ||
|
|
218
|
+
completionPlan.percentage < 0 || completionPlan.percentage > 100)) {
|
|
219
|
+
throw new Error('percentage must be between 0 and 100 for percentage completion');
|
|
220
|
+
}
|
|
221
|
+
if (completionType === 'critical_steps' && !completionPlan.steps.some(step => step.critical === true)) {
|
|
222
|
+
throw new Error('critical_steps completion requires at least one critical step');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const planId = uuidv4();
|
|
226
|
+
const planDoc = new PlanModel({
|
|
227
|
+
planId,
|
|
228
|
+
title: `${title} - Completion Plan`,
|
|
229
|
+
createdBy: identity.agentId,
|
|
230
|
+
channelId: identity.channelId,
|
|
231
|
+
items: completionPlan.steps.map((step, index) => ({
|
|
232
|
+
id: `item-${index + 1}`,
|
|
233
|
+
title: step.title.trim(),
|
|
234
|
+
description: step.description,
|
|
235
|
+
status: 'pending',
|
|
236
|
+
priority: step.critical ? 'high' : 'medium'
|
|
237
|
+
})),
|
|
238
|
+
metadata: { type: 'task_completion_plan', taskTitle: title }
|
|
239
|
+
});
|
|
240
|
+
await planDoc.save();
|
|
241
|
+
|
|
242
|
+
const completionConfig: TaskCompletionConfig = {
|
|
243
|
+
primary: {
|
|
244
|
+
type: 'plan-based',
|
|
245
|
+
planId,
|
|
246
|
+
completionType,
|
|
247
|
+
percentage: completionPlan.percentage
|
|
248
|
+
},
|
|
249
|
+
absoluteTimeout: typeof input.absoluteTimeout === 'number' ? input.absoluteTimeout : undefined,
|
|
250
|
+
timeoutBehavior: typeof input.absoluteTimeout === 'number' ? 'fail' : undefined,
|
|
251
|
+
allowManualCompletion: true
|
|
252
|
+
};
|
|
253
|
+
const assignees = requireAssignees(input.assignTo, identity.agentId);
|
|
254
|
+
const requestId = uuidv4();
|
|
255
|
+
|
|
122
256
|
try {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const memoryService = MemoryService.getInstance();
|
|
145
|
-
const channelMemory = await firstValueFrom(memoryService.getChannelMemory(context.channelId!));
|
|
146
|
-
const currentSharedState = channelMemory.sharedState || {};
|
|
147
|
-
await firstValueFrom(memoryService.updateChannelMemory(context.channelId!, {
|
|
148
|
-
sharedState: {
|
|
149
|
-
...currentSharedState,
|
|
150
|
-
[`plan:${planId}`]: {
|
|
151
|
-
...plan,
|
|
152
|
-
metadata: {
|
|
153
|
-
type: 'task_completion_plan',
|
|
154
|
-
taskTitle: input.title
|
|
155
|
-
}
|
|
257
|
+
const task = await emitCreateRequest(identity, requestId, {
|
|
258
|
+
channelId: identity.channelId,
|
|
259
|
+
title,
|
|
260
|
+
description,
|
|
261
|
+
assignmentScope: assignees.length > 1 ? 'multiple' : 'single',
|
|
262
|
+
assignmentStrategy: 'manual',
|
|
263
|
+
assignedAgentIds: assignees,
|
|
264
|
+
coordinationMode: 'collaborative',
|
|
265
|
+
priority: input.priority ?? 'medium',
|
|
266
|
+
metadata: { completionConfig, planId, enableMonitoring: true }
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
content: {
|
|
270
|
+
type: 'application/json',
|
|
271
|
+
data: {
|
|
272
|
+
success: true,
|
|
273
|
+
taskId: task.id,
|
|
274
|
+
planId,
|
|
275
|
+
totalSteps: planDoc.items.length,
|
|
276
|
+
criticalSteps: planDoc.items.filter(item => item.priority === 'high').length,
|
|
277
|
+
completionType
|
|
156
278
|
}
|
|
157
|
-
}
|
|
158
|
-
}));
|
|
159
|
-
|
|
160
|
-
// Also store in planning tool's active plans for compatibility
|
|
161
|
-
const activePlans = (global as any).activePlans || new Map();
|
|
162
|
-
activePlans.set(planId, plan);
|
|
163
|
-
(global as any).activePlans = activePlans;
|
|
164
|
-
|
|
165
|
-
// Create completion config
|
|
166
|
-
const completionConfig: TaskCompletionConfig = {
|
|
167
|
-
primary: {
|
|
168
|
-
type: 'plan-based',
|
|
169
|
-
planId: planId,
|
|
170
|
-
completionType: input.completionPlan.completionType || 'all_steps',
|
|
171
|
-
percentage: input.completionPlan.percentage
|
|
172
279
|
},
|
|
173
|
-
|
|
174
|
-
timeoutBehavior: 'complete',
|
|
175
|
-
allowManualCompletion: true
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
// Create the task with monitoring config
|
|
179
|
-
// If no assignTo specified and the caller is the orchestrator (Concierge),
|
|
180
|
-
// default to mxf-planner so the task actually gets picked up by the right agent
|
|
181
|
-
const callerIsOrchestrator = context.agentId?.includes('concierge') ||
|
|
182
|
-
(context as any).metadata?.role === 'orchestrator';
|
|
183
|
-
const defaultAssignee = callerIsOrchestrator ? 'mxf-planner' : (context.agentId || 'system');
|
|
184
|
-
const assignedAgentIds = input.assignTo || [defaultAssignee];
|
|
185
|
-
|
|
186
|
-
const taskId = uuidv4();
|
|
187
|
-
const taskPayload = createTaskEventPayload(
|
|
188
|
-
TaskEvents.CREATE_REQUEST,
|
|
189
|
-
context.agentId || 'system',
|
|
190
|
-
context.channelId || 'default',
|
|
191
|
-
{
|
|
192
|
-
taskId: taskId,
|
|
193
|
-
fromAgentId: context.agentId || 'system',
|
|
194
|
-
toAgentId: assignedAgentIds[0],
|
|
195
|
-
task: {
|
|
196
|
-
channelId: context.channelId || 'default',
|
|
197
|
-
title: input.title,
|
|
198
|
-
description: `${input.description}\n\nThis task will automatically complete when the plan steps are finished.`,
|
|
199
|
-
assignmentScope: assignedAgentIds.length > 1 ? 'multiple' : 'single',
|
|
200
|
-
assignmentStrategy: 'manual',
|
|
201
|
-
assignedAgentIds,
|
|
202
|
-
coordinationMode: 'collaborative',
|
|
203
|
-
priority: input.priority || 'medium',
|
|
204
|
-
metadata: {
|
|
205
|
-
completionConfig: completionConfig,
|
|
206
|
-
planId: planId,
|
|
207
|
-
enableMonitoring: true
|
|
208
|
-
}
|
|
209
|
-
} satisfies Partial<ChannelTask> & Pick<ChannelTask, 'title'>
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
EventBus.server.emit(TaskEvents.CREATE_REQUEST, taskPayload);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const content: McpToolResultContent = {
|
|
217
|
-
type: 'text',
|
|
218
|
-
data: `Task created successfully with automatic completion monitoring.
|
|
219
|
-
|
|
220
|
-
Task ID: ${taskId}
|
|
221
|
-
Plan ID: ${planId}
|
|
222
|
-
Total Steps: ${plan.items.length}
|
|
223
|
-
Critical Steps: ${plan.items.filter((s: any) => s.critical).length}
|
|
224
|
-
Completion Type: ${input.completionPlan.completionType || 'all_steps'}
|
|
225
|
-
|
|
226
|
-
The task will automatically complete when the plan criteria are met.`
|
|
280
|
+
metadata: { processingTime: Date.now() - startedAt, taskId: task.id, planId }
|
|
227
281
|
};
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
content,
|
|
231
|
-
metadata: {
|
|
232
|
-
processingTime: Date.now() - startTime,
|
|
233
|
-
taskId: taskId,
|
|
234
|
-
planId: planId
|
|
235
|
-
}
|
|
236
|
-
} as McpToolHandlerResult;
|
|
237
|
-
|
|
238
282
|
} catch (error) {
|
|
239
|
-
|
|
283
|
+
try {
|
|
284
|
+
await PlanModel.deleteOne({ planId, channelId: identity.channelId });
|
|
285
|
+
} catch (cleanupError) {
|
|
286
|
+
logger.error(`Failed to remove plan ${planId} after task creation failure: ${String(cleanupError)}`);
|
|
287
|
+
}
|
|
288
|
+
logger.error(`Failed to create task with plan: ${String(error)}`);
|
|
240
289
|
throw error;
|
|
241
290
|
}
|
|
242
291
|
}
|
|
243
292
|
};
|
|
244
293
|
|
|
245
|
-
/**
|
|
246
|
-
* Create a task with custom completion criteria
|
|
247
|
-
*/
|
|
248
294
|
export const task_create_custom_completion: McpToolDefinition = {
|
|
249
295
|
name: 'task_create_custom_completion',
|
|
250
|
-
description: '
|
|
296
|
+
description: 'Persist a task with a supported SystemLLM, output, or time-based completion monitor.',
|
|
251
297
|
inputSchema: {
|
|
252
298
|
type: 'object',
|
|
253
299
|
properties: {
|
|
254
|
-
title: {
|
|
255
|
-
|
|
256
|
-
description: 'Title of the task'
|
|
257
|
-
},
|
|
258
|
-
description: {
|
|
259
|
-
type: 'string',
|
|
260
|
-
description: 'Detailed description'
|
|
261
|
-
},
|
|
300
|
+
title: { type: 'string' },
|
|
301
|
+
description: { type: 'string' },
|
|
262
302
|
completionStrategy: {
|
|
263
303
|
type: 'string',
|
|
264
|
-
enum: ['systemllm-eval', 'output-based', 'time-based'
|
|
265
|
-
description: 'Type of completion strategy'
|
|
304
|
+
enum: ['systemllm-eval', 'output-based', 'time-based']
|
|
266
305
|
},
|
|
267
306
|
completionCriteria: {
|
|
268
307
|
type: 'object',
|
|
269
|
-
description: 'Strategy-specific criteria',
|
|
270
308
|
properties: {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
description: 'Objectives that must be met (for systemllm-eval)'
|
|
276
|
-
},
|
|
277
|
-
evaluationInterval: {
|
|
278
|
-
type: 'number',
|
|
279
|
-
description: 'How often to evaluate in ms (for systemllm-eval)',
|
|
280
|
-
default: 30000
|
|
281
|
-
},
|
|
282
|
-
confidenceThreshold: {
|
|
309
|
+
objectives: { type: 'array', minItems: 1, items: { type: 'string' } },
|
|
310
|
+
evaluationInterval: { type: 'number', minimum: 1, default: 30000 },
|
|
311
|
+
confidenceThreshold: { type: 'number', minimum: 0, maximum: 1, default: 0.8 },
|
|
312
|
+
maxEvaluations: {
|
|
283
313
|
type: 'number',
|
|
284
|
-
|
|
285
|
-
|
|
314
|
+
minimum: 1,
|
|
315
|
+
maximum: 100,
|
|
316
|
+
description: 'Maximum SystemLLM evaluations before the task fails'
|
|
286
317
|
},
|
|
287
|
-
// For output-based
|
|
288
318
|
requiredOutputs: {
|
|
289
319
|
type: 'array',
|
|
290
|
-
|
|
320
|
+
minItems: 1,
|
|
291
321
|
items: {
|
|
292
322
|
type: 'object',
|
|
293
323
|
properties: {
|
|
294
|
-
type: {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
type: 'string',
|
|
300
|
-
description: 'Regex pattern to match'
|
|
301
|
-
},
|
|
302
|
-
count: {
|
|
303
|
-
type: 'number',
|
|
304
|
-
description: 'Required count',
|
|
305
|
-
default: 1
|
|
306
|
-
}
|
|
307
|
-
}
|
|
324
|
+
type: { type: 'string', enum: ['message', 'tool_call'] },
|
|
325
|
+
pattern: { type: 'string', maxLength: 256 },
|
|
326
|
+
count: { type: 'number', minimum: 1, default: 1 }
|
|
327
|
+
},
|
|
328
|
+
required: ['type']
|
|
308
329
|
}
|
|
309
330
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
description: 'Minimum duration in ms (for time-based)'
|
|
314
|
-
},
|
|
315
|
-
maximumDuration: {
|
|
316
|
-
type: 'number',
|
|
317
|
-
description: 'Maximum duration in ms (for time-based)'
|
|
318
|
-
},
|
|
319
|
-
requireActivity: {
|
|
320
|
-
type: 'boolean',
|
|
321
|
-
description: 'Require some activity (for time-based)',
|
|
322
|
-
default: true
|
|
323
|
-
},
|
|
324
|
-
// For event-based
|
|
325
|
-
eventName: {
|
|
326
|
-
type: 'string',
|
|
327
|
-
description: 'Event name to watch for (for event-based)'
|
|
328
|
-
}
|
|
331
|
+
minimumDuration: { type: 'number', minimum: 0 },
|
|
332
|
+
maximumDuration: { type: 'number', minimum: 1 },
|
|
333
|
+
requireActivity: { type: 'boolean', default: true }
|
|
329
334
|
}
|
|
330
335
|
},
|
|
331
|
-
assignTo: {
|
|
332
|
-
type: 'array',
|
|
333
|
-
items: { type: 'string' },
|
|
334
|
-
description: 'Agent IDs to assign to'
|
|
335
|
-
}
|
|
336
|
+
assignTo: { type: 'array', minItems: 1, items: { type: 'string' } }
|
|
336
337
|
},
|
|
337
338
|
required: ['title', 'description', 'completionStrategy', 'completionCriteria']
|
|
338
339
|
},
|
|
339
340
|
enabled: true,
|
|
340
341
|
handler: async (input: McpToolInput, context: McpToolHandlerContext): Promise<McpToolHandlerResult> => {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
break;
|
|
356
|
-
|
|
357
|
-
case 'output-based':
|
|
358
|
-
primaryCriteria = {
|
|
359
|
-
type: 'output-based',
|
|
360
|
-
requiredOutputs: input.completionCriteria.requiredOutputs || []
|
|
361
|
-
};
|
|
362
|
-
break;
|
|
363
|
-
|
|
364
|
-
case 'time-based':
|
|
365
|
-
primaryCriteria = {
|
|
366
|
-
type: 'time-based',
|
|
367
|
-
minimumDuration: input.completionCriteria.minimumDuration,
|
|
368
|
-
maximumDuration: input.completionCriteria.maximumDuration || 300000, // 5 min default
|
|
369
|
-
requireActivity: input.completionCriteria.requireActivity !== false
|
|
370
|
-
};
|
|
371
|
-
break;
|
|
372
|
-
|
|
373
|
-
case 'event-based':
|
|
374
|
-
primaryCriteria = {
|
|
375
|
-
type: 'event-based',
|
|
376
|
-
eventName: input.completionCriteria.eventName
|
|
377
|
-
};
|
|
378
|
-
break;
|
|
342
|
+
const startedAt = Date.now();
|
|
343
|
+
const identity = requireIdentity(context);
|
|
344
|
+
const title = requireString(input.title, 'title');
|
|
345
|
+
const description = requireString(input.description, 'description');
|
|
346
|
+
const criteria = input.completionCriteria as Record<string, unknown>;
|
|
347
|
+
if (!criteria || typeof criteria !== 'object') {
|
|
348
|
+
throw new Error('completionCriteria is required');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
let primary: TaskCompletionConfig['primary'];
|
|
352
|
+
if (input.completionStrategy === 'systemllm-eval') {
|
|
353
|
+
if (!Array.isArray(criteria.objectives) || criteria.objectives.length === 0 ||
|
|
354
|
+
criteria.objectives.some(objective => typeof objective !== 'string' || objective.trim().length === 0)) {
|
|
355
|
+
throw new Error('systemllm-eval requires at least one objective');
|
|
379
356
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
357
|
+
if (!Number.isInteger(criteria.maxEvaluations) ||
|
|
358
|
+
(criteria.maxEvaluations as number) < 1 ||
|
|
359
|
+
(criteria.maxEvaluations as number) > 100) {
|
|
360
|
+
throw new Error('systemllm-eval requires maxEvaluations between 1 and 100');
|
|
361
|
+
}
|
|
362
|
+
primary = {
|
|
363
|
+
type: 'systemllm-eval',
|
|
364
|
+
objectives: criteria.objectives as string[],
|
|
365
|
+
evaluationInterval: typeof criteria.evaluationInterval === 'number'
|
|
366
|
+
? criteria.evaluationInterval
|
|
367
|
+
: 30_000,
|
|
368
|
+
confidenceThreshold: typeof criteria.confidenceThreshold === 'number'
|
|
369
|
+
? criteria.confidenceThreshold
|
|
370
|
+
: 0.8,
|
|
371
|
+
maxEvaluations: criteria.maxEvaluations as number
|
|
384
372
|
};
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
task: {
|
|
397
|
-
channelId: context.channelId || 'default',
|
|
398
|
-
title: input.title,
|
|
399
|
-
description: input.description,
|
|
400
|
-
assignmentScope: input.assignTo && input.assignTo.length > 1 ? 'multiple' : 'single',
|
|
401
|
-
assignmentStrategy: 'manual',
|
|
402
|
-
assignedAgentIds: input.assignTo || [context.agentId || 'system'],
|
|
403
|
-
coordinationMode: 'collaborative',
|
|
404
|
-
metadata: {
|
|
405
|
-
completionConfig: completionConfig,
|
|
406
|
-
enableMonitoring: true
|
|
407
|
-
}
|
|
408
|
-
} satisfies Partial<ChannelTask> & Pick<ChannelTask, 'title'>
|
|
409
|
-
}
|
|
410
|
-
);
|
|
411
|
-
|
|
412
|
-
EventBus.server.emit(TaskEvents.CREATE_REQUEST, taskPayload);
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const content: McpToolResultContent = {
|
|
416
|
-
type: 'text',
|
|
417
|
-
data: `Task created with ${input.completionStrategy} completion monitoring.
|
|
418
|
-
|
|
419
|
-
Task ID: ${taskId}
|
|
420
|
-
Strategy: ${input.completionStrategy}
|
|
421
|
-
${input.completionStrategy === 'systemllm-eval' ? `Objectives: ${input.completionCriteria.objectives?.length || 0}` : ''}
|
|
422
|
-
${input.completionStrategy === 'time-based' ? `Duration: ${input.completionCriteria.minimumDuration || 0}-${input.completionCriteria.maximumDuration}ms` : ''}
|
|
423
|
-
|
|
424
|
-
The task will be monitored and automatically completed when criteria are met.`
|
|
373
|
+
} else if (input.completionStrategy === 'output-based') {
|
|
374
|
+
if (!Array.isArray(criteria.requiredOutputs) || criteria.requiredOutputs.length === 0) {
|
|
375
|
+
throw new Error('output-based completion requires at least one output');
|
|
376
|
+
}
|
|
377
|
+
primary = {
|
|
378
|
+
type: 'output-based',
|
|
379
|
+
requiredOutputs: criteria.requiredOutputs as Array<{
|
|
380
|
+
type: 'message' | 'tool_call';
|
|
381
|
+
pattern?: string;
|
|
382
|
+
count?: number;
|
|
383
|
+
}>
|
|
425
384
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
385
|
+
} else if (input.completionStrategy === 'time-based') {
|
|
386
|
+
if (typeof criteria.maximumDuration !== 'number' || criteria.maximumDuration <= 0) {
|
|
387
|
+
throw new Error('time-based completion requires a positive maximumDuration');
|
|
388
|
+
}
|
|
389
|
+
primary = {
|
|
390
|
+
type: 'time-based',
|
|
391
|
+
minimumDuration: typeof criteria.minimumDuration === 'number'
|
|
392
|
+
? criteria.minimumDuration
|
|
393
|
+
: undefined,
|
|
394
|
+
maximumDuration: criteria.maximumDuration,
|
|
395
|
+
requireActivity: criteria.requireActivity !== false
|
|
396
|
+
};
|
|
397
|
+
} else {
|
|
398
|
+
throw new Error(`Unsupported completion strategy: ${String(input.completionStrategy)}`);
|
|
438
399
|
}
|
|
400
|
+
|
|
401
|
+
const assignees = requireAssignees(input.assignTo, identity.agentId);
|
|
402
|
+
const requestId = uuidv4();
|
|
403
|
+
const task = await emitCreateRequest(identity, requestId, {
|
|
404
|
+
channelId: identity.channelId,
|
|
405
|
+
title,
|
|
406
|
+
description,
|
|
407
|
+
assignmentScope: assignees.length > 1 ? 'multiple' : 'single',
|
|
408
|
+
assignmentStrategy: 'manual',
|
|
409
|
+
assignedAgentIds: assignees,
|
|
410
|
+
coordinationMode: 'collaborative',
|
|
411
|
+
priority: 'medium',
|
|
412
|
+
metadata: {
|
|
413
|
+
completionConfig: { primary, allowManualCompletion: true } satisfies TaskCompletionConfig,
|
|
414
|
+
enableMonitoring: true
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
return {
|
|
418
|
+
content: {
|
|
419
|
+
type: 'application/json',
|
|
420
|
+
data: {
|
|
421
|
+
success: true,
|
|
422
|
+
taskId: task.id,
|
|
423
|
+
strategy: primary.type,
|
|
424
|
+
monitoringConfigured: true
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
metadata: { processingTime: Date.now() - startedAt, taskId: task.id }
|
|
428
|
+
};
|
|
439
429
|
}
|
|
440
430
|
};
|
|
441
431
|
|
|
442
|
-
/**
|
|
443
|
-
* Link an existing task to a plan
|
|
444
|
-
*/
|
|
445
432
|
export const task_link_to_plan: McpToolDefinition = {
|
|
446
433
|
name: 'task_link_to_plan',
|
|
447
|
-
|
|
448
|
-
// metadata. It does NOT itself start the completion monitor — the monitor is
|
|
449
|
-
// started by TaskService when a task is created with this metadata. The old
|
|
450
|
-
// description promised "the task will now automatically complete when plan
|
|
451
|
-
// criteria are met", which was untrue twice over: the event it emitted
|
|
452
|
-
// ('task:update_metadata') had no listeners anywhere, so not even the metadata
|
|
453
|
-
// was written.
|
|
454
|
-
description:
|
|
455
|
-
'Record a plan-based completion config on an existing task: which plan it is ' +
|
|
456
|
-
'linked to and what counts as done (all steps, critical steps, or a percentage). ' +
|
|
457
|
-
'Writing the config does not by itself start the completion monitor — check ' +
|
|
458
|
-
'task_monitoring_status to see whether the task is actually being monitored.',
|
|
434
|
+
description: 'Persist a plan-based completion config on an existing same-channel task and start monitoring it.',
|
|
459
435
|
inputSchema: {
|
|
460
436
|
type: 'object',
|
|
461
437
|
properties: {
|
|
462
|
-
taskId: {
|
|
463
|
-
|
|
464
|
-
description: 'ID of the existing task'
|
|
465
|
-
},
|
|
466
|
-
planId: {
|
|
467
|
-
type: 'string',
|
|
468
|
-
description: 'ID of the plan to link to'
|
|
469
|
-
},
|
|
438
|
+
taskId: { type: 'string' },
|
|
439
|
+
planId: { type: 'string' },
|
|
470
440
|
completionType: {
|
|
471
441
|
type: 'string',
|
|
472
442
|
enum: ['all_steps', 'critical_steps', 'percentage'],
|
|
473
443
|
default: 'all_steps'
|
|
474
444
|
},
|
|
475
|
-
percentage: {
|
|
476
|
-
type: 'number',
|
|
477
|
-
description: 'Required percentage (if using percentage type)',
|
|
478
|
-
minimum: 0,
|
|
479
|
-
maximum: 100
|
|
480
|
-
}
|
|
445
|
+
percentage: { type: 'number', minimum: 0, maximum: 100 }
|
|
481
446
|
},
|
|
482
447
|
required: ['taskId', 'planId']
|
|
483
448
|
},
|
|
484
449
|
enabled: true,
|
|
485
450
|
handler: async (input: McpToolInput, context: McpToolHandlerContext): Promise<McpToolHandlerResult> => {
|
|
451
|
+
const startedAt = Date.now();
|
|
452
|
+
const identity = requireIdentity(context);
|
|
453
|
+
const taskId = requireString(input.taskId, 'taskId');
|
|
454
|
+
const planId = requireString(input.planId, 'planId');
|
|
455
|
+
const lockKey = `${identity.channelId}\0${planId}`;
|
|
456
|
+
if (planUpdateLocks.has(lockKey)) {
|
|
457
|
+
throw new Error(`Plan ${planId} is already being linked in this channel`);
|
|
458
|
+
}
|
|
459
|
+
planUpdateLocks.add(lockKey);
|
|
486
460
|
try {
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
461
|
+
const completionType = input.completionType ?? 'all_steps';
|
|
462
|
+
if (completionType === 'percentage' && typeof input.percentage !== 'number') {
|
|
463
|
+
throw new Error('percentage is required for percentage completion');
|
|
464
|
+
}
|
|
465
|
+
const plan = await PlanModel.findOne({ planId, channelId: identity.channelId });
|
|
466
|
+
if (!plan) {
|
|
467
|
+
throw new Error(`Plan ${planId} not found in channel ${identity.channelId}`);
|
|
468
|
+
}
|
|
469
|
+
if (completionType === 'critical_steps' && !plan.items.some(item => item.priority === 'high')) {
|
|
470
|
+
throw new Error(`Plan ${planId} contains no critical steps`);
|
|
471
|
+
}
|
|
472
|
+
const task = await Task.findOne({ _id: taskId, channelId: identity.channelId });
|
|
473
|
+
if (!task) {
|
|
474
|
+
throw new Error(`Task ${taskId} not found in channel ${identity.channelId}`);
|
|
496
475
|
}
|
|
497
|
-
|
|
498
|
-
// Acquire lock
|
|
499
|
-
planUpdateLocks.set(input.planId, true);
|
|
500
|
-
|
|
501
|
-
try {
|
|
502
|
-
const completionType = input.completionType || 'all_steps';
|
|
503
|
-
|
|
504
|
-
// 'percentage' completion needs a percentage. Without one the config
|
|
505
|
-
// is meaningless and the monitor could never decide the task is done.
|
|
506
|
-
if (completionType === 'percentage' && typeof input.percentage !== 'number') {
|
|
507
|
-
throw new Error(
|
|
508
|
-
'percentage is required when completionType is "percentage".'
|
|
509
|
-
);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const completionConfig: TaskCompletionConfig = {
|
|
513
|
-
primary: {
|
|
514
|
-
type: 'plan-based',
|
|
515
|
-
planId: input.planId,
|
|
516
|
-
completionType,
|
|
517
|
-
percentage: input.percentage
|
|
518
|
-
},
|
|
519
|
-
allowManualCompletion: true
|
|
520
|
-
} as TaskCompletionConfig;
|
|
521
476
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
477
|
+
const completionConfig: TaskCompletionConfig = {
|
|
478
|
+
primary: {
|
|
479
|
+
type: 'plan-based',
|
|
480
|
+
planId,
|
|
481
|
+
completionType,
|
|
482
|
+
percentage: typeof input.percentage === 'number' ? input.percentage : undefined
|
|
483
|
+
},
|
|
484
|
+
allowManualCompletion: true
|
|
485
|
+
};
|
|
486
|
+
const requestId = uuidv4();
|
|
487
|
+
const updatedTask = await awaitTaskEvent(
|
|
488
|
+
requestId,
|
|
489
|
+
identity.channelId,
|
|
490
|
+
TaskEvents.PROGRESS_UPDATED,
|
|
491
|
+
() => EventBus.server.emit(
|
|
534
492
|
Events.Task.UPDATE_REQUEST,
|
|
535
493
|
createTaskEventPayload(
|
|
536
494
|
Events.Task.UPDATE_REQUEST,
|
|
537
|
-
|
|
538
|
-
|
|
495
|
+
identity.agentId,
|
|
496
|
+
identity.channelId,
|
|
539
497
|
{
|
|
540
|
-
taskId
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
498
|
+
taskId,
|
|
499
|
+
requestId,
|
|
500
|
+
fromAgentId: identity.agentId,
|
|
501
|
+
toAgentId: task.assignedAgentId ?? identity.agentId,
|
|
502
|
+
task: {
|
|
503
|
+
taskId,
|
|
504
|
+
requestId,
|
|
505
|
+
metadata: {
|
|
506
|
+
...(task.metadata ?? {}),
|
|
507
|
+
completionConfig,
|
|
508
|
+
planId,
|
|
509
|
+
enableMonitoring: true
|
|
510
|
+
}
|
|
544
511
|
}
|
|
545
|
-
}
|
|
512
|
+
}
|
|
546
513
|
)
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
|
|
514
|
+
)
|
|
515
|
+
);
|
|
516
|
+
return {
|
|
517
|
+
content: {
|
|
550
518
|
type: 'application/json',
|
|
551
519
|
data: {
|
|
552
|
-
|
|
553
|
-
|
|
520
|
+
success: true,
|
|
521
|
+
taskId: updatedTask.id,
|
|
522
|
+
planId,
|
|
554
523
|
completionType,
|
|
555
|
-
|
|
556
|
-
completionConfigWritten: true,
|
|
557
|
-
// Say only what is true. The write is asynchronous (it goes
|
|
558
|
-
// through the task update handler), and starting the monitor
|
|
559
|
-
// is a separate step owned by the task service.
|
|
560
|
-
note:
|
|
561
|
-
'The plan-based completion config has been submitted for this task. ' +
|
|
562
|
-
'Call task_monitoring_status to confirm the task is being monitored.'
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
return {
|
|
567
|
-
content,
|
|
568
|
-
metadata: {
|
|
569
|
-
processingTime: Date.now() - startTime
|
|
524
|
+
monitoringConfigured: true
|
|
570
525
|
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
} catch (error) {
|
|
578
|
-
logger.error(`Failed to link task to plan: ${error}`);
|
|
579
|
-
throw error;
|
|
526
|
+
},
|
|
527
|
+
metadata: { processingTime: Date.now() - startedAt }
|
|
528
|
+
};
|
|
529
|
+
} finally {
|
|
530
|
+
planUpdateLocks.delete(lockKey);
|
|
580
531
|
}
|
|
581
532
|
}
|
|
582
533
|
};
|
|
583
534
|
|
|
584
|
-
/**
|
|
585
|
-
* Get task monitoring status
|
|
586
|
-
*/
|
|
587
535
|
export const task_monitoring_status: McpToolDefinition = {
|
|
588
536
|
name: 'task_monitoring_status',
|
|
589
|
-
description: '
|
|
537
|
+
description: 'Read the persisted task state and automatic-completion configuration for a same-channel task.',
|
|
590
538
|
inputSchema: {
|
|
591
539
|
type: 'object',
|
|
592
|
-
properties: {
|
|
593
|
-
taskId: {
|
|
594
|
-
type: 'string',
|
|
595
|
-
description: 'ID of the task to check'
|
|
596
|
-
}
|
|
597
|
-
},
|
|
540
|
+
properties: { taskId: { type: 'string' } },
|
|
598
541
|
required: ['taskId']
|
|
599
542
|
},
|
|
600
543
|
enabled: true,
|
|
601
544
|
handler: async (input: McpToolInput, context: McpToolHandlerContext): Promise<McpToolHandlerResult> => {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
data: `Task monitoring status for ${input.taskId}:
|
|
608
|
-
|
|
609
|
-
Use task_update to check task status, or listen for task completion events on the channel.
|
|
610
|
-
Agent: ${context.agentId} | Channel: ${context.channelId}`
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
return {
|
|
614
|
-
content,
|
|
615
|
-
metadata: {
|
|
616
|
-
processingTime: Date.now() - startTime
|
|
617
|
-
}
|
|
618
|
-
} as McpToolHandlerResult;
|
|
619
|
-
|
|
620
|
-
} catch (error) {
|
|
621
|
-
logger.error(`Failed to get monitoring status: ${error}`);
|
|
622
|
-
throw error;
|
|
545
|
+
const identity = requireIdentity(context);
|
|
546
|
+
const taskId = requireString(input.taskId, 'taskId');
|
|
547
|
+
const task = await Task.findOne({ _id: taskId, channelId: identity.channelId });
|
|
548
|
+
if (!task) {
|
|
549
|
+
throw new Error(`Task ${taskId} not found in channel ${identity.channelId}`);
|
|
623
550
|
}
|
|
551
|
+
return {
|
|
552
|
+
content: {
|
|
553
|
+
type: 'application/json',
|
|
554
|
+
data: {
|
|
555
|
+
taskId,
|
|
556
|
+
channelId: identity.channelId,
|
|
557
|
+
status: task.status,
|
|
558
|
+
progress: task.progress,
|
|
559
|
+
monitoringConfigured: task.metadata?.enableMonitoring === true &&
|
|
560
|
+
task.metadata?.completionConfig !== undefined,
|
|
561
|
+
completionConfig: task.metadata?.completionConfig
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
};
|
|
624
565
|
}
|
|
625
566
|
};
|
|
626
567
|
|
|
627
|
-
/**
|
|
628
|
-
* Yield control after delegating a task to another agent.
|
|
629
|
-
*
|
|
630
|
-
* Calling this tool tells the framework "I delegated my work and I'm done —
|
|
631
|
-
* stop my LLM loop." Unlike task_complete, this does NOT mark the parent
|
|
632
|
-
* task as completed, so downstream agents continue their work uninterrupted.
|
|
633
|
-
*
|
|
634
|
-
* The agent loop in MxfAgent.ts recognises this tool name and breaks the
|
|
635
|
-
* iteration loop without setting the persistent taskCompleted flag.
|
|
636
|
-
*/
|
|
637
568
|
export const task_delegate: McpToolDefinition = {
|
|
638
569
|
name: 'task_delegate',
|
|
639
|
-
description: 'Signal that
|
|
570
|
+
description: 'Signal that work was delegated and yield the current agent loop without completing the parent task.',
|
|
640
571
|
inputSchema: {
|
|
641
572
|
type: 'object',
|
|
642
|
-
properties: {
|
|
643
|
-
summary: {
|
|
644
|
-
type: 'string',
|
|
645
|
-
description: 'Brief summary of what was delegated and to whom'
|
|
646
|
-
}
|
|
647
|
-
},
|
|
573
|
+
properties: { summary: { type: 'string' } },
|
|
648
574
|
required: ['summary']
|
|
649
575
|
},
|
|
650
576
|
enabled: true,
|
|
651
577
|
handler: async (input: McpToolInput, context: McpToolHandlerContext): Promise<McpToolHandlerResult> => {
|
|
578
|
+
const identity = requireIdentity(context);
|
|
579
|
+
const summary = requireString(input.summary, 'summary');
|
|
652
580
|
const content: McpToolResultContent = {
|
|
653
581
|
type: 'text',
|
|
654
|
-
data: `Delegation
|
|
582
|
+
data: `Delegation recorded for ${identity.agentId}.\n\n${summary}`
|
|
655
583
|
};
|
|
656
|
-
|
|
657
|
-
return {
|
|
658
|
-
content,
|
|
659
|
-
metadata: { delegated: true }
|
|
660
|
-
} as McpToolHandlerResult;
|
|
584
|
+
return { content, metadata: { delegated: true } };
|
|
661
585
|
}
|
|
662
586
|
};
|
|
663
587
|
|
|
664
|
-
// Export all task planning tools
|
|
665
588
|
export const taskPlanningTools = [
|
|
666
589
|
task_create_with_plan,
|
|
667
590
|
task_create_custom_completion,
|
|
668
591
|
task_link_to_plan,
|
|
669
592
|
task_monitoring_status,
|
|
670
593
|
task_delegate
|
|
671
|
-
];
|
|
594
|
+
];
|