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,781 @@
1
+ "use strict";
2
+ /**
3
+ * Pattern Index with Vector Similarity Search
4
+ *
5
+ * In-memory index of shared patterns with efficient vector similarity search
6
+ * using cosine distance. Includes LRU eviction, deduplication, and versioning.
7
+ *
8
+ * @module edge/p2p/sharing/PatternIndex
9
+ * @version 1.0.0
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PatternIndex = void 0;
13
+ exports.createPatternIndex = createPatternIndex;
14
+ const types_1 = require("./types");
15
+ /**
16
+ * Simple LRU cache implementation
17
+ */
18
+ class LRUCache {
19
+ constructor(capacity) {
20
+ this.cache = new Map();
21
+ this.head = null;
22
+ this.tail = null;
23
+ this.capacity = capacity;
24
+ }
25
+ get(key) {
26
+ const node = this.cache.get(key);
27
+ if (!node)
28
+ return undefined;
29
+ // Move to front
30
+ this.moveToFront(node);
31
+ node.accessTime = Date.now();
32
+ return node.value;
33
+ }
34
+ set(key, value) {
35
+ let evicted;
36
+ if (this.cache.has(key)) {
37
+ const node = this.cache.get(key);
38
+ node.value = value;
39
+ node.accessTime = Date.now();
40
+ this.moveToFront(node);
41
+ return undefined;
42
+ }
43
+ // Evict if at capacity
44
+ if (this.cache.size >= this.capacity) {
45
+ evicted = this.evictLRU();
46
+ }
47
+ // Add new node at front
48
+ const node = {
49
+ key,
50
+ value,
51
+ prev: null,
52
+ next: this.head,
53
+ accessTime: Date.now(),
54
+ };
55
+ if (this.head) {
56
+ this.head.prev = node;
57
+ }
58
+ this.head = node;
59
+ if (!this.tail) {
60
+ this.tail = node;
61
+ }
62
+ this.cache.set(key, node);
63
+ return evicted;
64
+ }
65
+ delete(key) {
66
+ const node = this.cache.get(key);
67
+ if (!node)
68
+ return false;
69
+ this.removeNode(node);
70
+ this.cache.delete(key);
71
+ return true;
72
+ }
73
+ has(key) {
74
+ return this.cache.has(key);
75
+ }
76
+ get size() {
77
+ return this.cache.size;
78
+ }
79
+ keys() {
80
+ return Array.from(this.cache.keys());
81
+ }
82
+ values() {
83
+ return Array.from(this.cache.values()).map((n) => n.value);
84
+ }
85
+ clear() {
86
+ this.cache.clear();
87
+ this.head = null;
88
+ this.tail = null;
89
+ }
90
+ moveToFront(node) {
91
+ if (node === this.head)
92
+ return;
93
+ this.removeNode(node);
94
+ node.prev = null;
95
+ node.next = this.head;
96
+ if (this.head) {
97
+ this.head.prev = node;
98
+ }
99
+ this.head = node;
100
+ if (!this.tail) {
101
+ this.tail = node;
102
+ }
103
+ }
104
+ removeNode(node) {
105
+ if (node.prev) {
106
+ node.prev.next = node.next;
107
+ }
108
+ else {
109
+ this.head = node.next;
110
+ }
111
+ if (node.next) {
112
+ node.next.prev = node.prev;
113
+ }
114
+ else {
115
+ this.tail = node.prev;
116
+ }
117
+ }
118
+ evictLRU() {
119
+ if (!this.tail)
120
+ return undefined;
121
+ const evicted = this.tail.value;
122
+ this.cache.delete(this.tail.key);
123
+ if (this.tail.prev) {
124
+ this.tail.prev.next = null;
125
+ this.tail = this.tail.prev;
126
+ }
127
+ else {
128
+ this.head = null;
129
+ this.tail = null;
130
+ }
131
+ return evicted;
132
+ }
133
+ }
134
+ // ============================================
135
+ // Pattern Index Class
136
+ // ============================================
137
+ /**
138
+ * In-memory pattern index with vector similarity search
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const index = new PatternIndex({ maxPatterns: 1000 });
143
+ *
144
+ * // Add patterns
145
+ * await index.add(pattern);
146
+ *
147
+ * // Search by embedding
148
+ * const matches = await index.search({
149
+ * embedding: queryVector,
150
+ * similarityThreshold: 0.7,
151
+ * limit: 10,
152
+ * });
153
+ *
154
+ * // Get by ID
155
+ * const pattern = index.get('pattern-id');
156
+ * ```
157
+ */
158
+ class PatternIndex {
159
+ constructor(config) {
160
+ this.eventHandlers = [];
161
+ this.config = {
162
+ maxPatterns: config?.maxPatterns ?? types_1.DEFAULT_CACHE_SIZE,
163
+ embeddingDimension: config?.embeddingDimension ?? types_1.DEFAULT_EMBEDDING_DIMENSION,
164
+ enableEviction: config?.enableEviction ?? true,
165
+ evictionThreshold: config?.evictionThreshold ?? 0.9,
166
+ enableDeduplication: config?.enableDeduplication ?? true,
167
+ enableExpiration: config?.enableExpiration ?? true,
168
+ };
169
+ this.patterns = new LRUCache(this.config.maxPatterns);
170
+ this.contentHashes = new Map();
171
+ this.embeddings = new Map();
172
+ this.lastUpdated = new Date().toISOString();
173
+ }
174
+ // ============================================
175
+ // CRUD Operations
176
+ // ============================================
177
+ /**
178
+ * Add a pattern to the index
179
+ */
180
+ add(pattern) {
181
+ // Check for duplicates by content hash
182
+ if (this.config.enableDeduplication) {
183
+ const existing = this.findByContentHash(pattern.content.contentHash);
184
+ if (existing) {
185
+ throw new types_1.SharingError(`Duplicate pattern: ${existing}`, types_1.SharingErrorCode.DUPLICATE_PATTERN);
186
+ }
187
+ }
188
+ // Check capacity
189
+ if (this.patterns.size >= this.config.maxPatterns) {
190
+ if (!this.config.enableEviction) {
191
+ throw new types_1.SharingError('Pattern index is full', types_1.SharingErrorCode.INDEX_FULL);
192
+ }
193
+ }
194
+ // Normalize embedding
195
+ const embedding = this.normalizeEmbedding(pattern.embedding);
196
+ // Add to LRU cache (may evict)
197
+ const evicted = this.patterns.set(pattern.id, pattern);
198
+ // Track content hash
199
+ this.contentHashes.set(pattern.content.contentHash, pattern.id);
200
+ // Store embedding
201
+ this.embeddings.set(pattern.id, embedding);
202
+ // Update timestamp
203
+ this.lastUpdated = new Date().toISOString();
204
+ // Emit event
205
+ this.emit({
206
+ type: types_1.SharingEventType.PATTERN_ADDED,
207
+ timestamp: Date.now(),
208
+ details: { patternId: pattern.id, category: pattern.category },
209
+ });
210
+ // Clean up evicted pattern's hash
211
+ if (evicted) {
212
+ this.contentHashes.delete(evicted.content.contentHash);
213
+ this.embeddings.delete(evicted.id);
214
+ this.emit({
215
+ type: types_1.SharingEventType.PATTERN_REMOVED,
216
+ timestamp: Date.now(),
217
+ details: { patternId: evicted.id, reason: 'eviction' },
218
+ });
219
+ }
220
+ return evicted ?? null;
221
+ }
222
+ /**
223
+ * Get a pattern by ID
224
+ */
225
+ get(id) {
226
+ const pattern = this.patterns.get(id);
227
+ // Check expiration
228
+ if (pattern && this.config.enableExpiration && pattern.expiresAt) {
229
+ if (new Date(pattern.expiresAt) < new Date()) {
230
+ this.remove(id);
231
+ return undefined;
232
+ }
233
+ }
234
+ return pattern;
235
+ }
236
+ /**
237
+ * Update a pattern
238
+ */
239
+ update(id, updates) {
240
+ const existing = this.patterns.get(id);
241
+ if (!existing)
242
+ return undefined;
243
+ // Check for content hash changes
244
+ if (updates.content?.contentHash &&
245
+ updates.content.contentHash !== existing.content.contentHash) {
246
+ // Update hash mapping
247
+ this.contentHashes.delete(existing.content.contentHash);
248
+ this.contentHashes.set(updates.content.contentHash, id);
249
+ }
250
+ // Merge updates
251
+ const updated = {
252
+ ...existing,
253
+ ...updates,
254
+ id, // Preserve ID
255
+ updatedAt: new Date().toISOString(),
256
+ };
257
+ // Update embedding if provided
258
+ if (updates.embedding) {
259
+ const embedding = this.normalizeEmbedding(updates.embedding);
260
+ this.embeddings.set(id, embedding);
261
+ updated.embedding = Array.from(embedding);
262
+ }
263
+ this.patterns.set(id, updated);
264
+ this.lastUpdated = new Date().toISOString();
265
+ this.emit({
266
+ type: types_1.SharingEventType.PATTERN_UPDATED,
267
+ timestamp: Date.now(),
268
+ details: { patternId: id },
269
+ });
270
+ return updated;
271
+ }
272
+ /**
273
+ * Remove a pattern by ID
274
+ */
275
+ remove(id) {
276
+ const pattern = this.patterns.get(id);
277
+ if (!pattern)
278
+ return false;
279
+ this.contentHashes.delete(pattern.content.contentHash);
280
+ this.embeddings.delete(id);
281
+ const removed = this.patterns.delete(id);
282
+ this.lastUpdated = new Date().toISOString();
283
+ if (removed) {
284
+ this.emit({
285
+ type: types_1.SharingEventType.PATTERN_REMOVED,
286
+ timestamp: Date.now(),
287
+ details: { patternId: id },
288
+ });
289
+ }
290
+ return removed;
291
+ }
292
+ /**
293
+ * Check if pattern exists
294
+ */
295
+ has(id) {
296
+ return this.patterns.has(id);
297
+ }
298
+ /**
299
+ * Clear all patterns
300
+ */
301
+ clear() {
302
+ this.patterns.clear();
303
+ this.contentHashes.clear();
304
+ this.embeddings.clear();
305
+ this.lastUpdated = new Date().toISOString();
306
+ }
307
+ // ============================================
308
+ // Search Operations
309
+ // ============================================
310
+ /**
311
+ * Search patterns by query
312
+ */
313
+ search(query) {
314
+ const startTime = Date.now();
315
+ const matches = [];
316
+ const threshold = query.similarityThreshold ?? 0.5;
317
+ const limit = query.limit ?? 10;
318
+ const offset = query.offset ?? 0;
319
+ // Get query embedding
320
+ const queryEmbedding = query.embedding
321
+ ? this.normalizeEmbedding(query.embedding)
322
+ : null;
323
+ // Iterate through patterns
324
+ for (const pattern of this.patterns.values()) {
325
+ // Apply filters
326
+ if (!this.matchesFilters(pattern, query))
327
+ continue;
328
+ // Check expiration
329
+ if (this.config.enableExpiration &&
330
+ !query.includeExpired &&
331
+ pattern.expiresAt) {
332
+ if (new Date(pattern.expiresAt) < new Date())
333
+ continue;
334
+ }
335
+ // Calculate similarity
336
+ let similarity = 0;
337
+ let textScore = 0;
338
+ if (queryEmbedding) {
339
+ const patternEmbedding = this.embeddings.get(pattern.id);
340
+ if (patternEmbedding) {
341
+ similarity = this.cosineSimilarity(queryEmbedding, patternEmbedding);
342
+ }
343
+ }
344
+ // Text search
345
+ if (query.textQuery) {
346
+ textScore = this.textMatch(pattern, query.textQuery);
347
+ }
348
+ // Combined relevance
349
+ const relevance = queryEmbedding
350
+ ? similarity * 0.7 + textScore * 0.3
351
+ : textScore;
352
+ if (relevance >= threshold || (!queryEmbedding && textScore > 0)) {
353
+ matches.push({
354
+ pattern,
355
+ similarity,
356
+ textScore,
357
+ relevance,
358
+ matchReason: this.generateMatchReason(similarity, textScore, query),
359
+ });
360
+ }
361
+ }
362
+ // Sort by relevance
363
+ matches.sort((a, b) => b.relevance - a.relevance);
364
+ // Apply pagination
365
+ const paginatedMatches = matches.slice(offset, offset + limit);
366
+ return {
367
+ matches: paginatedMatches,
368
+ totalCount: matches.length,
369
+ query,
370
+ duration: Date.now() - startTime,
371
+ cached: false,
372
+ };
373
+ }
374
+ /**
375
+ * Find similar patterns by embedding
376
+ */
377
+ findSimilar(embedding, limit = 10, threshold = 0.5) {
378
+ const queryEmbedding = this.normalizeEmbedding(embedding);
379
+ const matches = [];
380
+ for (const pattern of this.patterns.values()) {
381
+ const patternEmbedding = this.embeddings.get(pattern.id);
382
+ if (!patternEmbedding)
383
+ continue;
384
+ const similarity = this.cosineSimilarity(queryEmbedding, patternEmbedding);
385
+ if (similarity >= threshold) {
386
+ matches.push({
387
+ pattern,
388
+ similarity,
389
+ relevance: similarity,
390
+ matchReason: `Similarity: ${(similarity * 100).toFixed(1)}%`,
391
+ });
392
+ }
393
+ }
394
+ matches.sort((a, b) => b.similarity - a.similarity);
395
+ return matches.slice(0, limit);
396
+ }
397
+ /**
398
+ * Find pattern by content hash (deduplication)
399
+ */
400
+ findByContentHash(hash) {
401
+ return this.contentHashes.get(hash);
402
+ }
403
+ /**
404
+ * Find patterns by category
405
+ */
406
+ findByCategory(category) {
407
+ return this.patterns.values().filter((p) => p.category === category);
408
+ }
409
+ /**
410
+ * Find patterns by domain
411
+ */
412
+ findByDomain(domain) {
413
+ return this.patterns.values().filter((p) => p.domain === domain);
414
+ }
415
+ /**
416
+ * Find patterns by tags
417
+ */
418
+ findByTags(tags) {
419
+ const tagSet = new Set(tags.map((t) => t.toLowerCase()));
420
+ return this.patterns.values().filter((p) => p.metadata.tags.some((t) => tagSet.has(t.toLowerCase())));
421
+ }
422
+ // ============================================
423
+ // Version and Conflict Detection
424
+ // ============================================
425
+ /**
426
+ * Check if a pattern version conflicts with existing
427
+ */
428
+ checkConflict(pattern) {
429
+ const existing = this.get(pattern.id);
430
+ if (!existing)
431
+ return null;
432
+ // Compare vector clocks
433
+ const comparison = this.compareVectorClocks(existing.version.vectorClock, pattern.version.vectorClock);
434
+ if (comparison === 'concurrent') {
435
+ return {
436
+ patternId: pattern.id,
437
+ localVersion: existing.version,
438
+ remoteVersion: pattern.version,
439
+ conflictType: 'concurrent_update',
440
+ };
441
+ }
442
+ if (comparison === 'equal' && existing.content.contentHash !== pattern.content.contentHash) {
443
+ return {
444
+ patternId: pattern.id,
445
+ localVersion: existing.version,
446
+ remoteVersion: pattern.version,
447
+ conflictType: 'content_divergence',
448
+ };
449
+ }
450
+ return null;
451
+ }
452
+ /**
453
+ * Compare two vector clocks
454
+ * Returns: 'before', 'after', 'equal', 'concurrent'
455
+ */
456
+ compareVectorClocks(a, b) {
457
+ const allKeys = new Set([...Object.keys(a.clock), ...Object.keys(b.clock)]);
458
+ let aLessOrEqual = true; // All a values <= b values
459
+ let bLessOrEqual = true; // All b values <= a values
460
+ for (const key of allKeys) {
461
+ const aVal = a.clock[key] || 0;
462
+ const bVal = b.clock[key] || 0;
463
+ // If a has a larger value than b for any key, a is NOT <= b
464
+ if (aVal > bVal)
465
+ aLessOrEqual = false;
466
+ // If b has a larger value than a for any key, b is NOT <= a
467
+ if (bVal > aVal)
468
+ bLessOrEqual = false;
469
+ }
470
+ // Both <= means equal
471
+ if (aLessOrEqual && bLessOrEqual)
472
+ return 'equal';
473
+ // a <= b (and not b <= a) means a happened before b
474
+ if (aLessOrEqual)
475
+ return 'before';
476
+ // b <= a (and not a <= b) means a happened after b
477
+ if (bLessOrEqual)
478
+ return 'after';
479
+ // Neither is <= the other means concurrent
480
+ return 'concurrent';
481
+ }
482
+ /**
483
+ * Increment vector clock for local agent
484
+ */
485
+ incrementClock(clock, agentId) {
486
+ return {
487
+ clock: {
488
+ ...clock.clock,
489
+ [agentId]: (clock.clock[agentId] || 0) + 1,
490
+ },
491
+ };
492
+ }
493
+ /**
494
+ * Merge two vector clocks
495
+ */
496
+ mergeClock(a, b) {
497
+ const merged = { ...a.clock };
498
+ for (const [key, value] of Object.entries(b.clock)) {
499
+ merged[key] = Math.max(merged[key] || 0, value);
500
+ }
501
+ return { clock: merged };
502
+ }
503
+ // ============================================
504
+ // Cleanup and Maintenance
505
+ // ============================================
506
+ /**
507
+ * Remove expired patterns
508
+ */
509
+ cleanupExpired() {
510
+ if (!this.config.enableExpiration)
511
+ return 0;
512
+ const now = new Date();
513
+ const toRemove = [];
514
+ for (const pattern of this.patterns.values()) {
515
+ if (pattern.expiresAt && new Date(pattern.expiresAt) < now) {
516
+ toRemove.push(pattern.id);
517
+ }
518
+ }
519
+ for (const id of toRemove) {
520
+ this.remove(id);
521
+ }
522
+ return toRemove.length;
523
+ }
524
+ /**
525
+ * Get all pattern IDs
526
+ */
527
+ getAllIds() {
528
+ return this.patterns.keys();
529
+ }
530
+ /**
531
+ * Get all patterns
532
+ */
533
+ getAll() {
534
+ return this.patterns.values();
535
+ }
536
+ /**
537
+ * Get pattern summaries
538
+ */
539
+ getSummaries() {
540
+ return this.patterns.values().map((p) => ({
541
+ id: p.id,
542
+ category: p.category,
543
+ type: p.type,
544
+ domain: p.domain,
545
+ contentHash: p.content.contentHash,
546
+ quality: p.quality.level,
547
+ tags: p.metadata.tags,
548
+ }));
549
+ }
550
+ // ============================================
551
+ // Statistics
552
+ // ============================================
553
+ /**
554
+ * Get index statistics
555
+ */
556
+ getStats() {
557
+ const byCategory = {
558
+ [types_1.PatternCategory.TEST]: 0,
559
+ [types_1.PatternCategory.CODE]: 0,
560
+ [types_1.PatternCategory.REFACTOR]: 0,
561
+ [types_1.PatternCategory.DEFECT_FIX]: 0,
562
+ [types_1.PatternCategory.PERFORMANCE]: 0,
563
+ [types_1.PatternCategory.SECURITY]: 0,
564
+ };
565
+ const byQuality = {
566
+ [types_1.PatternQuality.UNVERIFIED]: 0,
567
+ [types_1.PatternQuality.LOW]: 0,
568
+ [types_1.PatternQuality.MEDIUM]: 0,
569
+ [types_1.PatternQuality.HIGH]: 0,
570
+ [types_1.PatternQuality.CURATED]: 0,
571
+ };
572
+ for (const pattern of this.patterns.values()) {
573
+ byCategory[pattern.category]++;
574
+ byQuality[pattern.quality.level]++;
575
+ }
576
+ // Estimate memory usage
577
+ let memoryUsage = 0;
578
+ for (const embedding of this.embeddings.values()) {
579
+ memoryUsage += embedding.byteLength;
580
+ }
581
+ // Add rough estimate for pattern objects
582
+ memoryUsage += this.patterns.size * 1024; // ~1KB per pattern estimate
583
+ return {
584
+ totalPatterns: this.patterns.size,
585
+ byCategory,
586
+ byQuality,
587
+ memoryUsage,
588
+ lastUpdated: this.lastUpdated,
589
+ version: '1.0.0',
590
+ };
591
+ }
592
+ /**
593
+ * Get current size
594
+ */
595
+ get size() {
596
+ return this.patterns.size;
597
+ }
598
+ // ============================================
599
+ // Events
600
+ // ============================================
601
+ /**
602
+ * Subscribe to events
603
+ */
604
+ on(handler) {
605
+ this.eventHandlers.push(handler);
606
+ }
607
+ /**
608
+ * Unsubscribe from events
609
+ */
610
+ off(handler) {
611
+ const index = this.eventHandlers.indexOf(handler);
612
+ if (index !== -1) {
613
+ this.eventHandlers.splice(index, 1);
614
+ }
615
+ }
616
+ /**
617
+ * Emit an event
618
+ */
619
+ emit(event) {
620
+ for (const handler of this.eventHandlers) {
621
+ try {
622
+ handler(event);
623
+ }
624
+ catch {
625
+ // Ignore handler errors
626
+ }
627
+ }
628
+ }
629
+ // ============================================
630
+ // Private Helpers
631
+ // ============================================
632
+ /**
633
+ * Normalize embedding to Float32Array
634
+ */
635
+ normalizeEmbedding(embedding) {
636
+ if (embedding instanceof Float32Array) {
637
+ return embedding;
638
+ }
639
+ return new Float32Array(embedding);
640
+ }
641
+ /**
642
+ * Calculate cosine similarity
643
+ */
644
+ cosineSimilarity(a, b) {
645
+ if (a.length !== b.length) {
646
+ const minLen = Math.min(a.length, b.length);
647
+ a = a.slice(0, minLen);
648
+ b = b.slice(0, minLen);
649
+ }
650
+ let dotProduct = 0;
651
+ let normA = 0;
652
+ let normB = 0;
653
+ for (let i = 0; i < a.length; i++) {
654
+ dotProduct += a[i] * b[i];
655
+ normA += a[i] * a[i];
656
+ normB += b[i] * b[i];
657
+ }
658
+ const denominator = Math.sqrt(normA) * Math.sqrt(normB);
659
+ return denominator === 0 ? 0 : dotProduct / denominator;
660
+ }
661
+ /**
662
+ * Check if pattern matches query filters
663
+ */
664
+ matchesFilters(pattern, query) {
665
+ // Category filter
666
+ if (query.categories && query.categories.length > 0) {
667
+ if (!query.categories.includes(pattern.category))
668
+ return false;
669
+ }
670
+ // Type filter
671
+ if (query.types && query.types.length > 0) {
672
+ if (!query.types.includes(pattern.type))
673
+ return false;
674
+ }
675
+ // Domain filter
676
+ if (query.domains && query.domains.length > 0) {
677
+ if (!query.domains.includes(pattern.domain))
678
+ return false;
679
+ }
680
+ // Tag filter
681
+ if (query.tags && query.tags.length > 0) {
682
+ const patternTags = new Set(pattern.metadata.tags.map((t) => t.toLowerCase()));
683
+ if (!query.tags.some((t) => patternTags.has(t.toLowerCase())))
684
+ return false;
685
+ }
686
+ // Language filter
687
+ if (query.language && pattern.content.language !== query.language) {
688
+ return false;
689
+ }
690
+ // Framework filter
691
+ if (query.framework && pattern.content.framework !== query.framework) {
692
+ return false;
693
+ }
694
+ // Quality filter
695
+ if (query.minQuality) {
696
+ const qualityOrder = [
697
+ types_1.PatternQuality.UNVERIFIED,
698
+ types_1.PatternQuality.LOW,
699
+ types_1.PatternQuality.MEDIUM,
700
+ types_1.PatternQuality.HIGH,
701
+ types_1.PatternQuality.CURATED,
702
+ ];
703
+ const minIndex = qualityOrder.indexOf(query.minQuality);
704
+ const patternIndex = qualityOrder.indexOf(pattern.quality.level);
705
+ if (patternIndex < minIndex)
706
+ return false;
707
+ }
708
+ // Success rate filter
709
+ if (query.minSuccessRate !== undefined) {
710
+ if (pattern.quality.successRate < query.minSuccessRate)
711
+ return false;
712
+ }
713
+ // Usage count filter
714
+ if (query.minUsageCount !== undefined) {
715
+ if (pattern.quality.usageCount < query.minUsageCount)
716
+ return false;
717
+ }
718
+ return true;
719
+ }
720
+ /**
721
+ * Simple text matching score
722
+ */
723
+ textMatch(pattern, query) {
724
+ const queryLower = query.toLowerCase();
725
+ const words = queryLower.split(/\s+/);
726
+ let score = 0;
727
+ // Check name
728
+ if (pattern.metadata.name?.toLowerCase().includes(queryLower)) {
729
+ score += 1;
730
+ }
731
+ // Check description
732
+ if (pattern.metadata.description?.toLowerCase().includes(queryLower)) {
733
+ score += 0.5;
734
+ }
735
+ // Check tags
736
+ for (const tag of pattern.metadata.tags) {
737
+ if (tag.toLowerCase().includes(queryLower)) {
738
+ score += 0.3;
739
+ }
740
+ }
741
+ // Check content
742
+ const contentLower = pattern.content.raw.toLowerCase();
743
+ for (const word of words) {
744
+ if (word.length > 2 && contentLower.includes(word)) {
745
+ score += 0.1;
746
+ }
747
+ }
748
+ // Normalize
749
+ return Math.min(1, score);
750
+ }
751
+ /**
752
+ * Generate match reason string
753
+ */
754
+ generateMatchReason(similarity, textScore, query) {
755
+ const reasons = [];
756
+ if (similarity > 0) {
757
+ reasons.push(`Vector similarity: ${(similarity * 100).toFixed(1)}%`);
758
+ }
759
+ if (textScore > 0) {
760
+ reasons.push(`Text match: ${(textScore * 100).toFixed(1)}%`);
761
+ }
762
+ if (query.categories?.length) {
763
+ reasons.push(`Category filter: ${query.categories.join(', ')}`);
764
+ }
765
+ if (query.tags?.length) {
766
+ reasons.push(`Tag filter: ${query.tags.join(', ')}`);
767
+ }
768
+ return reasons.join('; ') || 'Matched filters';
769
+ }
770
+ }
771
+ exports.PatternIndex = PatternIndex;
772
+ // ============================================
773
+ // Factory Functions
774
+ // ============================================
775
+ /**
776
+ * Create a new pattern index
777
+ */
778
+ function createPatternIndex(config) {
779
+ return new PatternIndex(config);
780
+ }
781
+ //# sourceMappingURL=PatternIndex.js.map