claude-flow-novice 1.6.4 → 1.6.5

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 (269) hide show
  1. package/.claude/commands/parse-epic.js +180 -0
  2. package/.claude/settings.local.json +2 -1
  3. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +37 -2
  4. package/.claude-flow-novice/dist/mcp/transports/base.js +5 -0
  5. package/.claude-flow-novice/dist/mcp/transports/base.js.map +1 -0
  6. package/.claude-flow-novice/dist/mcp/transports/http.js +414 -0
  7. package/.claude-flow-novice/dist/mcp/transports/http.js.map +1 -0
  8. package/.claude-flow-novice/dist/mcp/transports/stdio.js +217 -0
  9. package/.claude-flow-novice/dist/mcp/transports/stdio.js.map +1 -0
  10. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js +129 -0
  11. package/.claude-flow-novice/dist/src/cli/commands/parse-epic.js.map +1 -0
  12. package/.claude-flow-novice/dist/src/cli/index.js +3 -0
  13. package/.claude-flow-novice/dist/src/cli/index.js.map +1 -1
  14. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js +266 -0
  15. package/.claude-flow-novice/dist/src/cli/utils/epic-parser.js.map +1 -0
  16. package/.claude-flow-novice/dist/src/communication/message-bus.js +105 -2
  17. package/.claude-flow-novice/dist/src/communication/message-bus.js.map +1 -1
  18. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +1 -1
  19. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js +632 -0
  21. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/artifact-cache-optimizer.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js +11 -0
  23. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/cache/index.js.map +1 -0
  24. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js +318 -0
  25. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  26. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js +234 -0
  27. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/completion-detector.js.map +1 -0
  28. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js +347 -0
  29. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/hierarchical-detector.js.map +1 -0
  30. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js +13 -0
  31. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/index.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js +173 -0
  33. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/lamport-clock.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js +526 -0
  35. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/mesh-detector.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js +443 -0
  37. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/sdk-completion-detector.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js +366 -0
  39. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/completion/swarm-shutdown.js.map +1 -0
  40. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js +287 -0
  41. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinator-factory.js.map +1 -0
  42. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js +364 -0
  43. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  44. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js +492 -0
  45. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/cascading-shutdown.js.map +1 -0
  46. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js +786 -0
  47. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  48. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js +16 -0
  49. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/index.js.map +1 -0
  50. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js +342 -0
  51. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/parent-child-manager.js.map +1 -0
  52. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js +601 -0
  53. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  54. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js +9 -0
  55. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/agent-state.js.map +1 -0
  56. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js +413 -0
  57. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dead-letter-queue.js.map +1 -0
  58. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js +471 -0
  59. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-graph.js.map +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js +379 -0
  61. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-node.js.map +1 -0
  62. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js +335 -0
  63. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/dependency-resolver.js.map +1 -0
  64. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js +211 -0
  65. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/help-request-metrics.js.map +1 -0
  66. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js +33 -0
  67. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/index.js.map +1 -0
  68. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js +920 -0
  69. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-broker.js.map +1 -0
  70. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js +385 -0
  71. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message-router.js.map +1 -0
  72. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js +138 -0
  73. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/message.js.map +1 -0
  74. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js +478 -0
  75. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.js.map +1 -0
  76. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js +358 -0
  77. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine-config.js.map +1 -0
  78. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js +588 -0
  79. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-machine.js.map +1 -0
  80. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js +153 -0
  81. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/state-transition.js.map +1 -0
  82. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js +360 -0
  83. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/task-scheduler.js.map +1 -0
  84. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js +337 -0
  85. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/core/topic-manager.js.map +1 -0
  86. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js +424 -0
  87. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/deadlock-detector.js.map +1 -0
  88. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js +9 -0
  89. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/index.js.map +1 -0
  90. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js +669 -0
  91. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/deadlock/resource-manager.js.map +1 -0
  92. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js +451 -0
  93. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/artifact-storage.js.map +1 -0
  94. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js +271 -0
  95. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/cycle-detector.js.map +1 -0
  96. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js +335 -0
  97. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-graph.js.map +1 -0
  98. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js +439 -0
  99. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-manager.js.map +1 -0
  100. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js +92 -0
  101. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/dependency-request.js.map +1 -0
  102. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js +21 -0
  103. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/index.js.map +1 -0
  104. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js +223 -0
  105. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/dependency/topological-sort.js.map +1 -0
  106. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js +436 -0
  107. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-coordinator.js.map +1 -0
  108. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js +278 -0
  109. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-matcher.js.map +1 -0
  110. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js +317 -0
  111. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request-handler.js.map +1 -0
  112. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js +273 -0
  113. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/help-request.js.map +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js +15 -0
  115. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/index.js.map +1 -0
  116. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js +512 -0
  117. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/help-system/waiting-agent-pool.js.map +1 -0
  118. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js +67 -0
  119. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/index.js.map +1 -0
  120. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js +557 -0
  121. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/help-deadlock-integration.js.map +1 -0
  122. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js +14 -0
  123. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/index.js.map +1 -0
  124. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js +212 -0
  125. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  126. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js +552 -0
  127. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/message-bus-completion-integration.js.map +1 -0
  128. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js +635 -0
  129. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/integration/state-machine-integration.js.map +1 -0
  130. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js +28 -0
  131. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/IArtifactStorage.js.map +1 -0
  132. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js +9 -0
  133. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ICoordinator.js.map +1 -0
  134. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js +25 -0
  135. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/ISessionStore.js.map +1 -0
  136. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js +14 -0
  137. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/interfaces/index.js.map +1 -0
  138. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js +308 -0
  139. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/artifact-adapter.js.map +1 -0
  140. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js +439 -0
  141. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/completion-storage.js.map +1 -0
  142. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js +540 -0
  143. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-graph-storage.js.map +1 -0
  144. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js +367 -0
  145. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/dependency-storage.js.map +1 -0
  146. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js +14 -0
  147. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/index.js.map +1 -0
  148. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js +518 -0
  149. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/message-storage.js.map +1 -0
  150. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js +377 -0
  151. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/memory/state-storage.js.map +1 -0
  152. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js +371 -0
  153. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channel.js.map +1 -0
  154. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js +355 -0
  155. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/dependency-channel.js.map +1 -0
  156. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js +424 -0
  157. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/help-channel.js.map +1 -0
  158. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js +16 -0
  159. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/index.js.map +1 -0
  160. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js +295 -0
  161. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/state-channel.js.map +1 -0
  162. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js +411 -0
  163. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/channels/task-channel.js.map +1 -0
  164. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js +14 -0
  165. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/index.js.map +1 -0
  166. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js +387 -0
  167. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-bus.js.map +1 -0
  168. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js +589 -0
  169. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-persistence.js.map +1 -0
  170. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js +444 -0
  171. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/messaging/message-router.js.map +1 -0
  172. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js +560 -0
  173. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/artifact-storage.js.map +1 -0
  174. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js +335 -0
  175. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/background-orchestrator.js.map +1 -0
  176. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js +104 -0
  177. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/bash-output-monitor.js.map +1 -0
  178. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js +847 -0
  179. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/checkpoint-manager.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js +470 -0
  181. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/help-coordinator.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js +450 -0
  183. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/hierarchical-background-integration.js.map +1 -0
  184. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js +13 -0
  185. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/index.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js +625 -0
  187. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/message-bus-integration.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js +545 -0
  189. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/multi-level-control.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js +740 -0
  191. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-controller.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js +415 -0
  193. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/query-message-integration.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js +615 -0
  195. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/session-pool-optimizer.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js +547 -0
  197. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-machine-integration.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js +342 -0
  199. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/sdk/state-sdk-integration.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js +259 -0
  201. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/security/payload-validator.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js +273 -0
  203. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/framework-registry.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js +8 -0
  205. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/index.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js +310 -0
  207. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-config-manager.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js +218 -0
  209. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/truth/truth-validator.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js +9 -0
  211. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/types/sdk.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js +6 -0
  213. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/index.js.map +1 -0
  214. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js +145 -0
  215. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/priority-queue.js.map +1 -0
  216. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js +122 -0
  217. package/.claude-flow-novice/dist/src/coordination/archives/v2-sdk-typescript/v2/utils/sdk-helpers.js.map +1 -0
  218. package/.claude-flow-novice/dist/src/coordination/config-translator.js +17 -43
  219. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -1
  220. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +34 -76
  221. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -1
  222. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js +172 -0
  223. package/.claude-flow-novice/dist/src/coordination/shared/core/agent-state.js.map +1 -0
  224. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js +7 -0
  225. package/.claude-flow-novice/dist/src/coordination/shared/core/index.js.map +1 -0
  226. package/.claude-flow-novice/dist/src/coordination/shared/index.js +19 -0
  227. package/.claude-flow-novice/dist/src/coordination/shared/index.js.map +1 -0
  228. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js +24 -0
  229. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/ICoordinator.js.map +1 -0
  230. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js +7 -0
  231. package/.claude-flow-novice/dist/src/coordination/shared/interfaces/index.js.map +1 -0
  232. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js +920 -0
  233. package/.claude-flow-novice/dist/src/coordination/shared/message-broker.js.map +1 -0
  234. package/.claude-flow-novice/dist/src/coordination/shared/message.js +138 -0
  235. package/.claude-flow-novice/dist/src/coordination/shared/message.js.map +1 -0
  236. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js +259 -0
  237. package/.claude-flow-novice/dist/src/coordination/shared/security/payload-validator.js.map +1 -0
  238. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js +17 -0
  239. package/.claude-flow-novice/dist/src/coordination/shared/transparency/index.js.map +1 -0
  240. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js +19 -0
  241. package/.claude-flow-novice/dist/src/coordination/shared/transparency/interfaces/transparency-system.js.map +1 -0
  242. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js +357 -0
  243. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-integration.js.map +1 -0
  244. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js +679 -0
  245. package/.claude-flow-novice/dist/src/coordination/shared/transparency/transparency-system.js.map +1 -0
  246. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js +7 -0
  247. package/.claude-flow-novice/dist/src/coordination/shared/types/index.js.map +1 -0
  248. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js +10 -0
  249. package/.claude-flow-novice/dist/src/coordination/shared/types/sdk.js.map +1 -0
  250. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js +52 -2
  251. package/.claude-flow-novice/dist/src/feature-flags/core/FeatureFlagManager.js.map +1 -1
  252. package/.claude-flow-novice/dist/src/mcp/mcp-server-novice.js +37 -2
  253. package/.claude-flow-novice/dist/src/mcp/session-manager.js +3 -1
  254. package/.claude-flow-novice/dist/src/mcp/session-manager.js.map +1 -1
  255. package/.claude-flow-novice/dist/src/providers/provider-manager.js +36 -3
  256. package/.claude-flow-novice/dist/src/providers/provider-manager.js.map +1 -1
  257. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js +65 -41
  258. package/.claude-flow-novice/dist/src/utils/markdown-sanitizer.js.map +1 -1
  259. package/.claude-flow-novice/dist/src/web/api/server.js +1 -1
  260. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -1
  261. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js +30 -0
  262. package/.claude-flow-novice/dist/src/workflows/progressive-rollout-manager.js.map +1 -1
  263. package/.claude-flow-novice/metrics.db-shm +0 -0
  264. package/.claude-flow-novice/metrics.db-wal +0 -0
  265. package/package.json +2 -2
  266. package/scripts/monitoring/alert-monitor.sh +220 -0
  267. package/scripts/monitoring/view-alerts.sh +307 -0
  268. package/scripts/test-zai-api.cjs +2 -2
  269. package/src/slash-commands/parse-epic.js +1 -1
