claude-flow-novice 1.6.1 → 1.6.2

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 (244) hide show
  1. package/.claude/agents/cfn-loop/product-owner.md +54 -4
  2. package/.claude/commands/cfn-claude-sync.md +303 -0
  3. package/.claude/commands/cfn-loop-epic.md +290 -0
  4. package/.claude/commands/cfn-loop-single.md +168 -0
  5. package/.claude/commands/cfn-loop-sprints.md +384 -0
  6. package/.claude/commands/cfn-loop.md +180 -0
  7. package/.claude/commands/metrics-summary.md +58 -0
  8. package/.claude/commands/parse-epic.md +357 -0
  9. package/.claude/settings.json +4 -4
  10. package/.claude/settings.local.json +9 -2
  11. package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
  12. package/.claude-flow-novice/dist/mcp/server.js +21 -2
  13. package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
  14. package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
  16. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
  17. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
  18. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
  19. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
  21. package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
  23. package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
  24. package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
  26. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
  28. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
  30. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
  32. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
  33. package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
  34. package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
  36. package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
  37. package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
  38. package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
  39. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
  40. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
  41. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
  42. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
  44. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
  46. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
  48. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
  50. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
  52. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
  54. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
  56. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
  58. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
  61. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
  62. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
  63. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
  64. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
  65. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
  66. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
  67. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
  68. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
  69. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
  70. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
  71. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
  72. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
  74. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
  76. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
  78. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
  80. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
  82. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
  84. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
  86. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
  88. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
  90. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
  92. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
  94. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
  96. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
  98. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
  100. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
  102. package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
  103. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
  104. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
  105. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
  106. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
  108. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
  110. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
  112. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
  115. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
  116. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
  117. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
  118. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
  120. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
  122. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
  124. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
  126. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
  128. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
  130. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
  132. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
  134. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
  136. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
  137. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
  138. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
  139. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
  140. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
  142. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
  143. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
  144. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
  145. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
  146. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
  147. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
  148. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
  149. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
  150. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
  152. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
  154. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
  156. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
  158. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
  160. package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
  161. package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
  162. package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
  163. package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
  164. package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
  165. package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
  166. package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
  168. package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
  169. package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
  170. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  171. package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
  172. package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
  173. package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
  174. package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
  175. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
  176. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
  177. package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
  178. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
  179. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
  181. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
  183. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
  184. package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
  185. package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
  187. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
  189. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
  191. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
  193. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
  195. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
  197. package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
  199. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
  201. package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
  203. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
  205. package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
  207. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
  209. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
  211. package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
  213. package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
  214. package/.claude-flow-novice/metrics.db +0 -0
  215. package/.claude-flow-novice/metrics.db-shm +0 -0
  216. package/.claude-flow-novice/metrics.db-wal +0 -0
  217. package/CLAUDE.md +29 -0
  218. package/README.md +27 -0
  219. package/config/hooks/post-edit-pipeline.js +36 -2
  220. package/examples/metrics-counter-demo.ts +106 -0
  221. package/examples/persistent-metrics-demo.ts +83 -0
  222. package/examples/phase-5-multi-level-control.ts +282 -0
  223. package/examples/session-pool-optimizer-example.ts +311 -0
  224. package/package.json +15 -3
  225. package/scripts/check-routing-stats.cjs +122 -0
  226. package/scripts/pre-publish-validation.cjs +212 -0
  227. package/scripts/test-provider-routing.cjs +228 -0
  228. package/scripts/test-routing-telemetry.cjs +147 -0
  229. package/scripts/test-zai-10k.cjs +81 -0
  230. package/scripts/test-zai-api.cjs +191 -0
  231. package/scripts/test-zai-diagnostic.cjs +151 -0
  232. package/scripts/test-zai-final.cjs +128 -0
  233. package/scripts/test-zai-with-env.cjs +85 -0
  234. package/scripts/validate-coordination-cli.js +69 -0
  235. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  236. package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
  237. package/src/observability/metrics-counter.ts +347 -0
  238. package/src/observability/metrics-storage.ts +356 -0
  239. package/src/observability/telemetry.ts +658 -0
  240. package/src/slash-commands/cfn-claude-sync.js +533 -0
  241. package/src/slash-commands/index.js +5 -0
  242. package/src/slash-commands/metrics-summary-class.js +74 -0
  243. package/src/slash-commands/metrics-summary.js +335 -0
  244. package/src/slash-commands/register-all-commands.js +12 -0
