@mxf-dev/core 2.0.4 → 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.
Files changed (466) hide show
  1. package/dist/config/ModelContextLimits.d.ts.map +1 -1
  2. package/dist/config/ModelContextLimits.js +7 -1
  3. package/dist/config/ModelContextLimits.js.map +1 -1
  4. package/dist/constants/CoreTools.d.ts +6 -5
  5. package/dist/constants/CoreTools.d.ts.map +1 -1
  6. package/dist/constants/CoreTools.js +6 -5
  7. package/dist/constants/CoreTools.js.map +1 -1
  8. package/dist/constants/DefaultPhaseProfiles.d.ts.map +1 -1
  9. package/dist/constants/DefaultPhaseProfiles.js +29 -0
  10. package/dist/constants/DefaultPhaseProfiles.js.map +1 -1
  11. package/dist/constants/ReservedIdentities.d.ts +14 -0
  12. package/dist/constants/ReservedIdentities.d.ts.map +1 -0
  13. package/dist/constants/ReservedIdentities.js +42 -0
  14. package/dist/constants/ReservedIdentities.js.map +1 -0
  15. package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.d.ts +16 -16
  16. package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.d.ts.map +1 -1
  17. package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.js +98 -36
  18. package/dist/database/adapters/mongodb/MongoKnowledgeGraphRepository.js.map +1 -1
  19. package/dist/events/ClientEventBus.d.ts +28 -0
  20. package/dist/events/ClientEventBus.d.ts.map +1 -1
  21. package/dist/events/ClientEventBus.js +87 -40
  22. package/dist/events/ClientEventBus.js.map +1 -1
  23. package/dist/events/EventBus.d.ts +19 -1
  24. package/dist/events/EventBus.d.ts.map +1 -1
  25. package/dist/events/EventBus.js +23 -0
  26. package/dist/events/EventBus.js.map +1 -1
  27. package/dist/events/EventBusBase.d.ts +37 -6
  28. package/dist/events/EventBusBase.d.ts.map +1 -1
  29. package/dist/events/EventBusBase.js +75 -27
  30. package/dist/events/EventBusBase.js.map +1 -1
  31. package/dist/events/EventNames.d.ts +49 -36
  32. package/dist/events/EventNames.d.ts.map +1 -1
  33. package/dist/events/EventNames.js +38 -36
  34. package/dist/events/EventNames.js.map +1 -1
  35. package/dist/events/PublicEvents.d.ts +5 -1
  36. package/dist/events/PublicEvents.d.ts.map +1 -1
  37. package/dist/events/PublicEvents.js +7 -0
  38. package/dist/events/PublicEvents.js.map +1 -1
  39. package/dist/events/ServerEventBus.d.ts +7 -54
  40. package/dist/events/ServerEventBus.d.ts.map +1 -1
  41. package/dist/events/ServerEventBus.js +10 -96
  42. package/dist/events/ServerEventBus.js.map +1 -1
  43. package/dist/events/event-definitions/ControlLoopEvents.d.ts +35 -0
  44. package/dist/events/event-definitions/ControlLoopEvents.d.ts.map +1 -1
  45. package/dist/events/event-definitions/ControlLoopEvents.js +6 -0
  46. package/dist/events/event-definitions/ControlLoopEvents.js.map +1 -1
  47. package/dist/events/event-definitions/SdkEvents.d.ts +55 -0
  48. package/dist/events/event-definitions/SdkEvents.d.ts.map +1 -0
  49. package/dist/events/event-definitions/SdkEvents.js +36 -0
  50. package/dist/events/event-definitions/SdkEvents.js.map +1 -0
  51. package/dist/events/event-definitions/TaskEvents.d.ts +2 -7
  52. package/dist/events/event-definitions/TaskEvents.d.ts.map +1 -1
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +2 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/interfaces/AgentInterfaces.d.ts +5 -0
  58. package/dist/interfaces/AgentInterfaces.d.ts.map +1 -1
  59. package/dist/interfaces/ChannelConfig.d.ts +2 -2
  60. package/dist/interfaces/ChannelConfig.d.ts.map +1 -1
  61. package/dist/interfaces/ConversationMessage.d.ts +1 -1
  62. package/dist/interfaces/ConversationMessage.d.ts.map +1 -1
  63. package/dist/interfaces/IMemoryPersistence.d.ts +47 -1
  64. package/dist/interfaces/IMemoryPersistence.d.ts.map +1 -1
  65. package/dist/interfaces/SocketServiceInterface.d.ts +3 -2
  66. package/dist/interfaces/SocketServiceInterface.d.ts.map +1 -1
  67. package/dist/interfaces/TaskInterfaces.d.ts +14 -1
  68. package/dist/interfaces/TaskInterfaces.d.ts.map +1 -1
  69. package/dist/models/agent.d.ts +0 -1
  70. package/dist/models/agent.d.ts.map +1 -1
  71. package/dist/models/agent.js +0 -5
  72. package/dist/models/agent.js.map +1 -1
  73. package/dist/models/agentIdentityReservation.d.ts +42 -0
  74. package/dist/models/agentIdentityReservation.d.ts.map +1 -0
  75. package/dist/models/agentIdentityReservation.js +52 -0
  76. package/dist/models/agentIdentityReservation.js.map +1 -0
  77. package/dist/models/channel.d.ts +2 -0
  78. package/dist/models/channel.d.ts.map +1 -1
  79. package/dist/models/channel.js.map +1 -1
  80. package/dist/models/channelKey.d.ts +1 -0
  81. package/dist/models/channelKey.d.ts.map +1 -1
  82. package/dist/models/channelKey.js +5 -0
  83. package/dist/models/channelKey.js.map +1 -1
  84. package/dist/models/memory.d.ts +1 -1
  85. package/dist/models/memory.d.ts.map +1 -1
  86. package/dist/models/memory.js +9 -12
  87. package/dist/models/memory.js.map +1 -1
  88. package/dist/models/memoryStrata.d.ts +3 -16
  89. package/dist/models/memoryStrata.d.ts.map +1 -1
  90. package/dist/models/memoryStrata.js +3 -5
  91. package/dist/models/memoryStrata.js.map +1 -1
  92. package/dist/models/plan.d.ts +2 -2
  93. package/dist/models/plan.d.ts.map +1 -1
  94. package/dist/models/plan.js +1 -1
  95. package/dist/models/plan.js.map +1 -1
  96. package/dist/models/taskEffectiveness.d.ts +1 -0
  97. package/dist/models/taskEffectiveness.d.ts.map +1 -1
  98. package/dist/models/taskEffectiveness.js +7 -1
  99. package/dist/models/taskEffectiveness.js.map +1 -1
  100. package/dist/models/user.d.ts +4 -0
  101. package/dist/models/user.d.ts.map +1 -1
  102. package/dist/models/user.js +8 -0
  103. package/dist/models/user.js.map +1 -1
  104. package/dist/protocols/mcp/LlmTestEnvironmentGuard.d.ts +16 -0
  105. package/dist/protocols/mcp/LlmTestEnvironmentGuard.d.ts.map +1 -0
  106. package/dist/protocols/mcp/LlmTestEnvironmentGuard.js +25 -0
  107. package/dist/protocols/mcp/LlmTestEnvironmentGuard.js.map +1 -0
  108. package/dist/protocols/mcp/McpServerTypes.d.ts +9 -0
  109. package/dist/protocols/mcp/McpServerTypes.d.ts.map +1 -1
  110. package/dist/protocols/mcp/providers/AnthropicMcpClient.d.ts.map +1 -1
  111. package/dist/protocols/mcp/providers/AnthropicMcpClient.js +1 -0
  112. package/dist/protocols/mcp/providers/AnthropicMcpClient.js.map +1 -1
  113. package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.d.ts.map +1 -1
  114. package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.js +1 -0
  115. package/dist/protocols/mcp/providers/AzureOpenAiMcpClient.js.map +1 -1
  116. package/dist/protocols/mcp/providers/BaseMcpClient.d.ts +4 -0
  117. package/dist/protocols/mcp/providers/BaseMcpClient.d.ts.map +1 -1
  118. package/dist/protocols/mcp/providers/BaseMcpClient.js +10 -0
  119. package/dist/protocols/mcp/providers/BaseMcpClient.js.map +1 -1
  120. package/dist/protocols/mcp/providers/CustomMcpClient.d.ts.map +1 -1
  121. package/dist/protocols/mcp/providers/CustomMcpClient.js +7 -0
  122. package/dist/protocols/mcp/providers/CustomMcpClient.js.map +1 -1
  123. package/dist/protocols/mcp/providers/GeminiMcpClient.d.ts.map +1 -1
  124. package/dist/protocols/mcp/providers/GeminiMcpClient.js +1 -0
  125. package/dist/protocols/mcp/providers/GeminiMcpClient.js.map +1 -1
  126. package/dist/protocols/mcp/providers/OllamaMcpClient.d.ts +1 -0
  127. package/dist/protocols/mcp/providers/OllamaMcpClient.d.ts.map +1 -1
  128. package/dist/protocols/mcp/providers/OllamaMcpClient.js +1 -0
  129. package/dist/protocols/mcp/providers/OllamaMcpClient.js.map +1 -1
  130. package/dist/protocols/mcp/providers/OpenAiMcpClient.d.ts.map +1 -1
  131. package/dist/protocols/mcp/providers/OpenAiMcpClient.js +1 -0
  132. package/dist/protocols/mcp/providers/OpenAiMcpClient.js.map +1 -1
  133. package/dist/protocols/mcp/providers/OpenRouterMcpClient.d.ts.map +1 -1
  134. package/dist/protocols/mcp/providers/OpenRouterMcpClient.js +2 -0
  135. package/dist/protocols/mcp/providers/OpenRouterMcpClient.js.map +1 -1
  136. package/dist/protocols/mcp/providers/XaiMcpClient.d.ts.map +1 -1
  137. package/dist/protocols/mcp/providers/XaiMcpClient.js +1 -0
  138. package/dist/protocols/mcp/providers/XaiMcpClient.js.map +1 -1
  139. package/dist/protocols/mcp/security/BrowserTargetGuard.d.ts +14 -0
  140. package/dist/protocols/mcp/security/BrowserTargetGuard.d.ts.map +1 -0
  141. package/dist/protocols/mcp/security/BrowserTargetGuard.js +55 -0
  142. package/dist/protocols/mcp/security/BrowserTargetGuard.js.map +1 -0
  143. package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.d.ts +24 -0
  144. package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.d.ts.map +1 -0
  145. package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.js +33 -0
  146. package/dist/protocols/mcp/security/ExternalMcpRegistrationPolicy.js.map +1 -0
  147. package/dist/protocols/mcp/security/HttpTargetGuard.d.ts.map +1 -1
  148. package/dist/protocols/mcp/security/HttpTargetGuard.js +68 -6
  149. package/dist/protocols/mcp/security/HttpTargetGuard.js.map +1 -1
  150. package/dist/protocols/mcp/security/McpSecurityGuard.d.ts.map +1 -1
  151. package/dist/protocols/mcp/security/McpSecurityGuard.js +7 -5
  152. package/dist/protocols/mcp/security/McpSecurityGuard.js.map +1 -1
  153. package/dist/protocols/mcp/security/McpToolPolicy.d.ts +18 -0
  154. package/dist/protocols/mcp/security/McpToolPolicy.d.ts.map +1 -1
  155. package/dist/protocols/mcp/security/McpToolPolicy.js +60 -0
  156. package/dist/protocols/mcp/security/McpToolPolicy.js.map +1 -1
  157. package/dist/protocols/mcp/services/ExternalMcpServerManager.d.ts +118 -5
  158. package/dist/protocols/mcp/services/ExternalMcpServerManager.d.ts.map +1 -1
  159. package/dist/protocols/mcp/services/ExternalMcpServerManager.js +499 -98
  160. package/dist/protocols/mcp/services/ExternalMcpServerManager.js.map +1 -1
  161. package/dist/protocols/mcp/services/ExternalServerConfigs.d.ts +2 -2
  162. package/dist/protocols/mcp/services/ExternalServerConfigs.d.ts.map +1 -1
  163. package/dist/protocols/mcp/services/ExternalServerConfigs.js +25 -8
  164. package/dist/protocols/mcp/services/ExternalServerConfigs.js.map +1 -1
  165. package/dist/protocols/mcp/tools/AnalyticsTools.d.ts +3 -37
  166. package/dist/protocols/mcp/tools/AnalyticsTools.d.ts.map +1 -1
  167. package/dist/protocols/mcp/tools/AnalyticsTools.js +134 -614
  168. package/dist/protocols/mcp/tools/AnalyticsTools.js.map +1 -1
  169. package/dist/protocols/mcp/tools/CodeAnalysisTools.d.ts.map +1 -1
  170. package/dist/protocols/mcp/tools/CodeAnalysisTools.js +16 -13
  171. package/dist/protocols/mcp/tools/CodeAnalysisTools.js.map +1 -1
  172. package/dist/protocols/mcp/tools/EffectivenessTools.d.ts.map +1 -1
  173. package/dist/protocols/mcp/tools/EffectivenessTools.js +94 -30
  174. package/dist/protocols/mcp/tools/EffectivenessTools.js.map +1 -1
  175. package/dist/protocols/mcp/tools/GitTools.d.ts.map +1 -1
  176. package/dist/protocols/mcp/tools/GitTools.js +9 -5
  177. package/dist/protocols/mcp/tools/GitTools.js.map +1 -1
  178. package/dist/protocols/mcp/tools/InfrastructureTools.d.ts +10 -40
  179. package/dist/protocols/mcp/tools/InfrastructureTools.d.ts.map +1 -1
  180. package/dist/protocols/mcp/tools/InfrastructureTools.js +29 -70
  181. package/dist/protocols/mcp/tools/InfrastructureTools.js.map +1 -1
  182. package/dist/protocols/mcp/tools/JsonTools.d.ts.map +1 -1
  183. package/dist/protocols/mcp/tools/JsonTools.js +4 -4
  184. package/dist/protocols/mcp/tools/JsonTools.js.map +1 -1
  185. package/dist/protocols/mcp/tools/KnowledgeGraphTools.d.ts +55 -592
  186. package/dist/protocols/mcp/tools/KnowledgeGraphTools.d.ts.map +1 -1
  187. package/dist/protocols/mcp/tools/KnowledgeGraphTools.js +169 -119
  188. package/dist/protocols/mcp/tools/KnowledgeGraphTools.js.map +1 -1
  189. package/dist/protocols/mcp/tools/MemorySearchTools.d.ts +6 -6
  190. package/dist/protocols/mcp/tools/MemorySearchTools.d.ts.map +1 -1
  191. package/dist/protocols/mcp/tools/MemorySearchTools.js +107 -39
  192. package/dist/protocols/mcp/tools/MemorySearchTools.js.map +1 -1
  193. package/dist/protocols/mcp/tools/MemoryUtilityTools.d.ts +4 -5
  194. package/dist/protocols/mcp/tools/MemoryUtilityTools.d.ts.map +1 -1
  195. package/dist/protocols/mcp/tools/MemoryUtilityTools.js +59 -208
  196. package/dist/protocols/mcp/tools/MemoryUtilityTools.js.map +1 -1
  197. package/dist/protocols/mcp/tools/PlanningTools.d.ts +2 -1
  198. package/dist/protocols/mcp/tools/PlanningTools.d.ts.map +1 -1
  199. package/dist/protocols/mcp/tools/PlanningTools.js +111 -49
  200. package/dist/protocols/mcp/tools/PlanningTools.js.map +1 -1
  201. package/dist/protocols/mcp/tools/ProjectContextTools.d.ts.map +1 -1
  202. package/dist/protocols/mcp/tools/ProjectContextTools.js +18 -12
  203. package/dist/protocols/mcp/tools/ProjectContextTools.js.map +1 -1
  204. package/dist/protocols/mcp/tools/SafetyTools.d.ts.map +1 -1
  205. package/dist/protocols/mcp/tools/SafetyTools.js +16 -13
  206. package/dist/protocols/mcp/tools/SafetyTools.js.map +1 -1
  207. package/dist/protocols/mcp/tools/SearchProjectTools.d.ts +24 -7
  208. package/dist/protocols/mcp/tools/SearchProjectTools.d.ts.map +1 -1
  209. package/dist/protocols/mcp/tools/SearchProjectTools.js +226 -126
  210. package/dist/protocols/mcp/tools/SearchProjectTools.js.map +1 -1
  211. package/dist/protocols/mcp/tools/TaskPlanningTools.d.ts +0 -32
  212. package/dist/protocols/mcp/tools/TaskPlanningTools.d.ts.map +1 -1
  213. package/dist/protocols/mcp/tools/TaskPlanningTools.js +363 -450
  214. package/dist/protocols/mcp/tools/TaskPlanningTools.js.map +1 -1
  215. package/dist/protocols/mcp/tools/TestTools.d.ts.map +1 -1
  216. package/dist/protocols/mcp/tools/TestTools.js +18 -11
  217. package/dist/protocols/mcp/tools/TestTools.js.map +1 -1
  218. package/dist/protocols/mcp/tools/TypeScriptTools.d.ts.map +1 -1
  219. package/dist/protocols/mcp/tools/TypeScriptTools.js +22 -12
  220. package/dist/protocols/mcp/tools/TypeScriptTools.js.map +1 -1
  221. package/dist/protocols/mcp/tools/UserInputTools.d.ts.map +1 -1
  222. package/dist/protocols/mcp/tools/UserInputTools.js +14 -1
  223. package/dist/protocols/mcp/tools/UserInputTools.js.map +1 -1
  224. package/dist/protocols/mcp/tools/UserMemoryTools.d.ts +3 -1
  225. package/dist/protocols/mcp/tools/UserMemoryTools.d.ts.map +1 -1
  226. package/dist/protocols/mcp/tools/UserMemoryTools.js +27 -62
  227. package/dist/protocols/mcp/tools/UserMemoryTools.js.map +1 -1
  228. package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.d.ts.map +1 -1
  229. package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.js +14 -60
  230. package/dist/protocols/mcp/tools/shell/ShellExecuteHandler.js.map +1 -1
  231. package/dist/protocols/mcp/tools/shell/ShellSandbox.d.ts.map +1 -1
  232. package/dist/protocols/mcp/tools/shell/ShellSandbox.js +9 -27
  233. package/dist/protocols/mcp/tools/shell/ShellSandbox.js.map +1 -1
  234. package/dist/repositories/interfaces/IKnowledgeGraphRepository.d.ts +40 -30
  235. package/dist/repositories/interfaces/IKnowledgeGraphRepository.d.ts.map +1 -1
  236. package/dist/schemas/EventPayloadSchema.d.ts +28 -0
  237. package/dist/schemas/EventPayloadSchema.d.ts.map +1 -1
  238. package/dist/schemas/EventPayloadSchema.js +30 -1
  239. package/dist/schemas/EventPayloadSchema.js.map +1 -1
  240. package/dist/schemas/MxpProtocolSchemas.d.ts +6 -6
  241. package/dist/services/AgentPerformanceService.d.ts +11 -0
  242. package/dist/services/AgentPerformanceService.d.ts.map +1 -1
  243. package/dist/services/AgentPerformanceService.js +59 -33
  244. package/dist/services/AgentPerformanceService.js.map +1 -1
  245. package/dist/services/AutoCorrectionService.d.ts +3 -0
  246. package/dist/services/AutoCorrectionService.d.ts.map +1 -1
  247. package/dist/services/AutoCorrectionService.js +19 -2
  248. package/dist/services/AutoCorrectionService.js.map +1 -1
  249. package/dist/services/BackgroundTaskManager.d.ts +23 -7
  250. package/dist/services/BackgroundTaskManager.d.ts.map +1 -1
  251. package/dist/services/BackgroundTaskManager.js +137 -57
  252. package/dist/services/BackgroundTaskManager.js.map +1 -1
  253. package/dist/services/BrowserManager.d.ts +2 -0
  254. package/dist/services/BrowserManager.d.ts.map +1 -1
  255. package/dist/services/BrowserManager.js +18 -15
  256. package/dist/services/BrowserManager.js.map +1 -1
  257. package/dist/services/ChannelContextMemoryOperations.d.ts +8 -1
  258. package/dist/services/ChannelContextMemoryOperations.d.ts.map +1 -1
  259. package/dist/services/ChannelContextMemoryOperations.js +89 -165
  260. package/dist/services/ChannelContextMemoryOperations.js.map +1 -1
  261. package/dist/services/ChannelContextMessageOperations.d.ts +4 -3
  262. package/dist/services/ChannelContextMessageOperations.d.ts.map +1 -1
  263. package/dist/services/ChannelContextMessageOperations.js +72 -212
  264. package/dist/services/ChannelContextMessageOperations.js.map +1 -1
  265. package/dist/services/MemoryService.d.ts +52 -21
  266. package/dist/services/MemoryService.d.ts.map +1 -1
  267. package/dist/services/MemoryService.js +775 -548
  268. package/dist/services/MemoryService.js.map +1 -1
  269. package/dist/services/PatternLearningService.d.ts +5 -0
  270. package/dist/services/PatternLearningService.d.ts.map +1 -1
  271. package/dist/services/PatternLearningService.js +26 -3
  272. package/dist/services/PatternLearningService.js.map +1 -1
  273. package/dist/services/PerformanceOptimizationService.d.ts +2 -1
  274. package/dist/services/PerformanceOptimizationService.d.ts.map +1 -1
  275. package/dist/services/PerformanceOptimizationService.js +21 -6
  276. package/dist/services/PerformanceOptimizationService.js.map +1 -1
  277. package/dist/services/PredictiveAnalyticsService.d.ts +1 -0
  278. package/dist/services/PredictiveAnalyticsService.d.ts.map +1 -1
  279. package/dist/services/PredictiveAnalyticsService.js +18 -6
  280. package/dist/services/PredictiveAnalyticsService.js.map +1 -1
  281. package/dist/services/ProactiveValidationService.d.ts +6 -0
  282. package/dist/services/ProactiveValidationService.d.ts.map +1 -1
  283. package/dist/services/ProactiveValidationService.js +58 -39
  284. package/dist/services/ProactiveValidationService.js.map +1 -1
  285. package/dist/services/TaskEffectivenessService.d.ts +55 -31
  286. package/dist/services/TaskEffectivenessService.d.ts.map +1 -1
  287. package/dist/services/TaskEffectivenessService.js +243 -125
  288. package/dist/services/TaskEffectivenessService.js.map +1 -1
  289. package/dist/services/ToolExecutionInterceptor.d.ts +4 -0
  290. package/dist/services/ToolExecutionInterceptor.d.ts.map +1 -1
  291. package/dist/services/ToolExecutionInterceptor.js +31 -5
  292. package/dist/services/ToolExecutionInterceptor.js.map +1 -1
  293. package/dist/services/UserInputRequestManager.d.ts +13 -3
  294. package/dist/services/UserInputRequestManager.d.ts.map +1 -1
  295. package/dist/services/UserInputRequestManager.js +42 -6
  296. package/dist/services/UserInputRequestManager.js.map +1 -1
  297. package/dist/services/UserMemoryService.d.ts +2 -0
  298. package/dist/services/UserMemoryService.d.ts.map +1 -1
  299. package/dist/services/UserMemoryService.js +9 -4
  300. package/dist/services/UserMemoryService.js.map +1 -1
  301. package/dist/services/ValidationAnalyticsService.d.ts +4 -0
  302. package/dist/services/ValidationAnalyticsService.d.ts.map +1 -1
  303. package/dist/services/ValidationAnalyticsService.js +30 -8
  304. package/dist/services/ValidationAnalyticsService.js.map +1 -1
  305. package/dist/services/ValidationCacheService.d.ts +3 -1
  306. package/dist/services/ValidationCacheService.d.ts.map +1 -1
  307. package/dist/services/ValidationCacheService.js +25 -4
  308. package/dist/services/ValidationCacheService.js.map +1 -1
  309. package/dist/services/ValidationMiddleware.d.ts +7 -0
  310. package/dist/services/ValidationMiddleware.d.ts.map +1 -1
  311. package/dist/services/ValidationMiddleware.js +53 -10
  312. package/dist/services/ValidationMiddleware.js.map +1 -1
  313. package/dist/services/ValidationPerformanceService.d.ts +3 -0
  314. package/dist/services/ValidationPerformanceService.d.ts.map +1 -1
  315. package/dist/services/ValidationPerformanceService.js +28 -11
  316. package/dist/services/ValidationPerformanceService.js.map +1 -1
  317. package/dist/services/WebSearchService.d.ts.map +1 -1
  318. package/dist/services/WebSearchService.js +9 -0
  319. package/dist/services/WebSearchService.js.map +1 -1
  320. package/dist/services/dag/TaskDagService.d.ts +3 -0
  321. package/dist/services/dag/TaskDagService.d.ts.map +1 -1
  322. package/dist/services/dag/TaskDagService.js +18 -0
  323. package/dist/services/dag/TaskDagService.js.map +1 -1
  324. package/dist/services/kg/EntityQValueManager.d.ts +3 -1
  325. package/dist/services/kg/EntityQValueManager.d.ts.map +1 -1
  326. package/dist/services/kg/EntityQValueManager.js +10 -10
  327. package/dist/services/kg/EntityQValueManager.js.map +1 -1
  328. package/dist/services/kg/GraphSurpriseCalculator.d.ts +0 -4
  329. package/dist/services/kg/GraphSurpriseCalculator.d.ts.map +1 -1
  330. package/dist/services/kg/GraphSurpriseCalculator.js +0 -9
  331. package/dist/services/kg/GraphSurpriseCalculator.js.map +1 -1
  332. package/dist/services/kg/KnowledgeGraphService.d.ts +12 -12
  333. package/dist/services/kg/KnowledgeGraphService.d.ts.map +1 -1
  334. package/dist/services/kg/KnowledgeGraphService.js +43 -51
  335. package/dist/services/kg/KnowledgeGraphService.js.map +1 -1
  336. package/dist/services/kg/OrparGraphIntegration.d.ts.map +1 -1
  337. package/dist/services/kg/OrparGraphIntegration.js +6 -5
  338. package/dist/services/kg/OrparGraphIntegration.js.map +1 -1
  339. package/dist/services/orpar-memory/CycleConsolidationTrigger.d.ts +1 -0
  340. package/dist/services/orpar-memory/CycleConsolidationTrigger.d.ts.map +1 -1
  341. package/dist/services/orpar-memory/CycleConsolidationTrigger.js +8 -1
  342. package/dist/services/orpar-memory/CycleConsolidationTrigger.js.map +1 -1
  343. package/dist/services/orpar-memory/OrparMemoryCoordinator.d.ts +8 -1
  344. package/dist/services/orpar-memory/OrparMemoryCoordinator.d.ts.map +1 -1
  345. package/dist/services/orpar-memory/OrparMemoryCoordinator.js +93 -45
  346. package/dist/services/orpar-memory/OrparMemoryCoordinator.js.map +1 -1
  347. package/dist/services/orpar-memory/SurpriseOrparAdapter.d.ts +1 -0
  348. package/dist/services/orpar-memory/SurpriseOrparAdapter.d.ts.map +1 -1
  349. package/dist/services/orpar-memory/SurpriseOrparAdapter.js +8 -1
  350. package/dist/services/orpar-memory/SurpriseOrparAdapter.js.map +1 -1
  351. package/dist/types/ChannelContext.d.ts +2 -1
  352. package/dist/types/ChannelContext.d.ts.map +1 -1
  353. package/dist/types/EffectivenessTypes.d.ts +4 -1
  354. package/dist/types/EffectivenessTypes.d.ts.map +1 -1
  355. package/dist/types/TaskCompletionTypes.d.ts +7 -5
  356. package/dist/types/TaskCompletionTypes.d.ts.map +1 -1
  357. package/dist/types/TaskTypes.d.ts +8 -1
  358. package/dist/types/TaskTypes.d.ts.map +1 -1
  359. package/dist/utils/GlobMatcher.d.ts +37 -0
  360. package/dist/utils/GlobMatcher.d.ts.map +1 -0
  361. package/dist/utils/GlobMatcher.js +131 -0
  362. package/dist/utils/GlobMatcher.js.map +1 -0
  363. package/package.json +1 -1
  364. package/src/config/ModelContextLimits.ts +7 -1
  365. package/src/constants/CoreTools.ts +6 -5
  366. package/src/constants/DefaultPhaseProfiles.ts +29 -0
  367. package/src/constants/ReservedIdentities.ts +51 -0
  368. package/src/database/adapters/mongodb/MongoKnowledgeGraphRepository.ts +115 -36
  369. package/src/events/ClientEventBus.ts +117 -48
  370. package/src/events/EventBus.ts +32 -2
  371. package/src/events/EventBusBase.ts +132 -39
  372. package/src/events/EventNames.ts +43 -36
  373. package/src/events/PublicEvents.ts +8 -0
  374. package/src/events/ServerEventBus.ts +9 -128
  375. package/src/events/event-definitions/ControlLoopEvents.ts +12 -0
  376. package/src/events/event-definitions/SdkEvents.ts +58 -0
  377. package/src/events/event-definitions/TaskEvents.ts +2 -2
  378. package/src/index.ts +15 -0
  379. package/src/interfaces/AgentInterfaces.ts +5 -0
  380. package/src/interfaces/ChannelConfig.ts +2 -2
  381. package/src/interfaces/ConversationMessage.ts +5 -0
  382. package/src/interfaces/IMemoryPersistence.ts +55 -1
  383. package/src/interfaces/SocketServiceInterface.ts +3 -2
  384. package/src/interfaces/TaskInterfaces.ts +16 -1
  385. package/src/models/agent.ts +0 -6
  386. package/src/models/agentIdentityReservation.ts +77 -0
  387. package/src/models/channel.ts +2 -0
  388. package/src/models/channelKey.ts +10 -0
  389. package/src/models/memory.ts +18 -19
  390. package/src/models/memoryStrata.ts +9 -23
  391. package/src/models/plan.ts +3 -3
  392. package/src/models/taskEffectiveness.ts +9 -2
  393. package/src/models/user.ts +12 -0
  394. package/src/protocols/mcp/LlmTestEnvironmentGuard.ts +30 -0
  395. package/src/protocols/mcp/McpServerTypes.ts +9 -0
  396. package/src/protocols/mcp/providers/AnthropicMcpClient.ts +2 -0
  397. package/src/protocols/mcp/providers/AzureOpenAiMcpClient.ts +1 -0
  398. package/src/protocols/mcp/providers/BaseMcpClient.ts +13 -0
  399. package/src/protocols/mcp/providers/CustomMcpClient.ts +7 -0
  400. package/src/protocols/mcp/providers/GeminiMcpClient.ts +2 -0
  401. package/src/protocols/mcp/providers/OllamaMcpClient.ts +3 -1
  402. package/src/protocols/mcp/providers/OpenAiMcpClient.ts +2 -0
  403. package/src/protocols/mcp/providers/OpenRouterMcpClient.ts +3 -0
  404. package/src/protocols/mcp/providers/XaiMcpClient.ts +2 -0
  405. package/src/protocols/mcp/security/BrowserTargetGuard.ts +64 -0
  406. package/src/protocols/mcp/security/ExternalMcpRegistrationPolicy.ts +38 -0
  407. package/src/protocols/mcp/security/HttpTargetGuard.ts +77 -6
  408. package/src/protocols/mcp/security/McpSecurityGuard.ts +7 -5
  409. package/src/protocols/mcp/security/McpToolPolicy.ts +74 -0
  410. package/src/protocols/mcp/services/ExternalMcpServerManager.ts +656 -111
  411. package/src/protocols/mcp/services/ExternalServerConfigs.ts +26 -8
  412. package/src/protocols/mcp/tools/AnalyticsTools.ts +167 -641
  413. package/src/protocols/mcp/tools/CodeAnalysisTools.ts +44 -14
  414. package/src/protocols/mcp/tools/EffectivenessTools.ts +185 -45
  415. package/src/protocols/mcp/tools/GitTools.ts +15 -5
  416. package/src/protocols/mcp/tools/InfrastructureTools.ts +42 -90
  417. package/src/protocols/mcp/tools/JsonTools.ts +7 -4
  418. package/src/protocols/mcp/tools/KnowledgeGraphTools.ts +313 -164
  419. package/src/protocols/mcp/tools/MemorySearchTools.ts +158 -46
  420. package/src/protocols/mcp/tools/MemoryUtilityTools.ts +85 -232
  421. package/src/protocols/mcp/tools/PlanningTools.ts +137 -59
  422. package/src/protocols/mcp/tools/ProjectContextTools.ts +33 -12
  423. package/src/protocols/mcp/tools/SafetyTools.ts +49 -13
  424. package/src/protocols/mcp/tools/SearchProjectTools.ts +294 -153
  425. package/src/protocols/mcp/tools/TaskPlanningTools.ts +437 -514
  426. package/src/protocols/mcp/tools/TestTools.ts +41 -11
  427. package/src/protocols/mcp/tools/TypeScriptTools.ts +61 -12
  428. package/src/protocols/mcp/tools/UserInputTools.ts +15 -1
  429. package/src/protocols/mcp/tools/UserMemoryTools.ts +27 -62
  430. package/src/protocols/mcp/tools/shell/ShellExecuteHandler.ts +26 -84
  431. package/src/protocols/mcp/tools/shell/ShellSandbox.ts +13 -31
  432. package/src/repositories/interfaces/IKnowledgeGraphRepository.ts +45 -27
  433. package/src/schemas/EventPayloadSchema.ts +45 -1
  434. package/src/services/AgentPerformanceService.ts +85 -36
  435. package/src/services/AutoCorrectionService.ts +25 -6
  436. package/src/services/BackgroundTaskManager.ts +183 -76
  437. package/src/services/BrowserManager.ts +20 -16
  438. package/src/services/ChannelContextMemoryOperations.ts +169 -202
  439. package/src/services/ChannelContextMessageOperations.ts +112 -274
  440. package/src/services/MemoryService.ts +1053 -760
  441. package/src/services/PatternLearningService.ts +32 -7
  442. package/src/services/PerformanceOptimizationService.ts +26 -9
  443. package/src/services/PredictiveAnalyticsService.ts +23 -10
  444. package/src/services/ProactiveValidationService.ts +66 -40
  445. package/src/services/TaskEffectivenessService.ts +421 -206
  446. package/src/services/ToolExecutionInterceptor.ts +40 -9
  447. package/src/services/UserInputRequestManager.ts +51 -6
  448. package/src/services/UserMemoryService.ts +12 -3
  449. package/src/services/ValidationAnalyticsService.ts +36 -11
  450. package/src/services/ValidationCacheService.ts +30 -7
  451. package/src/services/ValidationMiddleware.ts +62 -14
  452. package/src/services/ValidationPerformanceService.ts +47 -25
  453. package/src/services/WebSearchService.ts +16 -4
  454. package/src/services/dag/TaskDagService.ts +20 -1
  455. package/src/services/kg/EntityQValueManager.ts +21 -10
  456. package/src/services/kg/GraphSurpriseCalculator.ts +0 -14
  457. package/src/services/kg/KnowledgeGraphService.ts +56 -48
  458. package/src/services/kg/OrparGraphIntegration.ts +11 -5
  459. package/src/services/orpar-memory/CycleConsolidationTrigger.ts +10 -1
  460. package/src/services/orpar-memory/OrparMemoryCoordinator.ts +142 -71
  461. package/src/services/orpar-memory/SurpriseOrparAdapter.ts +10 -1
  462. package/src/types/ChannelContext.ts +3 -1
  463. package/src/types/EffectivenessTypes.ts +6 -2
  464. package/src/types/TaskCompletionTypes.ts +9 -9
  465. package/src/types/TaskTypes.ts +12 -1
  466. package/src/utils/GlobMatcher.ts +157 -0
