@claude-flow/shared 3.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (541) hide show
  1. package/.agentic-flow/intelligence.json +16 -0
  2. package/README.md +323 -0
  3. package/__tests__/coverage/base.css +224 -0
  4. package/__tests__/coverage/block-navigation.js +87 -0
  5. package/__tests__/coverage/coverage-final.json +50 -0
  6. package/__tests__/coverage/favicon.png +0 -0
  7. package/__tests__/coverage/index.html +326 -0
  8. package/__tests__/coverage/lcov-report/base.css +224 -0
  9. package/__tests__/coverage/lcov-report/block-navigation.js +87 -0
  10. package/__tests__/coverage/lcov-report/favicon.png +0 -0
  11. package/__tests__/coverage/lcov-report/index.html +326 -0
  12. package/__tests__/coverage/lcov-report/prettify.css +1 -0
  13. package/__tests__/coverage/lcov-report/prettify.js +2 -0
  14. package/__tests__/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  15. package/__tests__/coverage/lcov-report/sorter.js +210 -0
  16. package/__tests__/coverage/lcov-report/src/core/config/defaults.ts.html +706 -0
  17. package/__tests__/coverage/lcov-report/src/core/config/index.html +161 -0
  18. package/__tests__/coverage/lcov-report/src/core/config/loader.ts.html +898 -0
  19. package/__tests__/coverage/lcov-report/src/core/config/schema.ts.html +649 -0
  20. package/__tests__/coverage/lcov-report/src/core/config/validator.ts.html +712 -0
  21. package/__tests__/coverage/lcov-report/src/core/event-bus.ts.html +793 -0
  22. package/__tests__/coverage/lcov-report/src/core/index.html +116 -0
  23. package/__tests__/coverage/lcov-report/src/core/interfaces/event.interface.ts.html +886 -0
  24. package/__tests__/coverage/lcov-report/src/core/interfaces/index.html +116 -0
  25. package/__tests__/coverage/lcov-report/src/core/orchestrator/event-coordinator.ts.html +451 -0
  26. package/__tests__/coverage/lcov-report/src/core/orchestrator/health-monitor.ts.html +727 -0
  27. package/__tests__/coverage/lcov-report/src/core/orchestrator/index.html +176 -0
  28. package/__tests__/coverage/lcov-report/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
  29. package/__tests__/coverage/lcov-report/src/core/orchestrator/session-manager.ts.html +922 -0
  30. package/__tests__/coverage/lcov-report/src/core/orchestrator/task-manager.ts.html +1036 -0
  31. package/__tests__/coverage/lcov-report/src/events/domain-events.ts.html +1837 -0
  32. package/__tests__/coverage/lcov-report/src/events/event-store.ts.html +1849 -0
  33. package/__tests__/coverage/lcov-report/src/events/example-usage.ts.html +964 -0
  34. package/__tests__/coverage/lcov-report/src/events/index.html +176 -0
  35. package/__tests__/coverage/lcov-report/src/events/projections.ts.html +1768 -0
  36. package/__tests__/coverage/lcov-report/src/events/state-reconstructor.ts.html +1132 -0
  37. package/__tests__/coverage/lcov-report/src/events.ts.html +1186 -0
  38. package/__tests__/coverage/lcov-report/src/hooks/example-usage.ts.html +1582 -0
  39. package/__tests__/coverage/lcov-report/src/hooks/executor.ts.html +1222 -0
  40. package/__tests__/coverage/lcov-report/src/hooks/index.html +191 -0
  41. package/__tests__/coverage/lcov-report/src/hooks/registry.ts.html +1084 -0
  42. package/__tests__/coverage/lcov-report/src/hooks/safety/bash-safety.ts.html +1897 -0
  43. package/__tests__/coverage/lcov-report/src/hooks/safety/file-organization.ts.html +1504 -0
  44. package/__tests__/coverage/lcov-report/src/hooks/safety/git-commit.ts.html +1954 -0
  45. package/__tests__/coverage/lcov-report/src/hooks/safety/index.html +146 -0
  46. package/__tests__/coverage/lcov-report/src/hooks/session-hooks.ts.html +1762 -0
  47. package/__tests__/coverage/lcov-report/src/hooks/task-hooks.ts.html +1624 -0
  48. package/__tests__/coverage/lcov-report/src/hooks/types.ts.html +1156 -0
  49. package/__tests__/coverage/lcov-report/src/index.html +176 -0
  50. package/__tests__/coverage/lcov-report/src/mcp/connection-pool.ts.html +1399 -0
  51. package/__tests__/coverage/lcov-report/src/mcp/index.html +176 -0
  52. package/__tests__/coverage/lcov-report/src/mcp/server.ts.html +2407 -0
  53. package/__tests__/coverage/lcov-report/src/mcp/session-manager.ts.html +1369 -0
  54. package/__tests__/coverage/lcov-report/src/mcp/tool-registry.ts.html +1783 -0
  55. package/__tests__/coverage/lcov-report/src/mcp/transport/http.ts.html +1756 -0
  56. package/__tests__/coverage/lcov-report/src/mcp/transport/index.html +146 -0
  57. package/__tests__/coverage/lcov-report/src/mcp/transport/stdio.ts.html +1057 -0
  58. package/__tests__/coverage/lcov-report/src/mcp/transport/websocket.ts.html +1537 -0
  59. package/__tests__/coverage/lcov-report/src/mcp/types.ts.html +1780 -0
  60. package/__tests__/coverage/lcov-report/src/plugin-interface.ts.html +2074 -0
  61. package/__tests__/coverage/lcov-report/src/plugin-loader.ts.html +1999 -0
  62. package/__tests__/coverage/lcov-report/src/plugin-registry.ts.html +1897 -0
  63. package/__tests__/coverage/lcov-report/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
  64. package/__tests__/coverage/lcov-report/src/plugins/official/index.html +131 -0
  65. package/__tests__/coverage/lcov-report/src/plugins/official/maestro-plugin.ts.html +1609 -0
  66. package/__tests__/coverage/lcov-report/src/resilience/bulkhead.ts.html +916 -0
  67. package/__tests__/coverage/lcov-report/src/resilience/circuit-breaker.ts.html +1063 -0
  68. package/__tests__/coverage/lcov-report/src/resilience/index.html +161 -0
  69. package/__tests__/coverage/lcov-report/src/resilience/rate-limiter.ts.html +1345 -0
  70. package/__tests__/coverage/lcov-report/src/resilience/retry.ts.html +757 -0
  71. package/__tests__/coverage/lcov-report/src/security/index.html +131 -0
  72. package/__tests__/coverage/lcov-report/src/security/input-validation.ts.html +880 -0
  73. package/__tests__/coverage/lcov-report/src/security/secure-random.ts.html +562 -0
  74. package/__tests__/coverage/lcov-report/src/types/index.html +131 -0
  75. package/__tests__/coverage/lcov-report/src/types/swarm.types.ts.html +850 -0
  76. package/__tests__/coverage/lcov-report/src/types/task.types.ts.html +700 -0
  77. package/__tests__/coverage/lcov-report/src/types.ts.html +1186 -0
  78. package/__tests__/coverage/lcov-report/src/utils/index.html +116 -0
  79. package/__tests__/coverage/lcov-report/src/utils/secure-logger.ts.html +856 -0
  80. package/__tests__/coverage/lcov.info +19877 -0
  81. package/__tests__/coverage/prettify.css +1 -0
  82. package/__tests__/coverage/prettify.js +2 -0
  83. package/__tests__/coverage/sort-arrow-sprite.png +0 -0
  84. package/__tests__/coverage/sorter.js +210 -0
  85. package/__tests__/coverage/src/core/config/defaults.ts.html +706 -0
  86. package/__tests__/coverage/src/core/config/index.html +161 -0
  87. package/__tests__/coverage/src/core/config/loader.ts.html +898 -0
  88. package/__tests__/coverage/src/core/config/schema.ts.html +649 -0
  89. package/__tests__/coverage/src/core/config/validator.ts.html +712 -0
  90. package/__tests__/coverage/src/core/event-bus.ts.html +793 -0
  91. package/__tests__/coverage/src/core/index.html +116 -0
  92. package/__tests__/coverage/src/core/interfaces/event.interface.ts.html +886 -0
  93. package/__tests__/coverage/src/core/interfaces/index.html +116 -0
  94. package/__tests__/coverage/src/core/orchestrator/event-coordinator.ts.html +451 -0
  95. package/__tests__/coverage/src/core/orchestrator/health-monitor.ts.html +727 -0
  96. package/__tests__/coverage/src/core/orchestrator/index.html +176 -0
  97. package/__tests__/coverage/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
  98. package/__tests__/coverage/src/core/orchestrator/session-manager.ts.html +922 -0
  99. package/__tests__/coverage/src/core/orchestrator/task-manager.ts.html +1036 -0
  100. package/__tests__/coverage/src/events/domain-events.ts.html +1837 -0
  101. package/__tests__/coverage/src/events/event-store.ts.html +1849 -0
  102. package/__tests__/coverage/src/events/example-usage.ts.html +964 -0
  103. package/__tests__/coverage/src/events/index.html +176 -0
  104. package/__tests__/coverage/src/events/projections.ts.html +1768 -0
  105. package/__tests__/coverage/src/events/state-reconstructor.ts.html +1132 -0
  106. package/__tests__/coverage/src/events.ts.html +1186 -0
  107. package/__tests__/coverage/src/hooks/example-usage.ts.html +1582 -0
  108. package/__tests__/coverage/src/hooks/executor.ts.html +1222 -0
  109. package/__tests__/coverage/src/hooks/index.html +191 -0
  110. package/__tests__/coverage/src/hooks/registry.ts.html +1084 -0
  111. package/__tests__/coverage/src/hooks/safety/bash-safety.ts.html +1897 -0
  112. package/__tests__/coverage/src/hooks/safety/file-organization.ts.html +1504 -0
  113. package/__tests__/coverage/src/hooks/safety/git-commit.ts.html +1954 -0
  114. package/__tests__/coverage/src/hooks/safety/index.html +146 -0
  115. package/__tests__/coverage/src/hooks/session-hooks.ts.html +1762 -0
  116. package/__tests__/coverage/src/hooks/task-hooks.ts.html +1624 -0
  117. package/__tests__/coverage/src/hooks/types.ts.html +1156 -0
  118. package/__tests__/coverage/src/index.html +176 -0
  119. package/__tests__/coverage/src/mcp/connection-pool.ts.html +1399 -0
  120. package/__tests__/coverage/src/mcp/index.html +176 -0
  121. package/__tests__/coverage/src/mcp/server.ts.html +2407 -0
  122. package/__tests__/coverage/src/mcp/session-manager.ts.html +1369 -0
  123. package/__tests__/coverage/src/mcp/tool-registry.ts.html +1783 -0
  124. package/__tests__/coverage/src/mcp/transport/http.ts.html +1756 -0
  125. package/__tests__/coverage/src/mcp/transport/index.html +146 -0
  126. package/__tests__/coverage/src/mcp/transport/stdio.ts.html +1057 -0
  127. package/__tests__/coverage/src/mcp/transport/websocket.ts.html +1537 -0
  128. package/__tests__/coverage/src/mcp/types.ts.html +1780 -0
  129. package/__tests__/coverage/src/plugin-interface.ts.html +2074 -0
  130. package/__tests__/coverage/src/plugin-loader.ts.html +1999 -0
  131. package/__tests__/coverage/src/plugin-registry.ts.html +1897 -0
  132. package/__tests__/coverage/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
  133. package/__tests__/coverage/src/plugins/official/index.html +131 -0
  134. package/__tests__/coverage/src/plugins/official/maestro-plugin.ts.html +1609 -0
  135. package/__tests__/coverage/src/resilience/bulkhead.ts.html +916 -0
  136. package/__tests__/coverage/src/resilience/circuit-breaker.ts.html +1063 -0
  137. package/__tests__/coverage/src/resilience/index.html +161 -0
  138. package/__tests__/coverage/src/resilience/rate-limiter.ts.html +1345 -0
  139. package/__tests__/coverage/src/resilience/retry.ts.html +757 -0
  140. package/__tests__/coverage/src/security/index.html +131 -0
  141. package/__tests__/coverage/src/security/input-validation.ts.html +880 -0
  142. package/__tests__/coverage/src/security/secure-random.ts.html +562 -0
  143. package/__tests__/coverage/src/types/index.html +131 -0
  144. package/__tests__/coverage/src/types/swarm.types.ts.html +850 -0
  145. package/__tests__/coverage/src/types/task.types.ts.html +700 -0
  146. package/__tests__/coverage/src/types.ts.html +1186 -0
  147. package/__tests__/coverage/src/utils/index.html +116 -0
  148. package/__tests__/coverage/src/utils/secure-logger.ts.html +856 -0
  149. package/__tests__/hooks/bash-safety.test.ts +289 -0
  150. package/__tests__/hooks/file-organization.test.ts +335 -0
  151. package/__tests__/hooks/git-commit.test.ts +336 -0
  152. package/__tests__/hooks/index.ts +23 -0
  153. package/__tests__/hooks/session-hooks.test.ts +357 -0
  154. package/__tests__/hooks/task-hooks.test.ts +193 -0
  155. package/dist/core/config/defaults.d.ts +41 -0
  156. package/dist/core/config/defaults.d.ts.map +1 -0
  157. package/dist/core/config/defaults.js +186 -0
  158. package/dist/core/config/defaults.js.map +1 -0
  159. package/dist/core/config/index.d.ts +8 -0
  160. package/dist/core/config/index.d.ts.map +1 -0
  161. package/dist/core/config/index.js +12 -0
  162. package/dist/core/config/index.js.map +1 -0
  163. package/dist/core/config/loader.d.ts +45 -0
  164. package/dist/core/config/loader.d.ts.map +1 -0
  165. package/dist/core/config/loader.js +222 -0
  166. package/dist/core/config/loader.js.map +1 -0
  167. package/dist/core/config/schema.d.ts +1134 -0
  168. package/dist/core/config/schema.d.ts.map +1 -0
  169. package/dist/core/config/schema.js +158 -0
  170. package/dist/core/config/schema.js.map +1 -0
  171. package/dist/core/config/validator.d.ts +92 -0
  172. package/dist/core/config/validator.d.ts.map +1 -0
  173. package/dist/core/config/validator.js +147 -0
  174. package/dist/core/config/validator.js.map +1 -0
  175. package/dist/core/event-bus.d.ts +31 -0
  176. package/dist/core/event-bus.d.ts.map +1 -0
  177. package/dist/core/event-bus.js +197 -0
  178. package/dist/core/event-bus.js.map +1 -0
  179. package/dist/core/index.d.ts +15 -0
  180. package/dist/core/index.d.ts.map +1 -0
  181. package/dist/core/index.js +19 -0
  182. package/dist/core/index.js.map +1 -0
  183. package/dist/core/interfaces/agent.interface.d.ts +200 -0
  184. package/dist/core/interfaces/agent.interface.d.ts.map +1 -0
  185. package/dist/core/interfaces/agent.interface.js +6 -0
  186. package/dist/core/interfaces/agent.interface.js.map +1 -0
  187. package/dist/core/interfaces/coordinator.interface.d.ts +310 -0
  188. package/dist/core/interfaces/coordinator.interface.d.ts.map +1 -0
  189. package/dist/core/interfaces/coordinator.interface.js +7 -0
  190. package/dist/core/interfaces/coordinator.interface.js.map +1 -0
  191. package/dist/core/interfaces/event.interface.d.ts +224 -0
  192. package/dist/core/interfaces/event.interface.d.ts.map +1 -0
  193. package/dist/core/interfaces/event.interface.js +46 -0
  194. package/dist/core/interfaces/event.interface.js.map +1 -0
  195. package/dist/core/interfaces/index.d.ts +10 -0
  196. package/dist/core/interfaces/index.d.ts.map +1 -0
  197. package/dist/core/interfaces/index.js +15 -0
  198. package/dist/core/interfaces/index.js.map +1 -0
  199. package/dist/core/interfaces/memory.interface.d.ts +298 -0
  200. package/dist/core/interfaces/memory.interface.d.ts.map +1 -0
  201. package/dist/core/interfaces/memory.interface.js +7 -0
  202. package/dist/core/interfaces/memory.interface.js.map +1 -0
  203. package/dist/core/interfaces/task.interface.d.ts +185 -0
  204. package/dist/core/interfaces/task.interface.d.ts.map +1 -0
  205. package/dist/core/interfaces/task.interface.js +6 -0
  206. package/dist/core/interfaces/task.interface.js.map +1 -0
  207. package/dist/core/orchestrator/event-coordinator.d.ts +35 -0
  208. package/dist/core/orchestrator/event-coordinator.d.ts.map +1 -0
  209. package/dist/core/orchestrator/event-coordinator.js +101 -0
  210. package/dist/core/orchestrator/event-coordinator.js.map +1 -0
  211. package/dist/core/orchestrator/health-monitor.d.ts +60 -0
  212. package/dist/core/orchestrator/health-monitor.d.ts.map +1 -0
  213. package/dist/core/orchestrator/health-monitor.js +166 -0
  214. package/dist/core/orchestrator/health-monitor.js.map +1 -0
  215. package/dist/core/orchestrator/index.d.ts +46 -0
  216. package/dist/core/orchestrator/index.d.ts.map +1 -0
  217. package/dist/core/orchestrator/index.js +64 -0
  218. package/dist/core/orchestrator/index.js.map +1 -0
  219. package/dist/core/orchestrator/lifecycle-manager.d.ts +56 -0
  220. package/dist/core/orchestrator/lifecycle-manager.d.ts.map +1 -0
  221. package/dist/core/orchestrator/lifecycle-manager.js +195 -0
  222. package/dist/core/orchestrator/lifecycle-manager.js.map +1 -0
  223. package/dist/core/orchestrator/session-manager.d.ts +83 -0
  224. package/dist/core/orchestrator/session-manager.d.ts.map +1 -0
  225. package/dist/core/orchestrator/session-manager.js +193 -0
  226. package/dist/core/orchestrator/session-manager.js.map +1 -0
  227. package/dist/core/orchestrator/task-manager.d.ts +49 -0
  228. package/dist/core/orchestrator/task-manager.d.ts.map +1 -0
  229. package/dist/core/orchestrator/task-manager.js +253 -0
  230. package/dist/core/orchestrator/task-manager.js.map +1 -0
  231. package/dist/events/domain-events.d.ts +282 -0
  232. package/dist/events/domain-events.d.ts.map +1 -0
  233. package/dist/events/domain-events.js +165 -0
  234. package/dist/events/domain-events.js.map +1 -0
  235. package/dist/events/event-store.d.ts +126 -0
  236. package/dist/events/event-store.d.ts.map +1 -0
  237. package/dist/events/event-store.js +416 -0
  238. package/dist/events/event-store.js.map +1 -0
  239. package/dist/events/event-store.test.d.ts +8 -0
  240. package/dist/events/event-store.test.d.ts.map +1 -0
  241. package/dist/events/event-store.test.js +293 -0
  242. package/dist/events/event-store.test.js.map +1 -0
  243. package/dist/events/example-usage.d.ts +10 -0
  244. package/dist/events/example-usage.d.ts.map +1 -0
  245. package/dist/events/example-usage.js +193 -0
  246. package/dist/events/example-usage.js.map +1 -0
  247. package/dist/events/index.d.ts +19 -0
  248. package/dist/events/index.d.ts.map +1 -0
  249. package/dist/events/index.js +20 -0
  250. package/dist/events/index.js.map +1 -0
  251. package/dist/events/projections.d.ts +177 -0
  252. package/dist/events/projections.d.ts.map +1 -0
  253. package/dist/events/projections.js +421 -0
  254. package/dist/events/projections.js.map +1 -0
  255. package/dist/events/state-reconstructor.d.ts +101 -0
  256. package/dist/events/state-reconstructor.d.ts.map +1 -0
  257. package/dist/events/state-reconstructor.js +263 -0
  258. package/dist/events/state-reconstructor.js.map +1 -0
  259. package/dist/events.d.ts +80 -0
  260. package/dist/events.d.ts.map +1 -0
  261. package/dist/events.js +249 -0
  262. package/dist/events.js.map +1 -0
  263. package/dist/hooks/example-usage.d.ts +42 -0
  264. package/dist/hooks/example-usage.d.ts.map +1 -0
  265. package/dist/hooks/example-usage.js +351 -0
  266. package/dist/hooks/example-usage.js.map +1 -0
  267. package/dist/hooks/executor.d.ts +100 -0
  268. package/dist/hooks/executor.d.ts.map +1 -0
  269. package/dist/hooks/executor.js +264 -0
  270. package/dist/hooks/executor.js.map +1 -0
  271. package/dist/hooks/hooks.test.d.ts +9 -0
  272. package/dist/hooks/hooks.test.d.ts.map +1 -0
  273. package/dist/hooks/hooks.test.js +322 -0
  274. package/dist/hooks/hooks.test.js.map +1 -0
  275. package/dist/hooks/index.d.ts +52 -0
  276. package/dist/hooks/index.d.ts.map +1 -0
  277. package/dist/hooks/index.js +51 -0
  278. package/dist/hooks/index.js.map +1 -0
  279. package/dist/hooks/registry.d.ts +133 -0
  280. package/dist/hooks/registry.d.ts.map +1 -0
  281. package/dist/hooks/registry.js +277 -0
  282. package/dist/hooks/registry.js.map +1 -0
  283. package/dist/hooks/safety/bash-safety.d.ts +105 -0
  284. package/dist/hooks/safety/bash-safety.d.ts.map +1 -0
  285. package/dist/hooks/safety/bash-safety.js +481 -0
  286. package/dist/hooks/safety/bash-safety.js.map +1 -0
  287. package/dist/hooks/safety/file-organization.d.ts +144 -0
  288. package/dist/hooks/safety/file-organization.d.ts.map +1 -0
  289. package/dist/hooks/safety/file-organization.js +328 -0
  290. package/dist/hooks/safety/file-organization.js.map +1 -0
  291. package/dist/hooks/safety/git-commit.d.ts +158 -0
  292. package/dist/hooks/safety/git-commit.d.ts.map +1 -0
  293. package/dist/hooks/safety/git-commit.js +450 -0
  294. package/dist/hooks/safety/git-commit.js.map +1 -0
  295. package/dist/hooks/safety/index.d.ts +17 -0
  296. package/dist/hooks/safety/index.d.ts.map +1 -0
  297. package/dist/hooks/safety/index.js +17 -0
  298. package/dist/hooks/safety/index.js.map +1 -0
  299. package/dist/hooks/session-hooks.d.ts +234 -0
  300. package/dist/hooks/session-hooks.d.ts.map +1 -0
  301. package/dist/hooks/session-hooks.js +334 -0
  302. package/dist/hooks/session-hooks.js.map +1 -0
  303. package/dist/hooks/task-hooks.d.ts +163 -0
  304. package/dist/hooks/task-hooks.d.ts.map +1 -0
  305. package/dist/hooks/task-hooks.js +326 -0
  306. package/dist/hooks/task-hooks.js.map +1 -0
  307. package/dist/hooks/types.d.ts +267 -0
  308. package/dist/hooks/types.d.ts.map +1 -0
  309. package/dist/hooks/types.js +62 -0
  310. package/dist/hooks/types.js.map +1 -0
  311. package/dist/hooks/verify-exports.test.d.ts +9 -0
  312. package/dist/hooks/verify-exports.test.d.ts.map +1 -0
  313. package/dist/hooks/verify-exports.test.js +93 -0
  314. package/dist/hooks/verify-exports.test.js.map +1 -0
  315. package/dist/index.d.ts +19 -0
  316. package/dist/index.d.ts.map +1 -0
  317. package/dist/index.js +46 -0
  318. package/dist/index.js.map +1 -0
  319. package/dist/mcp/connection-pool.d.ts +98 -0
  320. package/dist/mcp/connection-pool.d.ts.map +1 -0
  321. package/dist/mcp/connection-pool.js +364 -0
  322. package/dist/mcp/connection-pool.js.map +1 -0
  323. package/dist/mcp/index.d.ts +69 -0
  324. package/dist/mcp/index.d.ts.map +1 -0
  325. package/dist/mcp/index.js +84 -0
  326. package/dist/mcp/index.js.map +1 -0
  327. package/dist/mcp/server.d.ts +166 -0
  328. package/dist/mcp/server.d.ts.map +1 -0
  329. package/dist/mcp/server.js +593 -0
  330. package/dist/mcp/server.js.map +1 -0
  331. package/dist/mcp/session-manager.d.ts +136 -0
  332. package/dist/mcp/session-manager.d.ts.map +1 -0
  333. package/dist/mcp/session-manager.js +335 -0
  334. package/dist/mcp/session-manager.js.map +1 -0
  335. package/dist/mcp/tool-registry.d.ts +178 -0
  336. package/dist/mcp/tool-registry.d.ts.map +1 -0
  337. package/dist/mcp/tool-registry.js +439 -0
  338. package/dist/mcp/tool-registry.js.map +1 -0
  339. package/dist/mcp/transport/http.d.ts +104 -0
  340. package/dist/mcp/transport/http.d.ts.map +1 -0
  341. package/dist/mcp/transport/http.js +476 -0
  342. package/dist/mcp/transport/http.js.map +1 -0
  343. package/dist/mcp/transport/index.d.ts +102 -0
  344. package/dist/mcp/transport/index.d.ts.map +1 -0
  345. package/dist/mcp/transport/index.js +238 -0
  346. package/dist/mcp/transport/index.js.map +1 -0
  347. package/dist/mcp/transport/stdio.d.ts +104 -0
  348. package/dist/mcp/transport/stdio.d.ts.map +1 -0
  349. package/dist/mcp/transport/stdio.js +263 -0
  350. package/dist/mcp/transport/stdio.js.map +1 -0
  351. package/dist/mcp/transport/websocket.d.ts +133 -0
  352. package/dist/mcp/transport/websocket.d.ts.map +1 -0
  353. package/dist/mcp/transport/websocket.js +396 -0
  354. package/dist/mcp/transport/websocket.js.map +1 -0
  355. package/dist/mcp/types.d.ts +438 -0
  356. package/dist/mcp/types.d.ts.map +1 -0
  357. package/dist/mcp/types.js +54 -0
  358. package/dist/mcp/types.js.map +1 -0
  359. package/dist/plugin-interface.d.ts +544 -0
  360. package/dist/plugin-interface.d.ts.map +1 -0
  361. package/dist/plugin-interface.js +23 -0
  362. package/dist/plugin-interface.js.map +1 -0
  363. package/dist/plugin-loader.d.ts +139 -0
  364. package/dist/plugin-loader.d.ts.map +1 -0
  365. package/dist/plugin-loader.js +434 -0
  366. package/dist/plugin-loader.js.map +1 -0
  367. package/dist/plugin-registry.d.ts +183 -0
  368. package/dist/plugin-registry.d.ts.map +1 -0
  369. package/dist/plugin-registry.js +457 -0
  370. package/dist/plugin-registry.js.map +1 -0
  371. package/dist/plugins/index.d.ts +10 -0
  372. package/dist/plugins/index.d.ts.map +1 -0
  373. package/dist/plugins/index.js +10 -0
  374. package/dist/plugins/index.js.map +1 -0
  375. package/dist/plugins/official/hive-mind-plugin.d.ts +106 -0
  376. package/dist/plugins/official/hive-mind-plugin.d.ts.map +1 -0
  377. package/dist/plugins/official/hive-mind-plugin.js +241 -0
  378. package/dist/plugins/official/hive-mind-plugin.js.map +1 -0
  379. package/dist/plugins/official/index.d.ts +10 -0
  380. package/dist/plugins/official/index.d.ts.map +1 -0
  381. package/dist/plugins/official/index.js +10 -0
  382. package/dist/plugins/official/index.js.map +1 -0
  383. package/dist/plugins/official/maestro-plugin.d.ts +121 -0
  384. package/dist/plugins/official/maestro-plugin.d.ts.map +1 -0
  385. package/dist/plugins/official/maestro-plugin.js +355 -0
  386. package/dist/plugins/official/maestro-plugin.js.map +1 -0
  387. package/dist/plugins/types.d.ts +93 -0
  388. package/dist/plugins/types.d.ts.map +1 -0
  389. package/dist/plugins/types.js +9 -0
  390. package/dist/plugins/types.js.map +1 -0
  391. package/dist/resilience/bulkhead.d.ts +105 -0
  392. package/dist/resilience/bulkhead.d.ts.map +1 -0
  393. package/dist/resilience/bulkhead.js +206 -0
  394. package/dist/resilience/bulkhead.js.map +1 -0
  395. package/dist/resilience/circuit-breaker.d.ts +132 -0
  396. package/dist/resilience/circuit-breaker.d.ts.map +1 -0
  397. package/dist/resilience/circuit-breaker.js +233 -0
  398. package/dist/resilience/circuit-breaker.js.map +1 -0
  399. package/dist/resilience/index.d.ts +19 -0
  400. package/dist/resilience/index.d.ts.map +1 -0
  401. package/dist/resilience/index.js +19 -0
  402. package/dist/resilience/index.js.map +1 -0
  403. package/dist/resilience/rate-limiter.d.ts +168 -0
  404. package/dist/resilience/rate-limiter.d.ts.map +1 -0
  405. package/dist/resilience/rate-limiter.js +314 -0
  406. package/dist/resilience/rate-limiter.js.map +1 -0
  407. package/dist/resilience/retry.d.ts +91 -0
  408. package/dist/resilience/retry.d.ts.map +1 -0
  409. package/dist/resilience/retry.js +159 -0
  410. package/dist/resilience/retry.js.map +1 -0
  411. package/dist/security/index.d.ts +10 -0
  412. package/dist/security/index.d.ts.map +1 -0
  413. package/dist/security/index.js +12 -0
  414. package/dist/security/index.js.map +1 -0
  415. package/dist/security/input-validation.d.ts +73 -0
  416. package/dist/security/input-validation.d.ts.map +1 -0
  417. package/dist/security/input-validation.js +201 -0
  418. package/dist/security/input-validation.js.map +1 -0
  419. package/dist/security/secure-random.d.ts +92 -0
  420. package/dist/security/secure-random.d.ts.map +1 -0
  421. package/dist/security/secure-random.js +142 -0
  422. package/dist/security/secure-random.js.map +1 -0
  423. package/dist/types/agent.types.d.ts +137 -0
  424. package/dist/types/agent.types.d.ts.map +1 -0
  425. package/dist/types/agent.types.js +6 -0
  426. package/dist/types/agent.types.js.map +1 -0
  427. package/dist/types/index.d.ts +11 -0
  428. package/dist/types/index.d.ts.map +1 -0
  429. package/dist/types/index.js +17 -0
  430. package/dist/types/index.js.map +1 -0
  431. package/dist/types/mcp.types.d.ts +266 -0
  432. package/dist/types/mcp.types.d.ts.map +1 -0
  433. package/dist/types/mcp.types.js +7 -0
  434. package/dist/types/mcp.types.js.map +1 -0
  435. package/dist/types/memory.types.d.ts +236 -0
  436. package/dist/types/memory.types.d.ts.map +1 -0
  437. package/dist/types/memory.types.js +7 -0
  438. package/dist/types/memory.types.js.map +1 -0
  439. package/dist/types/swarm.types.d.ts +186 -0
  440. package/dist/types/swarm.types.d.ts.map +1 -0
  441. package/dist/types/swarm.types.js +65 -0
  442. package/dist/types/swarm.types.js.map +1 -0
  443. package/dist/types/task.types.d.ts +178 -0
  444. package/dist/types/task.types.d.ts.map +1 -0
  445. package/dist/types/task.types.js +32 -0
  446. package/dist/types/task.types.js.map +1 -0
  447. package/dist/types.d.ts +197 -0
  448. package/dist/types.d.ts.map +1 -0
  449. package/dist/types.js +21 -0
  450. package/dist/types.js.map +1 -0
  451. package/dist/utils/secure-logger.d.ts +69 -0
  452. package/dist/utils/secure-logger.d.ts.map +1 -0
  453. package/dist/utils/secure-logger.js +208 -0
  454. package/dist/utils/secure-logger.js.map +1 -0
  455. package/docs/EVENTS_IMPLEMENTATION_SUMMARY.md +388 -0
  456. package/docs/EVENTS_QUICK_REFERENCE.md +470 -0
  457. package/docs/EVENTS_README.md +352 -0
  458. package/package.json +34 -0
  459. package/src/core/config/defaults.ts +207 -0
  460. package/src/core/config/index.ts +15 -0
  461. package/src/core/config/loader.ts +271 -0
  462. package/src/core/config/schema.ts +188 -0
  463. package/src/core/config/validator.ts +209 -0
  464. package/src/core/event-bus.ts +236 -0
  465. package/src/core/index.ts +22 -0
  466. package/src/core/interfaces/agent.interface.ts +251 -0
  467. package/src/core/interfaces/coordinator.interface.ts +363 -0
  468. package/src/core/interfaces/event.interface.ts +267 -0
  469. package/src/core/interfaces/index.ts +19 -0
  470. package/src/core/interfaces/memory.interface.ts +332 -0
  471. package/src/core/interfaces/task.interface.ts +223 -0
  472. package/src/core/orchestrator/event-coordinator.ts +122 -0
  473. package/src/core/orchestrator/health-monitor.ts +214 -0
  474. package/src/core/orchestrator/index.ts +89 -0
  475. package/src/core/orchestrator/lifecycle-manager.ts +263 -0
  476. package/src/core/orchestrator/session-manager.ts +279 -0
  477. package/src/core/orchestrator/task-manager.ts +317 -0
  478. package/src/events/domain-events.ts +584 -0
  479. package/src/events/event-store.test.ts +387 -0
  480. package/src/events/event-store.ts +588 -0
  481. package/src/events/example-usage.ts +293 -0
  482. package/src/events/index.ts +90 -0
  483. package/src/events/projections.ts +561 -0
  484. package/src/events/state-reconstructor.ts +349 -0
  485. package/src/events.ts +367 -0
  486. package/src/hooks/INTEGRATION.md +658 -0
  487. package/src/hooks/README.md +532 -0
  488. package/src/hooks/example-usage.ts +499 -0
  489. package/src/hooks/executor.ts +379 -0
  490. package/src/hooks/hooks.test.ts +421 -0
  491. package/src/hooks/index.ts +131 -0
  492. package/src/hooks/registry.ts +333 -0
  493. package/src/hooks/safety/bash-safety.ts +604 -0
  494. package/src/hooks/safety/file-organization.ts +473 -0
  495. package/src/hooks/safety/git-commit.ts +623 -0
  496. package/src/hooks/safety/index.ts +46 -0
  497. package/src/hooks/session-hooks.ts +559 -0
  498. package/src/hooks/task-hooks.ts +513 -0
  499. package/src/hooks/types.ts +357 -0
  500. package/src/hooks/verify-exports.test.ts +125 -0
  501. package/src/index.ts +190 -0
  502. package/src/mcp/connection-pool.ts +438 -0
  503. package/src/mcp/index.ts +183 -0
  504. package/src/mcp/server.ts +774 -0
  505. package/src/mcp/session-manager.ts +428 -0
  506. package/src/mcp/tool-registry.ts +566 -0
  507. package/src/mcp/transport/http.ts +557 -0
  508. package/src/mcp/transport/index.ts +294 -0
  509. package/src/mcp/transport/stdio.ts +324 -0
  510. package/src/mcp/transport/websocket.ts +484 -0
  511. package/src/mcp/types.ts +565 -0
  512. package/src/plugin-interface.ts +663 -0
  513. package/src/plugin-loader.ts +638 -0
  514. package/src/plugin-registry.ts +604 -0
  515. package/src/plugins/index.ts +34 -0
  516. package/src/plugins/official/hive-mind-plugin.ts +330 -0
  517. package/src/plugins/official/index.ts +24 -0
  518. package/src/plugins/official/maestro-plugin.ts +508 -0
  519. package/src/plugins/types.ts +108 -0
  520. package/src/resilience/bulkhead.ts +277 -0
  521. package/src/resilience/circuit-breaker.ts +326 -0
  522. package/src/resilience/index.ts +26 -0
  523. package/src/resilience/rate-limiter.ts +420 -0
  524. package/src/resilience/retry.ts +224 -0
  525. package/src/security/index.ts +39 -0
  526. package/src/security/input-validation.ts +265 -0
  527. package/src/security/secure-random.ts +159 -0
  528. package/src/types/agent.types.ts +144 -0
  529. package/src/types/index.ts +22 -0
  530. package/src/types/mcp.types.ts +300 -0
  531. package/src/types/memory.types.ts +263 -0
  532. package/src/types/swarm.types.ts +255 -0
  533. package/src/types/task.types.ts +205 -0
  534. package/src/types.ts +367 -0
  535. package/src/utils/secure-logger.d.ts +69 -0
  536. package/src/utils/secure-logger.d.ts.map +1 -0
  537. package/src/utils/secure-logger.js +208 -0
  538. package/src/utils/secure-logger.js.map +1 -0
  539. package/src/utils/secure-logger.ts +257 -0
  540. package/tsconfig.json +9 -0
  541. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,604 @@
