@holoscript/framework 6.0.3

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 (329) hide show
  1. package/ALL-test-results.json +1 -0
  2. package/CHANGELOG.md +8 -0
  3. package/LICENSE +21 -0
  4. package/ROADMAP.md +175 -0
  5. package/dist/AgentManifest-CB4xM-Ma.d.cts +704 -0
  6. package/dist/AgentManifest-CB4xM-Ma.d.ts +704 -0
  7. package/dist/BehaviorTree-BrBFECv5.d.cts +103 -0
  8. package/dist/BehaviorTree-BrBFECv5.d.ts +103 -0
  9. package/dist/InvisibleWallet-BB6tFvRA.d.cts +1732 -0
  10. package/dist/InvisibleWallet-rtRrBOA8.d.ts +1732 -0
  11. package/dist/OrchestratorAgent-BvWgf9uw.d.cts +798 -0
  12. package/dist/OrchestratorAgent-Q_CbVTmO.d.ts +798 -0
  13. package/dist/agents/index.cjs +4790 -0
  14. package/dist/agents/index.d.cts +1788 -0
  15. package/dist/agents/index.d.ts +1788 -0
  16. package/dist/agents/index.js +4695 -0
  17. package/dist/ai/index.cjs +5347 -0
  18. package/dist/ai/index.d.cts +1753 -0
  19. package/dist/ai/index.d.ts +1753 -0
  20. package/dist/ai/index.js +5244 -0
  21. package/dist/behavior.cjs +449 -0
  22. package/dist/behavior.d.cts +130 -0
  23. package/dist/behavior.d.ts +130 -0
  24. package/dist/behavior.js +407 -0
  25. package/dist/economy/index.cjs +3659 -0
  26. package/dist/economy/index.d.cts +747 -0
  27. package/dist/economy/index.d.ts +747 -0
  28. package/dist/economy/index.js +3617 -0
  29. package/dist/implementations-D9T3un9D.d.cts +236 -0
  30. package/dist/implementations-D9T3un9D.d.ts +236 -0
  31. package/dist/index.cjs +24550 -0
  32. package/dist/index.d.cts +1729 -0
  33. package/dist/index.d.ts +1729 -0
  34. package/dist/index.js +24277 -0
  35. package/dist/learning/index.cjs +219 -0
  36. package/dist/learning/index.d.cts +104 -0
  37. package/dist/learning/index.d.ts +104 -0
  38. package/dist/learning/index.js +189 -0
  39. package/dist/negotiation/index.cjs +970 -0
  40. package/dist/negotiation/index.d.cts +610 -0
  41. package/dist/negotiation/index.d.ts +610 -0
  42. package/dist/negotiation/index.js +931 -0
  43. package/dist/skills/index.cjs +1118 -0
  44. package/dist/skills/index.d.cts +289 -0
  45. package/dist/skills/index.d.ts +289 -0
  46. package/dist/skills/index.js +1079 -0
  47. package/dist/swarm/index.cjs +5268 -0
  48. package/dist/swarm/index.d.cts +2433 -0
  49. package/dist/swarm/index.d.ts +2433 -0
  50. package/dist/swarm/index.js +5221 -0
  51. package/dist/training/index.cjs +2745 -0
  52. package/dist/training/index.d.cts +1734 -0
  53. package/dist/training/index.d.ts +1734 -0
  54. package/dist/training/index.js +2687 -0
  55. package/extract-failures.js +10 -0
  56. package/package.json +82 -0
  57. package/src/__tests__/bounty-marketplace.test.ts +374 -0
  58. package/src/__tests__/delegation.test.ts +144 -0
  59. package/src/__tests__/distributed-claimer.test.ts +147 -0
  60. package/src/__tests__/done-log-audit.test.ts +342 -0
  61. package/src/__tests__/framework.test.ts +865 -0
  62. package/src/__tests__/goal-synthesizer.test.ts +236 -0
  63. package/src/__tests__/presence.test.ts +223 -0
  64. package/src/__tests__/protocol-agent.test.ts +254 -0
  65. package/src/__tests__/revenue-splitter.test.ts +114 -0
  66. package/src/__tests__/scenario-driven-todo.test.ts +197 -0
  67. package/src/__tests__/self-improve.test.ts +349 -0
  68. package/src/__tests__/service-lifecycle.test.ts +237 -0
  69. package/src/__tests__/skill-router.test.ts +121 -0
  70. package/src/agents/AgentManifest.ts +493 -0
  71. package/src/agents/AgentRegistry.ts +475 -0
  72. package/src/agents/AgentTypes.ts +585 -0
  73. package/src/agents/AgentWalletRegistry.ts +83 -0
  74. package/src/agents/AuthenticatedCRDT.ts +388 -0
  75. package/src/agents/CapabilityMatcher.ts +453 -0
  76. package/src/agents/CrossRealityHandoff.ts +305 -0
  77. package/src/agents/CulturalMemory.ts +454 -0
  78. package/src/agents/FederatedRegistryAdapter.ts +429 -0
  79. package/src/agents/NormEngine.ts +450 -0
  80. package/src/agents/OrchestratorAgent.ts +414 -0
  81. package/src/agents/SkillWorkflowEngine.ts +472 -0
  82. package/src/agents/TaskDelegationService.ts +551 -0
  83. package/src/agents/__tests__/AgentManifest.prod.test.ts +134 -0
  84. package/src/agents/__tests__/AgentManifest.test.ts +182 -0
  85. package/src/agents/__tests__/AgentModule.test.ts +864 -0
  86. package/src/agents/__tests__/AgentRegistry.prod.test.ts +125 -0
  87. package/src/agents/__tests__/AgentRegistry.test.ts +148 -0
  88. package/src/agents/__tests__/AgentTypes.test.ts +534 -0
  89. package/src/agents/__tests__/AgentWalletRegistry.test.ts +152 -0
  90. package/src/agents/__tests__/AuthenticatedCRDT.test.ts +558 -0
  91. package/src/agents/__tests__/CapabilityMatcher.prod.test.ts +117 -0
  92. package/src/agents/__tests__/CapabilityMatcher.test.ts +178 -0
  93. package/src/agents/__tests__/CrossRealityHandoff.test.ts +402 -0
  94. package/src/agents/__tests__/CulturalMemory.test.ts +200 -0
  95. package/src/agents/__tests__/FederatedRegistryAdapter.test.ts +409 -0
  96. package/src/agents/__tests__/NormEngine.test.ts +276 -0
  97. package/src/agents/__tests__/OrchestratorAgent.test.ts +182 -0
  98. package/src/agents/__tests__/SkillWorkflowEngine.test.ts +357 -0
  99. package/src/agents/__tests__/TaskDelegationService.test.ts +446 -0
  100. package/src/agents/index.ts +107 -0
  101. package/src/agents/spatial-comms/Layer1RealTime.ts +621 -0
  102. package/src/agents/spatial-comms/Layer2A2A.ts +661 -0
  103. package/src/agents/spatial-comms/Layer3MCP.ts +651 -0
  104. package/src/agents/spatial-comms/ProtocolTypes.ts +543 -0
  105. package/src/agents/spatial-comms/SpatialCommClient.ts +483 -0
  106. package/src/agents/spatial-comms/__tests__/performance-benchmark.test.ts +465 -0
  107. package/src/agents/spatial-comms/examples/multi-agent-world-creation.ts +409 -0
  108. package/src/agents/spatial-comms/index.ts +66 -0
  109. package/src/ai/AIAdapter.ts +313 -0
  110. package/src/ai/AICopilot.ts +331 -0
  111. package/src/ai/AIOutputValidator.ts +203 -0
  112. package/src/ai/BTNodes.ts +239 -0
  113. package/src/ai/BehaviorSelector.ts +135 -0
  114. package/src/ai/BehaviorTree.ts +153 -0
  115. package/src/ai/Blackboard.ts +165 -0
  116. package/src/ai/GenerationAnalytics.ts +461 -0
  117. package/src/ai/GenerationCache.ts +265 -0
  118. package/src/ai/GoalPlanner.ts +165 -0
  119. package/src/ai/HoloScriptGenerator.ts +580 -0
  120. package/src/ai/InfluenceMap.ts +180 -0
  121. package/src/ai/NavMesh.ts +168 -0
  122. package/src/ai/PerceptionSystem.ts +178 -0
  123. package/src/ai/PromptTemplates.ts +453 -0
  124. package/src/ai/SemanticSearchService.ts +80 -0
  125. package/src/ai/StateMachine.ts +196 -0
  126. package/src/ai/SteeringBehavior.ts +150 -0
  127. package/src/ai/SteeringBehaviors.ts +244 -0
  128. package/src/ai/TrainingDataGenerator.ts +1082 -0
  129. package/src/ai/UtilityAI.ts +145 -0
  130. package/src/ai/__tests__/AIAdapter.prod.test.ts +259 -0
  131. package/src/ai/__tests__/AIAdapter.test.ts +109 -0
  132. package/src/ai/__tests__/AICopilot.prod.test.ts +341 -0
  133. package/src/ai/__tests__/AICopilot.test.ts +178 -0
  134. package/src/ai/__tests__/AIOutputValidator.prod.test.ts +226 -0
  135. package/src/ai/__tests__/AIOutputValidator.test.ts +138 -0
  136. package/src/ai/__tests__/BTNodes.prod.test.ts +391 -0
  137. package/src/ai/__tests__/BTNodes.test.ts +263 -0
  138. package/src/ai/__tests__/BehaviorSelector.prod.test.ts +129 -0
  139. package/src/ai/__tests__/BehaviorSelector.test.ts +132 -0
  140. package/src/ai/__tests__/BehaviorTree.prod.test.ts +266 -0
  141. package/src/ai/__tests__/BehaviorTree.test.ts +216 -0
  142. package/src/ai/__tests__/Blackboard.prod.test.ts +339 -0
  143. package/src/ai/__tests__/Blackboard.test.ts +183 -0
  144. package/src/ai/__tests__/GenerationAnalytics.prod.test.ts +141 -0
  145. package/src/ai/__tests__/GenerationAnalytics.test.ts +165 -0
  146. package/src/ai/__tests__/GenerationCache.prod.test.ts +144 -0
  147. package/src/ai/__tests__/GenerationCache.test.ts +171 -0
  148. package/src/ai/__tests__/GoalPlanner.prod.test.ts +189 -0
  149. package/src/ai/__tests__/GoalPlanner.test.ts +137 -0
  150. package/src/ai/__tests__/GoalPlannerDepth.prod.test.ts +217 -0
  151. package/src/ai/__tests__/HoloScriptGenerator.test.ts +125 -0
  152. package/src/ai/__tests__/InfluenceMap.prod.test.ts +146 -0
  153. package/src/ai/__tests__/InfluenceMap.test.ts +149 -0
  154. package/src/ai/__tests__/NavMesh.prod.test.ts +141 -0
  155. package/src/ai/__tests__/NavMesh.test.ts +159 -0
  156. package/src/ai/__tests__/PerceptionSystem.prod.test.ts +135 -0
  157. package/src/ai/__tests__/PerceptionSystem.test.ts +250 -0
  158. package/src/ai/__tests__/PromptTemplates.prod.test.ts +313 -0
  159. package/src/ai/__tests__/PromptTemplates.test.ts +146 -0
  160. package/src/ai/__tests__/SemanticSearch.test.ts +37 -0
  161. package/src/ai/__tests__/StateMachine.prod.test.ts +162 -0
  162. package/src/ai/__tests__/StateMachine.test.ts +163 -0
  163. package/src/ai/__tests__/SteeringBehavior.prod.test.ts +251 -0
  164. package/src/ai/__tests__/SteeringBehavior.test.ts +135 -0
  165. package/src/ai/__tests__/SteeringBehaviors.prod.test.ts +133 -0
  166. package/src/ai/__tests__/SteeringBehaviors.test.ts +151 -0
  167. package/src/ai/__tests__/TrainingDataGenerator.prod.test.ts +286 -0
  168. package/src/ai/__tests__/TrainingDataGenerator.test.ts +286 -0
  169. package/src/ai/__tests__/UtilityAI.prod.test.ts +207 -0
  170. package/src/ai/__tests__/UtilityAI.test.ts +155 -0
  171. package/src/ai/__tests__/adapters.prod.test.ts +263 -0
  172. package/src/ai/__tests__/adapters.test.ts +320 -0
  173. package/src/ai/adapters.ts +1585 -0
  174. package/src/ai/index.ts +130 -0
  175. package/src/behavior/BehaviorPresets.ts +140 -0
  176. package/src/behavior/BehaviorTree.ts +236 -0
  177. package/src/behavior/StateMachine.ts +176 -0
  178. package/src/behavior/StateTrait.ts +67 -0
  179. package/src/behavior/index.ts +8 -0
  180. package/src/behavior.ts +8 -0
  181. package/src/board/audit.ts +284 -0
  182. package/src/board/board-ops.ts +336 -0
  183. package/src/board/board-types.ts +302 -0
  184. package/src/board/index.ts +69 -0
  185. package/src/define-agent.ts +46 -0
  186. package/src/define-team.ts +33 -0
  187. package/src/delegation.ts +265 -0
  188. package/src/distributed-claimer.ts +228 -0
  189. package/src/economy/AgentBudgetEnforcer.ts +464 -0
  190. package/src/economy/BountyManager.ts +185 -0
  191. package/src/economy/CreatorRevenueAggregator.ts +460 -0
  192. package/src/economy/InvisibleWallet.ts +82 -0
  193. package/src/economy/KnowledgeMarketplace.ts +193 -0
  194. package/src/economy/PaymentWebhookService.ts +512 -0
  195. package/src/economy/RevenueSplitter.ts +156 -0
  196. package/src/economy/SubscriptionManager.ts +546 -0
  197. package/src/economy/UnifiedBudgetOptimizer.ts +635 -0
  198. package/src/economy/UsageMeter.ts +440 -0
  199. package/src/economy/_core-stubs.ts +219 -0
  200. package/src/economy/index.ts +100 -0
  201. package/src/economy/x402-facilitator.ts +1978 -0
  202. package/src/index.ts +348 -0
  203. package/src/knowledge/__tests__/knowledge-consolidator.test.ts +444 -0
  204. package/src/knowledge/__tests__/knowledge-store-vector.test.ts +291 -0
  205. package/src/knowledge/brain.ts +167 -0
  206. package/src/knowledge/consolidation.ts +581 -0
  207. package/src/knowledge/knowledge-consolidator.ts +510 -0
  208. package/src/knowledge/knowledge-store.ts +616 -0
  209. package/src/learning/MemoryConsolidator.ts +102 -0
  210. package/src/learning/MemoryScorer.ts +69 -0
  211. package/src/learning/ProceduralCompiler.ts +45 -0
  212. package/src/learning/SemanticClusterer.ts +66 -0
  213. package/src/learning/index.ts +8 -0
  214. package/src/llm/llm-adapter.ts +159 -0
  215. package/src/mesh/index.ts +309 -0
  216. package/src/negotiation/NegotiationProtocol.ts +694 -0
  217. package/src/negotiation/NegotiationTypes.ts +473 -0
  218. package/src/negotiation/VotingMechanisms.ts +691 -0
  219. package/src/negotiation/index.ts +49 -0
  220. package/src/protocol/goal-synthesizer.ts +317 -0
  221. package/src/protocol/implementations.ts +474 -0
  222. package/src/protocol/micro-phase-decomposer.ts +299 -0
  223. package/src/protocol/micro-step-decomposer.test.ts +306 -0
  224. package/src/protocol-agent.test.ts +353 -0
  225. package/src/protocol-agent.ts +670 -0
  226. package/src/self-improve/absorb-scanner.ts +252 -0
  227. package/src/self-improve/evolution-engine.ts +149 -0
  228. package/src/self-improve/framework-absorber.ts +214 -0
  229. package/src/self-improve/index.ts +50 -0
  230. package/src/self-improve/prompt-optimizer.ts +212 -0
  231. package/src/self-improve/test-generator.ts +175 -0
  232. package/src/skill-router.ts +186 -0
  233. package/src/skills/index.ts +5 -0
  234. package/src/skills/skill-md-bridge.ts +1699 -0
  235. package/src/swarm/ACOEngine.ts +261 -0
  236. package/src/swarm/CollectiveIntelligence.ts +383 -0
  237. package/src/swarm/ContributionSynthesizer.ts +481 -0
  238. package/src/swarm/LeaderElection.ts +393 -0
  239. package/src/swarm/PSOEngine.ts +206 -0
  240. package/src/swarm/QuorumPolicy.ts +173 -0
  241. package/src/swarm/SwarmCoordinator.ts +335 -0
  242. package/src/swarm/SwarmManager.ts +442 -0
  243. package/src/swarm/SwarmMembership.ts +456 -0
  244. package/src/swarm/VotingRound.ts +255 -0
  245. package/src/swarm/__tests__/ACOEngine.prod.test.ts +164 -0
  246. package/src/swarm/__tests__/ACOEngine.test.ts +117 -0
  247. package/src/swarm/__tests__/CollectiveIntelligence.prod.test.ts +296 -0
  248. package/src/swarm/__tests__/CollectiveIntelligence.test.ts +457 -0
  249. package/src/swarm/__tests__/ContributionSynthesizer.prod.test.ts +269 -0
  250. package/src/swarm/__tests__/ContributionSynthesizer.test.ts +254 -0
  251. package/src/swarm/__tests__/LeaderElection.prod.test.ts +196 -0
  252. package/src/swarm/__tests__/LeaderElection.test.ts +151 -0
  253. package/src/swarm/__tests__/PSOEngine.prod.test.ts +162 -0
  254. package/src/swarm/__tests__/PSOEngine.test.ts +106 -0
  255. package/src/swarm/__tests__/QuorumPolicy.prod.test.ts +216 -0
  256. package/src/swarm/__tests__/QuorumPolicy.test.ts +177 -0
  257. package/src/swarm/__tests__/SwarmCoordinator.prod.test.ts +186 -0
  258. package/src/swarm/__tests__/SwarmCoordinator.test.ts +167 -0
  259. package/src/swarm/__tests__/SwarmManager.prod.test.ts +308 -0
  260. package/src/swarm/__tests__/SwarmManager.test.ts +373 -0
  261. package/src/swarm/__tests__/SwarmMembership.prod.test.ts +273 -0
  262. package/src/swarm/__tests__/SwarmMembership.test.ts +264 -0
  263. package/src/swarm/__tests__/VotingRound.prod.test.ts +233 -0
  264. package/src/swarm/__tests__/VotingRound.test.ts +174 -0
  265. package/src/swarm/analytics/SwarmInspector.ts +476 -0
  266. package/src/swarm/analytics/SwarmMetrics.ts +449 -0
  267. package/src/swarm/analytics/__tests__/SwarmInspector.prod.test.ts +366 -0
  268. package/src/swarm/analytics/__tests__/SwarmInspector.test.ts +454 -0
  269. package/src/swarm/analytics/__tests__/SwarmMetrics.prod.test.ts +254 -0
  270. package/src/swarm/analytics/__tests__/SwarmMetrics.test.ts +370 -0
  271. package/src/swarm/analytics/index.ts +7 -0
  272. package/src/swarm/index.ts +69 -0
  273. package/src/swarm/messaging/BroadcastChannel.ts +509 -0
  274. package/src/swarm/messaging/GossipProtocol.ts +565 -0
  275. package/src/swarm/messaging/SwarmEventBus.ts +443 -0
  276. package/src/swarm/messaging/__tests__/BroadcastChannel.prod.test.ts +331 -0
  277. package/src/swarm/messaging/__tests__/BroadcastChannel.test.ts +333 -0
  278. package/src/swarm/messaging/__tests__/GossipProtocol.prod.test.ts +356 -0
  279. package/src/swarm/messaging/__tests__/GossipProtocol.test.ts +437 -0
  280. package/src/swarm/messaging/__tests__/SwarmEventBus.prod.test.ts +191 -0
  281. package/src/swarm/messaging/__tests__/SwarmEventBus.test.ts +247 -0
  282. package/src/swarm/messaging/index.ts +8 -0
  283. package/src/swarm/spatial/FlockingBehavior.ts +462 -0
  284. package/src/swarm/spatial/FormationController.ts +500 -0
  285. package/src/swarm/spatial/Vector3.ts +170 -0
  286. package/src/swarm/spatial/ZoneClaiming.ts +509 -0
  287. package/src/swarm/spatial/__tests__/FlockingBehavior.prod.test.ts +239 -0
  288. package/src/swarm/spatial/__tests__/FlockingBehavior.test.ts +298 -0
  289. package/src/swarm/spatial/__tests__/FormationController.prod.test.ts +240 -0
  290. package/src/swarm/spatial/__tests__/FormationController.test.ts +297 -0
  291. package/src/swarm/spatial/__tests__/Vector3.prod.test.ts +283 -0
  292. package/src/swarm/spatial/__tests__/Vector3.test.ts +224 -0
  293. package/src/swarm/spatial/__tests__/ZoneClaiming.prod.test.ts +246 -0
  294. package/src/swarm/spatial/__tests__/ZoneClaiming.test.ts +374 -0
  295. package/src/swarm/spatial/index.ts +28 -0
  296. package/src/team.ts +1245 -0
  297. package/src/training/LRScheduler.ts +377 -0
  298. package/src/training/QualityScoringPipeline.ts +139 -0
  299. package/src/training/SoftDedup.ts +461 -0
  300. package/src/training/SparsityMonitor.ts +685 -0
  301. package/src/training/SparsityMonitorTypes.ts +209 -0
  302. package/src/training/SpatialTrainingDataGenerator.ts +1526 -0
  303. package/src/training/SpatialTrainingDataTypes.ts +216 -0
  304. package/src/training/TrainingPipelineConfig.ts +215 -0
  305. package/src/training/constants.ts +94 -0
  306. package/src/training/index.ts +138 -0
  307. package/src/training/schema.ts +147 -0
  308. package/src/training/scripts/generate-novel-use-cases-dataset.ts +272 -0
  309. package/src/training/scripts/generate-spatial-dataset.ts +521 -0
  310. package/src/training/training/data/novel-use-cases.jsonl +153 -0
  311. package/src/training/training/data/spatial-reasoning-10k.jsonl +9354 -0
  312. package/src/training/trainingmonkey/TrainingMonkeyIntegration.ts +477 -0
  313. package/src/training/trainingmonkey/TrainingMonkeyTypes.ts +230 -0
  314. package/src/training/trainingmonkey/index.ts +26 -0
  315. package/src/training/trait-mappings.ts +157 -0
  316. package/src/types/core-stubs.d.ts +113 -0
  317. package/src/types.ts +304 -0
  318. package/test-output.txt +0 -0
  319. package/test-result.json +1 -0
  320. package/tsc-errors.txt +4 -0
  321. package/tsc_output.txt +0 -0
  322. package/tsconfig.json +14 -0
  323. package/tsup-learning-esm.config.ts +12 -0
  324. package/tsup.config.ts +21 -0
  325. package/typescript-errors-2.txt +0 -0
  326. package/typescript-errors.txt +22 -0
  327. package/vitest-log-utf8.txt +268 -0
  328. package/vitest-log.txt +0 -0
  329. package/vitest.config.ts +8 -0