@@ -40,15 +40,27 @@ import { TOOL_CATEGORIES } from '../../../constants/ToolNames.js';
40
40
  import { defineTool, ToolRunContext } from '../defineTool.js';
41
41
  import { ToolError } from '../ToolError.js';
42
42
  import { executeShellCommand } from './InfrastructureTools.js';
43
+ import { resolveWorkspacePath } from '../security/McpToolPolicy.js';
43
44
 
44
45
  /** Exit code the shell reports when a command could not be found or spawned. */
45
46
  const COMMAND_NOT_FOUND = 127;
46
47
 
47
48
  const workingDirectoryProperty = {
48
49
  type: 'string',
49
- description: 'Working directory path (defaults to the server working directory)'
50
+ description: 'Working directory under MXF_WORKSPACE_ROOT (defaults to MXF_WORKSPACE_ROOT)'
50
51
  };
51
52
 
53
+ function resolveTestFiles(
54
+ inputs: string[] | undefined,
55
+ workingDirectory: string,
56
+ consumer: string
57
+ ): string[] {
58
+ return (inputs ?? []).map(input => resolveWorkspacePath(
59
+ path.resolve(workingDirectory, input),
60
+ consumer
61
+ ));
62
+ }
63
+
52
64
  /** Outcome of a test run, in the shape every runner here reports. */
