@mxf-dev/core 2.0.5 → 3.1.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/ConfigManager.d.ts +64 -0
- package/dist/config/ConfigManager.d.ts.map +1 -1
- package/dist/config/ConfigManager.js +68 -1
- package/dist/config/ConfigManager.js.map +1 -1
- 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/MongoChannelRepository.d.ts.map +1 -1
- package/dist/database/adapters/mongodb/MongoChannelRepository.js +2 -1
- package/dist/database/adapters/mongodb/MongoChannelRepository.js.map +1 -1
- 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 +50 -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/ConfigEvents.d.ts +6 -0
- package/dist/events/event-definitions/ConfigEvents.d.ts.map +1 -1
- package/dist/events/event-definitions/ConfigEvents.js +0 -5
- package/dist/events/event-definitions/ConfigEvents.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/SystemEvents.d.ts +16 -0
- package/dist/events/event-definitions/SystemEvents.d.ts.map +1 -1
- package/dist/events/event-definitions/SystemEvents.js +2 -0
- package/dist/events/event-definitions/SystemEvents.js.map +1 -1
- 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/Channel.d.ts +3 -0
- package/dist/interfaces/Channel.d.ts.map +1 -1
- package/dist/interfaces/ChannelConfig.d.ts +4 -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 +4 -0
- package/dist/models/channel.d.ts.map +1 -1
- package/dist/models/channel.js +8 -0
- 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/prompts/MxfAgentSystemPrompt.d.ts.map +1 -1
- package/dist/prompts/MxfAgentSystemPrompt.js +9 -1
- package/dist/prompts/MxfAgentSystemPrompt.js.map +1 -1
- package/dist/prompts/SystemLlmStanceGuidance.d.ts +37 -0
- package/dist/prompts/SystemLlmStanceGuidance.d.ts.map +1 -0
- package/dist/prompts/SystemLlmStanceGuidance.js +48 -0
- package/dist/prompts/SystemLlmStanceGuidance.js.map +1 -0
- 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/IChannelRepository.d.ts +2 -0
- package/dist/repositories/interfaces/IChannelRepository.d.ts.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 +41 -1
- package/dist/schemas/EventPayloadSchema.d.ts.map +1 -1
- package/dist/schemas/EventPayloadSchema.js +54 -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 +29 -7
- package/dist/services/BackgroundTaskManager.d.ts.map +1 -1
- package/dist/services/BackgroundTaskManager.js +171 -60
- 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/SystemLlmStanceTypes.d.ts +123 -0
- package/dist/types/SystemLlmStanceTypes.d.ts.map +1 -0
- package/dist/types/SystemLlmStanceTypes.js +101 -0
- package/dist/types/SystemLlmStanceTypes.js.map +1 -0
- 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/dist/utils/PromptTemplateReplacer.d.ts +5 -0
- package/dist/utils/PromptTemplateReplacer.d.ts.map +1 -1
- package/dist/utils/PromptTemplateReplacer.js +13 -0
- package/dist/utils/PromptTemplateReplacer.js.map +1 -1
- package/package.json +1 -1
- package/src/config/ConfigManager.ts +126 -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/MongoChannelRepository.ts +2 -1
- 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/ConfigEvents.ts +8 -0
- package/src/events/event-definitions/ControlLoopEvents.ts +12 -0
- package/src/events/event-definitions/SdkEvents.ts +58 -0
- package/src/events/event-definitions/SystemEvents.ts +24 -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/Channel.ts +4 -0
- package/src/interfaces/ChannelConfig.ts +8 -2
- package/src/interfaces/ConversationMessage.ts +6 -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 +12 -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/prompts/MxfAgentSystemPrompt.ts +9 -1
- package/src/prompts/SystemLlmStanceGuidance.ts +67 -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/IChannelRepository.ts +2 -0
- package/src/repositories/interfaces/IKnowledgeGraphRepository.ts +45 -27
- package/src/schemas/EventPayloadSchema.ts +85 -2
- package/src/services/AgentPerformanceService.ts +85 -36
- package/src/services/AutoCorrectionService.ts +25 -6
- package/src/services/BackgroundTaskManager.ts +217 -79
- 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/SystemLlmStanceTypes.ts +162 -0
- package/src/types/TaskCompletionTypes.ts +9 -9
- package/src/types/TaskTypes.ts +12 -1
- package/src/utils/GlobMatcher.ts +157 -0
- package/src/utils/PromptTemplateReplacer.ts +17 -0
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
import { v4 as uuidv4 } from 'uuid';
|
|
55
|
+
import type { Subscription } from 'rxjs';
|
|
55
56
|
import { Logger } from '../../utils/Logger.js';
|
|
56
57
|
import { EventBus } from '../../events/EventBus.js';
|
|
57
58
|
import { Events, ControlLoopEvents } from '../../events/EventNames.js';
|
|
@@ -94,6 +95,8 @@ export class OrparMemoryCoordinator {
|
|
|
94
95
|
private static instance: OrparMemoryCoordinator;
|
|
95
96
|
private logger: Logger;
|
|
96
97
|
private enabled: boolean = false;
|
|
98
|
+
private initialized: boolean = false;
|
|
99
|
+
private eventSubscriptions: Subscription[] = [];
|
|
97
100
|
|
|
98
101
|
// Component services
|
|
99
102
|
private phaseStrataRouter: PhaseStrataRouter;
|
|
@@ -112,6 +115,7 @@ export class OrparMemoryCoordinator {
|
|
|
112
115
|
outcome: CycleOutcome;
|
|
113
116
|
completedAt: number;
|
|
114
117
|
}> = new Map();
|
|
118
|
+
private recentlyCompletedExpiryTimers: Map<string, NodeJS.Timeout> = new Map();
|
|
115
119
|
private static readonly RECENTLY_COMPLETED_TTL_MS = 60_000;
|
|
116
120
|
|
|
117
121
|
// Fix #2: Per-cycle locking to prevent race conditions
|
|
@@ -147,25 +151,36 @@ export class OrparMemoryCoordinator {
|
|
|
147
151
|
* Initialize the coordinator and all component services
|
|
148
152
|
*/
|
|
149
153
|
public initialize(): void {
|
|
154
|
+
if (this.initialized) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
150
158
|
this.enabled = isOrparMemoryIntegrationEnabled();
|
|
151
159
|
|
|
152
160
|
if (this.enabled) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
try {
|
|
162
|
+
// Initialize all component services
|
|
163
|
+
this.phaseStrataRouter.initialize();
|
|
164
|
+
this.surpriseAdapter.initialize();
|
|
165
|
+
this.phaseRewarder.initialize();
|
|
166
|
+
this.consolidationTrigger.initialize();
|
|
167
|
+
this.memoryOperations.initialize();
|
|
168
|
+
|
|
169
|
+
// Setup event listeners
|
|
170
|
+
this.setupEventListeners();
|
|
171
|
+
|
|
172
|
+
// Fix #3: Start stale cycle cleanup
|
|
173
|
+
this.startStaleCycleCleanup();
|
|
174
|
+
this.initialized = true;
|
|
175
|
+
|
|
176
|
+
this.logger.info('[OrparMemoryCoordinator] Initialized with ORPAR-Memory integration ENABLED');
|
|
177
|
+
this.logger.info('[OrparMemoryCoordinator] All component services initialized');
|
|
178
|
+
} catch (error) {
|
|
179
|
+
this.shutdown();
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
168
182
|
} else {
|
|
183
|
+
this.initialized = true;
|
|
169
184
|
this.logger.info(
|
|
170
185
|
'[OrparMemoryCoordinator] ORPAR-Memory integration is DISABLED. ' +
|
|
171
186
|
'Enable with ORPAR_MEMORY_INTEGRATION_ENABLED=true'
|
|
@@ -284,46 +299,58 @@ export class OrparMemoryCoordinator {
|
|
|
284
299
|
*/
|
|
285
300
|
private setupEventListeners(): void {
|
|
286
301
|
// Listen to control loop events to track cycle phases (server-side ControlLoop)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
302
|
+
this.eventSubscriptions.push(
|
|
303
|
+
EventBus.server.on(ControlLoopEvents.OBSERVATION, payload => {
|
|
304
|
+
this.onPhaseEvent('observation', payload, 'controlLoop');
|
|
305
|
+
})
|
|
306
|
+
);
|
|
307
|
+
this.eventSubscriptions.push(
|
|
308
|
+
EventBus.server.on(ControlLoopEvents.REASONING, payload => {
|
|
309
|
+
this.onPhaseEvent('reasoning', payload, 'controlLoop');
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
this.eventSubscriptions.push(
|
|
313
|
+
EventBus.server.on(ControlLoopEvents.PLAN, payload => {
|
|
314
|
+
this.onPhaseEvent('planning', payload, 'controlLoop');
|
|
315
|
+
})
|
|
316
|
+
);
|
|
317
|
+
this.eventSubscriptions.push(
|
|
318
|
+
EventBus.server.on(ControlLoopEvents.EXECUTION, payload => {
|
|
319
|
+
this.onPhaseEvent('action', payload, 'controlLoop');
|
|
320
|
+
})
|
|
321
|
+
);
|
|
322
|
+
this.eventSubscriptions.push(
|
|
323
|
+
EventBus.server.on(ControlLoopEvents.REFLECTION, payload => {
|
|
324
|
+
this.onPhaseEvent('reflection', payload, 'controlLoop');
|
|
325
|
+
})
|
|
326
|
+
);
|
|
306
327
|
|
|
307
328
|
// Listen to ORPAR tool events (agent-driven ORPAR tools)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
329
|
+
this.eventSubscriptions.push(
|
|
330
|
+
EventBus.server.on(OrparEvents.OBSERVE, payload => {
|
|
331
|
+
this.onOrparToolEvent('observation', payload);
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
this.eventSubscriptions.push(
|
|
335
|
+
EventBus.server.on(OrparEvents.REASON, payload => {
|
|
336
|
+
this.onOrparToolEvent('reasoning', payload);
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
this.eventSubscriptions.push(
|
|
340
|
+
EventBus.server.on(OrparEvents.PLAN, payload => {
|
|
341
|
+
this.onOrparToolEvent('planning', payload);
|
|
342
|
+
})
|
|
343
|
+
);
|
|
344
|
+
this.eventSubscriptions.push(
|
|
345
|
+
EventBus.server.on(OrparEvents.ACT, payload => {
|
|
346
|
+
this.onOrparToolEvent('action', payload);
|
|
347
|
+
})
|
|
348
|
+
);
|
|
349
|
+
this.eventSubscriptions.push(
|
|
350
|
+
EventBus.server.on(OrparEvents.REFLECT, payload => {
|
|
351
|
+
this.onOrparToolEvent('reflection', payload);
|
|
352
|
+
})
|
|
353
|
+
);
|
|
327
354
|
|
|
328
355
|
// Fill phase memory usage from actual retrievals.
|
|
329
356
|
//
|
|
@@ -333,19 +360,26 @@ export class OrparMemoryCoordinator {
|
|
|
333
360
|
// therefore always empty, so PhaseWeightedRewarder returned no rewards and cycle
|
|
334
361
|
// consolidation iterated zero memories. Subscribing here is what makes
|
|
335
362
|
// phase-weighted rewards real.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
this.
|
|
339
|
-
|
|
340
|
-
|
|
363
|
+
this.eventSubscriptions.push(
|
|
364
|
+
EventBus.server.on(OrparMemoryEvents.PHASE_MEMORY_RETRIEVED, payload => {
|
|
365
|
+
if (this.enabled) {
|
|
366
|
+
this.onPhaseMemoryRetrieved(payload);
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
);
|
|
341
370
|
|
|
342
371
|
// Listen for task completion to retroactively update rewards when
|
|
343
372
|
// the ORPAR cycle completed before task_complete was called
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
this.
|
|
347
|
-
|
|
348
|
-
|
|
373
|
+
this.eventSubscriptions.push(
|
|
374
|
+
EventBus.server.on(Events.Task.COMPLETED, (payload): Promise<void> | undefined => {
|
|
375
|
+
if (this.enabled) {
|
|
376
|
+
// Return the persistence chain so EventBus.drain() keeps the
|
|
377
|
+
// database open until retroactive Q-value updates finish.
|
|
378
|
+
return this.onTaskCompleted(payload);
|
|
379
|
+
}
|
|
380
|
+
return undefined;
|
|
381
|
+
})
|
|
382
|
+
);
|
|
349
383
|
|
|
350
384
|
this.logger.debug('[OrparMemoryCoordinator] Event listeners registered for ControlLoop, OrparTools, PhaseMemory, and TaskEvents');
|
|
351
385
|
}
|
|
@@ -688,9 +722,7 @@ export class OrparMemoryCoordinator {
|
|
|
688
722
|
outcome,
|
|
689
723
|
completedAt: Date.now(),
|
|
690
724
|
});
|
|
691
|
-
|
|
692
|
-
this.recentlyCompletedCycles.delete(cacheKey);
|
|
693
|
-
}, OrparMemoryCoordinator.RECENTLY_COMPLETED_TTL_MS);
|
|
725
|
+
this.scheduleRecentlyCompletedExpiry(cacheKey);
|
|
694
726
|
}
|
|
695
727
|
|
|
696
728
|
// Remove from active cycles
|
|
@@ -718,7 +750,7 @@ export class OrparMemoryCoordinator {
|
|
|
718
750
|
|
|
719
751
|
// Already successful — no recalculation needed
|
|
720
752
|
if (cached.outcome.success) {
|
|
721
|
-
this.
|
|
753
|
+
this.clearRecentlyCompletedCycle(cacheKey);
|
|
722
754
|
return;
|
|
723
755
|
}
|
|
724
756
|
|
|
@@ -749,7 +781,30 @@ export class OrparMemoryCoordinator {
|
|
|
749
781
|
);
|
|
750
782
|
}
|
|
751
783
|
|
|
784
|
+
this.clearRecentlyCompletedCycle(cacheKey);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
private scheduleRecentlyCompletedExpiry(cacheKey: string): void {
|
|
788
|
+
const existingTimer = this.recentlyCompletedExpiryTimers.get(cacheKey);
|
|
789
|
+
if (existingTimer) {
|
|
790
|
+
clearTimeout(existingTimer);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
const expiryTimer = setTimeout(() => {
|
|
794
|
+
this.recentlyCompletedCycles.delete(cacheKey);
|
|
795
|
+
this.recentlyCompletedExpiryTimers.delete(cacheKey);
|
|
796
|
+
}, OrparMemoryCoordinator.RECENTLY_COMPLETED_TTL_MS);
|
|
797
|
+
expiryTimer.unref();
|
|
798
|
+
this.recentlyCompletedExpiryTimers.set(cacheKey, expiryTimer);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
private clearRecentlyCompletedCycle(cacheKey: string): void {
|
|
752
802
|
this.recentlyCompletedCycles.delete(cacheKey);
|
|
803
|
+
const expiryTimer = this.recentlyCompletedExpiryTimers.get(cacheKey);
|
|
804
|
+
if (expiryTimer) {
|
|
805
|
+
clearTimeout(expiryTimer);
|
|
806
|
+
this.recentlyCompletedExpiryTimers.delete(cacheKey);
|
|
807
|
+
}
|
|
753
808
|
}
|
|
754
809
|
|
|
755
810
|
// =========================================================================
|
|
@@ -1050,11 +1105,21 @@ export class OrparMemoryCoordinator {
|
|
|
1050
1105
|
].join('\n');
|
|
1051
1106
|
}
|
|
1052
1107
|
|
|
1053
|
-
/**
|
|
1054
|
-
|
|
1055
|
-
*/
|
|
1056
|
-
public reset(): void {
|
|
1108
|
+
/** Release all coordinator-owned process resources and runtime state. */
|
|
1109
|
+
public shutdown(): void {
|
|
1057
1110
|
this.enabled = false;
|
|
1111
|
+
this.initialized = false;
|
|
1112
|
+
|
|
1113
|
+
for (const subscription of this.eventSubscriptions) {
|
|
1114
|
+
subscription.unsubscribe();
|
|
1115
|
+
}
|
|
1116
|
+
this.eventSubscriptions = [];
|
|
1117
|
+
|
|
1118
|
+
for (const expiryTimer of this.recentlyCompletedExpiryTimers.values()) {
|
|
1119
|
+
clearTimeout(expiryTimer);
|
|
1120
|
+
}
|
|
1121
|
+
this.recentlyCompletedExpiryTimers.clear();
|
|
1122
|
+
|
|
1058
1123
|
this.activeCycles.clear();
|
|
1059
1124
|
this.recentlyCompletedCycles.clear();
|
|
1060
1125
|
|
|
@@ -1070,7 +1135,13 @@ export class OrparMemoryCoordinator {
|
|
|
1070
1135
|
this.phaseRewarder.reset();
|
|
1071
1136
|
this.consolidationTrigger.reset();
|
|
1072
1137
|
this.memoryOperations.reset();
|
|
1138
|
+
}
|
|
1073
1139
|
|
|
1140
|
+
/**
|
|
1141
|
+
* Reset the coordinator and its cached configuration (useful for testing).
|
|
1142
|
+
*/
|
|
1143
|
+
public reset(): void {
|
|
1144
|
+
this.shutdown();
|
|
1074
1145
|
// Reset config
|
|
1075
1146
|
resetOrparMemoryConfig();
|
|
1076
1147
|
}
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import { createBaseEventPayload } from '../../schemas/EventPayloadSchema.js';
|
|
38
|
+
import type { Subscription } from 'rxjs';
|
|
38
39
|
import { Logger } from '../../utils/Logger.js';
|
|
39
40
|
import { EventBus } from '../../events/EventBus.js';
|
|
40
41
|
import {
|
|
@@ -87,6 +88,7 @@ export class SurpriseOrparAdapter {
|
|
|
87
88
|
private logger: Logger;
|
|
88
89
|
private enabled: boolean = false;
|
|
89
90
|
private thresholds: SurpriseThresholds;
|
|
91
|
+
private graphSurpriseSubscription?: Subscription;
|
|
90
92
|
|
|
91
93
|
// Track surprise momentum per agent/cycle
|
|
92
94
|
private surpriseMomentum: Map<string, number[]> = new Map();
|
|
@@ -137,13 +139,18 @@ export class SurpriseOrparAdapter {
|
|
|
137
139
|
* observation cycles.
|
|
138
140
|
*/
|
|
139
141
|
private setupGraphSurpriseListener(): void {
|
|
142
|
+
if (this.graphSurpriseSubscription && !this.graphSurpriseSubscription.closed) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.graphSurpriseSubscription = undefined;
|
|
146
|
+
|
|
140
147
|
// Only set up listener if Knowledge Graph surprise detection is enabled
|
|
141
148
|
if (!isKnowledgeGraphEnabled() || !isSurpriseDetectionEnabled()) {
|
|
142
149
|
this.logger.debug('[SurpriseOrparAdapter] Knowledge Graph surprise integration disabled');
|
|
143
150
|
return;
|
|
144
151
|
}
|
|
145
152
|
|
|
146
|
-
EventBus.server.on(
|
|
153
|
+
this.graphSurpriseSubscription = EventBus.server.on(
|
|
147
154
|
KnowledgeGraphEvents.HIGH_SURPRISE_RELATIONSHIP,
|
|
148
155
|
(payload: { data: HighSurpriseRelationshipEventData; agentId?: AgentId; channelId?: ChannelId }) => {
|
|
149
156
|
this.handleGraphSurpriseEvent(payload);
|
|
@@ -567,6 +574,8 @@ export class SurpriseOrparAdapter {
|
|
|
567
574
|
*/
|
|
568
575
|
public reset(): void {
|
|
569
576
|
this.enabled = false;
|
|
577
|
+
this.graphSurpriseSubscription?.unsubscribe();
|
|
578
|
+
this.graphSurpriseSubscription = undefined;
|
|
570
579
|
this.surpriseMomentum.clear();
|
|
571
580
|
}
|
|
572
581
|
}
|
|
@@ -272,12 +272,14 @@ export interface IChannelContextService {
|
|
|
272
272
|
* @param channelId - Channel ID
|
|
273
273
|
* @param context - Channel context to save
|
|
274
274
|
* @param historyEntry - Optional history entry to record with this update
|
|
275
|
+
* @param expectedContextUpdatedAt - Persisted revision required for an update
|
|
275
276
|
* @returns Observable of the saved context
|
|
276
277
|
*/
|
|
277
278
|
saveContextToMemory(
|
|
278
279
|
channelId: ChannelId,
|
|
279
280
|
context: ChannelContextType,
|
|
280
|
-
historyEntry?: ChannelContextHistoryEntry
|
|
281
|
+
historyEntry?: ChannelContextHistoryEntry,
|
|
282
|
+
expectedContextUpdatedAt?: number
|
|
281
283
|
): Observable<ChannelContextType>;
|
|
282
284
|
|
|
283
285
|
/**
|
|
@@ -125,6 +125,9 @@ export interface TaskEffectivenessMetrics {
|
|
|
125
125
|
export interface TaskDefinition {
|
|
126
126
|
/** Unique task identifier */
|
|
127
127
|
taskId: string;
|
|
128
|
+
|
|
129
|
+
/** Agent that owns this effectiveness record */
|
|
130
|
+
agentId: AgentId;
|
|
128
131
|
|
|
129
132
|
/** Channel where task is executed */
|
|
130
133
|
channelId: ChannelId;
|
|
@@ -267,9 +270,10 @@ export interface EffectivenessAnalytics {
|
|
|
267
270
|
export interface TaskExecutionEvent {
|
|
268
271
|
eventId: string;
|
|
269
272
|
taskId: string;
|
|
273
|
+
agentId: AgentId;
|
|
274
|
+
channelId: ChannelId;
|
|
270
275
|
timestamp: number;
|
|
271
276
|
type: 'start' | 'step' | 'tool_use' | 'agent_join' | 'human_input' | 'error' | 'complete';
|
|
272
|
-
agentId?: AgentId;
|
|
273
277
|
details: Record<string, any>;
|
|
274
278
|
}
|
|
275
279
|
|
|
@@ -300,4 +304,4 @@ export interface EffectivenessConfig {
|
|
|
300
304
|
enabled: boolean;
|
|
301
305
|
defaultBaselineType?: 'human' | 'previous_run' | 'traditional_method';
|
|
302
306
|
};
|
|
303
|
-
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Brad Anderson
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
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
|
+
* SystemLLM stance
|
|
23
|
+
*
|
|
24
|
+
* The stance decides how SystemLLM talks to agents, and in one case how it
|
|
25
|
+
* judges them:
|
|
26
|
+
*
|
|
27
|
+
* - `supportive` — the original behavior. Coordination hints are advisory and
|
|
28
|
+
* nothing SystemLLM says asks for a reply.
|
|
29
|
+
* - `critical` — an honest skeptic. SystemLLM reads what agents did and
|
|
30
|
+
* challenges completion claims, plans, and reflections it cannot square with
|
|
31
|
+
* the evidence. The `systemllm-eval` completion judge demands evidence per
|
|
32
|
+
* objective. If there is nothing wrong, it says nothing.
|
|
33
|
+
* - `hostile` — a test mode. SystemLLM issues plausible-but-wrong challenges
|
|
34
|
+
* and hints so an operator can measure whether agents verify before acting
|
|
35
|
+
* on system advice. Agents are told it is on; every hostile message is
|
|
36
|
+
* tagged; it never touches a decision (judge verdicts, task assignment).
|
|
37
|
+
*
|
|
38
|
+
* The server default comes from `SYSTEMLLM_STANCE`; a channel can carry its
|
|
39
|
+
* own in `systemLlmStance`. These types are shared by the server (which
|
|
40
|
+
* applies the stance), the SDK (which tells agents about it), and the channel
|
|
41
|
+
* model (which persists it).
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/** Every stance, in the order the documentation lists them. */
|
|
45
|
+
export const SYSTEMLLM_STANCES = ['supportive', 'critical', 'hostile'] as const;
|
|
46
|
+
|
|
47
|
+
export type SystemLlmStance = typeof SYSTEMLLM_STANCES[number];
|
|
48
|
+
|
|
49
|
+
/** The stance when nothing sets one: today's behavior. */
|
|
50
|
+
export const DEFAULT_SYSTEMLLM_STANCE: SystemLlmStance = 'supportive';
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The ceiling when nothing sets one: no ceiling. `SYSTEMLLM_STANCE_MAX` lowers
|
|
54
|
+
* it server-wide so that no channel, whatever its own stance says, goes
|
|
55
|
+
* above it — `critical` keeps hostile out of production, `supportive` turns
|
|
56
|
+
* challenges off everywhere without touching channel documents.
|
|
57
|
+
*/
|
|
58
|
+
export const DEFAULT_SYSTEMLLM_STANCE_CEILING: SystemLlmStance = 'hostile';
|
|
59
|
+
|
|
60
|
+
/** Stances from least to most adversarial; the index is the ordering. */
|
|
61
|
+
const STANCE_RANK: Record<SystemLlmStance, number> = { supportive: 0, critical: 1, hostile: 2 };
|
|
62
|
+
|
|
63
|
+
/** Whether `stance` is at or below `ceiling`. */
|
|
64
|
+
export function isStanceWithin(stance: SystemLlmStance, ceiling: SystemLlmStance): boolean {
|
|
65
|
+
return STANCE_RANK[stance] <= STANCE_RANK[ceiling];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** `stance`, lowered to `ceiling` when it is above it. */
|
|
69
|
+
export function capStance(stance: SystemLlmStance, ceiling: SystemLlmStance): SystemLlmStance {
|
|
70
|
+
return isStanceWithin(stance, ceiling) ? stance : ceiling;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isSystemLlmStance(value: unknown): value is SystemLlmStance {
|
|
74
|
+
return typeof value === 'string' && (SYSTEMLLM_STANCES as ReadonlyArray<string>).includes(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Parse a stance from configuration text.
|
|
79
|
+
*
|
|
80
|
+
* @param value - Raw value, for example from an environment variable or a channel document
|
|
81
|
+
* @param sourceName - What the value came from, for the error message (`SYSTEMLLM_STANCE`, `systemLlmStance`)
|
|
82
|
+
* @throws Error when the value is blank or is not one of the stances
|
|
83
|
+
*/
|
|
84
|
+
export function parseSystemLlmStance(value: string, sourceName: string): SystemLlmStance {
|
|
85
|
+
const trimmed = value.trim().toLowerCase();
|
|
86
|
+
if (trimmed.length === 0) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
`${sourceName} is set but blank. Name a stance (${SYSTEMLLM_STANCES.join(', ')}), or remove it.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (!isSystemLlmStance(trimmed)) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Unsupported ${sourceName} '${value}'. Expected one of: ${SYSTEMLLM_STANCES.join(', ')}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return trimmed;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* What prompted a challenge.
|
|
101
|
+
*
|
|
102
|
+
* - `completion_claim` — the agent called `task_complete` reporting success
|
|
103
|
+
* - `plan_posted` — the agent recorded a plan with `orpar_plan`
|
|
104
|
+
* - `reflection_success` — the agent recorded a reflection with `orpar_reflect`
|
|
105
|
+
* that did not say expectations were missed
|
|
106
|
+
*/
|
|
107
|
+
export const CHALLENGE_TRIGGERS = ['completion_claim', 'plan_posted', 'reflection_success'] as const;
|
|
108
|
+
|
|
109
|
+
export type ChallengeTrigger = typeof CHALLENGE_TRIGGERS[number];
|
|
110
|
+
|
|
111
|
+
/** How a challenge reached the agent. */
|
|
112
|
+
export type ChallengeDelivery = 'tool_result' | 'channel_message';
|
|
113
|
+
|
|
114
|
+
/** One thing SystemLLM disputes. */
|
|
115
|
+
export interface SystemLlmChallengePoint {
|
|
116
|
+
/** The agent's claim, quoted or paraphrased. */
|
|
117
|
+
claim: string;
|
|
118
|
+
/** Why the evidence does not support it. */
|
|
119
|
+
problem: string;
|
|
120
|
+
/** What would settle it: a tool result, a file, a message. */
|
|
121
|
+
evidenceNeeded: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A challenge SystemLLM issued to one agent about one task. */
|
|
125
|
+
export interface SystemLlmChallenge {
|
|
126
|
+
id: string;
|
|
127
|
+
channelId: string;
|
|
128
|
+
agentId: string;
|
|
129
|
+
taskId: string;
|
|
130
|
+
trigger: ChallengeTrigger;
|
|
131
|
+
stance: Exclude<SystemLlmStance, 'supportive'>;
|
|
132
|
+
delivery: ChallengeDelivery;
|
|
133
|
+
summary: string;
|
|
134
|
+
points: SystemLlmChallengePoint[];
|
|
135
|
+
createdAt: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Record kept on `task.metadata.systemLlmChallenges` so a trigger is
|
|
140
|
+
* challenged at most once per task, and so the history is auditable.
|
|
141
|
+
*/
|
|
142
|
+
export interface SystemLlmChallengeRecord {
|
|
143
|
+
id: string;
|
|
144
|
+
trigger: ChallengeTrigger;
|
|
145
|
+
stance: SystemLlmChallenge['stance'];
|
|
146
|
+
delivery: ChallengeDelivery;
|
|
147
|
+
summary: string;
|
|
148
|
+
points: SystemLlmChallengePoint[];
|
|
149
|
+
createdAt: number;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Key under `task.metadata` where challenge records are pushed. */
|
|
153
|
+
export const TASK_METADATA_CHALLENGES_KEY = 'systemLlmChallenges';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `context.messageType` on a channel message that carries a challenge.
|
|
157
|
+
* The SDK treats these as "answer this", unlike `coordination_suggestion`.
|
|
158
|
+
*/
|
|
159
|
+
export const SYSTEMLLM_CHALLENGE_MESSAGE_TYPE = 'systemllm_challenge';
|
|
160
|
+
|
|
161
|
+
/** `status` returned by `task_complete` when the claim was challenged instead of accepted. */
|
|
162
|
+
export const TASK_COMPLETION_CHALLENGED_STATUS = 'completion_challenged';
|
|
@@ -46,6 +46,7 @@ export interface SystemLLMEvalCompletion {
|
|
|
46
46
|
objectives: string[]; // What needs to be achieved
|
|
47
47
|
evaluationInterval: number; // How often to check (ms)
|
|
48
48
|
confidenceThreshold: number; // 0-1, required confidence
|
|
49
|
+
maxEvaluations: number; // Hard provider-call budget
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export interface OutputBasedCompletion {
|
|
@@ -67,7 +68,7 @@ export interface TimeBasedCompletion {
|
|
|
67
68
|
export interface EventBasedCompletion {
|
|
68
69
|
type: 'event-based';
|
|
69
70
|
eventName: string; // Event that triggers completion
|
|
70
|
-
eventData?: Record<string,
|
|
71
|
+
eventData?: Record<string, unknown>; // Optional data to match
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export interface ConsensusCompletion {
|
|
@@ -79,7 +80,7 @@ export interface ConsensusCompletion {
|
|
|
79
80
|
export interface CustomCompletion {
|
|
80
81
|
type: 'custom';
|
|
81
82
|
evaluatorFunction: string; // Name of custom evaluator
|
|
82
|
-
parameters?: Record<string,
|
|
83
|
+
parameters?: Record<string, unknown>;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
export type TaskCompletionCriteria =
|
|
@@ -98,12 +99,9 @@ export interface TaskCompletionConfig {
|
|
|
98
99
|
// Primary completion strategy
|
|
99
100
|
primary: TaskCompletionCriteria;
|
|
100
101
|
|
|
101
|
-
//
|
|
102
|
-
fallbacks?: TaskCompletionCriteria[];
|
|
103
|
-
|
|
104
|
-
// Global timeout (applies to all strategies)
|
|
102
|
+
// Optional hard deadline. A deadline may fail a task; it can never manufacture completion.
|
|
105
103
|
absoluteTimeout?: number;
|
|
106
|
-
timeoutBehavior?: '
|
|
104
|
+
timeoutBehavior?: 'fail';
|
|
107
105
|
|
|
108
106
|
// Whether agents can still manually complete
|
|
109
107
|
allowManualCompletion?: boolean;
|
|
@@ -111,6 +109,8 @@ export interface TaskCompletionConfig {
|
|
|
111
109
|
|
|
112
110
|
export interface TaskMonitoringState {
|
|
113
111
|
taskId: string;
|
|
112
|
+
channelId: string;
|
|
113
|
+
assignedAgentIds: string[];
|
|
114
114
|
startTime: number;
|
|
115
115
|
lastActivityTime: number;
|
|
116
116
|
activityCount: number;
|
|
@@ -125,7 +125,7 @@ export interface TaskMonitoringState {
|
|
|
125
125
|
toolCalls: Array<{
|
|
126
126
|
agentId: string;
|
|
127
127
|
toolName: string;
|
|
128
|
-
result:
|
|
128
|
+
result: unknown;
|
|
129
129
|
timestamp: number;
|
|
130
130
|
}>;
|
|
131
131
|
planProgress?: {
|
|
@@ -160,4 +160,4 @@ export interface TaskCompletionEvent {
|
|
|
160
160
|
confidence: number;
|
|
161
161
|
reason: string;
|
|
162
162
|
duration: number;
|
|
163
|
-
}
|
|
163
|
+
}
|
package/src/types/TaskTypes.ts
CHANGED
|
@@ -77,6 +77,7 @@ export interface ChannelTask {
|
|
|
77
77
|
// Task coordination
|
|
78
78
|
coordinationMode?: 'independent' | 'collaborative' | 'sequential' | 'hierarchical';
|
|
79
79
|
leadAgentId?: AgentId; // Primary coordinator for collaborative tasks
|
|
80
|
+
completionAgentId?: AgentId; // Agent authorized to report the terminal outcome
|
|
80
81
|
|
|
81
82
|
// Agent selection criteria
|
|
82
83
|
agentSelectionCriteria?: {
|
|
@@ -147,6 +148,7 @@ export interface CreateTaskRequest {
|
|
|
147
148
|
// Task coordination
|
|
148
149
|
coordinationMode?: 'independent' | 'collaborative' | 'sequential' | 'hierarchical';
|
|
149
150
|
leadAgentId?: AgentId; // Primary coordinator for collaborative tasks
|
|
151
|
+
completionAgentId?: AgentId; // Agent authorized to report the terminal outcome
|
|
150
152
|
|
|
151
153
|
// Agent selection criteria
|
|
152
154
|
agentSelectionCriteria?: {
|
|
@@ -176,6 +178,16 @@ export interface UpdateTaskRequest {
|
|
|
176
178
|
tags?: string[];
|
|
177
179
|
}
|
|
178
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Fields that may be changed without performing a task lifecycle transition.
|
|
183
|
+
* Status and assignment changes go through dedicated operations so actor
|
|
184
|
+
* authorization and legal-state predicates remain on the database write.
|
|
185
|
+
*/
|
|
186
|
+
export type NonLifecycleTaskUpdateRequest = Omit<
|
|
187
|
+
UpdateTaskRequest,
|
|
188
|
+
'status' | 'assignedAgentId'
|
|
189
|
+
>;
|
|
190
|
+
|
|
179
191
|
/**
|
|
180
192
|
* Agent assignment analysis from SystemLLM
|
|
181
193
|
*/
|
|
@@ -275,7 +287,6 @@ export interface TaskOrchestrationConfig {
|
|
|
275
287
|
// SystemLLM integration
|
|
276
288
|
enableLlmAssignment: boolean;
|
|
277
289
|
llmConfidenceThreshold: number; // Minimum confidence for LLM assignments
|
|
278
|
-
fallbackStrategy: AssignmentStrategy;
|
|
279
290
|
|
|
280
291
|
// Coordination behavior
|
|
281
292
|
enableTaskDependencies: boolean;
|