@@ -0,0 +1,2433 @@
1
+ import { ISwarmCoordinator, ISwarmConfig, ISwarmResult, ILeaderElection, IHiveContribution, IHiveSession, ICollectiveIntelligenceService } from '@holoscript/core';
2
+
3
+ /**
4
+ * Swarm Coordinator
5
+ *
6
+ * Implements ISwarmCoordinator interface for agent-task optimization.
7
+ * Supports PSO, ACO, and hybrid algorithms.
8
+ */
9
+
10
+ interface AgentInfo {
11
+ id: string;
12
+ capacity: number;
13
+ load: number;
14
+ }
15
+ interface TaskInfo {
16
+ id: string;
17
+ complexity: number;
18
+ priority: number;
19
+ }
20
+ /**
21
+ * Main swarm coordinator for multi-agent task optimization
22
+ */
23
+ declare class SwarmCoordinator implements ISwarmCoordinator {
24
+ private psoEngine;
25
+ private acoEngine;
26
+ private defaultConfig;
27
+ constructor(config?: Partial<ISwarmConfig>);
28
+ /**
29
+ * Optimize agent-task assignment
30
+ *
31
+ * Uses PSO to find optimal task-to-agent mapping that:
32
+ * - Balances load across agents
33
+ * - Respects capacity constraints
34
+ * - Prioritizes high-priority tasks
35
+ * - Minimizes complexity/load mismatch
36
+ */
37
+ optimize(agents: AgentInfo[], tasks: TaskInfo[], config?: Partial<ISwarmConfig>): Promise<ISwarmResult>;
38
+ /**
39
+ * Get recommended population size based on problem complexity
40
+ */
41
+ getRecommendedPopulation(problemSize: number): number;
42
+ /**
43
+ * Create fitness function for task assignment
44
+ */
45
+ private createFitnessFunction;
46
+ /**
47
+ * Create distance matrix for ACO from agents/tasks
48
+ */
49
+ private createDistanceMatrix;
50
+ /**
51
+ * Refine PSO solution using ACO local search
52
+ */
53
+ private refineWithACO;
54
+ /**
55
+ * Format result with improvement percentage
56
+ */
57
+ private formatResult;
58
+ /**
59
+ * Calculate improvement over baseline
60
+ */
61
+ private calculateImprovement;
62
+ }
63
+
64
+ /**
65
+ * Particle Swarm Optimization Engine
66
+ *
67
+ * Implements PSO algorithm for agent-task assignment optimization.
68
+ * Each particle represents a potential solution (task-to-agent mapping).
69
+ */
70
+ interface PSOConfig {
71
+ populationSize: number;
72
+ maxIterations: number;
73
+ convergenceThreshold: number;
74
+ inertiaWeight: number;
75
+ cognitiveWeight: number;
76
+ socialWeight: number;
77
+ velocityClamp: number;
78
+ }
79
+ interface Particle {
80
+ position: number[];
81
+ velocity: number[];
82
+ personalBest: number[];
83
+ personalBestFitness: number;
84
+ }
85
+ interface PSOResult {
86
+ bestSolution: number[];
87
+ bestFitness: number;
88
+ converged: boolean;
89
+ iterations: number;
90
+ fitnessHistory: number[];
91
+ }
92
+ /**
93
+ * Particle Swarm Optimization engine for task assignment
94
+ */
95
+ declare class PSOEngine {
96
+ private config;
97
+ constructor(config?: Partial<PSOConfig>);
98
+ /**
99
+ * Optimize task assignment using PSO
100
+ *
101
+ * @param agentCount Number of available agents
102
+ * @param taskCount Number of tasks to assign
103
+ * @param fitnessFunction Function to evaluate solution quality (higher is better)
104
+ * @returns Optimization result with best assignment
105
+ */
106
+ optimize(agentCount: number, taskCount: number, fitnessFunction: (assignment: number[]) => number): Promise<PSOResult>;
107
+ /**
108
+ * Initialize the particle swarm with random positions
109
+ */
110
+ private initializeSwarm;
111
+ /**
112
+ * Update particle velocity based on PSO equations
113
+ */
114
+ private updateVelocity;
115
+ /**
116
+ * Update particle position
117
+ */
118
+ private updatePosition;
119
+ /**
120
+ * Convert continuous positions to discrete agent indices
121
+ */
122
+ private discretize;
123
+ /**
124
+ * Get recommended population size for problem
125
+ */
126
+ getRecommendedPopulation(problemSize: number): number;
127
+ }
128
+
129
+ /**
130
+ * Ant Colony Optimization Engine
131
+ *
132
+ * Implements ACO algorithm for path-finding and task sequencing.
133
+ * Uses pheromone trails to find optimal ordering of choreography steps.
134
+ */
135
+ interface ACOConfig {
136
+ antCount: number;
137
+ maxIterations: number;
138
+ convergenceThreshold: number;
139
+ alpha: number;
140
+ beta: number;
141
+ evaporationRate: number;
142
+ q: number;
143
+ elitistWeight: number;
144
+ }
145
+ interface ACOResult {
146
+ bestPath: number[];
147
+ bestCost: number;
148
+ converged: boolean;
149
+ iterations: number;
150
+ costHistory: number[];
151
+ }
152
+ /**
153
+ * Ant Colony Optimization engine for path/sequence optimization
154
+ */
155
+ declare class ACOEngine {
156
+ private config;
157
+ constructor(config?: Partial<ACOConfig>);
158
+ /**
159
+ * Find optimal path through nodes (e.g., task execution order)
160
+ *
161
+ * @param nodes Number of nodes to visit
162
+ * @param distanceMatrix Distance/cost between nodes [i][j]
163
+ * @returns Optimization result with best path
164
+ */
165
+ optimize(nodes: number, distanceMatrix: number[][]): Promise<ACOResult>;
166
+ /**
167
+ * Initialize pheromone matrix with uniform values
168
+ */
169
+ private initializePheromones;
170
+ /**
171
+ * Compute heuristic values (inverse distance)
172
+ */
173
+ private computeHeuristics;
174
+ /**
175
+ * Construct a solution path for one ant
176
+ */
177
+ private constructSolution;
178
+ /**
179
+ * Calculate total path cost
180
+ */
181
+ private calculatePathCost;
182
+ /**
183
+ * Evaporate pheromones
184
+ */
185
+ private evaporatePheromones;
186
+ /**
187
+ * Deposit pheromones based on solution quality
188
+ */
189
+ private depositPheromones;
190
+ /**
191
+ * Elitist reinforcement of best path
192
+ */
193
+ private reinforceBestPath;
194
+ /**
195
+ * Get recommended ant count for problem
196
+ */
197
+ getRecommendedAntCount(nodes: number): number;
198
+ }
199
+
200
+ /**
201
+ * Leader Election System
202
+ *
203
+ * Implements Raft-inspired leader election for agent clusters.
204
+ * Provides fault-tolerant leader selection with automatic failover.
205
+ */
206
+
207
+ interface LeaderElectionConfig {
208
+ electionTimeoutMin: number;
209
+ electionTimeoutMax: number;
210
+ heartbeatInterval: number;
211
+ quorumSize?: number;
212
+ }
213
+ type ElectionRole = 'leader' | 'follower' | 'candidate';
214
+ interface ElectionState {
215
+ term: number;
216
+ votedFor: string | null;
217
+ role: ElectionRole;
218
+ leaderId: string | null;
219
+ votes: Set<string>;
220
+ }
221
+ /**
222
+ * Raft-inspired leader election for agent clusters
223
+ */
224
+ declare class LeaderElection implements ILeaderElection {
225
+ private nodeId;
226
+ private clusterMembers;
227
+ private config;
228
+ private state;
229
+ private electionTimer;
230
+ private heartbeatTimer;
231
+ private callbacks;
232
+ private messageHandler;
233
+ constructor(nodeId: string, clusterMembers: string[], config?: Partial<LeaderElectionConfig>);
234
+ /**
235
+ * Start participating in leader election
236
+ */
237
+ startElection(): Promise<string>;
238
+ /**
239
+ * Get current leader
240
+ */
241
+ getLeader(): string | null;
242
+ /**
243
+ * Get this node's current role
244
+ */
245
+ getRole(): ElectionRole;
246
+ /**
247
+ * Subscribe to leader changes
248
+ */
249
+ onLeaderChange(callback: (leaderId: string | null) => void): () => void;
250
+ /**
251
+ * Handle incoming election message
252
+ */
253
+ handleMessage(from: string, message: ElectionMessage): void;
254
+ /**
255
+ * Set message handler for sending messages to other nodes
256
+ */
257
+ setMessageHandler(handler: (from: string, message: ElectionMessage) => void): void;
258
+ /**
259
+ * Simulate receiving vote from another node (for testing/local clusters)
260
+ */
261
+ receiveVote(voterId: string): void;
262
+ /**
263
+ * Stop participating in election
264
+ */
265
+ stop(): void;
266
+ /**
267
+ * Transition to candidate role and start election
268
+ */
269
+ private becomeCandidate;
270
+ /**
271
+ * Transition to leader role
272
+ */
273
+ private becomeLeader;
274
+ /**
275
+ * Transition to follower role
276
+ */
277
+ private becomeFollower;
278
+ /**
279
+ * Request votes from all cluster members
280
+ */
281
+ private requestVotes;
282
+ /**
283
+ * Check if we've won the election
284
+ */
285
+ private checkElectionWin;
286
+ /**
287
+ * Send heartbeats to all followers
288
+ */
289
+ private sendHeartbeats;
290
+ /**
291
+ * Handle vote request from candidate
292
+ */
293
+ private handleVoteRequest;
294
+ /**
295
+ * Handle vote response
296
+ */
297
+ private handleVoteResponse;
298
+ /**
299
+ * Handle heartbeat from leader
300
+ */
301
+ private handleHeartbeat;
302
+ /**
303
+ * Reset election timeout
304
+ */
305
+ private resetElectionTimer;
306
+ /**
307
+ * Get random election timeout in configured range
308
+ */
309
+ private getRandomElectionTimeout;
310
+ /**
311
+ * Calculate quorum size (majority)
312
+ */
313
+ private getQuorumSize;
314
+ /**
315
+ * Notify all callbacks of leader change
316
+ */
317
+ private notifyLeaderChange;
318
+ }
319
+ type ElectionMessage = VoteRequestMessage | VoteResponseMessage | HeartbeatMessage;
320
+ interface VoteRequestMessage {
321
+ type: 'request-vote';
322
+ term: number;
323
+ candidateId: string;
324
+ }
325
+ interface VoteResponseMessage {
326
+ type: 'vote-response';
327
+ term: number;
328
+ voteGranted: boolean;
329
+ }
330
+ interface HeartbeatMessage {
331
+ type: 'heartbeat';
332
+ term: number;
333
+ leaderId: string;
334
+ }
335
+
336
+ /**
337
+ * Voting Round
338
+ *
339
+ * Manages voting on contributions in collective intelligence sessions.
340
+ */
341
+
342
+ interface Vote {
343
+ contributionId: string;
344
+ voterId: string;
345
+ vote: 'support' | 'oppose';
346
+ weight: number;
347
+ timestamp: number;
348
+ }
349
+ interface VotingResult {
350
+ contributionId: string;
351
+ supportVotes: number;
352
+ opposeVotes: number;
353
+ netScore: number;
354
+ weightedScore: number;
355
+ voterIds: string[];
356
+ }
357
+ interface VotingRoundConfig {
358
+ minVotesRequired: number;
359
+ superMajorityThreshold: number;
360
+ allowAbstain: boolean;
361
+ weightByConfidence: boolean;
362
+ }
363
+ /**
364
+ * Manages voting on a set of contributions
365
+ */
366
+ declare class VotingRound {
367
+ private config;
368
+ private votes;
369
+ private contributions;
370
+ private closed;
371
+ constructor(config?: Partial<VotingRoundConfig>);
372
+ /**
373
+ * Register a contribution for voting
374
+ */
375
+ registerContribution(contribution: IHiveContribution): void;
376
+ /**
377
+ * Cast a vote on a contribution
378
+ */
379
+ castVote(contributionId: string, voterId: string, vote: 'support' | 'oppose', voterConfidence?: number): void;
380
+ /**
381
+ * Get current results for a contribution
382
+ */
383
+ getResult(contributionId: string): VotingResult | undefined;
384
+ /**
385
+ * Get all results, ranked by score
386
+ */
387
+ getAllResults(): VotingResult[];
388
+ /**
389
+ * Check if a contribution has reached super-majority
390
+ */
391
+ hasSuperMajority(contributionId: string): boolean;
392
+ /**
393
+ * Get contributions that have reached super-majority
394
+ */
395
+ getApprovedContributions(): IHiveContribution[];
396
+ /**
397
+ * Get the top-ranked contribution
398
+ */
399
+ getWinner(): IHiveContribution | undefined;
400
+ /**
401
+ * Close the voting round
402
+ */
403
+ close(): void;
404
+ /**
405
+ * Check if voting is closed
406
+ */
407
+ isClosed(): boolean;
408
+ /**
409
+ * Get voting statistics
410
+ */
411
+ getStatistics(): {
412
+ totalContributions: number;
413
+ totalVotes: number;
414
+ participationRate: number;
415
+ hasConsensus: boolean;
416
+ };
417
+ }
418
+
419
+ /**
420
+ * Contribution Synthesizer
421
+ *
422
+ * Synthesizes multiple contributions into unified insights.
423
+ */
424
+
425
+ interface SynthesisResult {
426
+ synthesizedContent: string;
427
+ sourceContributions: string[];
428
+ synthesisMethod: 'merge' | 'consensus' | 'weighted' | 'hierarchical';
429
+ confidence: number;
430
+ metadata: {
431
+ totalContributions: number;
432
+ ideaCount: number;
433
+ critiqueCount: number;
434
+ consensusCount: number;
435
+ solutionCount: number;
436
+ averageConfidence: number;
437
+ keyThemes: string[];
438
+ };
439
+ }
440
+ interface SynthesizerConfig {
441
+ minConfidenceThreshold: number;
442
+ preferSolutions: boolean;
443
+ includeCritiques: boolean;
444
+ maxSourcesPerSynthesis: number;
445
+ }
446
+ /**
447
+ * Synthesizes contributions from a collective intelligence session
448
+ */
449
+ declare class ContributionSynthesizer {
450
+ private config;
451
+ constructor(config?: Partial<SynthesizerConfig>);
452
+ /**
453
+ * Synthesize all contributions in a session
454
+ */
455
+ synthesize(session: IHiveSession): SynthesisResult;
456
+ /**
457
+ * Synthesize a subset of contributions
458
+ */
459
+ synthesizeSubset(contributions: IHiveContribution[]): SynthesisResult;
460
+ /**
461
+ * Merge two contributions into one
462
+ */
463
+ merge(a: IHiveContribution, b: IHiveContribution): IHiveContribution;
464
+ /**
465
+ * Find similar contributions
466
+ */
467
+ findSimilar(target: IHiveContribution, candidates: IHiveContribution[], threshold?: number): IHiveContribution[];
468
+ private createEmptyResult;
469
+ private groupByType;
470
+ private determineSynthesisMethod;
471
+ private performSynthesis;
472
+ private synthesizeHierarchical;
473
+ private synthesizeConsensus;
474
+ private synthesizeWeighted;
475
+ private synthesizeMerge;
476
+ private extractKeyThemes;
477
+ private calculateAverageConfidence;
478
+ private calculateSimilarity;
479
+ }
480
+
481
+ /**
482
+ * Collective Intelligence Service
483
+ *
484
+ * Implements ICollectiveIntelligenceService for collaborative
485
+ * problem-solving through hive sessions.
486
+ */
487
+
488
+ interface CollectiveIntelligenceConfig {
489
+ maxParticipants: number;
490
+ votingThreshold: number;
491
+ synthesisMinContributions: number;
492
+ autoCloseOnResolution: boolean;
493
+ contributionTimeoutMs: number;
494
+ }
495
+ /**
496
+ * Collective Intelligence Service
497
+ *
498
+ * Enables groups of agents to collaborate on complex problems through
499
+ * structured sessions with contributions, voting, and synthesis.
500
+ */
501
+ declare class CollectiveIntelligence implements ICollectiveIntelligenceService {
502
+ private config;
503
+ private sessions;
504
+ private votingRounds;
505
+ private synthesizer;
506
+ private contributionIdCounter;
507
+ constructor(config?: Partial<CollectiveIntelligenceConfig>);
508
+ /**
509
+ * Create a new hive session
510
+ */
511
+ createSession(topic: string, goal: string, initiator: string): IHiveSession;
512
+ /**
513
+ * Join an existing session
514
+ */
515
+ join(sessionId: string, agentId: string): void;
516
+ /**
517
+ * Leave a session
518
+ */
519
+ leave(sessionId: string, agentId: string): void;
520
+ /**
521
+ * Contribute to a session
522
+ */
523
+ contribute(sessionId: string, contribution: Omit<IHiveContribution, 'id' | 'timestamp'>): IHiveContribution;
524
+ /**
525
+ * Vote on a contribution
526
+ */
527
+ vote(sessionId: string, contributionId: string, voterId: string, vote: 'support' | 'oppose'): void;
528
+ /**
529
+ * Synthesize all contributions
530
+ */
531
+ synthesize(sessionId: string): SynthesisResult;
532
+ /**
533
+ * Resolve a session with a final decision
534
+ */
535
+ resolve(sessionId: string, resolution: string): void;
536
+ /**
537
+ * Get a session by ID
538
+ */
539
+ getSession(sessionId: string): IHiveSession | undefined;
540
+ /**
541
+ * Get all active sessions
542
+ */
543
+ getActiveSessions(): IHiveSession[];
544
+ /**
545
+ * Close a session without resolution
546
+ */
547
+ closeSession(sessionId: string): void;
548
+ /**
549
+ * Get voting results for a session
550
+ */
551
+ getVotingResults(sessionId: string): VotingResult[];
552
+ /**
553
+ * Get the top-voted contribution
554
+ */
555
+ getTopContribution(sessionId: string): IHiveContribution | undefined;
556
+ /**
557
+ * Get session statistics
558
+ */
559
+ getSessionStats(sessionId: string): {
560
+ participantCount: number;
561
+ contributionCount: number;
562
+ votingStats: ReturnType<VotingRound['getStatistics']>;
563
+ contributionsByType: Record<IHiveContribution['type'], number>;
564
+ averageConfidence: number;
565
+ } | undefined;
566
+ /**
567
+ * Auto-resolve if consensus reached
568
+ */
569
+ checkForConsensus(sessionId: string): boolean;
570
+ /**
571
+ * Get contributions by a specific agent
572
+ */
573
+ getAgentContributions(sessionId: string, agentId: string): IHiveContribution[];
574
+ /**
575
+ * Find similar contributions in a session
576
+ */
577
+ findSimilarContributions(sessionId: string, contributionId: string): IHiveContribution[];
578
+ private generateSessionId;
579
+ private generateContributionId;
580
+ }
581
+
582
+ /**
583
+ * Quorum Policy
584
+ *
585
+ * Enforces minimum size requirements for swarm operations.
586
+ */
587
+ interface QuorumConfig {
588
+ minimumSize: number;
589
+ optimalSize: number;
590
+ maximumSize: number;
591
+ requireQuorumForOperations: boolean;
592
+ quorumPercentage: number;
593
+ }
594
+ type QuorumStatus = 'below-minimum' | 'quorum' | 'optimal' | 'above-maximum';
595
+ interface QuorumState {
596
+ currentSize: number;
597
+ status: QuorumStatus;
598
+ hasQuorum: boolean;
599
+ canOperate: boolean;
600
+ requiredForQuorum: number;
601
+ spotsAvailable: number;
602
+ }
603
+ /**
604
+ * Manages quorum requirements for a swarm
605
+ */
606
+ declare class QuorumPolicy {
607
+ private config;
608
+ private currentSize;
609
+ constructor(config?: Partial<QuorumConfig>);
610
+ private validateConfig;
611
+ /**
612
+ * Update the current member count
613
+ */
614
+ setMemberCount(count: number): void;
615
+ /**
616
+ * Check if a new member can join
617
+ */
618
+ canJoin(): boolean;
619
+ /**
620
+ * Check if a member can leave without breaking quorum
621
+ */
622
+ canLeave(): boolean;
623
+ /**
624
+ * Check if the swarm has achieved quorum
625
+ */
626
+ hasQuorum(): boolean;
627
+ /**
628
+ * Check if the swarm can operate
629
+ */
630
+ canOperate(): boolean;
631
+ /**
632
+ * Get the current quorum status
633
+ */
634
+ getStatus(): QuorumStatus;
635
+ /**
636
+ * Get full quorum state
637
+ */
638
+ getState(): QuorumState;
639
+ /**
640
+ * Check if the swarm should seek more members
641
+ */
642
+ shouldRecruit(): boolean;
643
+ /**
644
+ * Check if the swarm should consider splitting
645
+ */
646
+ shouldSplit(): boolean;
647
+ /**
648
+ * Calculate the health score of the swarm (0-1)
649
+ */
650
+ getHealthScore(): number;
651
+ /**
652
+ * Get the config
653
+ */
654
+ getConfig(): QuorumConfig;
655
+ }
656
+
657
+ /**
658
+ * Swarm Membership
659
+ *
660
+ * Manages agent membership in swarms with join/leave protocol.
661
+ */
662
+
663
+ interface MemberInfo {
664
+ agentId: string;
665
+ joinedAt: number;
666
+ role: 'leader' | 'member' | 'observer';
667
+ status: 'active' | 'inactive' | 'leaving';
668
+ lastHeartbeat: number;
669
+ metadata?: Record<string, unknown>;
670
+ }
671
+ interface JoinRequest {
672
+ agentId: string;
673
+ requestedRole?: MemberInfo['role'];
674
+ metadata?: Record<string, unknown>;
675
+ }
676
+ interface LeaveRequest {
677
+ agentId: string;
678
+ reason?: string;
679
+ graceful: boolean;
680
+ }
681
+ interface MembershipEvent {
682
+ type: 'joined' | 'left' | 'role-changed' | 'status-changed' | 'quorum-lost' | 'quorum-gained';
683
+ agentId: string;
684
+ timestamp: number;
685
+ details?: Record<string, unknown>;
686
+ }
687
+ interface SwarmMembershipConfig {
688
+ quorum: Partial<QuorumConfig>;
689
+ heartbeatTimeoutMs: number;
690
+ allowObservers: boolean;
691
+ maxObservers: number;
692
+ requireApprovalToJoin: boolean;
693
+ }
694
+ type MembershipEventHandler = (event: MembershipEvent) => void;
695
+ /**
696
+ * Manages membership for a single swarm
697
+ */
698
+ declare class SwarmMembership {
699
+ private config;
700
+ private members;
701
+ private quorumPolicy;
702
+ private eventHandlers;
703
+ private pendingJoins;
704
+ private leaderId;
705
+ constructor(config?: Partial<SwarmMembershipConfig>);
706
+ /**
707
+ * Request to join the swarm
708
+ */
709
+ join(request: JoinRequest): boolean;
710
+ /**
711
+ * Approve a pending join request (leader only)
712
+ */
713
+ approveJoin(approverId: string, agentId: string): boolean;
714
+ /**
715
+ * Leave the swarm
716
+ */
717
+ leave(request: LeaveRequest): boolean;
718
+ /**
719
+ * Force remove a member (for leadership or timeouts)
720
+ */
721
+ removeForcefully(agentId: string, _reason: string): void;
722
+ /**
723
+ * Update heartbeat for a member
724
+ */
725
+ heartbeat(agentId: string): void;
726
+ /**
727
+ * Check for timed-out members
728
+ */
729
+ checkTimeouts(): string[];
730
+ /**
731
+ * Change a member's role
732
+ */
733
+ changeRole(agentId: string, newRole: MemberInfo['role']): boolean;
734
+ /**
735
+ * Get member by ID
736
+ */
737
+ getMember(agentId: string): MemberInfo | undefined;
738
+ /**
739
+ * Get all members
740
+ */
741
+ getMembers(): MemberInfo[];
742
+ /**
743
+ * Get active members (non-observers)
744
+ */
745
+ getActiveMembers(): MemberInfo[];
746
+ /**
747
+ * Get the current leader
748
+ */
749
+ getLeader(): MemberInfo | undefined;
750
+ /**
751
+ * Get quorum state
752
+ */
753
+ getQuorumState(): QuorumState;
754
+ /**
755
+ * Get member count
756
+ */
757
+ getMemberCount(): number;
758
+ /**
759
+ * Subscribe to membership events
760
+ */
761
+ onEvent(handler: MembershipEventHandler): () => void;
762
+ /**
763
+ * Get pending join requests
764
+ */
765
+ getPendingJoins(): JoinRequest[];
766
+ private addMember;
767
+ private addObserver;
768
+ private removeMember;
769
+ private electNewLeader;
770
+ private getActiveMemberCount;
771
+ private emit;
772
+ }
773
+
774
+ /**
775
+ * Swarm Manager
776
+ *
777
+ * Orchestrates swarm formation, disbandment, and lifecycle.
778
+ */
779
+
780
+ interface SwarmInfo {
781
+ id: string;
782
+ name: string;
783
+ objective: string;
784
+ createdAt: number;
785
+ createdBy: string;
786
+ status: 'forming' | 'active' | 'disbanding' | 'disbanded';
787
+ membership: SwarmMembership;
788
+ metadata?: Record<string, unknown>;
789
+ }
790
+ interface CreateSwarmRequest {
791
+ name: string;
792
+ objective: string;
793
+ createdBy: string;
794
+ membershipConfig?: Partial<SwarmMembershipConfig>;
795
+ metadata?: Record<string, unknown>;
796
+ }
797
+ interface DisbandOptions {
798
+ reason: string;
799
+ redistributeTasks: boolean;
800
+ notifyMembers: boolean;
801
+ }
802
+ interface SwarmManagerConfig {
803
+ maxSwarmsPerAgent: number;
804
+ defaultMembershipConfig: Partial<SwarmMembershipConfig>;
805
+ disbandEmptySwarms: boolean;
806
+ disbandTimeoutMs: number;
807
+ }
808
+ interface SwarmEvent {
809
+ type: 'swarm-created' | 'swarm-disbanded' | 'member-joined' | 'member-left' | 'status-changed';
810
+ swarmId: string;
811
+ agentId?: string;
812
+ timestamp: number;
813
+ details?: Record<string, unknown>;
814
+ }
815
+ type SwarmEventHandler = (event: SwarmEvent) => void;
816
+ /**
817
+ * Manages the lifecycle of multiple swarms
818
+ */
819
+ declare class SwarmManager {
820
+ private config;
821
+ private swarms;
822
+ private agentSwarms;
823
+ private eventHandlers;
824
+ private disbandTimeouts;
825
+ constructor(config?: Partial<SwarmManagerConfig>);
826
+ /**
827
+ * Create a new swarm
828
+ */
829
+ createSwarm(request: CreateSwarmRequest): SwarmInfo;
830
+ /**
831
+ * Join an existing swarm
832
+ */
833
+ joinSwarm(swarmId: string, agentId: string, asObserver?: boolean): boolean;
834
+ /**
835
+ * Leave a swarm
836
+ */
837
+ leaveSwarm(swarmId: string, agentId: string, graceful?: boolean): boolean;
838
+ /**
839
+ * Disband a swarm
840
+ */
841
+ disbandSwarm(swarmId: string, options: DisbandOptions): void;
842
+ /**
843
+ * Get a swarm by ID
844
+ */
845
+ getSwarm(swarmId: string): SwarmInfo | undefined;
846
+ /**
847
+ * Get all swarms
848
+ */
849
+ getAllSwarms(): SwarmInfo[];
850
+ /**
851
+ * Get active swarms
852
+ */
853
+ getActiveSwarms(): SwarmInfo[];
854
+ /**
855
+ * Get swarms an agent is member of
856
+ */
857
+ getAgentSwarms(agentId: string): SwarmInfo[];
858
+ /**
859
+ * Find swarms by objective (simple text match)
860
+ */
861
+ findSwarmsByObjective(query: string): SwarmInfo[];
862
+ /**
863
+ * Get swarm statistics
864
+ */
865
+ getSwarmStats(swarmId: string): {
866
+ memberCount: number;
867
+ quorumState: QuorumState;
868
+ ageMs: number;
869
+ healthScore: number;
870
+ } | undefined;
871
+ /**
872
+ * Subscribe to swarm events
873
+ */
874
+ onEvent(handler: SwarmEventHandler): () => void;
875
+ /**
876
+ * Perform maintenance (check heartbeats, timeouts)
877
+ */
878
+ performMaintenance(): string[];
879
+ private handleMembershipEvent;
880
+ private checkForEmptySwarm;
881
+ private calculateHealthScore;
882
+ private trackAgentSwarm;
883
+ private untrackAgentSwarm;
884
+ private emit;
885
+ private generateSwarmId;
886
+ }
887
+
888
+ /**
889
+ * Vector3 - 3D vector for spatial calculations
890
+ * HoloScript v3.2 - Autonomous Agent Swarms
891
+ */
892
+ /**
893
+ * 3D Vector class for spatial operations
894
+ */
895
+ declare class Vector3 {
896
+ x: number;
897
+ y: number;
898
+ z: number;
899
+ constructor(x?: number, y?: number, z?: number);
900
+ /**
901
+ * Create from array
902
+ */
903
+ static fromArray(arr: number[]): Vector3;
904
+ /**
905
+ * Create zero vector
906
+ */
907
+ static zero(): Vector3;
908
+ /**
909
+ * Create unit vector
910
+ */
911
+ static one(): Vector3;
912
+ /**
913
+ * Add another vector
914
+ */
915
+ add(v: Vector3): Vector3;
916
+ /**
917
+ * Subtract another vector
918
+ */
919
+ subtract(v: Vector3): Vector3;
920
+ /**
921
+ * Multiply by scalar
922
+ */
923
+ multiply(scalar: number): Vector3;
924
+ /**
925
+ * Divide by scalar
926
+ */
927
+ divide(scalar: number): Vector3;
928
+ /**
929
+ * Get magnitude (length)
930
+ */
931
+ magnitude(): number;
932
+ /**
933
+ * Get squared magnitude (faster for comparisons)
934
+ */
935
+ magnitudeSquared(): number;
936
+ /**
937
+ * Normalize to unit vector
938
+ */
939
+ normalize(): Vector3;
940
+ /**
941
+ * Dot product
942
+ */
943
+ dot(v: Vector3): number;
944
+ /**
945
+ * Cross product
946
+ */
947
+ cross(v: Vector3): Vector3;
948
+ /**
949
+ * Distance to another vector
950
+ */
951
+ distanceTo(v: Vector3): number;
952
+ /**
953
+ * Squared distance (faster for comparisons)
954
+ */
955
+ distanceToSquared(v: Vector3): number;
956
+ /**
957
+ * Linear interpolation
958
+ */
959
+ lerp(v: Vector3, t: number): Vector3;
960
+ /**
961
+ * Clamp magnitude
962
+ */
963
+ clampMagnitude(maxLength: number): Vector3;
964
+ /**
965
+ * Check equality within epsilon
966
+ */
967
+ equals(v: Vector3, epsilon?: number): boolean;
968
+ /**
969
+ * Clone vector
970
+ */
971
+ clone(): Vector3;
972
+ /**
973
+ * Convert to array
974
+ */
975
+ toArray(): [number, number, number];
976
+ /**
977
+ * String representation
978
+ */
979
+ toString(): string;
980
+ }
981
+
982
+ /**
983
+ * FlockingBehavior - Boid-based swarm movement
984
+ * HoloScript v3.2 - Autonomous Agent Swarms
985
+ *
986
+ * Implements Craig Reynolds' Boids algorithm:
987
+ * - Separation: Steer to avoid crowding neighbors
988
+ * - Alignment: Steer towards average heading of neighbors
989
+ * - Cohesion: Steer towards average position of neighbors
990
+ */
991
+
992
+ /**
993
+ * Boid agent state
994
+ */
995
+ interface IBoid {
996
+ id: string;
997
+ position: Vector3;
998
+ velocity: Vector3;
999
+ acceleration: Vector3;
1000
+ maxSpeed: number;
1001
+ maxForce: number;
1002
+ }
1003
+ /**
1004
+ * Flocking configuration
1005
+ */
1006
+ interface IFlockingConfig {
1007
+ /** Radius for separation behavior */
1008
+ separationRadius: number;
1009
+ /** Radius for alignment behavior */
1010
+ alignmentRadius: number;
1011
+ /** Radius for cohesion behavior */
1012
+ cohesionRadius: number;
1013
+ /** Weight for separation force */
1014
+ separationWeight: number;
1015
+ /** Weight for alignment force */
1016
+ alignmentWeight: number;
1017
+ /** Weight for cohesion force */
1018
+ cohesionWeight: number;
1019
+ /** Maximum speed */
1020
+ maxSpeed: number;
1021
+ /** Maximum steering force */
1022
+ maxForce: number;
1023
+ /** Boundary mode */
1024
+ boundaryMode: 'wrap' | 'bounce' | 'contain';
1025
+ /** World bounds (if boundaryMode is not 'none') */
1026
+ worldBounds?: {
1027
+ min: Vector3;
1028
+ max: Vector3;
1029
+ };
1030
+ }
1031
+ /**
1032
+ * FlockingBehavior - Manages Boid-based swarm movement
1033
+ */
1034
+ declare class FlockingBehavior {
1035
+ private boids;
1036
+ private config;
1037
+ constructor(config?: Partial<IFlockingConfig>);
1038
+ /**
1039
+ * Add a boid to the flock
1040
+ */
1041
+ addBoid(id: string, position: Vector3, velocity?: Vector3): IBoid;
1042
+ /**
1043
+ * Remove a boid from the flock
1044
+ */
1045
+ removeBoid(id: string): boolean;
1046
+ /**
1047
+ * Get a boid by ID
1048
+ */
1049
+ getBoid(id: string): IBoid | undefined;
1050
+ /**
1051
+ * Get all boids
1052
+ */
1053
+ getAllBoids(): IBoid[];
1054
+ /**
1055
+ * Update boid position manually
1056
+ */
1057
+ setBoidPosition(id: string, position: Vector3): void;
1058
+ /**
1059
+ * Update a single boid
1060
+ */
1061
+ updateBoid(boid: IBoid, neighbors: IBoid[]): void;
1062
+ /**
1063
+ * Update all boids in the flock
1064
+ */
1065
+ update(): void;
1066
+ /**
1067
+ * Separation: Steer away from nearby boids
1068
+ */
1069
+ separate(boid: IBoid, neighbors: IBoid[]): Vector3;
1070
+ /**
1071
+ * Alignment: Steer towards average heading of neighbors
1072
+ */
1073
+ align(boid: IBoid, neighbors: IBoid[]): Vector3;
1074
+ /**
1075
+ * Cohesion: Steer towards center of mass of neighbors
1076
+ */
1077
+ cohere(boid: IBoid, neighbors: IBoid[]): Vector3;
1078
+ /**
1079
+ * Seek: Steer towards a target location
1080
+ */
1081
+ seek(boid: IBoid, target: Vector3): Vector3;
1082
+ /**
1083
+ * Flee: Steer away from a target location
1084
+ */
1085
+ flee(boid: IBoid, target: Vector3): Vector3;
1086
+ /**
1087
+ * Arrive: Seek with slowing as approaching target
1088
+ */
1089
+ arrive(boid: IBoid, target: Vector3, slowingRadius: number): Vector3;
1090
+ /**
1091
+ * Find neighbors within radius
1092
+ */
1093
+ findNeighbors(boid: IBoid, radius: number): IBoid[];
1094
+ /**
1095
+ * Handle world boundaries
1096
+ */
1097
+ private handleBoundaries;
1098
+ /**
1099
+ * Wrap position to opposite side
1100
+ */
1101
+ private wrapPosition;
1102
+ /**
1103
+ * Bounce off boundaries
1104
+ */
1105
+ private bouncePosition;
1106
+ /**
1107
+ * Contain within boundaries (clamp)
1108
+ */
1109
+ private containPosition;
1110
+ /**
1111
+ * Apply external force to a boid
1112
+ */
1113
+ applyForce(id: string, force: Vector3): void;
1114
+ /**
1115
+ * Apply force to all boids
1116
+ */
1117
+ applyForceToAll(force: Vector3): void;
1118
+ /**
1119
+ * Get flock center of mass
1120
+ */
1121
+ getFlockCenter(): Vector3;
1122
+ /**
1123
+ * Get average velocity (direction) of flock
1124
+ */
1125
+ getFlockDirection(): Vector3;
1126
+ /**
1127
+ * Get flock spread (radius from center)
1128
+ */
1129
+ getFlockSpread(): number;
1130
+ /**
1131
+ * Update configuration
1132
+ */
1133
+ setConfig(config: Partial<IFlockingConfig>): void;
1134
+ /**
1135
+ * Get current configuration
1136
+ */
1137
+ getConfig(): IFlockingConfig;
1138
+ }
1139
+
1140
+ /**
1141
+ * FormationController - Geometric swarm formations
1142
+ * HoloScript v3.2 - Autonomous Agent Swarms
1143
+ *
1144
+ * Manages precise geometric arrangements of swarm agents
1145
+ */
1146
+
1147
+ /**
1148
+ * Formation patterns
1149
+ */
1150
+ type FormationType = 'line' | 'circle' | 'grid' | 'wedge' | 'diamond' | 'sphere' | 'custom';
1151
+ /**
1152
+ * Formation slot - assigned position for an agent
1153
+ */
1154
+ interface IFormationSlot {
1155
+ index: number;
1156
+ agentId: string | null;
1157
+ localPosition: Vector3;
1158
+ worldPosition: Vector3;
1159
+ isLeaderSlot: boolean;
1160
+ }
1161
+ /**
1162
+ * Formation configuration
1163
+ */
1164
+ interface IFormationConfig {
1165
+ type: FormationType;
1166
+ spacing: number;
1167
+ orientation: Vector3;
1168
+ scale: number;
1169
+ centerOffset: Vector3;
1170
+ rotationAngle: number;
1171
+ }
1172
+ /**
1173
+ * FormationController - Manages geometric swarm formations
1174
+ */
1175
+ declare class FormationController {
1176
+ private slots;
1177
+ private agentSlots;
1178
+ private center;
1179
+ private config;
1180
+ private slotCount;
1181
+ constructor(config?: Partial<IFormationConfig>);
1182
+ /**
1183
+ * Generate formation slots for given count
1184
+ */
1185
+ generateSlots(count: number): IFormationSlot[];
1186
+ /**
1187
+ * Line formation - agents in a row
1188
+ */
1189
+ private generateLineFormation;
1190
+ /**
1191
+ * Circle formation - agents in a ring
1192
+ */
1193
+ private generateCircleFormation;
1194
+ /**
1195
+ * Grid formation - agents in rows and columns
1196
+ */
1197
+ private generateGridFormation;
1198
+ /**
1199
+ * Wedge formation - V-shaped, leader at point
1200
+ */
1201
+ private generateWedgeFormation;
1202
+ /**
1203
+ * Diamond formation - diamond shape, leader at front point
1204
+ */
1205
+ private generateDiamondFormation;
1206
+ /**
1207
+ * Sphere formation - 3D spherical arrangement
1208
+ */
1209
+ private generateSphereFormation;
1210
+ /**
1211
+ * Set custom formation positions
1212
+ */
1213
+ setCustomFormation(positions: Vector3[]): void;
1214
+ /**
1215
+ * Assign an agent to a slot
1216
+ */
1217
+ assignAgent(agentId: string, slotIndex?: number): number;
1218
+ /**
1219
+ * Remove an agent from its slot
1220
+ */
1221
+ removeAgent(agentId: string): boolean;
1222
+ /**
1223
+ * Get agent's assigned slot
1224
+ */
1225
+ getAgentSlot(agentId: string): IFormationSlot | undefined;
1226
+ /**
1227
+ * Get target position for an agent
1228
+ */
1229
+ getAgentTarget(agentId: string): Vector3 | undefined;
1230
+ /**
1231
+ * Get all slots
1232
+ */
1233
+ getAllSlots(): IFormationSlot[];
1234
+ /**
1235
+ * Get available (unassigned) slots
1236
+ */
1237
+ getAvailableSlots(): IFormationSlot[];
1238
+ /**
1239
+ * Get assigned slots
1240
+ */
1241
+ getAssignedSlots(): IFormationSlot[];
1242
+ /**
1243
+ * Set formation center position
1244
+ */
1245
+ setCenter(position: Vector3): void;
1246
+ /**
1247
+ * Get formation center
1248
+ */
1249
+ getCenter(): Vector3;
1250
+ /**
1251
+ * Set rotation angle
1252
+ */
1253
+ setRotation(angle: number): void;
1254
+ /**
1255
+ * Update world positions based on center and rotation
1256
+ */
1257
+ private updateWorldPositions;
1258
+ /**
1259
+ * Convert local position to world position
1260
+ */
1261
+ private localToWorld;
1262
+ /**
1263
+ * Check if formation is complete (all slots filled)
1264
+ */
1265
+ isComplete(): boolean;
1266
+ /**
1267
+ * Get formation completeness ratio
1268
+ */
1269
+ getCompletenessRatio(): number;
1270
+ /**
1271
+ * Get formation tightness (average distance from target)
1272
+ */
1273
+ getFormationTightness(agentPositions: Map<string, Vector3>): number;
1274
+ /**
1275
+ * Reoptimize slot assignments (minimize total distance)
1276
+ */
1277
+ optimizeAssignments(agentPositions: Map<string, Vector3>): void;
1278
+ /**
1279
+ * Update configuration
1280
+ */
1281
+ setConfig(config: Partial<IFormationConfig>): void;
1282
+ /**
1283
+ * Get current configuration
1284
+ */
1285
+ getConfig(): IFormationConfig;
1286
+ }
1287
+
1288
+ /**
1289
+ * ZoneClaiming - Territory awareness for swarm agents
1290
+ * HoloScript v3.2 - Autonomous Agent Swarms
1291
+ *
1292
+ * Manages spatial zones that agents can claim, contest, and defend
1293
+ */
1294
+
1295
+ /**
1296
+ * Zone state
1297
+ */
1298
+ type ZoneState = 'unclaimed' | 'contested' | 'claimed' | 'defended';
1299
+ /**
1300
+ * Zone claim
1301
+ */
1302
+ interface IZoneClaim {
1303
+ agentId: string;
1304
+ swarmId?: string;
1305
+ claimedAt: number;
1306
+ strength: number;
1307
+ lastReinforced: number;
1308
+ }
1309
+ /**
1310
+ * Zone definition
1311
+ */
1312
+ interface IZone {
1313
+ id: string;
1314
+ center: Vector3;
1315
+ radius: number;
1316
+ state: ZoneState;
1317
+ claims: IZoneClaim[];
1318
+ owner: string | null;
1319
+ ownerSwarm: string | null;
1320
+ value: number;
1321
+ metadata: Record<string, unknown>;
1322
+ }
1323
+ /**
1324
+ * Zone event
1325
+ */
1326
+ interface IZoneEvent {
1327
+ type: 'claimed' | 'contested' | 'captured' | 'defended' | 'abandoned';
1328
+ zoneId: string;
1329
+ agentId?: string;
1330
+ swarmId?: string;
1331
+ previousOwner?: string;
1332
+ timestamp: number;
1333
+ details?: Record<string, unknown>;
1334
+ }
1335
+ /**
1336
+ * Zone claiming configuration
1337
+ */
1338
+ interface IZoneClaimingConfig {
1339
+ /** Minimum strength to claim a zone */
1340
+ claimThreshold: number;
1341
+ /** Strength required to capture contested zone */
1342
+ captureThreshold: number;
1343
+ /** Decay rate per second for claim strength */
1344
+ strengthDecayRate: number;
1345
+ /** Reinforcement rate per second when in zone */
1346
+ reinforceRate: number;
1347
+ /** Bonus for having swarm members in zone */
1348
+ swarmBonus: number;
1349
+ /** Defense bonus for owner */
1350
+ defenseBonus: number;
1351
+ }
1352
+ type EventHandler$1 = (event: IZoneEvent) => void;
1353
+ /**
1354
+ * ZoneClaiming - Manages territory control mechanics
1355
+ */
1356
+ declare class ZoneClaiming {
1357
+ private zones;
1358
+ private agentZones;
1359
+ private config;
1360
+ private eventHandlers;
1361
+ constructor(config?: Partial<IZoneClaimingConfig>);
1362
+ /**
1363
+ * Create a new zone
1364
+ */
1365
+ createZone(id: string, center: Vector3, radius: number, options?: {
1366
+ value?: number;
1367
+ metadata?: Record<string, unknown>;
1368
+ }): IZone;
1369
+ /**
1370
+ * Remove a zone
1371
+ */
1372
+ removeZone(zoneId: string): boolean;
1373
+ /**
1374
+ * Get a zone by ID
1375
+ */
1376
+ getZone(zoneId: string): IZone | undefined;
1377
+ /**
1378
+ * Get all zones
1379
+ */
1380
+ getAllZones(): IZone[];
1381
+ /**
1382
+ * Find zones containing a position
1383
+ */
1384
+ findZonesAt(position: Vector3): IZone[];
1385
+ /**
1386
+ * Check if an agent is in a zone
1387
+ */
1388
+ isAgentInZone(agentId: string, zoneId: string, agentPosition: Vector3): boolean;
1389
+ /**
1390
+ * Add or reinforce an agent's claim to a zone
1391
+ */
1392
+ claimZone(agentId: string, zoneId: string, options?: {
1393
+ swarmId?: string;
1394
+ strength?: number;
1395
+ }): IZoneClaim | null;
1396
+ /**
1397
+ * Release an agent's claim to a zone
1398
+ */
1399
+ releaseClaim(agentId: string, zoneId: string): boolean;
1400
+ /**
1401
+ * Update zone state based on claims
1402
+ */
1403
+ private updateZoneState;
1404
+ /**
1405
+ * Apply decay to all claims
1406
+ */
1407
+ applyDecay(deltaTimeSeconds: number): void;
1408
+ /**
1409
+ * Get zones owned by an agent/swarm
1410
+ */
1411
+ getOwnedZones(ownerId: string): IZone[];
1412
+ /**
1413
+ * Get zones an agent has claims in
1414
+ */
1415
+ getAgentClaims(agentId: string): IZone[];
1416
+ /**
1417
+ * Get claim strength of an agent in a zone
1418
+ */
1419
+ getClaimStrength(agentId: string, zoneId: string): number;
1420
+ /**
1421
+ * Get total swarm strength in a zone
1422
+ */
1423
+ getSwarmStrength(swarmId: string, zoneId: string): number;
1424
+ /**
1425
+ * Get contested zones
1426
+ */
1427
+ getContestedZones(): IZone[];
1428
+ /**
1429
+ * Get unclaimed zones
1430
+ */
1431
+ getUnclaimedZones(): IZone[];
1432
+ /**
1433
+ * Get zones by state
1434
+ */
1435
+ getZonesByState(state: ZoneState): IZone[];
1436
+ /**
1437
+ * Calculate total value of owned zones
1438
+ */
1439
+ getTotalValue(ownerId: string): number;
1440
+ /**
1441
+ * Subscribe to zone events
1442
+ */
1443
+ onEvent(handler: EventHandler$1): () => void;
1444
+ /**
1445
+ * Emit an event
1446
+ */
1447
+ private emit;
1448
+ /**
1449
+ * Get zone statistics
1450
+ */
1451
+ getStatistics(): {
1452
+ total: number;
1453
+ unclaimed: number;
1454
+ contested: number;
1455
+ claimed: number;
1456
+ defended: number;
1457
+ totalValue: number;
1458
+ claimedValue: number;
1459
+ };
1460
+ /**
1461
+ * Update configuration
1462
+ */
1463
+ setConfig(config: Partial<IZoneClaimingConfig>): void;
1464
+ /**
1465
+ * Get current configuration
1466
+ */
1467
+ getConfig(): IZoneClaimingConfig;
1468
+ }
1469
+
1470
+ /**
1471
+ * SwarmEventBus - Central event coordination for swarm communication
1472
+ * HoloScript v3.2 - Autonomous Agent Swarms
1473
+ *
1474
+ * Decoupled pub/sub messaging between swarm components
1475
+ */
1476
+ /**
1477
+ * Event priority levels
1478
+ */
1479
+ type EventPriority = 'low' | 'normal' | 'high' | 'critical';
1480
+ /**
1481
+ * Swarm event interface
1482
+ */
1483
+ interface ISwarmEvent {
1484
+ id: string;
1485
+ type: string;
1486
+ source: string;
1487
+ target?: string | string[];
1488
+ payload: unknown;
1489
+ timestamp: number;
1490
+ priority: EventPriority;
1491
+ ttl?: number;
1492
+ metadata?: Record<string, unknown>;
1493
+ }
1494
+ /**
1495
+ * Event subscription
1496
+ */
1497
+ interface IEventSubscription {
1498
+ id: string;
1499
+ pattern: string | RegExp;
1500
+ handler: EventHandler;
1501
+ priority: EventPriority;
1502
+ once: boolean;
1503
+ }
1504
+ /**
1505
+ * Event handler function type
1506
+ */
1507
+ type EventHandler = (event: ISwarmEvent) => void | Promise<void>;
1508
+ /**
1509
+ * Event bus configuration
1510
+ */
1511
+ interface IEventBusConfig {
1512
+ /** Maximum events in queue */
1513
+ maxQueueSize: number;
1514
+ /** Default TTL for events */
1515
+ defaultTTL: number;
1516
+ /** Enable async event processing */
1517
+ asyncProcessing: boolean;
1518
+ /** Max concurrent async handlers */
1519
+ maxConcurrent: number;
1520
+ /** Dead letter queue enabled */
1521
+ enableDeadLetter: boolean;
1522
+ }
1523
+ /**
1524
+ * Event bus statistics
1525
+ */
1526
+ interface IEventBusStats {
1527
+ eventsPublished: number;
1528
+ eventsDelivered: number;
1529
+ eventsDropped: number;
1530
+ subscriptions: number;
1531
+ pendingEvents: number;
1532
+ deadLetterCount: number;
1533
+ }
1534
+ /**
1535
+ * SwarmEventBus - Central pub/sub event bus for swarm communication
1536
+ */
1537
+ declare class SwarmEventBus {
1538
+ private subscriptions;
1539
+ private eventQueue;
1540
+ private deadLetterQueue;
1541
+ private processing;
1542
+ private config;
1543
+ private stats;
1544
+ private nextId;
1545
+ constructor(config?: Partial<IEventBusConfig>);
1546
+ /**
1547
+ * Publish an event to the bus
1548
+ */
1549
+ publish(type: string, source: string, payload: unknown, options?: {
1550
+ target?: string | string[];
1551
+ priority?: EventPriority;
1552
+ ttl?: number;
1553
+ metadata?: Record<string, unknown>;
1554
+ }): string;
1555
+ /**
1556
+ * Insert event maintaining priority order
1557
+ */
1558
+ private insertByPriority;
1559
+ /**
1560
+ * Subscribe to events matching a pattern
1561
+ */
1562
+ subscribe(pattern: string | RegExp, handler: EventHandler, options?: {
1563
+ priority?: EventPriority;
1564
+ once?: boolean;
1565
+ }): string;
1566
+ /**
1567
+ * Subscribe to an event type once
1568
+ */
1569
+ once(pattern: string | RegExp, handler: EventHandler): string;
1570
+ /**
1571
+ * Unsubscribe from events
1572
+ */
1573
+ unsubscribe(subscriptionId: string): boolean;
1574
+ /**
1575
+ * Clear all subscriptions
1576
+ */
1577
+ clearSubscriptions(): void;
1578
+ /**
1579
+ * Process the event queue (public for testing)
1580
+ */
1581
+ processQueue(): Promise<void>;
1582
+ /**
1583
+ * Deliver event to matching subscribers
1584
+ */
1585
+ private deliverEvent;
1586
+ /**
1587
+ * Check if event type matches pattern
1588
+ */
1589
+ private matchesPattern;
1590
+ /**
1591
+ * Emit synchronously (bypass queue)
1592
+ */
1593
+ emit(type: string, source: string, payload: unknown, options?: {
1594
+ target?: string | string[];
1595
+ priority?: EventPriority;
1596
+ metadata?: Record<string, unknown>;
1597
+ }): void;
1598
+ /**
1599
+ * Get pending events in queue
1600
+ */
1601
+ getPendingEvents(): ISwarmEvent[];
1602
+ /**
1603
+ * Get dead letter queue
1604
+ */
1605
+ getDeadLetterQueue(): ISwarmEvent[];
1606
+ /**
1607
+ * Clear dead letter queue
1608
+ */
1609
+ clearDeadLetterQueue(): ISwarmEvent[];
1610
+ /**
1611
+ * Replay dead letter events
1612
+ */
1613
+ replayDeadLetters(): number;
1614
+ /**
1615
+ * Get event bus statistics
1616
+ */
1617
+ getStats(): IEventBusStats;
1618
+ /**
1619
+ * Reset statistics
1620
+ */
1621
+ resetStats(): void;
1622
+ /**
1623
+ * Get configuration
1624
+ */
1625
+ getConfig(): IEventBusConfig;
1626
+ /**
1627
+ * Update configuration
1628
+ */
1629
+ setConfig(config: Partial<IEventBusConfig>): void;
1630
+ }
1631
+
1632
+ /**
1633
+ * BroadcastChannel - Named messaging channels for swarm groups
1634
+ * HoloScript v3.2 - Autonomous Agent Swarms
1635
+ *
1636
+ * Provides named channels for targeted group communication
1637
+ */
1638
+ /**
1639
+ * Channel message
1640
+ */
1641
+ interface IChannelMessage {
1642
+ id: string;
1643
+ channelId: string;
1644
+ senderId: string;
1645
+ content: unknown;
1646
+ timestamp: number;
1647
+ replyTo?: string;
1648
+ metadata?: Record<string, unknown>;
1649
+ }
1650
+ /**
1651
+ * Channel subscriber info
1652
+ */
1653
+ interface IChannelSubscriber {
1654
+ id: string;
1655
+ agentId: string;
1656
+ joinedAt: number;
1657
+ role: 'publisher' | 'subscriber' | 'both';
1658
+ lastActivity: number;
1659
+ }
1660
+ /**
1661
+ * Channel configuration
1662
+ */
1663
+ interface IChannelConfig {
1664
+ /** Maximum subscribers per channel */
1665
+ maxSubscribers: number;
1666
+ /** Message history size */
1667
+ historySize: number;
1668
+ /** Allow replays */
1669
+ allowReplay: boolean;
1670
+ /** Require acknowledgment */
1671
+ requireAck: boolean;
1672
+ /** Message TTL in milliseconds */
1673
+ messageTTL: number;
1674
+ }
1675
+ /**
1676
+ * Message handler type
1677
+ */
1678
+ type MessageHandler = (message: IChannelMessage) => void | Promise<void>;
1679
+ /**
1680
+ * BroadcastChannel - Named channel for group messaging
1681
+ */
1682
+ declare class BroadcastChannel {
1683
+ readonly id: string;
1684
+ readonly name: string;
1685
+ readonly createdAt: number;
1686
+ private subscribers;
1687
+ private handlers;
1688
+ private history;
1689
+ private config;
1690
+ private nextMsgId;
1691
+ private pendingAcks;
1692
+ constructor(id: string, name: string, config?: Partial<IChannelConfig>);
1693
+ /**
1694
+ * Subscribe an agent to the channel
1695
+ */
1696
+ subscribe(agentId: string, handler: MessageHandler, options?: {
1697
+ role?: 'publisher' | 'subscriber' | 'both';
1698
+ }): string;
1699
+ /**
1700
+ * Unsubscribe from the channel
1701
+ */
1702
+ unsubscribe(subscriberId: string): boolean;
1703
+ /**
1704
+ * Broadcast a message to all subscribers
1705
+ */
1706
+ broadcast(senderId: string, content: unknown, options?: {
1707
+ replyTo?: string;
1708
+ metadata?: Record<string, unknown>;
1709
+ }): Promise<string>;
1710
+ /**
1711
+ * Send a direct message to specific subscriber
1712
+ */
1713
+ sendDirect(senderId: string, targetAgentId: string, content: unknown, options?: {
1714
+ replyTo?: string;
1715
+ metadata?: Record<string, unknown>;
1716
+ }): Promise<string | null>;
1717
+ /**
1718
+ * Acknowledge a message
1719
+ */
1720
+ acknowledge(messageId: string, agentId: string): boolean;
1721
+ /**
1722
+ * Check if message is fully acknowledged
1723
+ */
1724
+ isFullyAcknowledged(messageId: string): boolean;
1725
+ /**
1726
+ * Get pending acknowledgments for a message
1727
+ */
1728
+ getPendingAcks(messageId: string): string[];
1729
+ /**
1730
+ * Add message to history
1731
+ */
1732
+ private addToHistory;
1733
+ /**
1734
+ * Get message history
1735
+ */
1736
+ getHistory(options?: {
1737
+ limit?: number;
1738
+ since?: number;
1739
+ senderId?: string;
1740
+ }): IChannelMessage[];
1741
+ /**
1742
+ * Replay history to a subscriber
1743
+ */
1744
+ replayHistory(subscriberId: string, options?: {
1745
+ since?: number;
1746
+ limit?: number;
1747
+ }): Promise<number>;
1748
+ /**
1749
+ * Get all subscribers
1750
+ */
1751
+ getSubscribers(): IChannelSubscriber[];
1752
+ /**
1753
+ * Get subscriber count
1754
+ */
1755
+ getSubscriberCount(): number;
1756
+ /**
1757
+ * Check if agent is subscribed
1758
+ */
1759
+ isSubscribed(agentId: string): boolean;
1760
+ /**
1761
+ * Get channel statistics
1762
+ */
1763
+ getStats(): {
1764
+ subscriberCount: number;
1765
+ historySize: number;
1766
+ pendingAckCount: number;
1767
+ oldestMessage: number | null;
1768
+ newestMessage: number | null;
1769
+ };
1770
+ /**
1771
+ * Get configuration
1772
+ */
1773
+ getConfig(): IChannelConfig;
1774
+ /**
1775
+ * Clear history
1776
+ */
1777
+ clearHistory(): void;
1778
+ }
1779
+ /**
1780
+ * ChannelManager - Manages multiple broadcast channels
1781
+ */
1782
+ declare class ChannelManager {
1783
+ private channels;
1784
+ private agentChannels;
1785
+ private nextId;
1786
+ /**
1787
+ * Create a new channel
1788
+ */
1789
+ createChannel(name: string, config?: Partial<IChannelConfig>): BroadcastChannel;
1790
+ /**
1791
+ * Get a channel by ID
1792
+ */
1793
+ getChannel(channelId: string): BroadcastChannel | undefined;
1794
+ /**
1795
+ * Get channel by name
1796
+ */
1797
+ getChannelByName(name: string): BroadcastChannel | undefined;
1798
+ /**
1799
+ * Delete a channel
1800
+ */
1801
+ deleteChannel(channelId: string): boolean;
1802
+ /**
1803
+ * Get all channels
1804
+ */
1805
+ getAllChannels(): BroadcastChannel[];
1806
+ /**
1807
+ * Subscribe agent to channel
1808
+ */
1809
+ subscribeAgent(agentId: string, channelId: string, handler: MessageHandler, options?: {
1810
+ role?: 'publisher' | 'subscriber' | 'both';
1811
+ }): string;
1812
+ /**
1813
+ * Get channels an agent is subscribed to
1814
+ */
1815
+ getAgentChannels(agentId: string): BroadcastChannel[];
1816
+ /**
1817
+ * Broadcast to multiple channels
1818
+ */
1819
+ multicast(channelIds: string[], senderId: string, content: unknown, options?: {
1820
+ metadata?: Record<string, unknown>;
1821
+ }): Promise<Map<string, string>>;
1822
+ /**
1823
+ * Get channel count
1824
+ */
1825
+ getChannelCount(): number;
1826
+ }
1827
+
1828
+ /**
1829
+ * GossipProtocol - Epidemic-style message propagation
1830
+ * HoloScript v3.2 - Autonomous Agent Swarms
1831
+ *
1832
+ * Implements gossip-based message spreading for decentralized swarms
1833
+ */
1834
+ /**
1835
+ * Gossip message wrapper
1836
+ */
1837
+ interface IGossipMessage {
1838
+ id: string;
1839
+ originId: string;
1840
+ content: unknown;
1841
+ type: 'data' | 'heartbeat' | 'membership' | 'custom';
1842
+ version: number;
1843
+ createdAt: number;
1844
+ ttl: number;
1845
+ hops: number;
1846
+ path: string[];
1847
+ signature?: string;
1848
+ }
1849
+ /**
1850
+ * Peer information
1851
+ */
1852
+ interface IGossipPeer {
1853
+ id: string;
1854
+ address: string;
1855
+ lastSeen: number;
1856
+ failureCount: number;
1857
+ isActive: boolean;
1858
+ metadata?: Record<string, unknown>;
1859
+ }
1860
+ /**
1861
+ * Gossip protocol configuration
1862
+ */
1863
+ interface IGossipConfig {
1864
+ /** Number of peers to gossip to per round */
1865
+ fanout: number;
1866
+ /** Gossip interval in milliseconds */
1867
+ gossipInterval: number;
1868
+ /** Maximum TTL for messages */
1869
+ maxTTL: number;
1870
+ /** Maximum hops per message */
1871
+ maxHops: number;
1872
+ /** Failure threshold before marking peer inactive */
1873
+ failureThreshold: number;
1874
+ /** Time before peer considered stale */
1875
+ peerTimeout: number;
1876
+ /** Whether to deduplicate messages */
1877
+ deduplicate: boolean;
1878
+ }
1879
+ /**
1880
+ * Message handler for gossip
1881
+ */
1882
+ type GossipHandler = (message: IGossipMessage, from: string) => void | Promise<void>;
1883
+ /**
1884
+ * Peer selector strategy
1885
+ */
1886
+ type PeerSelector = (peers: IGossipPeer[], count: number, exclude?: string[]) => IGossipPeer[];
1887
+ /**
1888
+ * GossipProtocol - Epidemic-style message propagation
1889
+ */
1890
+ declare class GossipProtocol {
1891
+ readonly nodeId: string;
1892
+ private peers;
1893
+ private seenMessages;
1894
+ private messageQueue;
1895
+ private handlers;
1896
+ private config;
1897
+ private running;
1898
+ private gossipTimer;
1899
+ private peerSelector;
1900
+ private nextMsgId;
1901
+ private stats;
1902
+ constructor(nodeId: string, config?: Partial<IGossipConfig>);
1903
+ /**
1904
+ * Start the gossip protocol
1905
+ */
1906
+ start(): void;
1907
+ /**
1908
+ * Stop the gossip protocol
1909
+ */
1910
+ stop(): void;
1911
+ /**
1912
+ * Check if protocol is running
1913
+ */
1914
+ isRunning(): boolean;
1915
+ /**
1916
+ * Add a peer
1917
+ */
1918
+ addPeer(id: string, address: string, metadata?: Record<string, unknown>): void;
1919
+ /**
1920
+ * Remove a peer
1921
+ */
1922
+ removePeer(id: string): boolean;
1923
+ /**
1924
+ * Get a peer
1925
+ */
1926
+ getPeer(id: string): IGossipPeer | undefined;
1927
+ /**
1928
+ * Get all active peers
1929
+ */
1930
+ getActivePeers(): IGossipPeer[];
1931
+ /**
1932
+ * Get all peers
1933
+ */
1934
+ getAllPeers(): IGossipPeer[];
1935
+ /**
1936
+ * Publish a message to the gossip network
1937
+ */
1938
+ publish(content: unknown, type?: IGossipMessage['type'], options?: {
1939
+ ttl?: number;
1940
+ signature?: string;
1941
+ }): string;
1942
+ /**
1943
+ * Receive a message from a peer
1944
+ */
1945
+ receive(message: IGossipMessage, fromPeerId: string): Promise<boolean>;
1946
+ /**
1947
+ * Subscribe to message types
1948
+ */
1949
+ subscribe(type: IGossipMessage['type'] | '*', handler: GossipHandler): () => void;
1950
+ /**
1951
+ * Set custom peer selector
1952
+ */
1953
+ setPeerSelector(selector: PeerSelector): void;
1954
+ /**
1955
+ * Perform a gossip round
1956
+ */
1957
+ gossipRound(): Promise<void>;
1958
+ /**
1959
+ * Send a message to a peer (override for actual network)
1960
+ */
1961
+ protected sendToPeer(_peer: IGossipPeer, _message: IGossipMessage): Promise<void>;
1962
+ /**
1963
+ * Emit message to handlers
1964
+ */
1965
+ private emitToHandlers;
1966
+ /**
1967
+ * Random peer selection
1968
+ */
1969
+ private randomPeerSelection;
1970
+ /**
1971
+ * Clean old seen messages
1972
+ */
1973
+ private cleanSeenMessages;
1974
+ /**
1975
+ * Clean stale peers
1976
+ */
1977
+ private cleanStalePeers;
1978
+ /**
1979
+ * Send a heartbeat
1980
+ */
1981
+ publishHeartbeat(metadata?: Record<string, unknown>): string;
1982
+ /**
1983
+ * Announce membership change
1984
+ */
1985
+ publishMembership(action: 'join' | 'leave', metadata?: Record<string, unknown>): string;
1986
+ /**
1987
+ * Get statistics
1988
+ */
1989
+ getStats(): typeof this.stats & {
1990
+ peerCount: number;
1991
+ activePeerCount: number;
1992
+ queueSize: number;
1993
+ seenCount: number;
1994
+ };
1995
+ /**
1996
+ * Reset statistics
1997
+ */
1998
+ resetStats(): void;
1999
+ /**
2000
+ * Get configuration
2001
+ */
2002
+ getConfig(): IGossipConfig;
2003
+ }
2004
+ /**
2005
+ * Anti-entropy sync for eventual consistency
2006
+ */
2007
+ declare class AntiEntropySync {
2008
+ private nodeId;
2009
+ private protocol;
2010
+ private dataStore;
2011
+ constructor(nodeId: string, protocol: GossipProtocol);
2012
+ /**
2013
+ * Set a value (stores locally and gossips)
2014
+ */
2015
+ set(key: string, value: unknown): void;
2016
+ /**
2017
+ * Get a value
2018
+ */
2019
+ get(key: string): unknown;
2020
+ /**
2021
+ * Get all keys
2022
+ */
2023
+ keys(): string[];
2024
+ /**
2025
+ * Handle sync from gossip
2026
+ */
2027
+ private handleSync;
2028
+ /**
2029
+ * Get data snapshot
2030
+ */
2031
+ getSnapshot(): Map<string, unknown>;
2032
+ }
2033
+
2034
+ /**
2035
+ * SwarmMetrics - Real-time swarm performance metrics
2036
+ * HoloScript v3.2 - Autonomous Agent Swarms
2037
+ *
2038
+ * Collects and aggregates metrics for swarm monitoring
2039
+ */
2040
+ /**
2041
+ * Metric value with timestamp
2042
+ */
2043
+ interface IMetricValue {
2044
+ value: number;
2045
+ timestamp: number;
2046
+ labels?: Record<string, string>;
2047
+ }
2048
+ /**
2049
+ * Metric types
2050
+ */
2051
+ type MetricType = 'counter' | 'gauge' | 'histogram' | 'summary';
2052
+ /**
2053
+ * Histogram buckets
2054
+ */
2055
+ interface IHistogramBuckets {
2056
+ boundaries: number[];
2057
+ counts: number[];
2058
+ sum: number;
2059
+ count: number;
2060
+ }
2061
+ /**
2062
+ * Summary percentiles
2063
+ */
2064
+ interface ISummaryPercentiles {
2065
+ p50: number;
2066
+ p75: number;
2067
+ p90: number;
2068
+ p95: number;
2069
+ p99: number;
2070
+ count: number;
2071
+ sum: number;
2072
+ }
2073
+ /**
2074
+ * Metric definition
2075
+ */
2076
+ interface IMetricDefinition {
2077
+ name: string;
2078
+ type: MetricType;
2079
+ description: string;
2080
+ unit?: string;
2081
+ labels?: string[];
2082
+ }
2083
+ /**
2084
+ * Aggregated metric stats
2085
+ */
2086
+ interface IMetricStats {
2087
+ name: string;
2088
+ type: MetricType;
2089
+ currentValue: number;
2090
+ min: number;
2091
+ max: number;
2092
+ avg: number;
2093
+ count: number;
2094
+ lastUpdate: number;
2095
+ }
2096
+ /**
2097
+ * SwarmMetrics - Metrics collector for swarm monitoring
2098
+ */
2099
+ declare class SwarmMetrics {
2100
+ private metrics;
2101
+ private counters;
2102
+ private gauges;
2103
+ private histograms;
2104
+ private summaries;
2105
+ private retentionPeriod;
2106
+ private maxSamples;
2107
+ constructor(config?: {
2108
+ retentionPeriod?: number;
2109
+ maxSamples?: number;
2110
+ });
2111
+ /**
2112
+ * Register a new metric
2113
+ */
2114
+ register(definition: IMetricDefinition): void;
2115
+ /**
2116
+ * Increment a counter
2117
+ */
2118
+ increment(name: string, value?: number, _labels?: Record<string, string>): void;
2119
+ /**
2120
+ * Set gauge value
2121
+ */
2122
+ setGauge(name: string, value: number, labels?: Record<string, string>): void;
2123
+ /**
2124
+ * Observe a value for histogram
2125
+ */
2126
+ observeHistogram(name: string, value: number): void;
2127
+ /**
2128
+ * Set histogram boundaries
2129
+ */
2130
+ setHistogramBoundaries(name: string, boundaries: number[]): void;
2131
+ /**
2132
+ * Observe a value for summary
2133
+ */
2134
+ observeSummary(name: string, value: number): void;
2135
+ /**
2136
+ * Get counter value
2137
+ */
2138
+ getCounter(name: string): number;
2139
+ /**
2140
+ * Get current gauge value
2141
+ */
2142
+ getGauge(name: string): number | undefined;
2143
+ /**
2144
+ * Get gauge history
2145
+ */
2146
+ getGaugeHistory(name: string, since?: number): IMetricValue[];
2147
+ /**
2148
+ * Get histogram buckets
2149
+ */
2150
+ getHistogram(name: string): IHistogramBuckets | undefined;
2151
+ /**
2152
+ * Get summary percentiles
2153
+ */
2154
+ getSummary(name: string): ISummaryPercentiles | undefined;
2155
+ /**
2156
+ * Get metric statistics
2157
+ */
2158
+ getStats(name: string): IMetricStats | undefined;
2159
+ /**
2160
+ * Get all registered metrics
2161
+ */
2162
+ getRegistered(): IMetricDefinition[];
2163
+ /**
2164
+ * Reset a metric
2165
+ */
2166
+ reset(name: string): void;
2167
+ /**
2168
+ * Reset all metrics
2169
+ */
2170
+ resetAll(): void;
2171
+ /**
2172
+ * Get all stats as object
2173
+ */
2174
+ getAllStats(): Record<string, IMetricStats>;
2175
+ /**
2176
+ * Prune old gauge values
2177
+ */
2178
+ private pruneGauge;
2179
+ /**
2180
+ * Export metrics in Prometheus format
2181
+ */
2182
+ toPrometheus(): string;
2183
+ }
2184
+
2185
+ /**
2186
+ * SwarmInspector - Debugging and inspection tools for swarms
2187
+ * HoloScript v3.2 - Autonomous Agent Swarms
2188
+ *
2189
+ * Provides introspection, debugging, and visualization data for swarms
2190
+ */
2191
+ /**
2192
+ * Agent state snapshot
2193
+ */
2194
+ interface IAgentSnapshot {
2195
+ id: string;
2196
+ swarmId?: string;
2197
+ state: string;
2198
+ position?: {
2199
+ x: number;
2200
+ y: number;
2201
+ z: number;
2202
+ };
2203
+ velocity?: {
2204
+ x: number;
2205
+ y: number;
2206
+ z: number;
2207
+ };
2208
+ health: number;
2209
+ load: number;
2210
+ lastActive: number;
2211
+ properties: Record<string, unknown>;
2212
+ }
2213
+ /**
2214
+ * Swarm state snapshot
2215
+ */
2216
+ interface ISwarmSnapshot {
2217
+ id: string;
2218
+ name?: string;
2219
+ memberCount: number;
2220
+ leaderId?: string;
2221
+ state: string;
2222
+ formation?: string;
2223
+ centroid?: {
2224
+ x: number;
2225
+ y: number;
2226
+ z: number;
2227
+ };
2228
+ boundingBox?: {
2229
+ min: {
2230
+ x: number;
2231
+ y: number;
2232
+ z: number;
2233
+ };
2234
+ max: {
2235
+ x: number;
2236
+ y: number;
2237
+ z: number;
2238
+ };
2239
+ };
2240
+ createdAt: number;
2241
+ properties: Record<string, unknown>;
2242
+ }
2243
+ /**
2244
+ * Relationship between agents
2245
+ */
2246
+ interface IAgentRelation {
2247
+ sourceId: string;
2248
+ targetId: string;
2249
+ type: 'member' | 'leader' | 'neighbor' | 'communication' | 'custom';
2250
+ strength: number;
2251
+ metadata?: Record<string, unknown>;
2252
+ }
2253
+ /**
2254
+ * Debug event
2255
+ */
2256
+ interface IDebugEvent {
2257
+ id: string;
2258
+ timestamp: number;
2259
+ level: 'trace' | 'debug' | 'info' | 'warn' | 'error';
2260
+ source: string;
2261
+ message: string;
2262
+ data?: unknown;
2263
+ }
2264
+ /**
2265
+ * Health check result
2266
+ */
2267
+ interface IHealthCheck {
2268
+ name: string;
2269
+ status: 'healthy' | 'degraded' | 'unhealthy';
2270
+ message?: string;
2271
+ latency?: number;
2272
+ lastCheck: number;
2273
+ }
2274
+ /**
2275
+ * Inspection result
2276
+ */
2277
+ interface IInspectionResult {
2278
+ timestamp: number;
2279
+ swarms: ISwarmSnapshot[];
2280
+ agents: IAgentSnapshot[];
2281
+ relations: IAgentRelation[];
2282
+ health: IHealthCheck[];
2283
+ summary: {
2284
+ totalSwarms: number;
2285
+ totalAgents: number;
2286
+ healthyAgents: number;
2287
+ averageLoad: number;
2288
+ warnings: string[];
2289
+ };
2290
+ }
2291
+ /**
2292
+ * Event listener
2293
+ */
2294
+ type DebugEventListener = (event: IDebugEvent) => void;
2295
+ /**
2296
+ * SwarmInspector - Debugging and inspection tools
2297
+ */
2298
+ declare class SwarmInspector {
2299
+ private agentSnapshots;
2300
+ private swarmSnapshots;
2301
+ private relations;
2302
+ private healthChecks;
2303
+ private eventLog;
2304
+ private listeners;
2305
+ private maxEvents;
2306
+ private nextEventId;
2307
+ constructor(config?: {
2308
+ maxEvents?: number;
2309
+ });
2310
+ /**
2311
+ * Update agent snapshot
2312
+ */
2313
+ updateAgent(snapshot: IAgentSnapshot): void;
2314
+ /**
2315
+ * Remove agent snapshot
2316
+ */
2317
+ removeAgent(agentId: string): void;
2318
+ /**
2319
+ * Get agent snapshot
2320
+ */
2321
+ getAgent(agentId: string): IAgentSnapshot | undefined;
2322
+ /**
2323
+ * Get all agents
2324
+ */
2325
+ getAllAgents(): IAgentSnapshot[];
2326
+ /**
2327
+ * Get agents in swarm
2328
+ */
2329
+ getSwarmAgents(swarmId: string): IAgentSnapshot[];
2330
+ /**
2331
+ * Update swarm snapshot
2332
+ */
2333
+ updateSwarm(snapshot: ISwarmSnapshot): void;
2334
+ /**
2335
+ * Remove swarm snapshot
2336
+ */
2337
+ removeSwarm(swarmId: string): void;
2338
+ /**
2339
+ * Get swarm snapshot
2340
+ */
2341
+ getSwarm(swarmId: string): ISwarmSnapshot | undefined;
2342
+ /**
2343
+ * Get all swarms
2344
+ */
2345
+ getAllSwarms(): ISwarmSnapshot[];
2346
+ /**
2347
+ * Add relation between agents
2348
+ */
2349
+ addRelation(relation: IAgentRelation): void;
2350
+ /**
2351
+ * Remove relation
2352
+ */
2353
+ removeRelation(sourceId: string, targetId: string, type?: string): void;
2354
+ /**
2355
+ * Get relations for agent
2356
+ */
2357
+ getAgentRelations(agentId: string): IAgentRelation[];
2358
+ /**
2359
+ * Get all relations
2360
+ */
2361
+ getAllRelations(): IAgentRelation[];
2362
+ /**
2363
+ * Register health check result
2364
+ */
2365
+ registerHealthCheck(check: IHealthCheck): void;
2366
+ /**
2367
+ * Get health check
2368
+ */
2369
+ getHealthCheck(name: string): IHealthCheck | undefined;
2370
+ /**
2371
+ * Get all health checks
2372
+ */
2373
+ getAllHealthChecks(): IHealthCheck[];
2374
+ /**
2375
+ * Get overall health status
2376
+ */
2377
+ getOverallHealth(): 'healthy' | 'degraded' | 'unhealthy';
2378
+ /**
2379
+ * Log a debug event
2380
+ */
2381
+ log(level: IDebugEvent['level'], source: string, message: string, data?: unknown): void;
2382
+ /**
2383
+ * Log helpers
2384
+ */
2385
+ trace(source: string, message: string, data?: unknown): void;
2386
+ debug(source: string, message: string, data?: unknown): void;
2387
+ info(source: string, message: string, data?: unknown): void;
2388
+ warn(source: string, message: string, data?: unknown): void;
2389
+ error(source: string, message: string, data?: unknown): void;
2390
+ /**
2391
+ * Get event log
2392
+ */
2393
+ getEventLog(options?: {
2394
+ level?: IDebugEvent['level'];
2395
+ source?: string;
2396
+ since?: number;
2397
+ limit?: number;
2398
+ }): IDebugEvent[];
2399
+ /**
2400
+ * Add event listener
2401
+ */
2402
+ addEventListener(listener: DebugEventListener): () => void;
2403
+ /**
2404
+ * Clear event log
2405
+ */
2406
+ clearEventLog(): void;
2407
+ /**
2408
+ * Get full inspection result
2409
+ */
2410
+ inspect(): IInspectionResult;
2411
+ /**
2412
+ * Generate a visualization-ready graph
2413
+ */
2414
+ toGraph(): {
2415
+ nodes: Array<{
2416
+ id: string;
2417
+ type: 'agent' | 'swarm';
2418
+ data: unknown;
2419
+ }>;
2420
+ edges: Array<{
2421
+ source: string;
2422
+ target: string;
2423
+ type: string;
2424
+ weight: number;
2425
+ }>;
2426
+ };
2427
+ /**
2428
+ * Reset all state
2429
+ */
2430
+ reset(): void;
2431
+ }
2432
+
2433
+ export { type ACOConfig, ACOEngine, type ACOResult, type AgentInfo, AntiEntropySync, BroadcastChannel, ChannelManager, CollectiveIntelligence, type CollectiveIntelligenceConfig, ContributionSynthesizer, type CreateSwarmRequest, type DebugEventListener, type DisbandOptions, type ElectionMessage, type ElectionRole, type ElectionState, type EventHandler, type EventPriority, FlockingBehavior, FormationController, type FormationType, type GossipHandler, GossipProtocol, type HeartbeatMessage, type IAgentRelation, type IAgentSnapshot, type IBoid, type IChannelConfig, type IChannelMessage, type IChannelSubscriber, type IDebugEvent, type IEventBusConfig, type IEventBusStats, type IEventSubscription, type IFlockingConfig, type IFormationConfig, type IFormationSlot, type IGossipConfig, type IGossipMessage, type IGossipPeer, type IHealthCheck, type IHistogramBuckets, type IInspectionResult, type IMetricDefinition, type IMetricStats, type IMetricValue, type ISummaryPercentiles, type ISwarmEvent, type ISwarmSnapshot, type IZone, type IZoneClaim, type IZoneClaimingConfig, type IZoneEvent, type JoinRequest, LeaderElection, type LeaderElectionConfig, type LeaveRequest, type MemberInfo, type MembershipEvent, type MessageHandler, type MetricType, type PSOConfig, PSOEngine, type PSOResult, type Particle, type PeerSelector, type QuorumConfig, QuorumPolicy, type QuorumState, type QuorumStatus, SwarmCoordinator, type SwarmEvent, SwarmEventBus, type SwarmInfo, SwarmInspector, SwarmManager, type SwarmManagerConfig, SwarmMembership, type SwarmMembershipConfig, SwarmMetrics, type SynthesisResult, type SynthesizerConfig, type TaskInfo, Vector3, type Vote, type VoteRequestMessage, type VoteResponseMessage, type VotingResult, VotingRound, type VotingRoundConfig, ZoneClaiming, type ZoneState };