53
65
  export interface TestRunResult {
54
66
  runner: 'jest' | 'mocha' | 'vitest';
@@ -80,7 +92,7 @@ async function runTestRunner(
80
92
  channelId: context.channelId,
81
93
  requestId: context.requestId
82
94
  },
83
- workingDirectory: workingDirectory || process.cwd(),
95
+ workingDirectory,
84
96
  captureOutput: true
85
97
  });
86
98
 
@@ -197,6 +209,10 @@ export const jestTestTool = defineTool<
197
209
  }
198
210
  },
199
211
  run: async (input, context) => {
212
+ const workingDirectory = resolveWorkspacePath(
213
+ input.workingDirectory,
214
+ 'test_jest workingDirectory'
215
+ );
200
216
  const args = ['--no-watchman', '--passWithNoTests'];
201
217
 
202
218
  if (input.coverage) {
@@ -212,10 +228,10 @@ export const jestTestTool = defineTool<
212
228
  args.push('--testNamePattern', input.testNamePattern);
213
229
  }
214
230
  if (input.testFiles && input.testFiles.length > 0) {
215
- args.push(...input.testFiles);
231
+ args.push(...resolveTestFiles(input.testFiles, workingDirectory, 'test_jest file'));
216
232
  }
217
233
 
218
- return runTestRunner('jest', args, input.workingDirectory, context);
234
+ return runTestRunner('jest', args, workingDirectory, context);
219
235
  }
