agentic-qe 2.7.4 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (519) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/README.md +67 -2
  3. package/dist/cli/commands/agent/spawn.d.ts +12 -1
  4. package/dist/cli/commands/agent/spawn.d.ts.map +1 -1
  5. package/dist/cli/commands/agent/spawn.js +95 -8
  6. package/dist/cli/commands/agent/spawn.js.map +1 -1
  7. package/dist/cli/index.js +91 -0
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/core/memory/HNSWVectorMemory.js +1 -1
  10. package/dist/edge/adapters/BrowserHNSWAdapter.d.ts +134 -0
  11. package/dist/edge/adapters/BrowserHNSWAdapter.d.ts.map +1 -0
  12. package/dist/edge/adapters/BrowserHNSWAdapter.js +484 -0
  13. package/dist/edge/adapters/BrowserHNSWAdapter.js.map +1 -0
  14. package/dist/edge/adapters/IndexedDBStorage.d.ts +114 -0
  15. package/dist/edge/adapters/IndexedDBStorage.d.ts.map +1 -0
  16. package/dist/edge/adapters/IndexedDBStorage.js +478 -0
  17. package/dist/edge/adapters/IndexedDBStorage.js.map +1 -0
  18. package/dist/edge/adapters/index.d.ts +12 -0
  19. package/dist/edge/adapters/index.d.ts.map +1 -0
  20. package/dist/edge/adapters/index.js +22 -0
  21. package/dist/edge/adapters/index.js.map +1 -0
  22. package/dist/edge/browser/BrowserAgent.d.ts +241 -0
  23. package/dist/edge/browser/BrowserAgent.d.ts.map +1 -0
  24. package/dist/edge/browser/BrowserAgent.js +743 -0
  25. package/dist/edge/browser/BrowserAgent.js.map +1 -0
  26. package/dist/edge/index.d.ts +34 -0
  27. package/dist/edge/index.d.ts.map +1 -0
  28. package/dist/edge/index.js +114 -0
  29. package/dist/edge/index.js.map +1 -0
  30. package/dist/edge/p2p/coordination/CoordinationManager.d.ts +181 -0
  31. package/dist/edge/p2p/coordination/CoordinationManager.d.ts.map +1 -0
  32. package/dist/edge/p2p/coordination/CoordinationManager.js +851 -0
  33. package/dist/edge/p2p/coordination/CoordinationManager.js.map +1 -0
  34. package/dist/edge/p2p/coordination/HealthMonitor.d.ts +143 -0
  35. package/dist/edge/p2p/coordination/HealthMonitor.d.ts.map +1 -0
  36. package/dist/edge/p2p/coordination/HealthMonitor.js +432 -0
  37. package/dist/edge/p2p/coordination/HealthMonitor.js.map +1 -0
  38. package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts +146 -0
  39. package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts.map +1 -0
  40. package/dist/edge/p2p/coordination/SyncOrchestrator.js +783 -0
  41. package/dist/edge/p2p/coordination/SyncOrchestrator.js.map +1 -0
  42. package/dist/edge/p2p/coordination/index.d.ts +70 -0
  43. package/dist/edge/p2p/coordination/index.d.ts.map +1 -0
  44. package/dist/edge/p2p/coordination/index.js +107 -0
  45. package/dist/edge/p2p/coordination/index.js.map +1 -0
  46. package/dist/edge/p2p/coordination/types.d.ts +572 -0
  47. package/dist/edge/p2p/coordination/types.d.ts.map +1 -0
  48. package/dist/edge/p2p/coordination/types.js +366 -0
  49. package/dist/edge/p2p/coordination/types.js.map +1 -0
  50. package/dist/edge/p2p/crdt/CRDTStore.d.ts +324 -0
  51. package/dist/edge/p2p/crdt/CRDTStore.d.ts.map +1 -0
  52. package/dist/edge/p2p/crdt/CRDTStore.js +839 -0
  53. package/dist/edge/p2p/crdt/CRDTStore.js.map +1 -0
  54. package/dist/edge/p2p/crdt/GCounter.d.ts +173 -0
  55. package/dist/edge/p2p/crdt/GCounter.d.ts.map +1 -0
  56. package/dist/edge/p2p/crdt/GCounter.js +394 -0
  57. package/dist/edge/p2p/crdt/GCounter.js.map +1 -0
  58. package/dist/edge/p2p/crdt/LWWRegister.d.ts +200 -0
  59. package/dist/edge/p2p/crdt/LWWRegister.d.ts.map +1 -0
  60. package/dist/edge/p2p/crdt/LWWRegister.js +456 -0
  61. package/dist/edge/p2p/crdt/LWWRegister.js.map +1 -0
  62. package/dist/edge/p2p/crdt/ORSet.d.ts +232 -0
  63. package/dist/edge/p2p/crdt/ORSet.d.ts.map +1 -0
  64. package/dist/edge/p2p/crdt/ORSet.js +723 -0
  65. package/dist/edge/p2p/crdt/ORSet.js.map +1 -0
  66. package/dist/edge/p2p/crdt/PatternCRDT.d.ts +366 -0
  67. package/dist/edge/p2p/crdt/PatternCRDT.d.ts.map +1 -0
  68. package/dist/edge/p2p/crdt/PatternCRDT.js +838 -0
  69. package/dist/edge/p2p/crdt/PatternCRDT.js.map +1 -0
  70. package/dist/edge/p2p/crdt/VectorClock.d.ts +274 -0
  71. package/dist/edge/p2p/crdt/VectorClock.d.ts.map +1 -0
  72. package/dist/edge/p2p/crdt/VectorClock.js +499 -0
  73. package/dist/edge/p2p/crdt/VectorClock.js.map +1 -0
  74. package/dist/edge/p2p/crdt/index.d.ts +87 -0
  75. package/dist/edge/p2p/crdt/index.d.ts.map +1 -0
  76. package/dist/edge/p2p/crdt/index.js +120 -0
  77. package/dist/edge/p2p/crdt/index.js.map +1 -0
  78. package/dist/edge/p2p/crdt/types.d.ts +667 -0
  79. package/dist/edge/p2p/crdt/types.d.ts.map +1 -0
  80. package/dist/edge/p2p/crdt/types.js +208 -0
  81. package/dist/edge/p2p/crdt/types.js.map +1 -0
  82. package/dist/edge/p2p/crypto/Identity.d.ts +139 -0
  83. package/dist/edge/p2p/crypto/Identity.d.ts.map +1 -0
  84. package/dist/edge/p2p/crypto/Identity.js +449 -0
  85. package/dist/edge/p2p/crypto/Identity.js.map +1 -0
  86. package/dist/edge/p2p/crypto/KeyManager.d.ts +196 -0
  87. package/dist/edge/p2p/crypto/KeyManager.d.ts.map +1 -0
  88. package/dist/edge/p2p/crypto/KeyManager.js +576 -0
  89. package/dist/edge/p2p/crypto/KeyManager.js.map +1 -0
  90. package/dist/edge/p2p/crypto/Signer.d.ts +164 -0
  91. package/dist/edge/p2p/crypto/Signer.d.ts.map +1 -0
  92. package/dist/edge/p2p/crypto/Signer.js +357 -0
  93. package/dist/edge/p2p/crypto/Signer.js.map +1 -0
  94. package/dist/edge/p2p/crypto/index.d.ts +90 -0
  95. package/dist/edge/p2p/crypto/index.d.ts.map +1 -0
  96. package/dist/edge/p2p/crypto/index.js +158 -0
  97. package/dist/edge/p2p/crypto/index.js.map +1 -0
  98. package/dist/edge/p2p/crypto/types.d.ts +217 -0
  99. package/dist/edge/p2p/crypto/types.d.ts.map +1 -0
  100. package/dist/edge/p2p/crypto/types.js +42 -0
  101. package/dist/edge/p2p/crypto/types.js.map +1 -0
  102. package/dist/edge/p2p/federated/FederatedCoordinator.d.ts +270 -0
  103. package/dist/edge/p2p/federated/FederatedCoordinator.d.ts.map +1 -0
  104. package/dist/edge/p2p/federated/FederatedCoordinator.js +824 -0
  105. package/dist/edge/p2p/federated/FederatedCoordinator.js.map +1 -0
  106. package/dist/edge/p2p/federated/FederatedRound.d.ts +295 -0
  107. package/dist/edge/p2p/federated/FederatedRound.d.ts.map +1 -0
  108. package/dist/edge/p2p/federated/FederatedRound.js +819 -0
  109. package/dist/edge/p2p/federated/FederatedRound.js.map +1 -0
  110. package/dist/edge/p2p/federated/GradientAggregator.d.ts +226 -0
  111. package/dist/edge/p2p/federated/GradientAggregator.d.ts.map +1 -0
  112. package/dist/edge/p2p/federated/GradientAggregator.js +826 -0
  113. package/dist/edge/p2p/federated/GradientAggregator.js.map +1 -0
  114. package/dist/edge/p2p/federated/ModelManager.d.ts +248 -0
  115. package/dist/edge/p2p/federated/ModelManager.d.ts.map +1 -0
  116. package/dist/edge/p2p/federated/ModelManager.js +724 -0
  117. package/dist/edge/p2p/federated/ModelManager.js.map +1 -0
  118. package/dist/edge/p2p/federated/index.d.ts +65 -0
  119. package/dist/edge/p2p/federated/index.d.ts.map +1 -0
  120. package/dist/edge/p2p/federated/index.js +110 -0
  121. package/dist/edge/p2p/federated/index.js.map +1 -0
  122. package/dist/edge/p2p/federated/types.d.ts +905 -0
  123. package/dist/edge/p2p/federated/types.d.ts.map +1 -0
  124. package/dist/edge/p2p/federated/types.js +339 -0
  125. package/dist/edge/p2p/federated/types.js.map +1 -0
  126. package/dist/edge/p2p/index.d.ts +156 -0
  127. package/dist/edge/p2p/index.d.ts.map +1 -0
  128. package/dist/edge/p2p/index.js +242 -0
  129. package/dist/edge/p2p/index.js.map +1 -0
  130. package/dist/edge/p2p/nat/ConnectivityTester.d.ts +128 -0
  131. package/dist/edge/p2p/nat/ConnectivityTester.d.ts.map +1 -0
  132. package/dist/edge/p2p/nat/ConnectivityTester.js +560 -0
  133. package/dist/edge/p2p/nat/ConnectivityTester.js.map +1 -0
  134. package/dist/edge/p2p/nat/HolePuncher.d.ts +159 -0
  135. package/dist/edge/p2p/nat/HolePuncher.d.ts.map +1 -0
  136. package/dist/edge/p2p/nat/HolePuncher.js +569 -0
  137. package/dist/edge/p2p/nat/HolePuncher.js.map +1 -0
  138. package/dist/edge/p2p/nat/NATDetector.d.ts +109 -0
  139. package/dist/edge/p2p/nat/NATDetector.d.ts.map +1 -0
  140. package/dist/edge/p2p/nat/NATDetector.js +472 -0
  141. package/dist/edge/p2p/nat/NATDetector.js.map +1 -0
  142. package/dist/edge/p2p/nat/TURNManager.d.ts +158 -0
  143. package/dist/edge/p2p/nat/TURNManager.d.ts.map +1 -0
  144. package/dist/edge/p2p/nat/TURNManager.js +547 -0
  145. package/dist/edge/p2p/nat/TURNManager.js.map +1 -0
  146. package/dist/edge/p2p/nat/index.d.ts +74 -0
  147. package/dist/edge/p2p/nat/index.d.ts.map +1 -0
  148. package/dist/edge/p2p/nat/index.js +104 -0
  149. package/dist/edge/p2p/nat/index.js.map +1 -0
  150. package/dist/edge/p2p/nat/types.d.ts +583 -0
  151. package/dist/edge/p2p/nat/types.d.ts.map +1 -0
  152. package/dist/edge/p2p/nat/types.js +267 -0
  153. package/dist/edge/p2p/nat/types.js.map +1 -0
  154. package/dist/edge/p2p/protocol/AgentChannel.d.ts +333 -0
  155. package/dist/edge/p2p/protocol/AgentChannel.d.ts.map +1 -0
  156. package/dist/edge/p2p/protocol/AgentChannel.js +914 -0
  157. package/dist/edge/p2p/protocol/AgentChannel.js.map +1 -0
  158. package/dist/edge/p2p/protocol/MessageEncoder.d.ts +147 -0
  159. package/dist/edge/p2p/protocol/MessageEncoder.d.ts.map +1 -0
  160. package/dist/edge/p2p/protocol/MessageEncoder.js +738 -0
  161. package/dist/edge/p2p/protocol/MessageEncoder.js.map +1 -0
  162. package/dist/edge/p2p/protocol/MessageRouter.d.ts +266 -0
  163. package/dist/edge/p2p/protocol/MessageRouter.d.ts.map +1 -0
  164. package/dist/edge/p2p/protocol/MessageRouter.js +808 -0
  165. package/dist/edge/p2p/protocol/MessageRouter.js.map +1 -0
  166. package/dist/edge/p2p/protocol/ProtocolHandler.d.ts +309 -0
  167. package/dist/edge/p2p/protocol/ProtocolHandler.d.ts.map +1 -0
  168. package/dist/edge/p2p/protocol/ProtocolHandler.js +930 -0
  169. package/dist/edge/p2p/protocol/ProtocolHandler.js.map +1 -0
  170. package/dist/edge/p2p/protocol/index.d.ts +114 -0
  171. package/dist/edge/p2p/protocol/index.d.ts.map +1 -0
  172. package/dist/edge/p2p/protocol/index.js +206 -0
  173. package/dist/edge/p2p/protocol/index.js.map +1 -0
  174. package/dist/edge/p2p/protocol/types.d.ts +737 -0
  175. package/dist/edge/p2p/protocol/types.d.ts.map +1 -0
  176. package/dist/edge/p2p/protocol/types.js +490 -0
  177. package/dist/edge/p2p/protocol/types.js.map +1 -0
  178. package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts +284 -0
  179. package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts.map +1 -0
  180. package/dist/edge/p2p/sharing/PatternBroadcaster.js +644 -0
  181. package/dist/edge/p2p/sharing/PatternBroadcaster.js.map +1 -0
  182. package/dist/edge/p2p/sharing/PatternIndex.d.ts +168 -0
  183. package/dist/edge/p2p/sharing/PatternIndex.d.ts.map +1 -0
  184. package/dist/edge/p2p/sharing/PatternIndex.js +781 -0
  185. package/dist/edge/p2p/sharing/PatternIndex.js.map +1 -0
  186. package/dist/edge/p2p/sharing/PatternSerializer.d.ts +163 -0
  187. package/dist/edge/p2p/sharing/PatternSerializer.d.ts.map +1 -0
  188. package/dist/edge/p2p/sharing/PatternSerializer.js +696 -0
  189. package/dist/edge/p2p/sharing/PatternSerializer.js.map +1 -0
  190. package/dist/edge/p2p/sharing/PatternSyncManager.d.ts +242 -0
  191. package/dist/edge/p2p/sharing/PatternSyncManager.d.ts.map +1 -0
  192. package/dist/edge/p2p/sharing/PatternSyncManager.js +859 -0
  193. package/dist/edge/p2p/sharing/PatternSyncManager.js.map +1 -0
  194. package/dist/edge/p2p/sharing/index.d.ts +90 -0
  195. package/dist/edge/p2p/sharing/index.d.ts.map +1 -0
  196. package/dist/edge/p2p/sharing/index.js +152 -0
  197. package/dist/edge/p2p/sharing/index.js.map +1 -0
  198. package/dist/edge/p2p/sharing/types.d.ts +796 -0
  199. package/dist/edge/p2p/sharing/types.d.ts.map +1 -0
  200. package/dist/edge/p2p/sharing/types.js +264 -0
  201. package/dist/edge/p2p/sharing/types.js.map +1 -0
  202. package/dist/edge/p2p/webrtc/ConnectionPool.d.ts +218 -0
  203. package/dist/edge/p2p/webrtc/ConnectionPool.d.ts.map +1 -0
  204. package/dist/edge/p2p/webrtc/ConnectionPool.js +562 -0
  205. package/dist/edge/p2p/webrtc/ConnectionPool.js.map +1 -0
  206. package/dist/edge/p2p/webrtc/ICEManager.d.ts +171 -0
  207. package/dist/edge/p2p/webrtc/ICEManager.d.ts.map +1 -0
  208. package/dist/edge/p2p/webrtc/ICEManager.js +490 -0
  209. package/dist/edge/p2p/webrtc/ICEManager.js.map +1 -0
  210. package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts +159 -0
  211. package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts.map +1 -0
  212. package/dist/edge/p2p/webrtc/PeerConnectionManager.js +735 -0
  213. package/dist/edge/p2p/webrtc/PeerConnectionManager.js.map +1 -0
  214. package/dist/edge/p2p/webrtc/SignalingClient.d.ts +191 -0
  215. package/dist/edge/p2p/webrtc/SignalingClient.d.ts.map +1 -0
  216. package/dist/edge/p2p/webrtc/SignalingClient.js +608 -0
  217. package/dist/edge/p2p/webrtc/SignalingClient.js.map +1 -0
  218. package/dist/edge/p2p/webrtc/index.d.ts +158 -0
  219. package/dist/edge/p2p/webrtc/index.d.ts.map +1 -0
  220. package/dist/edge/p2p/webrtc/index.js +164 -0
  221. package/dist/edge/p2p/webrtc/index.js.map +1 -0
  222. package/dist/edge/p2p/webrtc/types.d.ts +665 -0
  223. package/dist/edge/p2p/webrtc/types.d.ts.map +1 -0
  224. package/dist/edge/p2p/webrtc/types.js +245 -0
  225. package/dist/edge/p2p/webrtc/types.js.map +1 -0
  226. package/dist/edge/server/AgentSpawnAPI.d.ts +98 -0
  227. package/dist/edge/server/AgentSpawnAPI.d.ts.map +1 -0
  228. package/dist/edge/server/AgentSpawnAPI.js +264 -0
  229. package/dist/edge/server/AgentSpawnAPI.js.map +1 -0
  230. package/dist/edge/server/SignalingServer.d.ts +71 -0
  231. package/dist/edge/server/SignalingServer.d.ts.map +1 -0
  232. package/dist/edge/server/SignalingServer.js +429 -0
  233. package/dist/edge/server/SignalingServer.js.map +1 -0
  234. package/dist/edge/server/index.d.ts +64 -0
  235. package/dist/edge/server/index.d.ts.map +1 -0
  236. package/dist/edge/server/index.js +318 -0
  237. package/dist/edge/server/index.js.map +1 -0
  238. package/dist/edge/types/browser-agent.types.d.ts +455 -0
  239. package/dist/edge/types/browser-agent.types.d.ts.map +1 -0
  240. package/dist/edge/types/browser-agent.types.js +116 -0
  241. package/dist/edge/types/browser-agent.types.js.map +1 -0
  242. package/dist/edge/types/index.d.ts +11 -0
  243. package/dist/edge/types/index.d.ts.map +1 -0
  244. package/dist/edge/types/index.js +17 -0
  245. package/dist/edge/types/index.js.map +1 -0
  246. package/dist/edge/types/storage.types.d.ts +207 -0
  247. package/dist/edge/types/storage.types.d.ts.map +1 -0
  248. package/dist/edge/types/storage.types.js +47 -0
  249. package/dist/edge/types/storage.types.js.map +1 -0
  250. package/dist/edge/wasm/shims.d.ts +224 -0
  251. package/dist/edge/wasm/shims.d.ts.map +1 -0
  252. package/dist/edge/wasm/shims.js +667 -0
  253. package/dist/edge/wasm/shims.js.map +1 -0
  254. package/dist/mcp/handlers/NewDomainToolsHandler.d.ts +33 -0
  255. package/dist/mcp/handlers/NewDomainToolsHandler.d.ts.map +1 -0
  256. package/dist/mcp/handlers/NewDomainToolsHandler.js +305 -0
  257. package/dist/mcp/handlers/NewDomainToolsHandler.js.map +1 -0
  258. package/dist/mcp/handlers/filtered/index.d.ts +15 -19
  259. package/dist/mcp/handlers/filtered/index.d.ts.map +1 -1
  260. package/dist/mcp/handlers/filtered/index.js +16 -27
  261. package/dist/mcp/handlers/filtered/index.js.map +1 -1
  262. package/dist/mcp/handlers/integration/index.d.ts +5 -4
  263. package/dist/mcp/handlers/integration/index.d.ts.map +1 -1
  264. package/dist/mcp/handlers/integration/index.js +7 -7
  265. package/dist/mcp/handlers/integration/index.js.map +1 -1
  266. package/dist/mcp/server-instructions.d.ts +1 -1
  267. package/dist/mcp/server-instructions.js +1 -1
  268. package/dist/mcp/server.d.ts.map +1 -1
  269. package/dist/mcp/server.js +14 -0
  270. package/dist/mcp/server.js.map +1 -1
  271. package/dist/mcp/tools.d.ts +8 -0
  272. package/dist/mcp/tools.d.ts.map +1 -1
  273. package/dist/mcp/tools.js +412 -1
  274. package/dist/mcp/tools.js.map +1 -1
  275. package/dist/planning/GOAPPlanner.d.ts +1 -0
  276. package/dist/planning/GOAPPlanner.d.ts.map +1 -1
  277. package/dist/planning/GOAPPlanner.js +12 -0
  278. package/dist/planning/GOAPPlanner.js.map +1 -1
  279. package/package.json +29 -8
  280. package/dist/alerting/AlertManager.d.ts +0 -120
  281. package/dist/alerting/AlertManager.d.ts.map +0 -1
  282. package/dist/alerting/AlertManager.js +0 -345
  283. package/dist/alerting/AlertManager.js.map +0 -1
  284. package/dist/alerting/FeedbackRouter.d.ts +0 -98
  285. package/dist/alerting/FeedbackRouter.d.ts.map +0 -1
  286. package/dist/alerting/FeedbackRouter.js +0 -331
  287. package/dist/alerting/FeedbackRouter.js.map +0 -1
  288. package/dist/alerting/StrategyApplicator.d.ts +0 -120
  289. package/dist/alerting/StrategyApplicator.d.ts.map +0 -1
  290. package/dist/alerting/StrategyApplicator.js +0 -299
  291. package/dist/alerting/StrategyApplicator.js.map +0 -1
  292. package/dist/alerting/index.d.ts +0 -68
  293. package/dist/alerting/index.d.ts.map +0 -1
  294. package/dist/alerting/index.js +0 -112
  295. package/dist/alerting/index.js.map +0 -1
  296. package/dist/alerting/types.d.ts +0 -118
  297. package/dist/alerting/types.d.ts.map +0 -1
  298. package/dist/alerting/types.js +0 -11
  299. package/dist/alerting/types.js.map +0 -1
  300. package/dist/cli/commands/fleet/backup.d.ts +0 -49
  301. package/dist/cli/commands/fleet/backup.d.ts.map +0 -1
  302. package/dist/cli/commands/fleet/backup.js +0 -88
  303. package/dist/cli/commands/fleet/backup.js.map +0 -1
  304. package/dist/cli/commands/fleet/health.d.ts +0 -154
  305. package/dist/cli/commands/fleet/health.d.ts.map +0 -1
  306. package/dist/cli/commands/fleet/health.js +0 -483
  307. package/dist/cli/commands/fleet/health.js.map +0 -1
  308. package/dist/cli/commands/fleet/init.d.ts +0 -11
  309. package/dist/cli/commands/fleet/init.d.ts.map +0 -1
  310. package/dist/cli/commands/fleet/init.js +0 -91
  311. package/dist/cli/commands/fleet/init.js.map +0 -1
  312. package/dist/cli/commands/fleet/logs.d.ts +0 -21
  313. package/dist/cli/commands/fleet/logs.d.ts.map +0 -1
  314. package/dist/cli/commands/fleet/logs.js +0 -267
  315. package/dist/cli/commands/fleet/logs.js.map +0 -1
  316. package/dist/cli/commands/fleet/metrics.d.ts +0 -27
  317. package/dist/cli/commands/fleet/metrics.d.ts.map +0 -1
  318. package/dist/cli/commands/fleet/metrics.js +0 -369
  319. package/dist/cli/commands/fleet/metrics.js.map +0 -1
  320. package/dist/cli/commands/fleet/monitor.d.ts +0 -18
  321. package/dist/cli/commands/fleet/monitor.d.ts.map +0 -1
  322. package/dist/cli/commands/fleet/monitor.js +0 -237
  323. package/dist/cli/commands/fleet/monitor.js.map +0 -1
  324. package/dist/cli/commands/fleet/optimize.d.ts +0 -42
  325. package/dist/cli/commands/fleet/optimize.d.ts.map +0 -1
  326. package/dist/cli/commands/fleet/optimize.js +0 -135
  327. package/dist/cli/commands/fleet/optimize.js.map +0 -1
  328. package/dist/cli/commands/fleet/recover.d.ts +0 -22
  329. package/dist/cli/commands/fleet/recover.d.ts.map +0 -1
  330. package/dist/cli/commands/fleet/recover.js +0 -99
  331. package/dist/cli/commands/fleet/recover.js.map +0 -1
  332. package/dist/cli/commands/fleet/restart.d.ts +0 -18
  333. package/dist/cli/commands/fleet/restart.d.ts.map +0 -1
  334. package/dist/cli/commands/fleet/restart.js +0 -290
  335. package/dist/cli/commands/fleet/restart.js.map +0 -1
  336. package/dist/cli/commands/fleet/scale.d.ts +0 -9
  337. package/dist/cli/commands/fleet/scale.d.ts.map +0 -1
  338. package/dist/cli/commands/fleet/scale.js +0 -77
  339. package/dist/cli/commands/fleet/scale.js.map +0 -1
  340. package/dist/cli/commands/fleet/shutdown.d.ts +0 -19
  341. package/dist/cli/commands/fleet/shutdown.d.ts.map +0 -1
  342. package/dist/cli/commands/fleet/shutdown.js +0 -307
  343. package/dist/cli/commands/fleet/shutdown.js.map +0 -1
  344. package/dist/cli/commands/fleet/status.d.ts +0 -10
  345. package/dist/cli/commands/fleet/status.d.ts.map +0 -1
  346. package/dist/cli/commands/fleet/status.js +0 -97
  347. package/dist/cli/commands/fleet/status.js.map +0 -1
  348. package/dist/cli/commands/fleet/topology.d.ts +0 -23
  349. package/dist/cli/commands/fleet/topology.d.ts.map +0 -1
  350. package/dist/cli/commands/fleet/topology.js +0 -376
  351. package/dist/cli/commands/fleet/topology.js.map +0 -1
  352. package/dist/cli/commands/monitor/alerts.d.ts +0 -45
  353. package/dist/cli/commands/monitor/alerts.d.ts.map +0 -1
  354. package/dist/cli/commands/monitor/alerts.js +0 -168
  355. package/dist/cli/commands/monitor/alerts.js.map +0 -1
  356. package/dist/cli/commands/monitor/analyze.d.ts +0 -49
  357. package/dist/cli/commands/monitor/analyze.d.ts.map +0 -1
  358. package/dist/cli/commands/monitor/analyze.js +0 -209
  359. package/dist/cli/commands/monitor/analyze.js.map +0 -1
  360. package/dist/cli/commands/monitor/compare.d.ts +0 -38
  361. package/dist/cli/commands/monitor/compare.d.ts.map +0 -1
  362. package/dist/cli/commands/monitor/compare.js +0 -177
  363. package/dist/cli/commands/monitor/compare.js.map +0 -1
  364. package/dist/cli/commands/monitor/dashboard.d.ts +0 -34
  365. package/dist/cli/commands/monitor/dashboard.d.ts.map +0 -1
  366. package/dist/cli/commands/monitor/dashboard.js +0 -157
  367. package/dist/cli/commands/monitor/dashboard.js.map +0 -1
  368. package/dist/cli/commands/monitor/export.d.ts +0 -36
  369. package/dist/cli/commands/monitor/export.d.ts.map +0 -1
  370. package/dist/cli/commands/monitor/export.js +0 -157
  371. package/dist/cli/commands/monitor/export.js.map +0 -1
  372. package/dist/cli/commands/monitor/index.d.ts +0 -11
  373. package/dist/cli/commands/monitor/index.d.ts.map +0 -1
  374. package/dist/cli/commands/monitor/index.js +0 -14
  375. package/dist/cli/commands/monitor/index.js.map +0 -1
  376. package/dist/cli/commands/quality/baseline.d.ts +0 -27
  377. package/dist/cli/commands/quality/baseline.d.ts.map +0 -1
  378. package/dist/cli/commands/quality/baseline.js +0 -124
  379. package/dist/cli/commands/quality/baseline.js.map +0 -1
  380. package/dist/cli/commands/quality/compare.d.ts +0 -36
  381. package/dist/cli/commands/quality/compare.d.ts.map +0 -1
  382. package/dist/cli/commands/quality/compare.js +0 -136
  383. package/dist/cli/commands/quality/compare.js.map +0 -1
  384. package/dist/cli/commands/quality/decision.d.ts +0 -81
  385. package/dist/cli/commands/quality/decision.d.ts.map +0 -1
  386. package/dist/cli/commands/quality/decision.js +0 -319
  387. package/dist/cli/commands/quality/decision.js.map +0 -1
  388. package/dist/cli/commands/quality/gate.d.ts +0 -47
  389. package/dist/cli/commands/quality/gate.d.ts.map +0 -1
  390. package/dist/cli/commands/quality/gate.js +0 -205
  391. package/dist/cli/commands/quality/gate.js.map +0 -1
  392. package/dist/cli/commands/quality/index.d.ts +0 -17
  393. package/dist/cli/commands/quality/index.d.ts.map +0 -1
  394. package/dist/cli/commands/quality/index.js +0 -41
  395. package/dist/cli/commands/quality/index.js.map +0 -1
  396. package/dist/cli/commands/quality/policy.d.ts +0 -57
  397. package/dist/cli/commands/quality/policy.d.ts.map +0 -1
  398. package/dist/cli/commands/quality/policy.js +0 -359
  399. package/dist/cli/commands/quality/policy.js.map +0 -1
  400. package/dist/cli/commands/quality/risk.d.ts +0 -41
  401. package/dist/cli/commands/quality/risk.d.ts.map +0 -1
  402. package/dist/cli/commands/quality/risk.js +0 -255
  403. package/dist/cli/commands/quality/risk.js.map +0 -1
  404. package/dist/cli/commands/quality/trends.d.ts +0 -40
  405. package/dist/cli/commands/quality/trends.d.ts.map +0 -1
  406. package/dist/cli/commands/quality/trends.js +0 -122
  407. package/dist/cli/commands/quality/trends.js.map +0 -1
  408. package/dist/cli/commands/quality/validate.d.ts +0 -44
  409. package/dist/cli/commands/quality/validate.d.ts.map +0 -1
  410. package/dist/cli/commands/quality/validate.js +0 -234
  411. package/dist/cli/commands/quality/validate.js.map +0 -1
  412. package/dist/cli/commands/test/analyze-failures.d.ts +0 -39
  413. package/dist/cli/commands/test/analyze-failures.d.ts.map +0 -1
  414. package/dist/cli/commands/test/analyze-failures.js +0 -113
  415. package/dist/cli/commands/test/analyze-failures.js.map +0 -1
  416. package/dist/cli/commands/test/clean.d.ts +0 -3
  417. package/dist/cli/commands/test/clean.d.ts.map +0 -1
  418. package/dist/cli/commands/test/clean.js +0 -148
  419. package/dist/cli/commands/test/clean.js.map +0 -1
  420. package/dist/cli/commands/test/debug.d.ts +0 -3
  421. package/dist/cli/commands/test/debug.d.ts.map +0 -1
  422. package/dist/cli/commands/test/debug.js +0 -167
  423. package/dist/cli/commands/test/debug.js.map +0 -1
  424. package/dist/cli/commands/test/diff.d.ts +0 -3
  425. package/dist/cli/commands/test/diff.d.ts.map +0 -1
  426. package/dist/cli/commands/test/diff.js +0 -195
  427. package/dist/cli/commands/test/diff.js.map +0 -1
  428. package/dist/cli/commands/test/flakiness.d.ts +0 -32
  429. package/dist/cli/commands/test/flakiness.d.ts.map +0 -1
  430. package/dist/cli/commands/test/flakiness.js +0 -121
  431. package/dist/cli/commands/test/flakiness.js.map +0 -1
  432. package/dist/cli/commands/test/index.d.ts +0 -17
  433. package/dist/cli/commands/test/index.d.ts.map +0 -1
  434. package/dist/cli/commands/test/index.js +0 -45
  435. package/dist/cli/commands/test/index.js.map +0 -1
  436. package/dist/cli/commands/test/mutate.d.ts +0 -29
  437. package/dist/cli/commands/test/mutate.d.ts.map +0 -1
  438. package/dist/cli/commands/test/mutate.js +0 -163
  439. package/dist/cli/commands/test/mutate.js.map +0 -1
  440. package/dist/cli/commands/test/parallel.d.ts +0 -3
  441. package/dist/cli/commands/test/parallel.d.ts.map +0 -1
  442. package/dist/cli/commands/test/parallel.js +0 -117
  443. package/dist/cli/commands/test/parallel.js.map +0 -1
  444. package/dist/cli/commands/test/profile.d.ts +0 -3
  445. package/dist/cli/commands/test/profile.d.ts.map +0 -1
  446. package/dist/cli/commands/test/profile.js +0 -156
  447. package/dist/cli/commands/test/profile.js.map +0 -1
  448. package/dist/cli/commands/test/queue.d.ts +0 -3
  449. package/dist/cli/commands/test/queue.d.ts.map +0 -1
  450. package/dist/cli/commands/test/queue.js +0 -140
  451. package/dist/cli/commands/test/queue.js.map +0 -1
  452. package/dist/cli/commands/test/retry.d.ts +0 -3
  453. package/dist/cli/commands/test/retry.d.ts.map +0 -1
  454. package/dist/cli/commands/test/retry.js +0 -105
  455. package/dist/cli/commands/test/retry.js.map +0 -1
  456. package/dist/cli/commands/test/snapshot.d.ts +0 -3
  457. package/dist/cli/commands/test/snapshot.d.ts.map +0 -1
  458. package/dist/cli/commands/test/snapshot.js +0 -176
  459. package/dist/cli/commands/test/snapshot.js.map +0 -1
  460. package/dist/cli/commands/test/trace.d.ts +0 -3
  461. package/dist/cli/commands/test/trace.d.ts.map +0 -1
  462. package/dist/cli/commands/test/trace.js +0 -137
  463. package/dist/cli/commands/test/trace.js.map +0 -1
  464. package/dist/cli/commands/test/watch.d.ts +0 -3
  465. package/dist/cli/commands/test/watch.d.ts.map +0 -1
  466. package/dist/cli/commands/test/watch.js +0 -130
  467. package/dist/cli/commands/test/watch.js.map +0 -1
  468. package/dist/cli/index-spec.d.ts +0 -3
  469. package/dist/cli/index-spec.d.ts.map +0 -1
  470. package/dist/cli/index-spec.js +0 -154
  471. package/dist/cli/index-spec.js.map +0 -1
  472. package/dist/cli/index-working.d.ts +0 -7
  473. package/dist/cli/index-working.d.ts.map +0 -1
  474. package/dist/cli/index-working.js +0 -617
  475. package/dist/cli/index-working.js.map +0 -1
  476. package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts +0 -83
  477. package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts.map +0 -1
  478. package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js +0 -130
  479. package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js.map +0 -1
  480. package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts +0 -58
  481. package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts.map +0 -1
  482. package/dist/mcp/handlers/filtered/flaky-detector-filtered.js +0 -84
  483. package/dist/mcp/handlers/filtered/flaky-detector-filtered.js.map +0 -1
  484. package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts +0 -54
  485. package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts.map +0 -1
  486. package/dist/mcp/handlers/filtered/security-scanner-filtered.js +0 -73
  487. package/dist/mcp/handlers/filtered/security-scanner-filtered.js.map +0 -1
  488. package/dist/mcp/handlers/integration/contract-validate.d.ts +0 -10
  489. package/dist/mcp/handlers/integration/contract-validate.d.ts.map +0 -1
  490. package/dist/mcp/handlers/integration/contract-validate.js +0 -348
  491. package/dist/mcp/handlers/integration/contract-validate.js.map +0 -1
  492. package/dist/reporting/ResultAggregator.d.ts +0 -107
  493. package/dist/reporting/ResultAggregator.d.ts.map +0 -1
  494. package/dist/reporting/ResultAggregator.js +0 -435
  495. package/dist/reporting/ResultAggregator.js.map +0 -1
  496. package/dist/reporting/index.d.ts +0 -48
  497. package/dist/reporting/index.d.ts.map +0 -1
  498. package/dist/reporting/index.js +0 -154
  499. package/dist/reporting/index.js.map +0 -1
  500. package/dist/reporting/reporters/ControlLoopReporter.d.ts +0 -128
  501. package/dist/reporting/reporters/ControlLoopReporter.d.ts.map +0 -1
  502. package/dist/reporting/reporters/ControlLoopReporter.js +0 -417
  503. package/dist/reporting/reporters/ControlLoopReporter.js.map +0 -1
  504. package/dist/reporting/reporters/HumanReadableReporter.d.ts +0 -140
  505. package/dist/reporting/reporters/HumanReadableReporter.d.ts.map +0 -1
  506. package/dist/reporting/reporters/HumanReadableReporter.js +0 -524
  507. package/dist/reporting/reporters/HumanReadableReporter.js.map +0 -1
  508. package/dist/reporting/reporters/JSONReporter.d.ts +0 -251
  509. package/dist/reporting/reporters/JSONReporter.d.ts.map +0 -1
  510. package/dist/reporting/reporters/JSONReporter.js +0 -325
  511. package/dist/reporting/reporters/JSONReporter.js.map +0 -1
  512. package/dist/reporting/reporters/index.d.ts +0 -14
  513. package/dist/reporting/reporters/index.d.ts.map +0 -1
  514. package/dist/reporting/reporters/index.js +0 -19
  515. package/dist/reporting/reporters/index.js.map +0 -1
  516. package/dist/reporting/types.d.ts +0 -427
  517. package/dist/reporting/types.d.ts.map +0 -1
  518. package/dist/reporting/types.js +0 -12
  519. package/dist/reporting/types.js.map +0 -1