@@ -0,0 +1,478 @@
1
+ /**
2
+ * Thread-Safe Resource Manager (Phase 8 Preparation)
3
+ *
4
+ * Rust-inspired concurrency patterns applied to TypeScript:
5
+ * - Atomic test-and-set for lock acquisition
6
+ * - Immutable queue updates for wait queue
7
+ * - Hard resource limits for DoS prevention
8
+ * - No race conditions in critical sections
9
+ *
10
+ * @module coordination/v2/core/resource-manager-safe
11
+ */ /**
12
+ * Thread-safe resource manager with deadlock prevention.
13
+ *
14
+ * Key safety properties:
15
+ * 1. Atomic lock operations (no check-then-act races)
16
+ * 2. Immutable wait queue updates (no concurrent modification)
17
+ * 3. Hard resource limits (prevents DoS)
18
+ * 4. Automatic stale lock cleanup
19
+ *
20
+ * Rust equivalent patterns:
21
+ * - Arc<RwLock<HashMap<ResourceId, AgentId>>> for locks
22
+ * - Arc<Mutex<BinaryHeap<LockRequest>>> for wait queue
23
+ * - Automatic Drop cleanup for stale locks
24
+ */ export class SafeResourceManager {
25
+ config;
26
+ resources = new Map();
27
+ locks = new Map();
28
+ waitQueues = new Map();
29
+ agentResources = new Map();
30
+ // Concurrency control
31
+ operationLock = false;
32
+ cleanupInterval;
33
+ constructor(config){
34
+ this.config = config;
35
+ // Start periodic cleanup (equivalent to Rust's background task)
36
+ this.cleanupInterval = setInterval(()=>{
37
+ this.cleanupStaleLocks().catch(console.error);
38
+ }, 30000);
39
+ }
40
+ /**
41
+ * Acquire resource lock with atomic test-and-set.
42
+ *
43
+ * Rust equivalent:
44
+ * ```rust
45
+ * let guard = resource.lock.compare_exchange(
46
+ * false, true, Ordering::AcqRel, Ordering::Acquire
47
+ * )?;
48
+ * ```
49
+ *
50
+ * @param resourceId - Resource to acquire
51
+ * @param agentId - Agent requesting lock
52
+ * @param priority - Request priority (higher = more urgent)
53
+ */ async acquire(resourceId, agentId, priority = 0) {
54
+ return this.withOperationLock(async ()=>{
55
+ // Check hard resource limit (DoS prevention)
56
+ if (this.resources.size >= this.config.maxResources && !this.resources.has(resourceId)) {
57
+ throw new Error(`Resource limit reached (${this.config.maxResources} max)`);
58
+ }
59
+ // Ensure resource exists
60
+ if (!this.resources.has(resourceId)) {
61
+ this.resources.set(resourceId, {
62
+ id: resourceId,
63
+ type: 'generic',
64
+ locked: false
65
+ });
66
+ }
67
+ // ATOMIC: Try to acquire lock
68
+ const acquired = this.tryAcquireLock(resourceId, agentId);
69
+ if (acquired) {
70
+ return; // Success - lock acquired
71
+ }
72
+ // Lock already held - add to wait queue
73
+ await this.enqueueWaitRequest(resourceId, agentId, priority);
74
+ });
75
+ }
76
+ /**
77
+ * Release resource lock and grant to next waiter.
78
+ *
79
+ * Rust equivalent:
80
+ * ```rust
81
+ * drop(guard); // Automatically releases lock
82
+ * if let Some(next) = wait_queue.pop() {
83
+ * grant_lock(next);
84
+ * }
85
+ * ```
86
+ */ async release(resourceId, agentId) {
87
+ return this.withOperationLock(async ()=>{
88
+ const currentLock = this.locks.get(resourceId);
89
+ if (currentLock !== agentId) {
90
+ console.warn(`[ResourceManager] Agent ${agentId} attempted to release unowned resource ${resourceId}`);
91
+ return;
92
+ }
93
+ // Release lock
94
+ this.releaseLock(resourceId, agentId);
95
+ // Grant to next in queue
96
+ const queue = this.waitQueues.get(resourceId);
97
+ if (queue && queue.length > 0) {
98
+ // Remove first waiter (immutable update)
99
+ const [nextRequest, ...remainingQueue] = queue;
100
+ this.waitQueues.set(resourceId, remainingQueue);
101
+ // Grant lock atomically
102
+ this.grantLock(resourceId, nextRequest.agentId);
103
+ console.log(`[ResourceManager] Lock granted to ${nextRequest.agentId} for ${resourceId}`);
104
+ }
105
+ });
106
+ }
107
+ /**
108
+ * Release all resources held by agent.
109
+ * Used during agent shutdown or deadlock recovery.
110
+ */ async releaseAllForAgent(agentId) {
111
+ const resourceIds = this.agentResources.get(agentId);
112
+ if (!resourceIds) return;
113
+ for (const resourceId of Array.from(resourceIds)){
114
+ await this.release(resourceId, agentId);
115
+ }
116
+ this.agentResources.delete(agentId);
117
+ }
118
+ /**
119
+ * Get current resource allocations (for WFG construction).
120
+ */ getAllocations() {
121
+ return new Map(this.locks);
122
+ }
123
+ /**
124
+ * Get waiting agents (for WFG edge construction).
125
+ * Returns map of agentId → resources they're waiting for.
126
+ */ getWaitingAgents() {
127
+ const waiting = new Map();
128
+ for (const [resourceId, queue] of Array.from(this.waitQueues.entries())){
129
+ for (const request of queue){
130
+ const resources = waiting.get(request.agentId) || [];
131
+ resources.push(resourceId);
132
+ waiting.set(request.agentId, resources);
133
+ }
134
+ }
135
+ return waiting;
136
+ }
137
+ /**
138
+ * Cleanup stale locks (automatic Drop-like behavior).
139
+ *
140
+ * Rust equivalent:
141
+ * ```rust
142
+ * impl Drop for ResourceGuard {
143
+ * fn drop(&mut self) {
144
+ * if self.held_too_long() {
145
+ * force_release(self.resource_id);
146
+ * }
147
+ * }
148
+ * }
149
+ * ```
150
+ */ async cleanupStaleLocks() {
151
+ return this.withOperationLock(async ()=>{
152
+ const now = Date.now();
153
+ const staleThreshold = this.config.resourceTimeout * 2;
154
+ for (const [resourceId, agentId] of Array.from(this.locks)){
155
+ const resource = this.resources.get(resourceId);
156
+ if (!resource?.lockedAt) continue;
157
+ const lockAge = now - resource.lockedAt;
158
+ if (lockAge > staleThreshold) {
159
+ console.warn(`[ResourceManager] Force releasing stale lock: ${resourceId} held by ${agentId} for ${lockAge}ms`);
160
+ this.releaseLock(resourceId, agentId);
161
+ }
162
+ }
163
+ // Cleanup stale wait requests
164
+ for (const [resourceId, queue] of Array.from(this.waitQueues)){
165
+ const fresh = queue.filter((req)=>{
166
+ const age = now - req.timestamp;
167
+ if (age > this.config.maxWaitTime) {
168
+ console.warn(`[ResourceManager] Removing stale wait request: ${req.agentId} waiting ${age}ms`);
169
+ return false;
170
+ }
171
+ return true;
172
+ });
173
+ if (fresh.length === 0) {
174
+ this.waitQueues.delete(resourceId);
175
+ } else {
176
+ this.waitQueues.set(resourceId, fresh);
177
+ }
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * Atomic test-and-set lock operation.
183
+ *
184
+ * CRITICAL: This must be atomic to prevent race conditions.
185
+ * Returns true if lock was acquired, false otherwise.
186
+ */ tryAcquireLock(resourceId, agentId) {
187
+ const resource = this.resources.get(resourceId);
188
+ // Check if already locked (atomic read)
189
+ if (resource.locked) {
190
+ // Already locked by someone else
191
+ if (resource.lockedBy !== agentId) {
192
+ return false;
193
+ }
194
+ // Already locked by us (re-entrant lock)
195
+ return true;
196
+ }
197
+ // Atomically set lock flag and metadata
198
+ resource.locked = true;
199
+ resource.lockedBy = agentId;
200
+ resource.lockedAt = Date.now();
201
+ this.locks.set(resourceId, agentId);
202
+ // Track agent resources
203
+ if (!this.agentResources.has(agentId)) {
204
+ this.agentResources.set(agentId, new Set());
205
+ }
206
+ this.agentResources.get(agentId).add(resourceId);
207
+ console.log(`[ResourceManager] Lock acquired: ${resourceId} by ${agentId}`);
208
+ return true;
209
+ }
210
+ /**
211
+ * Grant lock to specific agent (used after queue processing).
212
+ */ grantLock(resourceId, agentId) {
213
+ const resource = this.resources.get(resourceId);
214
+ resource.locked = true;
215
+ resource.lockedBy = agentId;
216
+ resource.lockedAt = Date.now();
217
+ this.locks.set(resourceId, agentId);
218
+ if (!this.agentResources.has(agentId)) {
219
+ this.agentResources.set(agentId, new Set());
220
+ }
221
+ this.agentResources.get(agentId).add(resourceId);
222
+ }
223
+ /**
224
+ * Release lock (internal - assumes caller holds operation lock).
225
+ */ releaseLock(resourceId, agentId) {
226
+ const resource = this.resources.get(resourceId);
227
+ if (!resource) return;
228
+ resource.locked = false;
229
+ delete resource.lockedBy;
230
+ delete resource.lockedAt;
231
+ this.locks.delete(resourceId);
232
+ this.agentResources.get(agentId)?.delete(resourceId);
233
+ console.log(`[ResourceManager] Lock released: ${resourceId} by ${agentId}`);
234
+ }
235
+ /**
236
+ * Add request to wait queue with priority ordering (immutable update).
237
+ *
238
+ * Rust equivalent:
239
+ * ```rust
240
+ * let mut queue = self.wait_queue.lock().unwrap();
241
+ * queue.push(request);
242
+ * queue.sort_by_key(|r| (Reverse(r.priority), r.timestamp));
243
+ * ```
244
+ */ async enqueueWaitRequest(resourceId, agentId, priority) {
245
+ const request = {
246
+ agentId,
247
+ resourceId,
248
+ timestamp: Date.now(),
249
+ priority
250
+ };
251
+ // IMMUTABLE UPDATE: Create new sorted queue
252
+ const oldQueue = this.waitQueues.get(resourceId) || [];
253
+ const newQueue = [
254
+ ...oldQueue,
255
+ request
256
+ ].sort((a, b)=>{
257
+ // Higher priority first, then FIFO
258
+ if (a.priority !== b.priority) {
259
+ return b.priority - a.priority;
260
+ }
261
+ return a.timestamp - b.timestamp;
262
+ });
263
+ this.waitQueues.set(resourceId, newQueue);
264
+ console.log(`[ResourceManager] Agent ${agentId} enqueued for ${resourceId} (priority=${priority}, queue_len=${newQueue.length})`);
265
+ // Wait for lock with timeout
266
+ const startTime = Date.now();
267
+ while(Date.now() - startTime < this.config.maxWaitTime){
268
+ // Check if we got the lock
269
+ if (this.locks.get(resourceId) === agentId) {
270
+ return; // Success
271
+ }
272
+ // Check if still in queue
273
+ const currentQueue = this.waitQueues.get(resourceId) || [];
274
+ if (!currentQueue.some((req)=>req.agentId === agentId)) {
275
+ throw new Error(`Wait request cancelled for ${resourceId}`);
276
+ }
277
+ // Yield CPU
278
+ await new Promise((resolve)=>setImmediate(resolve));
279
+ }
280
+ // Timeout - remove from queue
281
+ const finalQueue = this.waitQueues.get(resourceId) || [];
282
+ const filtered = finalQueue.filter((req)=>req.agentId !== agentId);
283
+ this.waitQueues.set(resourceId, filtered);
284
+ throw new Error(`Resource acquisition timeout for ${resourceId} (waited ${this.config.maxWaitTime}ms)`);
285
+ }
286
+ /**
287
+ * Operation lock helper (prevents concurrent state modifications).
288
+ *
289
+ * Rust equivalent:
290
+ * ```rust
291
+ * async fn with_lock<T, F>(&self, f: F) -> T
292
+ * where F: FnOnce() -> T {
293
+ * let _guard = self.lock.lock().await;
294
+ * f()
295
+ * }
296
+ * ```
297
+ */ async withOperationLock(fn) {
298
+ // Spin-lock (simple re-entrance guard)
299
+ while(this.operationLock){
300
+ await new Promise((resolve)=>setImmediate(resolve));
301
+ }
302
+ this.operationLock = true;
303
+ try {
304
+ return await fn();
305
+ } finally{
306
+ this.operationLock = false;
307
+ }
308
+ }
309
+ /**
310
+ * Shutdown gracefully.
311
+ */ async shutdown() {
312
+ if (this.cleanupInterval) {
313
+ clearInterval(this.cleanupInterval);
314
+ this.cleanupInterval = undefined;
315
+ }
316
+ // Final cleanup
317
+ await this.cleanupStaleLocks();
318
+ // Release all locks
319
+ for (const [resourceId, agentId] of Array.from(this.locks)){
320
+ this.releaseLock(resourceId, agentId);
321
+ }
322
+ this.resources.clear();
323
+ this.locks.clear();
324
+ this.waitQueues.clear();
325
+ this.agentResources.clear();
326
+ }
327
+ /**
328
+ * Health check metrics.
329
+ */ getHealthStatus() {
330
+ const now = Date.now();
331
+ let totalLockAge = 0;
332
+ let lockedCount = 0;
333
+ for (const [resourceId] of Array.from(this.locks.entries())){
334
+ const resource = this.resources.get(resourceId);
335
+ if (resource?.lockedAt) {
336
+ totalLockAge += now - resource.lockedAt;
337
+ lockedCount++;
338
+ }
339
+ }
340
+ const waitingAgents = new Set();
341
+ let totalWaiting = 0;
342
+ for (const queue of Array.from(this.waitQueues.values())){
343
+ totalWaiting += queue.length;
344
+ queue.forEach((req)=>waitingAgents.add(req.agentId));
345
+ }
346
+ return {
347
+ healthy: true,
348
+ metrics: {
349
+ totalResources: this.resources.size,
350
+ lockedResources: this.locks.size,
351
+ freeResources: this.resources.size - this.locks.size,
352
+ waitingAgents: waitingAgents.size,
353
+ totalWaitingRequests: totalWaiting,
354
+ averageLockAge: lockedCount > 0 ? totalLockAge / lockedCount : 0
355
+ }
356
+ };
357
+ }
358
+ }
359
+ /**
360
+ * Wait-For-Graph for deadlock detection (Phase 8).
361
+ *
362
+ * Rust equivalent:
363
+ * ```rust
364
+ * struct WaitForGraph {
365
+ * edges: Arc<RwLock<HashMap<AgentId, HashSet<AgentId>>>>,
366
+ * }
367
+ * ```
368
+ */ export class WaitForGraph {
369
+ edges = new Map();
370
+ lock = false;
371
+ /**
372
+ * Add wait relationship: waiter is waiting for holder.
373
+ */ async addEdge(waiter, holder) {
374
+ return this.withLock(async ()=>{
375
+ if (!this.edges.has(waiter)) {
376
+ this.edges.set(waiter, new Set());
377
+ }
378
+ this.edges.get(waiter).add(holder);
379
+ });
380
+ }
381
+ /**
382
+ * Remove wait relationship.
383
+ */ async removeEdge(waiter, holder) {
384
+ return this.withLock(async ()=>{
385
+ const holders = this.edges.get(waiter);
386
+ if (holders) {
387
+ holders.delete(holder);
388
+ if (holders.size === 0) {
389
+ this.edges.delete(waiter);
390
+ }
391
+ }
392
+ });
393
+ }
394
+ /**
395
+ * Detect cycle using DFS (returns cycle path if found).
396
+ *
397
+ * Rust equivalent:
398
+ * ```rust
399
+ * fn detect_cycle(&self) -> Option<Vec<AgentId>> {
400
+ * let graph = self.edges.read().unwrap();
401
+ * // DFS with visited/stack sets
402
+ * }
403
+ * ```
404
+ */ async detectCycle() {
405
+ return this.withLock(async ()=>{
406
+ const visited = new Set();
407
+ const stack = new Set();
408
+ for (const node of Array.from(this.edges.keys())){
409
+ if (!visited.has(node)) {
410
+ const cycle = this.dfs(node, visited, stack, []);
411
+ if (cycle) return cycle;
412
+ }
413
+ }
414
+ return null;
415
+ });
416
+ }
417
+ /**
418
+ * DFS cycle detection (internal).
419
+ */ dfs(node, visited, stack, path) {
420
+ visited.add(node);
421
+ stack.add(node);
422
+ path.push(node);
423
+ const neighbors = this.edges.get(node) || new Set();
424
+ for (const neighbor of Array.from(neighbors)){
425
+ if (!visited.has(neighbor)) {
426
+ const cycle = this.dfs(neighbor, visited, stack, [
427
+ ...path
428
+ ]);
429
+ if (cycle) return cycle;
430
+ } else if (stack.has(neighbor)) {
431
+ // Cycle found - extract cycle path
432
+ const cycleStart = path.indexOf(neighbor);
433
+ return path.slice(cycleStart);
434
+ }
435
+ }
436
+ stack.delete(node);
437
+ return null;
438
+ }
439
+ /**
440
+ * Create immutable snapshot of graph.
441
+ *
442
+ * Rust equivalent:
443
+ * ```rust
444
+ * fn snapshot(&self) -> HashMap<AgentId, HashSet<AgentId>> {
445
+ * self.edges.read().unwrap().clone()
446
+ * }
447
+ * ```
448
+ */ async snapshot() {
449
+ return this.withLock(async ()=>{
450
+ return new Map(Array.from(this.edges.entries()).map(([k, v])=>[
451
+ k,
452
+ new Set(v)
453
+ ]));
454
+ });
455
+ }
456
+ /**
457
+ * Clear all edges.
458
+ */ async clear() {
459
+ return this.withLock(async ()=>{
460
+ this.edges.clear();
461
+ });
462
+ }
463
+ /**
464
+ * Lock helper for atomic operations.
465
+ */ async withLock(fn) {
466
+ while(this.lock){
467
+ await new Promise((resolve)=>setImmediate(resolve));
468
+ }
469
+ this.lock = true;
470
+ try {
471
+ return await fn();
472
+ } finally{
473
+ this.lock = false;
474
+ }
475
+ }
476
+ }
477
+
478
+ //# sourceMappingURL=resource-manager-safe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../src/coordination/archives/v2-sdk-typescript/v2/core/resource-manager-safe.ts"],"names":["SafeResourceManager","resources","Map","locks","waitQueues","agentResources","operationLock","cleanupInterval","config","setInterval","cleanupStaleLocks","catch","console","error","acquire","resourceId","agentId","priority","withOperationLock","size","maxResources","has","Error","set","id","type","locked","acquired","tryAcquireLock","enqueueWaitRequest","release","currentLock","get","warn","releaseLock","queue","length","nextRequest","remainingQueue","grantLock","log","releaseAllForAgent","resourceIds","Array","from","delete","getAllocations","getWaitingAgents","waiting","entries","request","push","now","Date","staleThreshold","resourceTimeout","resource","lockedAt","lockAge","fresh","filter","req","age","timestamp","maxWaitTime","lockedBy","Set","add","oldQueue","newQueue","sort","a","b","startTime","currentQueue","some","Promise","resolve","setImmediate","finalQueue","filtered","fn","shutdown","clearInterval","undefined","clear","getHealthStatus","totalLockAge","lockedCount","waitingAgents","totalWaiting","values","forEach","healthy","metrics","totalResources","lockedResources","freeResources","totalWaitingRequests","averageLockAge","WaitForGraph","edges","lock","addEdge","waiter","holder","withLock","removeEdge","holders","detectCycle","visited","stack","node","keys","cycle","dfs","path","neighbors","neighbor","cycleStart","indexOf","slice","snapshot","map","k","v"],"mappings":"AAAA;;;;;;;;;;CAUC,GAyBD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMA;;IACHC,YAAY,IAAIC,MAAwB;IACxCC,QAAQ,IAAID,MAAsB;IAClCE,aAAa,IAAIF,MAA6B;IAC9CG,iBAAiB,IAAIH,MAA2B;IAExD,sBAAsB;IACdI,gBAAgB,MAAM;IACtBC,gBAAiC;IAEzC,YAAY,AAAQC,MAA6B,CAAE;aAA/BA,SAAAA;QAClB,gEAAgE;QAChE,IAAI,CAACD,eAAe,GAAGE,YAAY;YACjC,IAAI,CAACC,iBAAiB,GAAGC,KAAK,CAACC,QAAQC,KAAK;QAC9C,GAAG;IACL;IAEA;;;;;;;;;;;;;GAaC,GACD,MAAMC,QAAQC,UAAkB,EAAEC,OAAe,EAAEC,WAAW,CAAC,EAAiB;QAC9E,OAAO,IAAI,CAACC,iBAAiB,CAAC;YAC5B,6CAA6C;YAC7C,IAAI,IAAI,CAACjB,SAAS,CAACkB,IAAI,IAAI,IAAI,CAACX,MAAM,CAACY,YAAY,IAAI,CAAC,IAAI,CAACnB,SAAS,CAACoB,GAAG,CAACN,aAAa;gBACtF,MAAM,IAAIO,MAAM,CAAC,wBAAwB,EAAE,IAAI,CAACd,MAAM,CAACY,YAAY,CAAC,KAAK,CAAC;YAC5E;YAEA,yBAAyB;YACzB,IAAI,CAAC,IAAI,CAACnB,SAAS,CAACoB,GAAG,CAACN,aAAa;gBACnC,IAAI,CAACd,SAAS,CAACsB,GAAG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