220
236
  });
221
237
 
@@ -265,6 +281,10 @@ export const mochaTestTool = defineTool<
265
281
  }
266
282
  },
267
283
  run: async (input, context) => {
284
+ const workingDirectory = resolveWorkspacePath(
285
+ input.workingDirectory,
286
+ 'test_mocha workingDirectory'
287
+ );
268
288
  const args: string[] = [];
269
289
 
270
290
  if (input.reporter) {
@@ -280,10 +300,10 @@ export const mochaTestTool = defineTool<
280
300
  args.push('--recursive');
281
301
  }
282
302
  if (input.testFiles && input.testFiles.length > 0) {
283
- args.push(...input.testFiles);
303
+ args.push(...resolveTestFiles(input.testFiles, workingDirectory, 'test_mocha file'));
284
304
  }
285
305
 
286
- return runTestRunner('mocha', args, input.workingDirectory, context);
306
+ return runTestRunner('mocha', args, workingDirectory, context);
287
307
  }
288
308
  });
289
309
 
@@ -322,6 +342,10 @@ export const vitestTestTool = defineTool<
322
342
  }
323
343
  },
324
344
  run: async (input, context) => {
345
+ const workingDirectory = resolveWorkspacePath(
346
+ input.workingDirectory,
347
+ 'test_vitest workingDirectory'
348
+ );
325
349
  // `run` is Vitest's non-watching mode. Without it Vitest watches by
326
350
  // default and the process would never exit.
327
351
  const args = ['run'];
@@ -333,10 +357,10 @@ export const vitestTestTool = defineTool<
333
357
  args.push('--reporter', input.reporter);
334
358
  }