1
+ /**
2
+ * V3 Plugin Registry
3
+ * Domain-Driven Design - Plugin-Based Architecture (ADR-004)
4
+ *
5
+ * Central registry for tracking plugin state, metadata, and registrations
6
+ */
7
+
8
+ import type {
9
+ ClaudeFlowPlugin,
10
+ PluginInfo,
11
+ PluginLifecycleState,
12
+ PluginContext,
13
+ AgentTypeDefinition,
14
+ TaskTypeDefinition,
15
+ MCPToolDefinition,
16
+ CLICommandDefinition,
17
+ MemoryBackendFactory,
18
+ } from './plugin-interface.js';
19
+ import { PluginError } from './plugin-interface.js';
20
+
21
+ /**
22
+ * Plugin registry for managing plugin lifecycle and registrations
23
+ */
24
+ export class PluginRegistry {
25
+ private plugins = new Map<string, PluginInfo>();
26
+ private agentTypes = new Map<string, { plugin: string; definition: AgentTypeDefinition }>();
27
+ private taskTypes = new Map<string, { plugin: string; definition: TaskTypeDefinition }>();
28
+ private mcpTools = new Map<string, { plugin: string; definition: MCPToolDefinition }>();
29
+ private cliCommands = new Map<string, { plugin: string; definition: CLICommandDefinition }>();
30
+ private memoryBackends = new Map<string, { plugin: string; factory: MemoryBackendFactory }>();
31
+
32
+ /**
33
+ * Register a plugin in the registry
34
+ */
35
+ registerPlugin(
36
+ plugin: ClaudeFlowPlugin,
37
+ initialState: PluginLifecycleState,
38
+ context: PluginContext
39
+ ): void {
40
+ if (this.plugins.has(plugin.name)) {
41
+ throw new PluginError(
42
+ `Plugin '${plugin.name}' is already registered`,
43
+ plugin.name,
44
+ 'DUPLICATE_PLUGIN'
45
+ );
46
+ }
47
+
48
+ const info: PluginInfo = {
49
+ plugin,
50
+ state: initialState,
51
+ context,
52
+ metrics: {
53
+ agentTypesRegistered: 0,
54
+ taskTypesRegistered: 0,
55
+ mcpToolsRegistered: 0,
56
+ cliCommandsRegistered: 0,
57
+ memoryBackendsRegistered: 0,
58
+ },
59
+ };
60
+
61
+ this.plugins.set(plugin.name, info);
62
+ }
63
+
64
+ /**
65
+ * Unregister a plugin from the registry
66
+ */
67
+ unregisterPlugin(pluginName: string): boolean {
68
+ const info = this.plugins.get(pluginName);
69
+ if (!info) {
70
+ return false;
71
+ }
72
+
73
+ // Unregister all plugin's registrations
74
+ this.unregisterPluginAgentTypes(pluginName);
75
+ this.unregisterPluginTaskTypes(pluginName);
76
+ this.unregisterPluginMCPTools(pluginName);
77
+ this.unregisterPluginCLICommands(pluginName);
78
+ this.unregisterPluginMemoryBackends(pluginName);
79
+
80
+ // Remove plugin
81
+ return this.plugins.delete(pluginName);
82
+ }
83
+
84
+ /**
85
+ * Get a plugin by name
86
+ */
87
+ getPlugin(pluginName: string): PluginInfo | undefined {
88
+ return this.plugins.get(pluginName);
89
+ }
90
+
91
+ /**
92
+ * Get all registered plugins
93
+ */
94
+ getAllPlugins(): Map<string, PluginInfo> {
95
+ return new Map(this.plugins);
96
+ }
97
+
98
+ /**
99
+ * Get all plugin names
100
+ */
101
+ getPluginNames(): string[] {
102
+ return Array.from(this.plugins.keys());
103
+ }
104
+
105
+ /**
106
+ * Check if a plugin is registered
107
+ */
108
+ hasPlugin(pluginName: string): boolean {
109
+ return this.plugins.has(pluginName);
110
+ }
111
+
112
+ /**
113
+ * Get plugins by state
114
+ */
115
+ getPluginsByState(state: PluginLifecycleState): PluginInfo[] {
116
+ return Array.from(this.plugins.values()).filter((info) => info.state === state);
117
+ }
118
+
119
+ /**
120
+ * Get plugin count
121
+ */
122
+ getPluginCount(): number {
123
+ return this.plugins.size;
124
+ }
125
+
126
+ /**
127
+ * Update plugin state
128
+ */
129
+ updatePluginState(pluginName: string, state: PluginLifecycleState, error?: Error): void {
130
+ const info = this.plugins.get(pluginName);
131
+ if (!info) {
132
+ throw new PluginError(
133
+ `Plugin '${pluginName}' not found`,
134
+ pluginName,
135
+ 'INVALID_PLUGIN'
136
+ );
137
+ }
138
+
139
+ info.state = state;
140
+
141
+ if (state === 'initialized') {
142
+ info.initializedAt = new Date();
143
+ } else if (state === 'shutdown') {
144
+ info.shutdownAt = new Date();
145
+ } else if (state === 'error') {
146
+ info.error = error;
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Collect and update plugin metrics
152
+ */
153
+ collectPluginMetrics(pluginName: string): void {
154
+ const info = this.plugins.get(pluginName);
155
+ if (!info || !info.metrics) {
156
+ return;
157
+ }
158
+
159
+ const plugin = info.plugin;
160
+
161
+ // Count registered items
162
+ info.metrics.agentTypesRegistered = plugin.registerAgentTypes?.()?.length || 0;
163
+ info.metrics.taskTypesRegistered = plugin.registerTaskTypes?.()?.length || 0;
164
+ info.metrics.mcpToolsRegistered = plugin.registerMCPTools?.()?.length || 0;
165
+ info.metrics.cliCommandsRegistered = plugin.registerCLICommands?.()?.length || 0;
166
+ info.metrics.memoryBackendsRegistered = plugin.registerMemoryBackends?.()?.length || 0;
167
+ }
168
+
169
+ /**
170
+ * Get plugin status summary
171
+ */
172
+ getStatusSummary(): PluginRegistryStatus {
173
+ const states = Array.from(this.plugins.values()).reduce((acc, info) => {
174
+ acc[info.state] = (acc[info.state] || 0) + 1;
175
+ return acc;
176
+ }, {} as Record<PluginLifecycleState, number>);
177
+
178
+ return {
179
+ totalPlugins: this.plugins.size,
180
+ states,
181
+ agentTypesRegistered: this.agentTypes.size,
182
+ taskTypesRegistered: this.taskTypes.size,
183
+ mcpToolsRegistered: this.mcpTools.size,
184
+ cliCommandsRegistered: this.cliCommands.size,
185
+ memoryBackendsRegistered: this.memoryBackends.size,
186
+ };
187
+ }
188
+
189
+ // =============================================================================
190
+ // Agent Type Registry
191
+ // =============================================================================
192
+
193
+ /**
194
+ * Register agent types from a plugin
195
+ */
196
+ registerAgentTypes(pluginName: string): void {
197
+ const info = this.plugins.get(pluginName);
198
+ if (!info) {
199
+ throw new PluginError(
200
+ `Plugin '${pluginName}' not found`,
201
+ pluginName,
202
+ 'INVALID_PLUGIN'
203
+ );
204
+ }
205
+
206
+ const agentTypes = info.plugin.registerAgentTypes?.();
207
+ if (!agentTypes || agentTypes.length === 0) {
208
+ return;
209
+ }
210
+
211
+ for (const definition of agentTypes) {
212
+ if (this.agentTypes.has(definition.type)) {
213
+ throw new PluginError(
214
+ `Agent type '${definition.type}' is already registered by plugin '${this.agentTypes.get(definition.type)?.plugin}'`,
215
+ pluginName,
216
+ 'DUPLICATE_PLUGIN'
217
+ );
218
+ }
219
+
220
+ this.agentTypes.set(definition.type, { plugin: pluginName, definition });
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Unregister agent types from a plugin
226
+ */
227
+ unregisterPluginAgentTypes(pluginName: string): void {
228
+ for (const [type, entry] of Array.from(this.agentTypes.entries())) {
229
+ if (entry.plugin === pluginName) {
230
+ this.agentTypes.delete(type);
231
+ }
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Get agent type definition
237
+ */
238
+ getAgentType(type: string): AgentTypeDefinition | undefined {
239
+ return this.agentTypes.get(type)?.definition;
240
+ }
241
+
242
+ /**
243
+ * Get all agent types
244
+ */
245
+ getAllAgentTypes(): AgentTypeDefinition[] {
246
+ return Array.from(this.agentTypes.values()).map((entry) => entry.definition);
247
+ }
248
+
249
+ /**
250
+ * Get agent types by plugin
251
+ */
252
+ getAgentTypesByPlugin(pluginName: string): AgentTypeDefinition[] {
253
+ return Array.from(this.agentTypes.values())
254
+ .filter((entry) => entry.plugin === pluginName)
255
+ .map((entry) => entry.definition);
256
+ }
257
+
258
+ // =============================================================================
259
+ // Task Type Registry
260
+ // =============================================================================
261
+
262
+ /**
263
+ * Register task types from a plugin
264
+ */
265
+ registerTaskTypes(pluginName: string): void {
266
+ const info = this.plugins.get(pluginName);
267
+ if (!info) {
268
+ throw new PluginError(
269
+ `Plugin '${pluginName}' not found`,
270
+ pluginName,
271
+ 'INVALID_PLUGIN'
272
+ );
273
+ }
274
+
275
+ const taskTypes = info.plugin.registerTaskTypes?.();
276
+ if (!taskTypes || taskTypes.length === 0) {
277
+ return;
278
+ }
279
+
280
+ for (const definition of taskTypes) {
281
+ if (this.taskTypes.has(definition.type)) {
282
+ throw new PluginError(
283
+ `Task type '${definition.type}' is already registered by plugin '${this.taskTypes.get(definition.type)?.plugin}'`,
284
+ pluginName,
285
+ 'DUPLICATE_PLUGIN'
286
+ );
287
+ }
288
+
289
+ this.taskTypes.set(definition.type, { plugin: pluginName, definition });
290
+ }
291
+ }
292
+
293
+ /**
294
+ * Unregister task types from a plugin
295
+ */
296
+ unregisterPluginTaskTypes(pluginName: string): void {
297
+ for (const [type, entry] of Array.from(this.taskTypes.entries())) {
298
+ if (entry.plugin === pluginName) {
299
+ this.taskTypes.delete(type);
300
+ }
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Get task type definition
306
+ */
307
+ getTaskType(type: string): TaskTypeDefinition | undefined {
308
+ return this.taskTypes.get(type)?.definition;
309
+ }
310
+
311
+ /**
312
+ * Get all task types
313
+ */
314
+ getAllTaskTypes(): TaskTypeDefinition[] {
315
+ return Array.from(this.taskTypes.values()).map((entry) => entry.definition);
316
+ }
317
+
318
+ /**
319
+ * Get task types by plugin
320
+ */
321
+ getTaskTypesByPlugin(pluginName: string): TaskTypeDefinition[] {
322
+ return Array.from(this.taskTypes.values())
323
+ .filter((entry) => entry.plugin === pluginName)
324
+ .map((entry) => entry.definition);
325
+ }
326
+
327
+ // =============================================================================
328
+ // MCP Tool Registry
329
+ // =============================================================================
330
+
331
+ /**
332
+ * Register MCP tools from a plugin
333
+ */
334
+ registerMCPTools(pluginName: string): void {
335
+ const info = this.plugins.get(pluginName);
336
+ if (!info) {
337
+ throw new PluginError(
338
+ `Plugin '${pluginName}' not found`,
339
+ pluginName,
340
+ 'INVALID_PLUGIN'
341
+ );
342
+ }
343
+
344
+ const mcpTools = info.plugin.registerMCPTools?.();
345
+ if (!mcpTools || mcpTools.length === 0) {
346
+ return;
347
+ }
348
+
349
+ for (const definition of mcpTools) {
350
+ if (this.mcpTools.has(definition.name)) {
351
+ throw new PluginError(
352
+ `MCP tool '${definition.name}' is already registered by plugin '${this.mcpTools.get(definition.name)?.plugin}'`,
353
+ pluginName,
354
+ 'DUPLICATE_PLUGIN'
355
+ );
356
+ }
357
+
358
+ // Add plugin metadata
359
+ definition.pluginName = pluginName;
360
+
361
+ this.mcpTools.set(definition.name, { plugin: pluginName, definition });
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Unregister MCP tools from a plugin
367
+ */
368
+ unregisterPluginMCPTools(pluginName: string): void {
369
+ for (const [name, entry] of Array.from(this.mcpTools.entries())) {
370
+ if (entry.plugin === pluginName) {
371
+ this.mcpTools.delete(name);
372
+ }
373
+ }
374
+ }
375
+
376
+ /**
377
+ * Get MCP tool definition
378
+ */
379
+ getMCPTool(name: string): MCPToolDefinition | undefined {
380
+ return this.mcpTools.get(name)?.definition;
381
+ }
382
+
383
+ /**
384
+ * Get all MCP tools
385
+ */
386
+ getAllMCPTools(): MCPToolDefinition[] {
387
+ return Array.from(this.mcpTools.values()).map((entry) => entry.definition);
388
+ }
389
+
390
+ /**
391
+ * Get MCP tools by plugin
392
+ */
393
+ getMCPToolsByPlugin(pluginName: string): MCPToolDefinition[] {
394
+ return Array.from(this.mcpTools.values())
395
+ .filter((entry) => entry.plugin === pluginName)
396
+ .map((entry) => entry.definition);
397
+ }
398
+
399
+ // =============================================================================
400
+ // CLI Command Registry
401
+ // =============================================================================
402
+
403
+ /**
404
+ * Register CLI commands from a plugin
405
+ */
406
+ registerCLICommands(pluginName: string): void {
407
+ const info = this.plugins.get(pluginName);
408
+ if (!info) {
409
+ throw new PluginError(
410
+ `Plugin '${pluginName}' not found`,
411
+ pluginName,
412
+ 'INVALID_PLUGIN'
413
+ );
414
+ }
415
+
416
+ const cliCommands = info.plugin.registerCLICommands?.();
417
+ if (!cliCommands || cliCommands.length === 0) {
418
+ return;
419
+ }
420
+
421
+ for (const definition of cliCommands) {
422
+ if (this.cliCommands.has(definition.name)) {
423
+ throw new PluginError(
424
+ `CLI command '${definition.name}' is already registered by plugin '${this.cliCommands.get(definition.name)?.plugin}'`,
425
+ pluginName,
426
+ 'DUPLICATE_PLUGIN'
427
+ );
428
+ }
429
+
430
+ this.cliCommands.set(definition.name, { plugin: pluginName, definition });
431
+
432
+ // Register aliases
433
+ if (definition.aliases) {
434
+ for (const alias of definition.aliases) {
435
+ if (this.cliCommands.has(alias)) {
436
+ throw new PluginError(
437
+ `CLI command alias '${alias}' is already registered`,
438
+ pluginName,
439
+ 'DUPLICATE_PLUGIN'
440
+ );
441
+ }
442
+ this.cliCommands.set(alias, { plugin: pluginName, definition });
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ /**
449
+ * Unregister CLI commands from a plugin
450
+ */
451
+ unregisterPluginCLICommands(pluginName: string): void {
452
+ for (const [name, entry] of Array.from(this.cliCommands.entries())) {
453
+ if (entry.plugin === pluginName) {
454
+ this.cliCommands.delete(name);
455
+ }
456
+ }
457
+ }
458
+
459
+ /**
460
+ * Get CLI command definition
461
+ */
462
+ getCLICommand(name: string): CLICommandDefinition | undefined {
463
+ return this.cliCommands.get(name)?.definition;
464
+ }
465
+
466
+ /**
467
+ * Get all CLI commands
468
+ */
469
+ getAllCLICommands(): CLICommandDefinition[] {
470
+ const seen = new Set<CLICommandDefinition>();
471
+ return Array.from(this.cliCommands.values())
472
+ .map((entry) => entry.definition)
473
+ .filter((def) => {
474
+ if (seen.has(def)) return false;
475
+ seen.add(def);
476
+ return true;
477
+ });
478
+ }
479
+
480
+ /**
481
+ * Get CLI commands by plugin
482
+ */
483
+ getCLICommandsByPlugin(pluginName: string): CLICommandDefinition[] {
484
+ const seen = new Set<CLICommandDefinition>();
485
+ return Array.from(this.cliCommands.values())
486
+ .filter((entry) => entry.plugin === pluginName)
487
+ .map((entry) => entry.definition)
488
+ .filter((def) => {
489
+ if (seen.has(def)) return false;
490
+ seen.add(def);
491
+ return true;
492
+ });
493
+ }
494
+
495
+ // =============================================================================
496
+ // Memory Backend Registry
497
+ // =============================================================================
498
+
499
+ /**
500
+ * Register memory backends from a plugin
501
+ */
502
+ registerMemoryBackends(pluginName: string): void {
503
+ const info = this.plugins.get(pluginName);
504
+ if (!info) {
505
+ throw new PluginError(
506
+ `Plugin '${pluginName}' not found`,
507
+ pluginName,
508
+ 'INVALID_PLUGIN'
509
+ );
510
+ }
511
+
512
+ const memoryBackends = info.plugin.registerMemoryBackends?.();
513
+ if (!memoryBackends || memoryBackends.length === 0) {
514
+ return;
515
+ }
516
+
517
+ for (const factory of memoryBackends) {
518
+ if (this.memoryBackends.has(factory.name)) {
519
+ throw new PluginError(
520
+ `Memory backend '${factory.name}' is already registered by plugin '${this.memoryBackends.get(factory.name)?.plugin}'`,
521
+ pluginName,
522
+ 'DUPLICATE_PLUGIN'
523
+ );
524
+ }
525
+
526
+ this.memoryBackends.set(factory.name, { plugin: pluginName, factory });
527
+ }
528
+ }
529
+
530
+ /**
531
+ * Unregister memory backends from a plugin
532
+ */
533
+ unregisterPluginMemoryBackends(pluginName: string): void {
534
+ for (const [name, entry] of Array.from(this.memoryBackends.entries())) {
535
+ if (entry.plugin === pluginName) {
536
+ this.memoryBackends.delete(name);
537
+ }
538
+ }
539
+ }
540
+
541
+ /**
542
+ * Get memory backend factory
543
+ */
544
+ getMemoryBackend(name: string): MemoryBackendFactory | undefined {
545
+ return this.memoryBackends.get(name)?.factory;
546
+ }
547
+
548
+ /**
549
+ * Get all memory backends
550
+ */
551
+ getAllMemoryBackends(): MemoryBackendFactory[] {
552
+ return Array.from(this.memoryBackends.values()).map((entry) => entry.factory);
553
+ }
554
+
555
+ /**
556
+ * Get memory backends by plugin
557
+ */
558
+ getMemoryBackendsByPlugin(pluginName: string): MemoryBackendFactory[] {
559
+ return Array.from(this.memoryBackends.values())
560
+ .filter((entry) => entry.plugin === pluginName)
561
+ .map((entry) => entry.factory);
562
+ }
563
+
564
+ // =============================================================================
565
+ // Bulk Registration
566
+ // =============================================================================
567
+
568
+ /**
569
+ * Register all extension points from a plugin
570
+ */
571
+ registerAllFromPlugin(pluginName: string): void {
572
+ this.registerAgentTypes(pluginName);
573
+ this.registerTaskTypes(pluginName);
574
+ this.registerMCPTools(pluginName);
575
+ this.registerCLICommands(pluginName);
576
+ this.registerMemoryBackends(pluginName);
577
+ this.collectPluginMetrics(pluginName);
578
+ }
579
+
580
+ /**
581
+ * Clear all registrations (for testing)
582
+ */
583
+ clear(): void {
584
+ this.plugins.clear();
585
+ this.agentTypes.clear();
586
+ this.taskTypes.clear();
587
+ this.mcpTools.clear();
588
+ this.cliCommands.clear();
589
+ this.memoryBackends.clear();
590
+ }
591
+ }
592
+
593
+ /**
594
+ * Plugin registry status summary
595
+ */
596
+ export interface PluginRegistryStatus {
597
+ totalPlugins: number;
598
+ states: Record<PluginLifecycleState, number>;
599
+ agentTypesRegistered: number;
600
+ taskTypesRegistered: number;
601
+ mcpToolsRegistered: number;
602
+ cliCommandsRegistered: number;
603
+ memoryBackendsRegistered: number;
604
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Plugins System - ADR-004 Implementation
3
+ *
4
+ * Plugin architecture for extending Claude Flow functionality.
5
+ *
6
+ * @module v3/shared/plugins
7
+ */
8
+
9
+ // Types
10
+ export type {
11
+ PluginConfig,
12
+ PluginContext,
13
+ PluginEvent,
14
+ PluginEventHandler,
15
+ ClaudeFlowPlugin,
16
+ PluginMetadata,
17
+ IPluginRegistry,
18
+ IPluginLoader,
19
+ } from './types.js';
20
+
21
+ // Official Plugins
22
+ export {
23
+ HiveMindPlugin,
24
+ createHiveMindPlugin,
25
+ type HiveMindConfig,
26
+ type CollectiveDecision,
27
+ type EmergentPattern,
28
+ MaestroPlugin,
29
+ createMaestroPlugin,
30
+ type MaestroConfig,
31
+ type WorkflowStep,
32
+ type Workflow,
33
+ type OrchestrationResult,
34
+ } from './official/index.js';