@@ -0,0 +1,838 @@
1
+ "use strict";
2
+ /**
3
+ * Pattern CRDT - Specialized CRDT for SharedPattern Objects
4
+ *
5
+ * A composite CRDT that manages SharedPattern objects with different
6
+ * CRDT strategies for different fields:
7
+ * - LWW for scalar fields (content, type, category, domain)
8
+ * - ORSet for collection fields (tags)
9
+ * - GCounter for usage metrics
10
+ *
11
+ * @module edge/p2p/crdt/PatternCRDT
12
+ * @version 1.0.0
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PatternCRDT = void 0;
16
+ const types_1 = require("./types");
17
+ const VectorClock_1 = require("./VectorClock");
18
+ const GCounter_1 = require("./GCounter");
19
+ const LWWRegister_1 = require("./LWWRegister");
20
+ const ORSet_1 = require("./ORSet");
21
+ // ============================================
22
+ // Default Values
23
+ // ============================================
24
+ const DEFAULT_QUALITY = {
25
+ level: 'unverified',
26
+ successRate: 0,
27
+ uniqueUsers: 0,
28
+ avgConfidence: 0,
29
+ feedbackScore: 0,
30
+ };
31
+ const DEFAULT_SHARING_CONFIG = {
32
+ policy: 'public',
33
+ privacyLevel: 'anonymized',
34
+ redistributable: true,
35
+ };
36
+ // ============================================
37
+ // PatternCRDT Class
38
+ // ============================================
39
+ /**
40
+ * Composite CRDT for SharedPattern objects.
41
+ *
42
+ * Combines multiple CRDT types to provide automatic conflict resolution
43
+ * for pattern data:
44
+ * - Content, type, category, domain use LWW semantics
45
+ * - Tags use OR-Set semantics (add wins)
46
+ * - Usage count uses G-Counter
47
+ * - Metadata fields use LWW
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const pattern = new PatternCRDT('replica-1', {
52
+ * id: 'pattern-1',
53
+ * content: 'test code...',
54
+ * type: 'unit-test',
55
+ * category: 'test',
56
+ * domain: 'api',
57
+ * tags: ['typescript', 'jest'],
58
+ * });
59
+ *
60
+ * // Update fields
61
+ * pattern.setContent('updated code...');
62
+ * pattern.addTag('integration');
63
+ * pattern.incrementUsage();
64
+ *
65
+ * // Merge with remote
66
+ * pattern.merge(remoteState);
67
+ *
68
+ * // Get current data
69
+ * const data = pattern.getData();
70
+ * ```
71
+ */
72
+ class PatternCRDT {
73
+ /**
74
+ * Create a new PatternCRDT
75
+ *
76
+ * @param replicaId - Local replica identifier
77
+ * @param input - Pattern input data
78
+ * @param options - Optional configuration
79
+ */
80
+ constructor(replicaId, input, options) {
81
+ this.id = input.id;
82
+ this.replicaId = replicaId;
83
+ this.maxHistorySize = options?.maxHistorySize ?? 100;
84
+ // Initialize LWW registers
85
+ this.content = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-content`, input.content);
86
+ this.type = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-type`, input.type);
87
+ this.category = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-category`, input.category);
88
+ this.domain = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-domain`, input.domain);
89
+ this.quality = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-quality`, input.quality ?? DEFAULT_QUALITY);
90
+ this.sharingConfig = new LWWRegister_1.LWWRegister(replicaId, `${input.id}-sharing`, input.sharingConfig ?? DEFAULT_SHARING_CONFIG);
91
+ // Initialize ORSet for tags
92
+ this.tags = new ORSet_1.ORSet(replicaId, `${input.id}-tags`);
93
+ if (input.tags) {
94
+ for (const tag of input.tags) {
95
+ this.tags.add(tag);
96
+ }
97
+ }
98
+ // Initialize GCounter for usage
99
+ this.usageCount = new GCounter_1.GCounter(replicaId, `${input.id}-usage`, 0);
100
+ // Initialize metadata map
101
+ this.metadata = new Map();
102
+ if (input.metadata) {
103
+ for (const [key, value] of Object.entries(input.metadata)) {
104
+ this.metadata.set(key, new LWWRegister_1.LWWRegister(replicaId, `${input.id}-meta-${key}`, value));
105
+ }
106
+ }
107
+ // Initialize vector clock
108
+ this.vectorClock = new VectorClock_1.VectorClock(replicaId);
109
+ this.vectorClock.increment();
110
+ this.sequenceNumber = 0;
111
+ this.lastDeltaClock = this.vectorClock.clone();
112
+ this.history = [];
113
+ const now = Date.now();
114
+ this.crdtMetadata = {
115
+ createdAt: now,
116
+ updatedAt: now,
117
+ mergeCount: 0,
118
+ lastModifiedBy: replicaId,
119
+ };
120
+ }
121
+ // ============================================
122
+ // Getters
123
+ // ============================================
124
+ /**
125
+ * Get the current pattern data
126
+ *
127
+ * @returns Complete pattern data
128
+ */
129
+ value() {
130
+ return this.getData();
131
+ }
132
+ /**
133
+ * Get the current pattern data
134
+ *
135
+ * @returns Complete pattern data
136
+ */
137
+ getData() {
138
+ const metadataObj = {};
139
+ for (const [key, register] of this.metadata) {
140
+ metadataObj[key] = register.value();
141
+ }
142
+ return {
143
+ id: this.id,
144
+ content: this.content.value() ?? '',
145
+ type: this.type.value() ?? '',
146
+ category: this.category.value() ?? '',
147
+ domain: this.domain.value() ?? '',
148
+ tags: this.tags.values(),
149
+ metadata: metadataObj,
150
+ quality: this.quality.value() ?? DEFAULT_QUALITY,
151
+ usageCount: this.usageCount.value(),
152
+ sharingConfig: this.sharingConfig.value() ?? DEFAULT_SHARING_CONFIG,
153
+ lastModified: this.vectorClock.getLastModified(),
154
+ };
155
+ }
156
+ /**
157
+ * Get the pattern ID
158
+ *
159
+ * @returns Pattern ID
160
+ */
161
+ getId() {
162
+ return this.id;
163
+ }
164
+ /**
165
+ * Get the content
166
+ *
167
+ * @returns Pattern content
168
+ */
169
+ getContent() {
170
+ return this.content.value() ?? '';
171
+ }
172
+ /**
173
+ * Get the type
174
+ *
175
+ * @returns Pattern type
176
+ */
177
+ getType() {
178
+ return this.type.value() ?? '';
179
+ }
180
+ /**
181
+ * Get the category
182
+ *
183
+ * @returns Pattern category
184
+ */
185
+ getCategory() {
186
+ return this.category.value() ?? '';
187
+ }
188
+ /**
189
+ * Get the domain
190
+ *
191
+ * @returns Pattern domain
192
+ */
193
+ getDomain() {
194
+ return this.domain.value() ?? '';
195
+ }
196
+ /**
197
+ * Get all tags
198
+ *
199
+ * @returns Array of tags
200
+ */
201
+ getTags() {
202
+ return this.tags.values();
203
+ }
204
+ /**
205
+ * Get the usage count
206
+ *
207
+ * @returns Usage count
208
+ */
209
+ getUsageCount() {
210
+ return this.usageCount.value();
211
+ }
212
+ /**
213
+ * Get a metadata value
214
+ *
215
+ * @param key - Metadata key
216
+ * @returns Metadata value or undefined
217
+ */
218
+ getMetadata(key) {
219
+ return this.metadata.get(key)?.value();
220
+ }
221
+ /**
222
+ * Get the modification history
223
+ *
224
+ * @returns History entries
225
+ */
226
+ getHistory() {
227
+ return [...this.history];
228
+ }
229
+ // ============================================
230
+ // Setters
231
+ // ============================================
232
+ /**
233
+ * Set the content
234
+ *
235
+ * @param content - New content
236
+ */
237
+ setContent(content) {
238
+ this.recordHistory('content', this.content.value(), content);
239
+ this.content.set(content);
240
+ this.updateState();
241
+ }
242
+ /**
243
+ * Set the type
244
+ *
245
+ * @param type - New type
246
+ */
247
+ setType(type) {
248
+ this.recordHistory('type', this.type.value(), type);
249
+ this.type.set(type);
250
+ this.updateState();
251
+ }
252
+ /**
253
+ * Set the category
254
+ *
255
+ * @param category - New category
256
+ */
257
+ setCategory(category) {
258
+ this.recordHistory('category', this.category.value(), category);
259
+ this.category.set(category);
260
+ this.updateState();
261
+ }
262
+ /**
263
+ * Set the domain
264
+ *
265
+ * @param domain - New domain
266
+ */
267
+ setDomain(domain) {
268
+ this.recordHistory('domain', this.domain.value(), domain);
269
+ this.domain.set(domain);
270
+ this.updateState();
271
+ }
272
+ /**
273
+ * Add a tag
274
+ *
275
+ * @param tag - Tag to add
276
+ * @returns Tag identifier
277
+ */
278
+ addTag(tag) {
279
+ this.recordHistory('tags', this.tags.values(), [...this.tags.values(), tag]);
280
+ const result = this.tags.add(tag);
281
+ this.updateState();
282
+ return result;
283
+ }
284
+ /**
285
+ * Remove a tag
286
+ *
287
+ * @param tag - Tag to remove
288
+ * @returns Number of tags removed
289
+ */
290
+ removeTag(tag) {
291
+ const currentTags = this.tags.values();
292
+ const count = this.tags.remove(tag);
293
+ if (count > 0) {
294
+ this.recordHistory('tags', currentTags, this.tags.values());
295
+ this.updateState();
296
+ }
297
+ return count;
298
+ }
299
+ /**
300
+ * Set a metadata value
301
+ *
302
+ * @param key - Metadata key
303
+ * @param value - Metadata value
304
+ */
305
+ setMetadata(key, value) {
306
+ const existing = this.metadata.get(key);
307
+ if (existing) {
308
+ this.recordHistory(`metadata.${key}`, existing.value(), value);
309
+ existing.set(value);
310
+ }
311
+ else {
312
+ this.recordHistory(`metadata.${key}`, undefined, value);
313
+ this.metadata.set(key, new LWWRegister_1.LWWRegister(this.replicaId, `${this.id}-meta-${key}`, value));
314
+ }
315
+ this.updateState();
316
+ }
317
+ /**
318
+ * Remove a metadata entry
319
+ *
320
+ * @param key - Key to remove
321
+ * @returns True if removed
322
+ */
323
+ removeMetadata(key) {
324
+ const existing = this.metadata.get(key);
325
+ if (existing) {
326
+ this.recordHistory(`metadata.${key}`, existing.value(), undefined);
327
+ this.metadata.delete(key);
328
+ this.updateState();
329
+ return true;
330
+ }
331
+ return false;
332
+ }
333
+ /**
334
+ * Increment the usage count
335
+ *
336
+ * @param amount - Amount to increment (default 1)
337
+ * @returns New usage count
338
+ */
339
+ incrementUsage(amount = 1) {
340
+ const result = this.usageCount.increment(amount);
341
+ this.updateState();
342
+ return result;
343
+ }
344
+ /**
345
+ * Set quality metrics
346
+ *
347
+ * @param quality - New quality metrics
348
+ */
349
+ setQuality(quality) {
350
+ this.recordHistory('quality', this.quality.value(), quality);
351
+ this.quality.set(quality);
352
+ this.updateState();
353
+ }
354
+ /**
355
+ * Set sharing configuration
356
+ *
357
+ * @param config - New sharing config
358
+ */
359
+ setSharingConfig(config) {
360
+ this.recordHistory('sharingConfig', this.sharingConfig.value(), config);
361
+ this.sharingConfig.set(config);
362
+ this.updateState();
363
+ }
364
+ // ============================================
365
+ // State Management
366
+ // ============================================
367
+ /**
368
+ * Update internal state after modification
369
+ */
370
+ updateState() {
371
+ this.vectorClock.increment();
372
+ this.sequenceNumber++;
373
+ this.crdtMetadata.updatedAt = Date.now();
374
+ this.crdtMetadata.lastModifiedBy = this.replicaId;
375
+ }
376
+ /**
377
+ * Record a modification in history
378
+ */
379
+ recordHistory(field, prev, next) {
380
+ this.history.push({
381
+ field,
382
+ previousValue: prev,
383
+ newValue: next,
384
+ replica: this.replicaId,
385
+ timestamp: Date.now(),
386
+ });
387
+ // Trim history if too large
388
+ if (this.history.length > this.maxHistorySize) {
389
+ this.history = this.history.slice(-this.maxHistorySize);
390
+ }
391
+ }
392
+ /**
393
+ * Get the serializable state
394
+ *
395
+ * @returns CRDT state
396
+ */
397
+ state() {
398
+ const metadataObj = {};
399
+ for (const [key, register] of this.metadata) {
400
+ metadataObj[key] = register.state().value;
401
+ }
402
+ return {
403
+ type: types_1.CRDTType.PatternCRDT,
404
+ id: this.id,
405
+ vectorClock: this.vectorClock.serialize(),
406
+ origin: this.replicaId,
407
+ value: {
408
+ id: this.id,
409
+ content: this.content.state().value,
410
+ type: this.type.state().value,
411
+ category: this.category.state().value,
412
+ domain: this.domain.state().value,
413
+ tags: this.tags.state().value,
414
+ metadata: metadataObj,
415
+ quality: this.quality.state().value,
416
+ usageCount: this.usageCount.state().value,
417
+ sharingConfig: this.sharingConfig.state().value,
418
+ },
419
+ metadata: { ...this.crdtMetadata },
420
+ stateVersion: 1,
421
+ };
422
+ }
423
+ /**
424
+ * Restore a PatternCRDT from serialized state
425
+ *
426
+ * @param state - Serialized state
427
+ * @param replicaId - Local replica ID
428
+ * @returns Restored PatternCRDT
429
+ */
430
+ static fromState(state, replicaId) {
431
+ if (state.type !== types_1.CRDTType.PatternCRDT) {
432
+ throw new types_1.CRDTError(`Invalid CRDT type: expected ${types_1.CRDTType.PatternCRDT}, got ${state.type}`, types_1.CRDTErrorCode.InvalidType, state.id);
433
+ }
434
+ const v = state.value;
435
+ const pattern = new PatternCRDT(replicaId, {
436
+ id: v.id,
437
+ content: v.content.value,
438
+ type: v.type.value,
439
+ category: v.category.value,
440
+ domain: v.domain.value,
441
+ });
442
+ // Restore LWW registers with correct timestamps
443
+ pattern.content = LWWRegister_1.LWWRegister.fromState({
444
+ type: types_1.CRDTType.LWWRegister,
445
+ id: `${v.id}-content`,
446
+ vectorClock: state.vectorClock,
447
+ origin: state.origin,
448
+ value: v.content,
449
+ metadata: state.metadata,
450
+ stateVersion: 1,
451
+ }, replicaId);
452
+ pattern.type = LWWRegister_1.LWWRegister.fromState({
453
+ type: types_1.CRDTType.LWWRegister,
454
+ id: `${v.id}-type`,
455
+ vectorClock: state.vectorClock,
456
+ origin: state.origin,
457
+ value: v.type,
458
+ metadata: state.metadata,
459
+ stateVersion: 1,
460
+ }, replicaId);
461
+ pattern.category = LWWRegister_1.LWWRegister.fromState({
462
+ type: types_1.CRDTType.LWWRegister,
463
+ id: `${v.id}-category`,
464
+ vectorClock: state.vectorClock,
465
+ origin: state.origin,
466
+ value: v.category,
467
+ metadata: state.metadata,
468
+ stateVersion: 1,
469
+ }, replicaId);
470
+ pattern.domain = LWWRegister_1.LWWRegister.fromState({
471
+ type: types_1.CRDTType.LWWRegister,
472
+ id: `${v.id}-domain`,
473
+ vectorClock: state.vectorClock,
474
+ origin: state.origin,
475
+ value: v.domain,
476
+ metadata: state.metadata,
477
+ stateVersion: 1,
478
+ }, replicaId);
479
+ pattern.quality = LWWRegister_1.LWWRegister.fromState({
480
+ type: types_1.CRDTType.LWWRegister,
481
+ id: `${v.id}-quality`,
482
+ vectorClock: state.vectorClock,
483
+ origin: state.origin,
484
+ value: v.quality,
485
+ metadata: state.metadata,
486
+ stateVersion: 1,
487
+ }, replicaId);
488
+ pattern.sharingConfig = LWWRegister_1.LWWRegister.fromState({
489
+ type: types_1.CRDTType.LWWRegister,
490
+ id: `${v.id}-sharing`,
491
+ vectorClock: state.vectorClock,
492
+ origin: state.origin,
493
+ value: v.sharingConfig,
494
+ metadata: state.metadata,
495
+ stateVersion: 1,
496
+ }, replicaId);
497
+ // Restore ORSet for tags
498
+ pattern.tags = ORSet_1.ORSet.fromState({
499
+ type: types_1.CRDTType.ORSet,
500
+ id: `${v.id}-tags`,
501
+ vectorClock: state.vectorClock,
502
+ origin: state.origin,
503
+ value: v.tags,
504
+ metadata: state.metadata,
505
+ stateVersion: 1,
506
+ }, replicaId);
507
+ // Restore GCounter for usage
508
+ pattern.usageCount = GCounter_1.GCounter.fromState({
509
+ type: types_1.CRDTType.GCounter,
510
+ id: `${v.id}-usage`,
511
+ vectorClock: state.vectorClock,
512
+ origin: state.origin,
513
+ value: v.usageCount,
514
+ metadata: state.metadata,
515
+ stateVersion: 1,
516
+ }, replicaId);
517
+ // Restore metadata
518
+ pattern.metadata.clear();
519
+ for (const [key, lwwState] of Object.entries(v.metadata)) {
520
+ pattern.metadata.set(key, LWWRegister_1.LWWRegister.fromState({
521
+ type: types_1.CRDTType.LWWRegister,
522
+ id: `${v.id}-meta-${key}`,
523
+ vectorClock: state.vectorClock,
524
+ origin: state.origin,
525
+ value: lwwState,
526
+ metadata: state.metadata,
527
+ stateVersion: 1,
528
+ }, replicaId));
529
+ }
530
+ // Restore vector clock
531
+ pattern.vectorClock = VectorClock_1.VectorClock.fromSerialized(state.vectorClock, replicaId);
532
+ // Restore metadata
533
+ pattern.crdtMetadata = { ...state.metadata };
534
+ return pattern;
535
+ }
536
+ // ============================================
537
+ // Merge Operations
538
+ // ============================================
539
+ /**
540
+ * Merge with another PatternCRDT state
541
+ *
542
+ * Each field is merged according to its CRDT type:
543
+ * - LWW fields: last writer wins
544
+ * - ORSet fields: add wins for concurrent add/remove
545
+ * - GCounter fields: max per replica
546
+ *
547
+ * @param other - Other pattern state to merge
548
+ * @returns Merge result
549
+ */
550
+ merge(other) {
551
+ const startTime = Date.now();
552
+ const allConflicts = [];
553
+ let entriesMerged = 0;
554
+ let localChanged = false;
555
+ if (other.type !== types_1.CRDTType.PatternCRDT) {
556
+ throw new types_1.CRDTError(`Cannot merge different CRDT types`, types_1.CRDTErrorCode.InvalidType, this.id);
557
+ }
558
+ if (other.id !== this.id) {
559
+ throw new types_1.CRDTError(`Cannot merge different patterns`, types_1.CRDTErrorCode.InvalidState, this.id);
560
+ }
561
+ const v = other.value;
562
+ // Merge LWW fields
563
+ const contentResult = this.content.merge({
564
+ type: types_1.CRDTType.LWWRegister,
565
+ id: `${this.id}-content`,
566
+ vectorClock: other.vectorClock,
567
+ origin: other.origin,
568
+ value: v.content,
569
+ metadata: other.metadata,
570
+ stateVersion: 1,
571
+ });
572
+ if (contentResult.localChanged)
573
+ localChanged = true;
574
+ allConflicts.push(...contentResult.conflicts);
575
+ entriesMerged++;
576
+ const typeResult = this.type.merge({
577
+ type: types_1.CRDTType.LWWRegister,
578
+ id: `${this.id}-type`,
579
+ vectorClock: other.vectorClock,
580
+ origin: other.origin,
581
+ value: v.type,
582
+ metadata: other.metadata,
583
+ stateVersion: 1,
584
+ });
585
+ if (typeResult.localChanged)
586
+ localChanged = true;
587
+ allConflicts.push(...typeResult.conflicts);
588
+ entriesMerged++;
589
+ const categoryResult = this.category.merge({
590
+ type: types_1.CRDTType.LWWRegister,
591
+ id: `${this.id}-category`,
592
+ vectorClock: other.vectorClock,
593
+ origin: other.origin,
594
+ value: v.category,
595
+ metadata: other.metadata,
596
+ stateVersion: 1,
597
+ });
598
+ if (categoryResult.localChanged)
599
+ localChanged = true;
600
+ allConflicts.push(...categoryResult.conflicts);
601
+ entriesMerged++;
602
+ const domainResult = this.domain.merge({
603
+ type: types_1.CRDTType.LWWRegister,
604
+ id: `${this.id}-domain`,
605
+ vectorClock: other.vectorClock,
606
+ origin: other.origin,
607
+ value: v.domain,
608
+ metadata: other.metadata,
609
+ stateVersion: 1,
610
+ });
611
+ if (domainResult.localChanged)
612
+ localChanged = true;
613
+ allConflicts.push(...domainResult.conflicts);
614
+ entriesMerged++;
615
+ const qualityResult = this.quality.merge({
616
+ type: types_1.CRDTType.LWWRegister,
617
+ id: `${this.id}-quality`,
618
+ vectorClock: other.vectorClock,
619
+ origin: other.origin,
620
+ value: v.quality,
621
+ metadata: other.metadata,
622
+ stateVersion: 1,
623
+ });
624
+ if (qualityResult.localChanged)
625
+ localChanged = true;
626
+ allConflicts.push(...qualityResult.conflicts);
627
+ entriesMerged++;
628
+ const sharingResult = this.sharingConfig.merge({
629
+ type: types_1.CRDTType.LWWRegister,
630
+ id: `${this.id}-sharing`,
631
+ vectorClock: other.vectorClock,
632
+ origin: other.origin,
633
+ value: v.sharingConfig,
634
+ metadata: other.metadata,
635
+ stateVersion: 1,
636
+ });
637
+ if (sharingResult.localChanged)
638
+ localChanged = true;
639
+ allConflicts.push(...sharingResult.conflicts);
640
+ entriesMerged++;
641
+ // Merge ORSet tags
642
+ const tagsResult = this.tags.merge({
643
+ type: types_1.CRDTType.ORSet,
644
+ id: `${this.id}-tags`,
645
+ vectorClock: other.vectorClock,
646
+ origin: other.origin,
647
+ value: v.tags,
648
+ metadata: other.metadata,
649
+ stateVersion: 1,
650
+ });
651
+ if (tagsResult.localChanged)
652
+ localChanged = true;
653
+ allConflicts.push(...tagsResult.conflicts);
654
+ entriesMerged++;
655
+ // Merge GCounter usage
656
+ const usageResult = this.usageCount.merge({
657
+ type: types_1.CRDTType.GCounter,
658
+ id: `${this.id}-usage`,
659
+ vectorClock: other.vectorClock,
660
+ origin: other.origin,
661
+ value: v.usageCount,
662
+ metadata: other.metadata,
663
+ stateVersion: 1,
664
+ });
665
+ if (usageResult.localChanged)
666
+ localChanged = true;
667
+ entriesMerged++;
668
+ // Merge metadata entries
669
+ for (const [key, lwwState] of Object.entries(v.metadata)) {
670
+ const existing = this.metadata.get(key);
671
+ if (existing) {
672
+ const metaResult = existing.merge({
673
+ type: types_1.CRDTType.LWWRegister,
674
+ id: `${this.id}-meta-${key}`,
675
+ vectorClock: other.vectorClock,
676
+ origin: other.origin,
677
+ value: lwwState,
678
+ metadata: other.metadata,
679
+ stateVersion: 1,
680
+ });
681
+ if (metaResult.localChanged)
682
+ localChanged = true;
683
+ allConflicts.push(...metaResult.conflicts);
684
+ }
685
+ else {
686
+ this.metadata.set(key, LWWRegister_1.LWWRegister.fromState({
687
+ type: types_1.CRDTType.LWWRegister,
688
+ id: `${this.id}-meta-${key}`,
689
+ vectorClock: other.vectorClock,
690
+ origin: other.origin,
691
+ value: lwwState,
692
+ metadata: other.metadata,
693
+ stateVersion: 1,
694
+ }, this.replicaId));
695
+ localChanged = true;
696
+ }
697
+ entriesMerged++;
698
+ }
699
+ // Merge vector clock
700
+ const otherClock = VectorClock_1.VectorClock.fromSerialized(other.vectorClock, this.replicaId);
701
+ this.vectorClock.merge(otherClock);
702
+ // Update metadata
703
+ this.crdtMetadata.mergeCount++;
704
+ this.crdtMetadata.updatedAt = Date.now();
705
+ if (localChanged) {
706
+ this.crdtMetadata.lastModifiedBy = other.origin;
707
+ }
708
+ const stats = {
709
+ duration: Date.now() - startTime,
710
+ entriesMerged,
711
+ autoResolved: allConflicts.length,
712
+ tombstonesProcessed: tagsResult.stats.tombstonesProcessed,
713
+ memoryDelta: entriesMerged * 32,
714
+ };
715
+ return {
716
+ success: true,
717
+ mergedState: this.state(),
718
+ localChanged,
719
+ conflicts: allConflicts,
720
+ stats,
721
+ };
722
+ }
723
+ // ============================================
724
+ // Delta Operations
725
+ // ============================================
726
+ /**
727
+ * Generate a delta update since the last sync
728
+ *
729
+ * @param since - Vector clock of last sync
730
+ * @returns Delta update or null if no changes
731
+ */
732
+ generateDelta(since) {
733
+ const sinceClock = since
734
+ ? VectorClock_1.VectorClock.fromSerialized(since, this.replicaId)
735
+ : this.lastDeltaClock;
736
+ if (!this.vectorClock.happenedAfter(sinceClock) &&
737
+ !this.vectorClock.isConcurrent(sinceClock)) {
738
+ return null;
739
+ }
740
+ const operations = [];
741
+ // Generate a full state delta for simplicity
742
+ // In production, you'd want to track individual field changes
743
+ operations.push({
744
+ op: types_1.DeltaOpType.Set,
745
+ value: this.state().value,
746
+ replica: this.replicaId,
747
+ });
748
+ const delta = {
749
+ crdtId: this.id,
750
+ type: types_1.CRDTType.PatternCRDT,
751
+ origin: this.replicaId,
752
+ vectorClock: this.vectorClock.serialize(),
753
+ operations,
754
+ sequenceNumber: this.sequenceNumber,
755
+ generatedAt: Date.now(),
756
+ };
757
+ this.lastDeltaClock = this.vectorClock.clone();
758
+ return delta;
759
+ }
760
+ /**
761
+ * Apply a delta update
762
+ *
763
+ * @param delta - Delta to apply
764
+ * @returns True if applied successfully
765
+ */
766
+ applyDelta(delta) {
767
+ if (delta.type !== types_1.CRDTType.PatternCRDT) {
768
+ return false;
769
+ }
770
+ if (delta.crdtId !== this.id) {
771
+ return false;
772
+ }
773
+ let changed = false;
774
+ for (const op of delta.operations) {
775
+ if (op.op === types_1.DeltaOpType.Set && op.value) {
776
+ // Apply as full state merge
777
+ const result = this.merge({
778
+ type: types_1.CRDTType.PatternCRDT,
779
+ id: this.id,
780
+ vectorClock: delta.vectorClock,
781
+ origin: delta.origin,
782
+ value: op.value,
783
+ metadata: this.crdtMetadata,
784
+ stateVersion: 1,
785
+ });
786
+ if (result.localChanged) {
787
+ changed = true;
788
+ }
789
+ }
790
+ }
791
+ return changed;
792
+ }
793
+ // ============================================
794
+ // Utility Methods
795
+ // ============================================
796
+ /**
797
+ * Create a deep copy
798
+ *
799
+ * @returns Cloned PatternCRDT
800
+ */
801
+ clone() {
802
+ return PatternCRDT.fromState(this.state(), this.replicaId);
803
+ }
804
+ /**
805
+ * Get the replica ID
806
+ *
807
+ * @returns Replica ID
808
+ */
809
+ getReplicaId() {
810
+ return this.replicaId;
811
+ }
812
+ /**
813
+ * Get the vector clock
814
+ *
815
+ * @returns Vector clock copy
816
+ */
817
+ getVectorClock() {
818
+ return this.vectorClock.clone();
819
+ }
820
+ /**
821
+ * Get CRDT metadata
822
+ *
823
+ * @returns Metadata copy
824
+ */
825
+ getCRDTMetadata() {
826
+ return { ...this.crdtMetadata };
827
+ }
828
+ /**
829
+ * String representation
830
+ *
831
+ * @returns Debug string
832
+ */
833
+ toString() {
834
+ return `PatternCRDT{id=${this.id}, type=${this.getType()}, tags=${this.tags.size()}, usage=${this.usageCount.value()}}`;
835
+ }
836
+ }
837
+ exports.PatternCRDT = PatternCRDT;
838
+ //# sourceMappingURL=PatternCRDT.js.map