335
359
  if (input.testFiles && input.testFiles.length > 0) {
336
- args.push(...input.testFiles);
360
+ args.push(...resolveTestFiles(input.testFiles, workingDirectory, 'test_vitest file'));
337
361
  }
338
362
 
339
- return runTestRunner('vitest', args, input.workingDirectory, context);
363
+ return runTestRunner('vitest', args, workingDirectory, context);
340
364
  }
341
365
  });
342
366
 
@@ -348,7 +372,10 @@ export const vitestTestTool = defineTool<
348
372
  * steps later.
349
373
  */
350
374
  async function detectFramework(workingDirectory: string): Promise<'jest' | 'mocha' | 'vitest'> {
351
- const packageJsonPath = path.join(workingDirectory, 'package.json');
375
+ const packageJsonPath = resolveWorkspacePath(
376
+ path.join(workingDirectory, 'package.json'),
377
+ 'test_runner package.json'
378
+ );
352
379
 
353
380
  let raw: string;
354
381
  try {
@@ -426,7 +453,10 @@ export const testRunnerTool = defineTool<
426
453
  }
427
454
  },
428
455
  run: async (input, context) => {
429
- const workingDirectory = input.workingDirectory || process.cwd();
456
+ const workingDirectory = resolveWorkspacePath(
457
+ input.workingDirectory,
458
+ 'test_runner workingDirectory'
459
+ );
430
460
  const requested = input.framework ?? 'auto';
431
461
 
432
462
  const detected = requested === 'auto';
@@ -459,7 +489,7 @@ export const testRunnerTool = defineTool<
459
489
  }