@@ -0,0 +1,387 @@
1
+ /**
2
+ * Agent Coordination V2 - Message Bus
3
+ *
4
+ * Event-driven message bus with channel abstraction and pub/sub pattern.
5
+ * Provides unified interface for multi-channel communication with routing,
6
+ * priority queuing, and backpressure handling.
7
+ *
8
+ * Features:
9
+ * - Event-driven architecture (EventEmitter pattern)
10
+ * - Channel isolation (4 specialized channels)
11
+ * - Priority queue routing
12
+ * - Pub/sub with topic patterns
13
+ * - Backpressure coordination
14
+ * - Message ordering guarantees
15
+ *
16
+ * @module coordination/v2/messaging/message-bus
17
+ */ import { MessageRouter, ChannelType } from './message-router.js';
18
+ import { EventEmitter } from 'events';
19
+ /**
20
+ * Message bus events.
21
+ */ export var MessageBusEvent = /*#__PURE__*/ function(MessageBusEvent) {
22
+ /** Message published to bus */ MessageBusEvent["MESSAGE_PUBLISHED"] = "message-published";
23
+ /** Message delivered to subscriber */ MessageBusEvent["MESSAGE_DELIVERED"] = "message-delivered";
24
+ /** Message routed to channel */ MessageBusEvent["MESSAGE_ROUTED"] = "message-routed";
25
+ /** Subscription created */ MessageBusEvent["SUBSCRIBED"] = "subscribed";
26
+ /** Subscription removed */ MessageBusEvent["UNSUBSCRIBED"] = "unsubscribed";
27
+ /** Bus error */ MessageBusEvent["ERROR"] = "error";
28
+ return MessageBusEvent;
29
+ }({});
30
+ /**
31
+ * MessageBus - Event-driven message bus with channel abstraction.
32
+ *
33
+ * Unified interface for multi-channel pub/sub communication with
34
+ * priority-based routing, channel isolation, and backpressure handling.
35
+ *
36
+ * Architecture:
37
+ * - EventEmitter-based (event-driven pattern)
38
+ * - MessageRouter for priority queue routing
39
+ * - 4 specialized channels (coordination, task, help, event)
40
+ * - Auto-processing loop for continuous delivery
41
+ *
42
+ * Usage Patterns:
43
+ * - Pub/Sub: publish() + subscribe()
44
+ * - Direct channel access: getChannel()
45
+ * - Topic-based routing: Automatic via routing rules
46
+ *
47
+ * Performance:
48
+ * - publish(): O(log n) for routing + channel enqueue
49
+ * - subscribe(): O(1) for channel subscription
50
+ * - Auto-processing: Continuous background loop
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const bus = new MessageBus({
55
+ * autoProcess: true,
56
+ * autoProcessInterval: 10
57
+ * });
58
+ *
59
+ * // Subscribe to topics
60
+ * bus.subscribe('task.*', async (message) => {
61
+ * console.log('Task message:', message.payload);
62
+ * });
63
+ *
64
+ * // Publish messages
65
+ * bus.publish({
66
+ * topic: 'task.completed',
67
+ * payload: { taskId: 'task-1', result: 'success' },
68
+ * priority: 5
69
+ * });
70
+ *
71
+ * // Stats monitoring
72
+ * const stats = bus.getStats();
73
+ * console.log('Total published:', stats.totalPublished);
74
+ * ```
75
+ */ export class MessageBus extends EventEmitter {
76
+ /** Configuration */ config;
77
+ /** Message router */ router;
78
+ /** Auto-processing interval handle */ autoProcessTimer;
79
+ /** Statistics tracking */ stats;
80
+ /** Subscription registry (topic pattern -> subscription IDs) */ subscriptions;
81
+ /** Shutdown flag */ isShutdown;
82
+ constructor(config = {}){
83
+ super();
84
+ this.config = {
85
+ router: config.router ?? {},
86
+ autoProcess: config.autoProcess ?? true,
87
+ autoProcessInterval: config.autoProcessInterval ?? 10,
88
+ enableStats: config.enableStats ?? true
89
+ };
90
+ this.router = new MessageRouter(this.config.router);
91
+ this.autoProcessTimer = null;
92
+ this.isShutdown = false;
93
+ this.stats = {
94
+ totalPublished: 0,
95
+ totalDelivered: 0,
96
+ subscriptionCount: 0
97
+ };
98
+ this.subscriptions = new Map();
99
+ // Wire up router events
100
+ this.router.on('message-routed', (event)=>{
101
+ this.emit("message-routed", event);
102
+ });
103
+ this.router.on('error', (event)=>{
104
+ this.emit("error", event);
105
+ });
106
+ // Start auto-processing if enabled
107
+ if (this.config.autoProcess) {
108
+ this.startAutoProcessing();
109
+ }
110
+ }
111
+ /**
112
+ * Publish a message to the bus.
113
+ * Message is routed to appropriate channel based on topic.
114
+ *
115
+ * @param config - Message configuration
116
+ * @returns Created message object
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const message = bus.publish({
121
+ * topic: 'agent.status',
122
+ * payload: { agentId: 'agent-1', status: 'online' },
123
+ * priority: 5
124
+ * });
125
+ * ```
126
+ */ publish(config) {
127
+ if (this.isShutdown) {
128
+ throw new Error('Message bus is shutdown');
129
+ }
130
+ // Create message
131
+ const message = {
132
+ id: this.generateMessageId(),
133
+ topic: config.topic,
134
+ payload: config.payload,
135
+ priority: config.priority ?? 5,
136
+ timestamp: Date.now(),
137
+ replyTo: config.replyTo,
138
+ correlationId: config.correlationId,
139
+ senderId: config.senderId,
140
+ recipientId: config.recipientId,
141
+ deliverySemantics: config.deliverySemantics,
142
+ metadata: config.metadata
143
+ };
144
+ // Route to appropriate channel
145
+ this.router.route(message);
146
+ // Update statistics
147
+ this.stats.totalPublished++;
148
+ // Emit event
149
+ this.emit("message-published", {
150
+ messageId: message.id,
151
+ topic: message.topic,
152
+ priority: message.priority
153
+ });
154
+ return message;
155
+ }
156
+ /**
157
+ * Subscribe to messages matching topic pattern.
158
+ * Pattern supports wildcards (e.g., 'task.*', 'agent.status.*').
159
+ *
160
+ * @param topicPattern - Topic pattern to subscribe to
161
+ * @param handler - Message handler function
162
+ * @param priority - Handler priority (default: 0)
163
+ * @returns Subscription handle
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const sub = bus.subscribe('task.*', async (message) => {
168
+ * console.log('Task message:', message.payload);
169
+ * }, 10);
170
+ *
171
+ * // Later: unsubscribe
172
+ * sub.unsubscribe();
173
+ * ```
174
+ */ subscribe(topicPattern, handler, priority = 0) {
175
+ if (this.isShutdown) {
176
+ throw new Error('Message bus is shutdown');
177
+ }
178
+ // Determine which channel(s) to subscribe to based on pattern
179
+ const channelTypes = this.getChannelsForPattern(topicPattern);
180
+ if (channelTypes.length === 0) {
181
+ // Default to event channel for unknown patterns
182
+ channelTypes.push(ChannelType.EVENT);
183
+ }
184
+ // Subscribe to all matching channels
185
+ const channelSubscriptions = [];
186
+ for (const channelType of channelTypes){
187
+ const channel = this.router.getChannel(channelType);
188
+ if (channel) {
189
+ const sub = channel.subscribe(handler, priority);
190
+ channelSubscriptions.push(sub);
191
+ }
192
+ }
193
+ // Track subscription
194
+ const subscriptionId = `bus-sub-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
195
+ if (!this.subscriptions.has(topicPattern)) {
196
+ this.subscriptions.set(topicPattern, new Set());
197
+ }
198
+ this.subscriptions.get(topicPattern).add(subscriptionId);
199
+ this.stats.subscriptionCount++;
200
+ // Emit event
201
+ this.emit("subscribed", {
202
+ subscriptionId,
203
+ topicPattern,
204
+ channelTypes
205
+ });
206
+ // Return combined subscription
207
+ return {
208
+ id: subscriptionId,
209
+ topic: topicPattern,
210
+ createdAt: Date.now(),
211
+ unsubscribe: ()=>{
212
+ // Unsubscribe from all channels
213
+ for (const sub of channelSubscriptions){
214
+ sub.unsubscribe();
215
+ }
216
+ // Remove from tracking
217
+ const subs = this.subscriptions.get(topicPattern);
218
+ if (subs) {
219
+ subs.delete(subscriptionId);
220
+ if (subs.size === 0) {
221
+ this.subscriptions.delete(topicPattern);
222
+ }
223
+ }
224
+ this.stats.subscriptionCount--;
225
+ this.emit("unsubscribed", {
226
+ subscriptionId,
227
+ topicPattern
228
+ });
229
+ }
230
+ };
231
+ }
232
+ /**
233
+ * Get channel instance by type.
234
+ *
235
+ * @param channelType - Channel type
236
+ * @returns Channel instance or undefined
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const taskChannel = bus.getChannel(ChannelType.TASK);
241
+ * const stats = taskChannel.getStats();
242
+ * ```
243
+ */ getChannel(channelType) {
244
+ return this.router.getChannel(channelType);
245
+ }
246
+ /**
247
+ * Get all channels.
248
+ *
249
+ * @returns Map of channel type to channel instance
250
+ */ getAllChannels() {
251
+ return this.router.getAllChannels();
252
+ }
253
+ /**
254
+ * Process message queue manually.
255
+ * Normally handled by auto-processing, but can be called manually.
256
+ *
257
+ * @returns Number of messages processed
258
+ */ async processQueue() {
259
+ return await this.router.processQueue();
260
+ }
261
+ /**
262
+ * Get message bus statistics.
263
+ *
264
+ * @returns Statistics object
265
+ */ getStats() {
266
+ const routerStats = this.router.getStats();
267
+ // Aggregate channel stats
268
+ const channels = {};
269
+ const allChannels = this.router.getAllChannels();
270
+ for (const type of Object.values(ChannelType)){
271
+ const channel = allChannels.get(type);
272
+ if (channel) {
273
+ const channelStats = channel.getStats();
274
+ channels[type] = {
275
+ buffered: channelStats.currentBufferSize,
276
+ delivered: channelStats.totalDelivered,
277
+ dropped: channelStats.totalDropped,
278
+ subscribers: channelStats.totalSubscriptions,
279
+ avgLatencyMs: channelStats.avgLatencyMs
280
+ };
281
+ }
282
+ }
283
+ return {
284
+ totalPublished: this.stats.totalPublished,
285
+ totalDelivered: routerStats.channelStats[ChannelType.COORDINATION].delivered + routerStats.channelStats[ChannelType.TASK].delivered + routerStats.channelStats[ChannelType.HELP].delivered + routerStats.channelStats[ChannelType.EVENT].delivered,
286
+ totalDropped: routerStats.totalDropped,
287
+ totalSubscriptions: this.stats.subscriptionCount,
288
+ messagesByChannel: routerStats.messagesByChannel,
289
+ router: {
290
+ totalRouted: routerStats.totalRouted,
291
+ pendingMessages: routerStats.pendingMessages,
292
+ avgRoutingLatencyMs: routerStats.avgRoutingLatencyMs
293
+ },
294
+ channels
295
+ };
296
+ }
297
+ /**
298
+ * Start auto-processing loop.
299
+ */ startAutoProcessing() {
300
+ if (this.autoProcessTimer || this.isShutdown) {
301
+ return;
302
+ }
303
+ this.autoProcessTimer = setInterval(async ()=>{
304
+ try {
305
+ await this.processQueue();
306
+ } catch (error) {
307
+ this.emit("error", {
308
+ source: 'auto-processing',
309
+ error
310
+ });
311
+ }
312
+ }, this.config.autoProcessInterval);
313
+ // Prevent timer from blocking process exit
314
+ if (this.autoProcessTimer.unref) {
315
+ this.autoProcessTimer.unref();
316
+ }
317
+ }
318
+ /**
319
+ * Stop auto-processing loop.
320
+ */ stopAutoProcessing() {
321
+ if (this.autoProcessTimer) {
322
+ clearInterval(this.autoProcessTimer);
323
+ this.autoProcessTimer = null;
324
+ }
325
+ }
326
+ /**
327
+ * Determine which channels match a topic pattern.
328
+ *
329
+ * @param pattern - Topic pattern
330
+ * @returns Array of matching channel types
331
+ */ getChannelsForPattern(pattern) {
332
+ const channels = [];
333
+ // Simple pattern matching for common prefixes
334
+ if (pattern.startsWith('agent.') || pattern.startsWith('coordinator.') || pattern.startsWith('session.')) {
335
+ channels.push(ChannelType.COORDINATION);
336
+ }
337
+ if (pattern.startsWith('task.') || pattern.startsWith('job.') || pattern.startsWith('execution.')) {
338
+ channels.push(ChannelType.TASK);
339
+ }
340
+ if (pattern.startsWith('help.') || pattern.startsWith('assistance.')) {
341
+ channels.push(ChannelType.HELP);
342
+ }
343
+ // Wildcard or unknown patterns go to event channel
344
+ if (pattern === '*' || channels.length === 0) {
345
+ channels.push(ChannelType.EVENT);
346
+ }
347
+ return channels;
348
+ }
349
+ /**
350
+ * Generate unique message ID.
351
+ *
352
+ * @returns Message ID
353
+ */ generateMessageId() {
354
+ return `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
355
+ }
356
+ /**
357
+ * Clear all messages and statistics.
358
+ * Does not affect subscriptions.
359
+ */ clear() {
360
+ this.router.clear();
361
+ this.stats = {
362
+ totalPublished: 0,
363
+ totalDelivered: 0,
364
+ subscriptionCount: this.stats.subscriptionCount
365
+ };
366
+ }
367
+ /**
368
+ * Shutdown the message bus.
369
+ * Stops auto-processing, closes all channels, and clears subscriptions.
370
+ */ shutdown() {
371
+ if (this.isShutdown) {
372
+ return;
373
+ }
374
+ this.isShutdown = true;
375
+ this.stopAutoProcessing();
376
+ this.router.shutdown();
377
+ this.subscriptions.clear();
378
+ this.removeAllListeners();
379
+ }
380
+ /**
381
+ * Check if bus is shutdown.
382
+ */ get closed() {
383
+ return this.isShutdown;
384
+ }
385
+ }
386
+
387
+ //# sourceMappingURL=message-bus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/coordination/v2/messaging/message-bus.ts"],"names":["MessageRouter","ChannelType","EventEmitter","MessageBusEvent","MessageBus","config","router","autoProcessTimer","stats","subscriptions","isShutdown","autoProcess","autoProcessInterval","enableStats","totalPublished","totalDelivered","subscriptionCount","Map","on","event","emit","startAutoProcessing","publish","Error","message","id","generateMessageId","topic","payload","priority","timestamp","Date","now","replyTo","correlationId","senderId","recipientId","deliverySemantics","metadata","route","messageId","subscribe","topicPattern","handler","channelTypes","getChannelsForPattern","length","push","EVENT","channelSubscriptions","channelType","channel","getChannel","sub","subscriptionId","Math","random","toString","substr","has","set","Set","get","add","createdAt","unsubscribe","subs","delete","size","getAllChannels","processQueue","getStats","routerStats","channels","allChannels","type","Object","values","channelStats","buffered","currentBufferSize","delivered","dropped","totalDropped","subscribers","totalSubscriptions","avgLatencyMs","COORDINATION","TASK","HELP","messagesByChannel","totalRouted","pendingMessages","avgRoutingLatencyMs","setInterval","error","source","unref","stopAutoProcessing","clearInterval","pattern","startsWith","clear","shutdown","removeAllListeners","closed"],"mappings":"AAAA;;;;;;;;;;;;;;;;CAgBC,GAGD,SAASA,aAAa,EAAEC,WAAW,QAA2B,sBAAsB;AAEpF,SAASC,YAAY,QAAQ,SAAS;AAuDtC;;CAEC,GACD,OAAO,IAAA,AAAKC,yCAAAA;IACV,6BAA6B;IAG7B,oCAAoC;IAGpC,8BAA8B;IAG9B,yBAAyB;IAGzB,yBAAyB;IAGzB,cAAc;WAhBJA;MAkBX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CC,GACD,OAAO,MAAMC,mBAAmBF;IAC9B,kBAAkB,GAClB,AAAiBG,OAAmC;IAEpD,mBAAmB,GACnB,AAAiBC,OAAsB;IAEvC,oCAAoC,GACpC,AAAQC,iBAAwC;IAEhD,wBAAwB,GACxB,AAAQC,MAIN;IAEF,8DAA8D,GAC9D,AAAQC,cAAwC;IAEhD,kBAAkB,GAClB,AAAQC,WAAoB;IAE5B,YAAYL,SAA2B,CAAC,CAAC,CAAE;QACzC,KAAK;QAEL,IAAI,CAACA,MAAM,GAAG;YACZC,QAAQD,OAAOC,MAAM,IAAI,CAAC;YAC1BK,aAAaN,OAAOM,WAAW,IAAI;YACnCC,qBAAqBP,OAAOO,mBAAmB,IAAI;YACnDC,aAAaR,OAAOQ,WAAW,IAAI;QACrC;QAEA,IAAI,CAACP,MAAM,GAAG,IAAIN,cAAc,IAAI,CAACK,MAAM,CAACC,MAAM;QAClD,IAAI,CAACC,gBAAgB,GAAG;QACxB,IAAI,CAACG,UAAU,GAAG;QAElB,IAAI,CAACF,KAAK,GAAG;YACXM,gBAAgB;YAChBC,gBAAgB;YAChBC,mBAAmB;QACrB;QAEA,IAAI,CAACP,aAAa,GAAG,IAAIQ;QAEzB,wBAAwB;QACxB,IAAI,CAACX,MAAM,CAACY,EAAE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