460
490
 
461
491
  if (input.testFiles && input.testFiles.length > 0) {
462
- args.push(...input.testFiles);
492
+ args.push(...resolveTestFiles(input.testFiles, workingDirectory, 'test_runner file'));
463
493
  }
464
494
 
465
495
  const result = await runTestRunner(framework, args, workingDirectory, context);
@@ -38,15 +38,28 @@ import { TOOL_CATEGORIES } from '../../../constants/ToolNames.js';
38
38
  import { defineTool, ToolRunContext } from '../defineTool.js';
39
39
  import { ToolError } from '../ToolError.js';
40
40
  import { executeShellCommand, ShellCommandResult } from './InfrastructureTools.js';
41
+ import * as path from 'path';
42
+ import { resolveWorkspacePath } from '../security/McpToolPolicy.js';
41
43
 
42
44
  /** Exit code the shell reports when a command could not be found or spawned. */
43
45
  const COMMAND_NOT_FOUND = 127;
44
46
 
45
47
  const workingDirectoryProperty = {
46
48
  type: 'string',
47
- description: 'Working directory path (defaults to the server working directory)'
49
+ description: 'Working directory under MXF_WORKSPACE_ROOT (defaults to MXF_WORKSPACE_ROOT)'
48
50
  };
49
51
 
52
+ function resolveInputPaths(
53
+ inputs: string[] | undefined,
54
+ workingDirectory: string,
55
+ consumer: string
56
+ ): string[] {
57
+ return (inputs ?? []).map(input => resolveWorkspacePath(
58
+ path.resolve(workingDirectory, input),
59
+ consumer
60
+ ));
61
+ }
62
+
50
63
  /**
51
64
  * Run one of the node toolchain binaries via npx.
52
65
  *
@@ -64,7 +77,7 @@ async function runNpx(
64
77
  channelId: context.channelId,
65
78
  requestId: context.requestId
66
79
  },
67
- workingDirectory: workingDirectory || process.cwd(),
80
+ workingDirectory,
68
81
  captureOutput: true
69
82
  });
70
83
 
@@ -144,12 +157,20 @@ export const typescriptCheckTool = defineTool<
144
157
  }
145
158
  },
146
159
  run: async (input, context) => {
160
+ const workingDirectory = resolveWorkspacePath(
161
+ input.workingDirectory,
162
+ 'typescript_check workingDirectory'
163
+ );
147
164
  const tscArgs = ['tsc', '--noEmit', '--pretty', 'false'];
148
165
  if (input.files && input.files.length > 0) {
149
- tscArgs.push(...input.files);
166
+ tscArgs.push(...resolveInputPaths(
167
+ input.files,
168
+ workingDirectory,
169
+ 'typescript_check file'
170
+ ));
150
171
  }
151
172
 
152
- const result = await runNpx(tscArgs, input.workingDirectory, context);
173
+ const result = await runNpx(tscArgs, workingDirectory, context);
153
174
 
154
175
  // tsc writes diagnostics to stdout and exits 1 when it finds any. That is
155
176
  // the tool working, not the tool failing.
@@ -195,11 +216,15 @@ export const typescriptBuildTool = defineTool<
195
216
  },
196
217
  run: async (input, context) => {
197
218
  const startedAt = Date.now();
219
+ const workingDirectory = resolveWorkspacePath(
220
+ input.workingDirectory,
221
+ 'typescript_build workingDirectory'
222
+ );
198
223
 
199
224
  if (input.clean) {
200
225
  const cleanResult = await runNpx(
201
226
  ['tsc', '--build', '--clean'],
202
- input.workingDirectory,
227
+ workingDirectory,
203
228
  context
204
229
  );
205
230
  // A failed clean leaves stale output behind, which makes the build's
@@ -212,7 +237,7 @@ export const typescriptBuildTool = defineTool<
212
237
  }
213
238
  }
214
239
 
215
- const result = await runNpx(['tsc', '--build'], input.workingDirectory, context);
240
+ const result = await runNpx(['tsc', '--build'], workingDirectory, context);
216
241
 
217
242
  const errors = (result.stdout ?? '')
218
243
  .split('\n')
@@ -255,15 +280,23 @@ export const typescriptFormatTool = defineTool<
255
280
  },
256
281
  run: async (input, context) => {
257
282
  const mode: 'check' | 'write' = input.check ? 'check' : 'write';
283
+ const workingDirectory = resolveWorkspacePath(
284
+ input.workingDirectory,
285
+ 'typescript_format workingDirectory'
286
+ );
258
287
  const prettierArgs = ['prettier', input.check ? '--check' : '--write'];
259
288
 
260
289
  if (input.files && input.files.length > 0) {
261
- prettierArgs.push(...input.files);
290
+ prettierArgs.push(...resolveInputPaths(
291
+ input.files,
292
+ workingDirectory,
293
+ 'typescript_format file'
294
+ ));
262
295
  } else {
263
296
  prettierArgs.push('**/*.{ts,tsx,js,jsx}');
264
297
  }
265
298
 
266
- const result = await runNpx(prettierArgs, input.workingDirectory, context);
299
+ const result = await runNpx(prettierArgs, workingDirectory, context);
267
300
 
268
301
  // In check mode prettier exits 1 when files need formatting — a finding,
269
302
  // not a failure. In write mode a non-zero exit means it could not write.
@@ -314,18 +347,26 @@ export const typescriptLintTool = defineTool<
314
347
  }
315
348
  },
316
349
  run: async (input, context) => {
350
+ const workingDirectory = resolveWorkspacePath(
351
+ input.workingDirectory,
352
+ 'typescript_lint workingDirectory'
353
+ );
317
354
  const eslintArgs = ['eslint', '--format', 'json'];
318
355
  if (input.fix) {
319
356
  eslintArgs.push('--fix');
320
357
  }
321
358
 
322
359
  if (input.files && input.files.length > 0) {
323
- eslintArgs.push(...input.files);
360
+ eslintArgs.push(...resolveInputPaths(
361
+ input.files,
362
+ workingDirectory,
363
+ 'typescript_lint file'
364
+ ));
324
365
  } else {
325
366
  eslintArgs.push('**/*.{ts,tsx,js,jsx}');
326
367
  }
327
368
 
328
- const result = await runNpx(eslintArgs, input.workingDirectory, context);
369
+ const result = await runNpx(eslintArgs, workingDirectory, context);
329
370
 
330
371
  // ESLint exits 1 when it finds errors, but always prints its JSON report.
331
372
  // No parseable report means ESLint itself fell over — that is a failure,
@@ -386,16 +427,24 @@ export const typescriptTestTool = defineTool<
386
427
  }
387
428
  },
388
429
  run: async (input, context) => {
430
+ const workingDirectory = resolveWorkspacePath(
431
+ input.workingDirectory,
432
+ 'typescript_test workingDirectory'
433
+ );
389
434
  const jestArgs = ['jest', '--no-watchman', '--passWithNoTests'];
390
435
 
391
436
  if (input.coverage) {
392
437
  jestArgs.push('--coverage');
393
438
  }
394
439
  if (input.testFiles && input.testFiles.length > 0) {
395
- jestArgs.push(...input.testFiles);
440
+ jestArgs.push(...resolveInputPaths(
441
+ input.testFiles,
442
+ workingDirectory,
443
+ 'typescript_test file'
444
+ ));
396
445
  }
397
446
 
398
- const result = await runNpx(jestArgs, input.workingDirectory, context);
447
+ const result = await runNpx(jestArgs, workingDirectory, context);
399
448
 
400
449
  // Jest writes its summary to stderr, not stdout.
401
450
  const output = [result.stdout, result.stderr].filter(Boolean).join('\n');
@@ -343,8 +343,22 @@ Use after calling request_user_input to retrieve the response.`,
343
343
  context: McpToolHandlerContext
344
344
  ): Promise<McpToolHandlerResult> => {
345
345
  try {
346
+ const agentId = context.agentId as AgentId;
347
+ const channelId = context.channelId as ChannelId;
348
+ if (!agentId || !channelId) {
349
+ return {
350
+ content: {
351
+ type: 'text',
352
+ data: JSON.stringify({
353
+ success: false,
354
+ error: 'Agent ID and channel ID are required to read a user input response'
355
+ })
356
+ }
357
+ };
358
+ }
359
+
346
360
  const manager = UserInputRequestManager.getInstance();
347
- const result = manager.getRequest(input.requestId);
361
+ const result = manager.getRequest(input.requestId, agentId, channelId);
348
362
 
349
363
  if (!result) {
350
364
  return {
@@ -45,12 +45,17 @@ const logger = new Logger('info', 'UserMemoryTools', 'server');
45
45
  /** Valid memory types — used for input validation across all tools */
46
46
  const VALID_TYPES: UserMemoryType[] = ['user', 'feedback', 'project', 'reference'];
47
47
 
48
- /**
49
- * Resolves the userId from context. Prefers channelId (session-scoped) over
50
- * agentId, falling back to 'anonymous' if neither is set.
51
- */
52
- function getUserId(context: McpToolHandlerContext): string {
53
- return context.channelId || context.agentId || 'anonymous';
48
+ /** Derive a collision-safe persistent scope from authenticated identity only. */
49
+ export function getUserMemoryScopeKey(context: McpToolHandlerContext): string {
50
+ if (typeof context.agentId !== 'string' || context.agentId.trim().length === 0 ||
51
+ typeof context.channelId !== 'string' || context.channelId.trim().length === 0) {
52
+ throw new Error('User memory requires exact authenticated agent and channel identity');
53
+ }
54
+ if (context.agentId !== context.agentId.trim() ||
55
+ context.channelId !== context.channelId.trim()) {
56
+ throw new Error('User memory identity must not contain surrounding whitespace');
57
+ }
58
+ return JSON.stringify([context.agentId, context.channelId]);
54
59
  }
55
60
 
56
61
  // ─── Tool: user_memory_save ───────────────────────────────────────────────────
@@ -99,27 +104,22 @@ export const userMemorySaveTool: McpToolDefinition = {
99
104
 
100
105
  // Validate type is a recognised value
101
106
  if (!VALID_TYPES.includes(type)) {
102
- return {
103
- content: {
104
- type: 'text',
105
- data: `Invalid type "${type}". Must be one of: ${VALID_TYPES.join(', ')}.`
106
- }
107
- };
107
+ throw new Error(`Invalid type "${type}". Must be one of: ${VALID_TYPES.join(', ')}.`);
108
108
  }
109
109
 
110
110
  // Validate required string fields are non-empty
111
111
  if (!title?.trim()) {
112
- return { content: { type: 'text', data: 'title must not be empty.' } };
112
+ throw new Error('title must not be empty.');
113
113
  }
114
114
  if (!description?.trim()) {
115
- return { content: { type: 'text', data: 'description must not be empty.' } };
115
+ throw new Error('description must not be empty.');
116
116
  }
117
117
  if (!content?.trim()) {
118
- return { content: { type: 'text', data: 'content must not be empty.' } };
118
+ throw new Error('content must not be empty.');
119
119
  }
120
120
 
121
121
  try {
122
- const userId = getUserId(context);
122
+ const userId = getUserMemoryScopeKey(context);
123
123
  const service = UserMemoryService.getInstance();
124
124
  await service.save(userId, { type, title, description, content });
125
125
  logger.info(`Saved user memory "${title}" (${type}) for userId=${userId}`);
@@ -132,12 +132,7 @@ export const userMemorySaveTool: McpToolDefinition = {
132
132
  } catch (err) {
133
133
  const message = err instanceof Error ? err.message : String(err);
134
134
  logger.error('user_memory_save failed', err);
135
- return {
136
- content: {
137
- type: 'text',
138
- data: `Failed to save memory: ${message}`
139
- }
140
- };
135
+ throw new Error(`Failed to save memory: ${message}`);
141
136
  }
142
137
  }
143
138
  };
@@ -184,24 +179,19 @@ export const userMemoryRecallTool: McpToolDefinition = {
184
179
 
185
180
  // Validate query is non-empty
186
181
  if (!query?.trim()) {
187
- return { content: { type: 'text', data: 'query must not be empty.' } };
182
+ throw new Error('query must not be empty.');
188
183
  }
189
184
 
190
185
  // Validate optional type
191
186
  if (type !== undefined && !VALID_TYPES.includes(type)) {
192
- return {
193
- content: {
194
- type: 'text',
195
- data: `Invalid type "${type}". Must be one of: ${VALID_TYPES.join(', ')}.`
196
- }
197
- };
187
+ throw new Error(`Invalid type "${type}". Must be one of: ${VALID_TYPES.join(', ')}.`);
198
188
  }
199
189
 
200
190
  // Clamp limit to 1–50
201
191
  const resolvedLimit = limit !== undefined ? Math.min(50, Math.max(1, limit)) : 5;
202
192
 
203
193
  try {
204
- const userId = getUserId(context);
194
+ const userId = getUserMemoryScopeKey(context);
205
195
  const service = UserMemoryService.getInstance();
206
196
  const results = await service.recall(userId, query, { type, limit: resolvedLimit });
207
197
 
@@ -227,12 +217,7 @@ export const userMemoryRecallTool: McpToolDefinition = {
227
217
  } catch (err) {
228
218
  const message = err instanceof Error ? err.message : String(err);
229
219
  logger.error('user_memory_recall failed', err);
230
- return {
231
- content: {
232
- type: 'text',
233
- data: `Failed to recall memories: ${message}`
234
- }
235
- };
220
+ throw new Error(`Failed to recall memories: ${message}`);
236
221
  }
237
222
  }
238
223
  };
@@ -269,16 +254,11 @@ export const userMemoryForgetTool: McpToolDefinition = {
269
254
 
270
255
  // Require at least one deletion target
271
256
  if (!memoryId?.trim() && !searchTerm?.trim()) {
272
- return {
273
- content: {
274
- type: 'text',
275
- data: 'At least one of memoryId or searchTerm must be provided.'
276
- }
277
- };
257
+ throw new Error('At least one of memoryId or searchTerm must be provided.');
278
258
  }
279
259
 
280
260
  try {
281
- const userId = getUserId(context);
261
+ const userId = getUserMemoryScopeKey(context);
282
262
  const service = UserMemoryService.getInstance();
283
263
  const { deleted } = await service.forget(userId, {
284
264
  memoryId: memoryId?.trim() || undefined,
@@ -300,12 +280,7 @@ export const userMemoryForgetTool: McpToolDefinition = {
300
280
  } catch (err) {
301
281
  const message = err instanceof Error ? err.message : String(err);
302
282
  logger.error('user_memory_forget failed', err);
303
- return {
304
- content: {
305
- type: 'text',
306
- data: `Failed to delete memory: ${message}`
307
- }
308
- };
283
+ throw new Error(`Failed to delete memory: ${message}`);
309
284
  }
310
285
  }
311
286
  };
@@ -338,16 +313,11 @@ export const userMemoryShakeTool: McpToolDefinition = {
338
313
 
339
314
  // Validate thresholdDays if provided
340
315
  if (thresholdDays !== undefined && (typeof thresholdDays !== 'number' || thresholdDays < 1)) {
341
- return {
342
- content: {
343
- type: 'text',
344
- data: 'thresholdDays must be a number >= 1.'
345
- }
346
- };
316
+ throw new Error('thresholdDays must be a number >= 1.');
347
317
  }
348
318
 
349
319
  try {
350
- const userId = getUserId(context);
320
+ const userId = getUserMemoryScopeKey(context);
351
321
  const service = UserMemoryService.getInstance();
352
322
  const stale = await service.shake(userId, thresholdDays);
353
323
 
@@ -376,12 +346,7 @@ export const userMemoryShakeTool: McpToolDefinition = {
376
346
  } catch (err) {
377
347
  const message = err instanceof Error ? err.message : String(err);
378
348
  logger.error('user_memory_shake failed', err);
379
- return {
380
- content: {
381
- type: 'text',
382
- data: `Failed to shake memories: ${message}`
383
- }
384
- };
349
+ throw new Error(`Failed to shake memories: ${message}`);
385
350
  }
386
351
  }
387
352
  };