@framers/agentos 0.1.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 (601) hide show
  1. package/LICENSE +98 -0
  2. package/README.md +576 -0
  3. package/dist/api/AgentOS.d.ts +451 -0
  4. package/dist/api/AgentOS.d.ts.map +1 -0
  5. package/dist/api/AgentOS.js +1157 -0
  6. package/dist/api/AgentOS.js.map +1 -0
  7. package/dist/api/AgentOSOrchestrator.d.ts +157 -0
  8. package/dist/api/AgentOSOrchestrator.d.ts.map +1 -0
  9. package/dist/api/AgentOSOrchestrator.js +679 -0
  10. package/dist/api/AgentOSOrchestrator.js.map +1 -0
  11. package/dist/api/interfaces/IAgentOS.d.ts +138 -0
  12. package/dist/api/interfaces/IAgentOS.d.ts.map +1 -0
  13. package/dist/api/interfaces/IAgentOS.js +11 -0
  14. package/dist/api/interfaces/IAgentOS.js.map +1 -0
  15. package/dist/api/interfaces/IUnifiedAgent.d.ts +126 -0
  16. package/dist/api/interfaces/IUnifiedAgent.d.ts.map +1 -0
  17. package/dist/api/interfaces/IUnifiedAgent.js +3 -0
  18. package/dist/api/interfaces/IUnifiedAgent.js.map +1 -0
  19. package/dist/api/types/AgentOSInput.d.ts +114 -0
  20. package/dist/api/types/AgentOSInput.d.ts.map +1 -0
  21. package/dist/api/types/AgentOSInput.js +13 -0
  22. package/dist/api/types/AgentOSInput.js.map +1 -0
  23. package/dist/api/types/AgentOSResponse.d.ts +170 -0
  24. package/dist/api/types/AgentOSResponse.d.ts.map +1 -0
  25. package/dist/api/types/AgentOSResponse.js +25 -0
  26. package/dist/api/types/AgentOSResponse.js.map +1 -0
  27. package/dist/cognitive_substrate/GMI.d.ts +148 -0
  28. package/dist/cognitive_substrate/GMI.d.ts.map +1 -0
  29. package/dist/cognitive_substrate/GMI.js +1003 -0
  30. package/dist/cognitive_substrate/GMI.js.map +1 -0
  31. package/dist/cognitive_substrate/GMIManager.d.ts +98 -0
  32. package/dist/cognitive_substrate/GMIManager.d.ts.map +1 -0
  33. package/dist/cognitive_substrate/GMIManager.js +517 -0
  34. package/dist/cognitive_substrate/GMIManager.js.map +1 -0
  35. package/dist/cognitive_substrate/IGMI.d.ts +469 -0
  36. package/dist/cognitive_substrate/IGMI.d.ts.map +1 -0
  37. package/dist/cognitive_substrate/IGMI.js +111 -0
  38. package/dist/cognitive_substrate/IGMI.js.map +1 -0
  39. package/dist/cognitive_substrate/memory/IWorkingMemory.d.ts +139 -0
  40. package/dist/cognitive_substrate/memory/IWorkingMemory.d.ts.map +1 -0
  41. package/dist/cognitive_substrate/memory/IWorkingMemory.js +14 -0
  42. package/dist/cognitive_substrate/memory/IWorkingMemory.js.map +1 -0
  43. package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.d.ts +143 -0
  44. package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.d.ts.map +1 -0
  45. package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.js +186 -0
  46. package/dist/cognitive_substrate/memory/InMemoryWorkingMemory.js.map +1 -0
  47. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.d.ts +33 -0
  48. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.d.ts.map +1 -0
  49. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.js +138 -0
  50. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayManager.js.map +1 -0
  51. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.d.ts +32 -0
  52. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.d.ts.map +1 -0
  53. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.js +2 -0
  54. package/dist/cognitive_substrate/persona_overlays/PersonaOverlayTypes.js.map +1 -0
  55. package/dist/cognitive_substrate/personas/IPersonaDefinition.d.ts +336 -0
  56. package/dist/cognitive_substrate/personas/IPersonaDefinition.d.ts.map +1 -0
  57. package/dist/cognitive_substrate/personas/IPersonaDefinition.js +8 -0
  58. package/dist/cognitive_substrate/personas/IPersonaDefinition.js.map +1 -0
  59. package/dist/cognitive_substrate/personas/IPersonaLoader.d.ts +78 -0
  60. package/dist/cognitive_substrate/personas/IPersonaLoader.d.ts.map +1 -0
  61. package/dist/cognitive_substrate/personas/IPersonaLoader.js +9 -0
  62. package/dist/cognitive_substrate/personas/IPersonaLoader.js.map +1 -0
  63. package/dist/cognitive_substrate/personas/PersonaLoader.d.ts +60 -0
  64. package/dist/cognitive_substrate/personas/PersonaLoader.d.ts.map +1 -0
  65. package/dist/cognitive_substrate/personas/PersonaLoader.js +138 -0
  66. package/dist/cognitive_substrate/personas/PersonaLoader.js.map +1 -0
  67. package/dist/cognitive_substrate/personas/PersonaValidation.d.ts +139 -0
  68. package/dist/cognitive_substrate/personas/PersonaValidation.d.ts.map +1 -0
  69. package/dist/cognitive_substrate/personas/PersonaValidation.js +277 -0
  70. package/dist/cognitive_substrate/personas/PersonaValidation.js.map +1 -0
  71. package/dist/cognitive_substrate/personas/definitions/atlas_systems_architect.json +29 -0
  72. package/dist/cognitive_substrate/personas/definitions/default_assistant_persona.json +346 -0
  73. package/dist/cognitive_substrate/personas/definitions/default_free_assistant.json +13 -0
  74. package/dist/cognitive_substrate/personas/definitions/index.d.ts +14 -0
  75. package/dist/cognitive_substrate/personas/definitions/index.d.ts.map +1 -0
  76. package/dist/cognitive_substrate/personas/definitions/index.js +35 -0
  77. package/dist/cognitive_substrate/personas/definitions/index.js.map +1 -0
  78. package/dist/cognitive_substrate/personas/definitions/nerf_generalist.json +11 -0
  79. package/dist/cognitive_substrate/personas/definitions/v_researcher.json +11 -0
  80. package/dist/config/AgentOSConfig.d.ts +74 -0
  81. package/dist/config/AgentOSConfig.d.ts.map +1 -0
  82. package/dist/config/AgentOSConfig.js +399 -0
  83. package/dist/config/AgentOSConfig.js.map +1 -0
  84. package/dist/config/EmbeddingManagerConfiguration.d.ts +190 -0
  85. package/dist/config/EmbeddingManagerConfiguration.d.ts.map +1 -0
  86. package/dist/config/EmbeddingManagerConfiguration.js +16 -0
  87. package/dist/config/EmbeddingManagerConfiguration.js.map +1 -0
  88. package/dist/config/MemoryLifecycleManagerConfiguration.d.ts +165 -0
  89. package/dist/config/MemoryLifecycleManagerConfiguration.d.ts.map +1 -0
  90. package/dist/config/MemoryLifecycleManagerConfiguration.js +69 -0
  91. package/dist/config/MemoryLifecycleManagerConfiguration.js.map +1 -0
  92. package/dist/config/RetrievalAugmentorConfiguration.d.ts +98 -0
  93. package/dist/config/RetrievalAugmentorConfiguration.d.ts.map +1 -0
  94. package/dist/config/RetrievalAugmentorConfiguration.js +47 -0
  95. package/dist/config/RetrievalAugmentorConfiguration.js.map +1 -0
  96. package/dist/config/ToolOrchestratorConfig.d.ts +69 -0
  97. package/dist/config/ToolOrchestratorConfig.d.ts.map +1 -0
  98. package/dist/config/ToolOrchestratorConfig.js +11 -0
  99. package/dist/config/ToolOrchestratorConfig.js.map +1 -0
  100. package/dist/config/VectorStoreConfiguration.d.ts +223 -0
  101. package/dist/config/VectorStoreConfiguration.d.ts.map +1 -0
  102. package/dist/config/VectorStoreConfiguration.js +59 -0
  103. package/dist/config/VectorStoreConfiguration.js.map +1 -0
  104. package/dist/config/extension-secrets.json +38 -0
  105. package/dist/config/extensionSecrets.d.ts +13 -0
  106. package/dist/config/extensionSecrets.d.ts.map +1 -0
  107. package/dist/config/extensionSecrets.js +24 -0
  108. package/dist/config/extensionSecrets.js.map +1 -0
  109. package/dist/core/agency/AgencyMemoryManager.d.ts +300 -0
  110. package/dist/core/agency/AgencyMemoryManager.d.ts.map +1 -0
  111. package/dist/core/agency/AgencyMemoryManager.js +657 -0
  112. package/dist/core/agency/AgencyMemoryManager.js.map +1 -0
  113. package/dist/core/agency/AgencyRegistry.d.ts +100 -0
  114. package/dist/core/agency/AgencyRegistry.d.ts.map +1 -0
  115. package/dist/core/agency/AgencyRegistry.js +209 -0
  116. package/dist/core/agency/AgencyRegistry.js.map +1 -0
  117. package/dist/core/agency/AgencyTypes.d.ts +200 -0
  118. package/dist/core/agency/AgencyTypes.d.ts.map +1 -0
  119. package/dist/core/agency/AgencyTypes.js +7 -0
  120. package/dist/core/agency/AgencyTypes.js.map +1 -0
  121. package/dist/core/agency/AgentCommunicationBus.d.ts +150 -0
  122. package/dist/core/agency/AgentCommunicationBus.d.ts.map +1 -0
  123. package/dist/core/agency/AgentCommunicationBus.js +568 -0
  124. package/dist/core/agency/AgentCommunicationBus.js.map +1 -0
  125. package/dist/core/agency/IAgentCommunicationBus.d.ts +469 -0
  126. package/dist/core/agency/IAgentCommunicationBus.d.ts.map +1 -0
  127. package/dist/core/agency/IAgentCommunicationBus.js +40 -0
  128. package/dist/core/agency/IAgentCommunicationBus.js.map +1 -0
  129. package/dist/core/agency/index.d.ts +18 -0
  130. package/dist/core/agency/index.d.ts.map +1 -0
  131. package/dist/core/agency/index.js +18 -0
  132. package/dist/core/agency/index.js.map +1 -0
  133. package/dist/core/agents/AgentCore.d.ts +385 -0
  134. package/dist/core/agents/AgentCore.d.ts.map +1 -0
  135. package/dist/core/agents/AgentCore.js +527 -0
  136. package/dist/core/agents/AgentCore.js.map +1 -0
  137. package/dist/core/agents/AgentFactory.d.ts +123 -0
  138. package/dist/core/agents/AgentFactory.d.ts.map +1 -0
  139. package/dist/core/agents/AgentFactory.js +232 -0
  140. package/dist/core/agents/AgentFactory.js.map +1 -0
  141. package/dist/core/agents/AgentPoolAgent.d.ts +244 -0
  142. package/dist/core/agents/AgentPoolAgent.d.ts.map +1 -0
  143. package/dist/core/agents/AgentPoolAgent.js +697 -0
  144. package/dist/core/agents/AgentPoolAgent.js.map +1 -0
  145. package/dist/core/agents/AgentPoolConfig.d.ts +191 -0
  146. package/dist/core/agents/AgentPoolConfig.d.ts.map +1 -0
  147. package/dist/core/agents/AgentPoolConfig.js +58 -0
  148. package/dist/core/agents/AgentPoolConfig.js.map +1 -0
  149. package/dist/core/agents/IAgent.d.ts +226 -0
  150. package/dist/core/agents/IAgent.d.ts.map +1 -0
  151. package/dist/core/agents/IAgent.js +14 -0
  152. package/dist/core/agents/IAgent.js.map +1 -0
  153. package/dist/core/agents/IAgentFactory.d.ts +137 -0
  154. package/dist/core/agents/IAgentFactory.d.ts.map +1 -0
  155. package/dist/core/agents/IAgentFactory.js +13 -0
  156. package/dist/core/agents/IAgentFactory.js.map +1 -0
  157. package/dist/core/agents/tools/Tool.d.ts +17 -0
  158. package/dist/core/agents/tools/Tool.d.ts.map +1 -0
  159. package/dist/core/agents/tools/Tool.js +8 -0
  160. package/dist/core/agents/tools/Tool.js.map +1 -0
  161. package/dist/core/ai_utilities/HybridUtilityAI.d.ts +1 -0
  162. package/dist/core/ai_utilities/HybridUtilityAI.d.ts.map +1 -0
  163. package/dist/core/ai_utilities/HybridUtilityAI.js +2 -0
  164. package/dist/core/ai_utilities/HybridUtilityAI.js.map +1 -0
  165. package/dist/core/ai_utilities/IUtilityAI.d.ts +212 -0
  166. package/dist/core/ai_utilities/IUtilityAI.d.ts.map +1 -0
  167. package/dist/core/ai_utilities/IUtilityAI.js +11 -0
  168. package/dist/core/ai_utilities/IUtilityAI.js.map +1 -0
  169. package/dist/core/ai_utilities/LLMUtilityAI.d.ts +94 -0
  170. package/dist/core/ai_utilities/LLMUtilityAI.d.ts.map +1 -0
  171. package/dist/core/ai_utilities/LLMUtilityAI.js +434 -0
  172. package/dist/core/ai_utilities/LLMUtilityAI.js.map +1 -0
  173. package/dist/core/ai_utilities/StatisticalUtilityAI.d.ts +102 -0
  174. package/dist/core/ai_utilities/StatisticalUtilityAI.d.ts.map +1 -0
  175. package/dist/core/ai_utilities/StatisticalUtilityAI.js +617 -0
  176. package/dist/core/ai_utilities/StatisticalUtilityAI.js.map +1 -0
  177. package/dist/core/conversation/ConversationContext.d.ts +259 -0
  178. package/dist/core/conversation/ConversationContext.d.ts.map +1 -0
  179. package/dist/core/conversation/ConversationContext.js +450 -0
  180. package/dist/core/conversation/ConversationContext.js.map +1 -0
  181. package/dist/core/conversation/ConversationManager.d.ts +223 -0
  182. package/dist/core/conversation/ConversationManager.d.ts.map +1 -0
  183. package/dist/core/conversation/ConversationManager.js +558 -0
  184. package/dist/core/conversation/ConversationManager.js.map +1 -0
  185. package/dist/core/conversation/ConversationMessage.d.ts +184 -0
  186. package/dist/core/conversation/ConversationMessage.d.ts.map +1 -0
  187. package/dist/core/conversation/ConversationMessage.js +66 -0
  188. package/dist/core/conversation/ConversationMessage.js.map +1 -0
  189. package/dist/core/evaluation/Evaluator.d.ts +28 -0
  190. package/dist/core/evaluation/Evaluator.d.ts.map +1 -0
  191. package/dist/core/evaluation/Evaluator.js +490 -0
  192. package/dist/core/evaluation/Evaluator.js.map +1 -0
  193. package/dist/core/evaluation/IEvaluator.d.ts +309 -0
  194. package/dist/core/evaluation/IEvaluator.d.ts.map +1 -0
  195. package/dist/core/evaluation/IEvaluator.js +12 -0
  196. package/dist/core/evaluation/IEvaluator.js.map +1 -0
  197. package/dist/core/evaluation/LLMJudge.d.ts +105 -0
  198. package/dist/core/evaluation/LLMJudge.d.ts.map +1 -0
  199. package/dist/core/evaluation/LLMJudge.js +229 -0
  200. package/dist/core/evaluation/LLMJudge.js.map +1 -0
  201. package/dist/core/evaluation/index.d.ts +9 -0
  202. package/dist/core/evaluation/index.d.ts.map +1 -0
  203. package/dist/core/evaluation/index.js +9 -0
  204. package/dist/core/evaluation/index.js.map +1 -0
  205. package/dist/core/guardrails/IGuardrailService.d.ts +142 -0
  206. package/dist/core/guardrails/IGuardrailService.d.ts.map +1 -0
  207. package/dist/core/guardrails/IGuardrailService.js +24 -0
  208. package/dist/core/guardrails/IGuardrailService.js.map +1 -0
  209. package/dist/core/guardrails/guardrailDispatcher.d.ts +36 -0
  210. package/dist/core/guardrails/guardrailDispatcher.d.ts.map +1 -0
  211. package/dist/core/guardrails/guardrailDispatcher.js +240 -0
  212. package/dist/core/guardrails/guardrailDispatcher.js.map +1 -0
  213. package/dist/core/hitl/HumanInteractionManager.d.ts +146 -0
  214. package/dist/core/hitl/HumanInteractionManager.d.ts.map +1 -0
  215. package/dist/core/hitl/HumanInteractionManager.js +491 -0
  216. package/dist/core/hitl/HumanInteractionManager.js.map +1 -0
  217. package/dist/core/hitl/IHumanInteractionManager.d.ts +521 -0
  218. package/dist/core/hitl/IHumanInteractionManager.d.ts.map +1 -0
  219. package/dist/core/hitl/IHumanInteractionManager.js +33 -0
  220. package/dist/core/hitl/IHumanInteractionManager.js.map +1 -0
  221. package/dist/core/hitl/index.d.ts +17 -0
  222. package/dist/core/hitl/index.d.ts.map +1 -0
  223. package/dist/core/hitl/index.js +17 -0
  224. package/dist/core/hitl/index.js.map +1 -0
  225. package/dist/core/knowledge/IKnowledgeGraph.d.ts +351 -0
  226. package/dist/core/knowledge/IKnowledgeGraph.d.ts.map +1 -0
  227. package/dist/core/knowledge/IKnowledgeGraph.js +10 -0
  228. package/dist/core/knowledge/IKnowledgeGraph.js.map +1 -0
  229. package/dist/core/knowledge/KnowledgeGraph.d.ts +93 -0
  230. package/dist/core/knowledge/KnowledgeGraph.d.ts.map +1 -0
  231. package/dist/core/knowledge/KnowledgeGraph.js +601 -0
  232. package/dist/core/knowledge/KnowledgeGraph.js.map +1 -0
  233. package/dist/core/knowledge/index.d.ts +8 -0
  234. package/dist/core/knowledge/index.d.ts.map +1 -0
  235. package/dist/core/knowledge/index.js +8 -0
  236. package/dist/core/knowledge/index.js.map +1 -0
  237. package/dist/core/language/LanguageService.d.ts +77 -0
  238. package/dist/core/language/LanguageService.d.ts.map +1 -0
  239. package/dist/core/language/LanguageService.js +305 -0
  240. package/dist/core/language/LanguageService.js.map +1 -0
  241. package/dist/core/language/index.d.ts +6 -0
  242. package/dist/core/language/index.d.ts.map +1 -0
  243. package/dist/core/language/index.js +6 -0
  244. package/dist/core/language/index.js.map +1 -0
  245. package/dist/core/language/interfaces.d.ts +168 -0
  246. package/dist/core/language/interfaces.d.ts.map +1 -0
  247. package/dist/core/language/interfaces.js +37 -0
  248. package/dist/core/language/interfaces.js.map +1 -0
  249. package/dist/core/language/providers/DeepLTranslationProvider.d.ts +16 -0
  250. package/dist/core/language/providers/DeepLTranslationProvider.d.ts.map +1 -0
  251. package/dist/core/language/providers/DeepLTranslationProvider.js +28 -0
  252. package/dist/core/language/providers/DeepLTranslationProvider.js.map +1 -0
  253. package/dist/core/language/providers/OpenAITranslationProvider.d.ts +17 -0
  254. package/dist/core/language/providers/OpenAITranslationProvider.d.ts.map +1 -0
  255. package/dist/core/language/providers/OpenAITranslationProvider.js +34 -0
  256. package/dist/core/language/providers/OpenAITranslationProvider.js.map +1 -0
  257. package/dist/core/language/providers/WhisperDetectionProvider.d.ts +16 -0
  258. package/dist/core/language/providers/WhisperDetectionProvider.d.ts.map +1 -0
  259. package/dist/core/language/providers/WhisperDetectionProvider.js +15 -0
  260. package/dist/core/language/providers/WhisperDetectionProvider.js.map +1 -0
  261. package/dist/core/llm/IPromptEngine.d.ts +627 -0
  262. package/dist/core/llm/IPromptEngine.d.ts.map +1 -0
  263. package/dist/core/llm/IPromptEngine.js +81 -0
  264. package/dist/core/llm/IPromptEngine.js.map +1 -0
  265. package/dist/core/llm/PromptEngine.d.ts +108 -0
  266. package/dist/core/llm/PromptEngine.d.ts.map +1 -0
  267. package/dist/core/llm/PromptEngine.js +872 -0
  268. package/dist/core/llm/PromptEngine.js.map +1 -0
  269. package/dist/core/llm/providers/AIModelProviderManager.d.ts +74 -0
  270. package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -0
  271. package/dist/core/llm/providers/AIModelProviderManager.js +263 -0
  272. package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -0
  273. package/dist/core/llm/providers/IProvider.d.ts +327 -0
  274. package/dist/core/llm/providers/IProvider.d.ts.map +1 -0
  275. package/dist/core/llm/providers/IProvider.js +39 -0
  276. package/dist/core/llm/providers/IProvider.js.map +1 -0
  277. package/dist/core/llm/providers/errors/OllamaProviderError.d.ts +36 -0
  278. package/dist/core/llm/providers/errors/OllamaProviderError.d.ts.map +1 -0
  279. package/dist/core/llm/providers/errors/OllamaProviderError.js +40 -0
  280. package/dist/core/llm/providers/errors/OllamaProviderError.js.map +1 -0
  281. package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts +42 -0
  282. package/dist/core/llm/providers/errors/OpenAIProviderError.d.ts.map +1 -0
  283. package/dist/core/llm/providers/errors/OpenAIProviderError.js +44 -0
  284. package/dist/core/llm/providers/errors/OpenAIProviderError.js.map +1 -0
  285. package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts +39 -0
  286. package/dist/core/llm/providers/errors/OpenRouterProviderError.d.ts.map +1 -0
  287. package/dist/core/llm/providers/errors/OpenRouterProviderError.js +42 -0
  288. package/dist/core/llm/providers/errors/OpenRouterProviderError.js.map +1 -0
  289. package/dist/core/llm/providers/errors/ProviderError.d.ts +37 -0
  290. package/dist/core/llm/providers/errors/ProviderError.d.ts.map +1 -0
  291. package/dist/core/llm/providers/errors/ProviderError.js +36 -0
  292. package/dist/core/llm/providers/errors/ProviderError.js.map +1 -0
  293. package/dist/core/llm/providers/implementations/OllamaProvider.d.ts +80 -0
  294. package/dist/core/llm/providers/implementations/OllamaProvider.d.ts.map +1 -0
  295. package/dist/core/llm/providers/implementations/OllamaProvider.js +473 -0
  296. package/dist/core/llm/providers/implementations/OllamaProvider.js.map +1 -0
  297. package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +160 -0
  298. package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts.map +1 -0
  299. package/dist/core/llm/providers/implementations/OpenAIProvider.js +672 -0
  300. package/dist/core/llm/providers/implementations/OpenAIProvider.js.map +1 -0
  301. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts +51 -0
  302. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -0
  303. package/dist/core/llm/providers/implementations/OpenRouterProvider.js +499 -0
  304. package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -0
  305. package/dist/core/llm/routing/IModelRouter.d.ts +129 -0
  306. package/dist/core/llm/routing/IModelRouter.d.ts.map +1 -0
  307. package/dist/core/llm/routing/IModelRouter.js +14 -0
  308. package/dist/core/llm/routing/IModelRouter.js.map +1 -0
  309. package/dist/core/llm/routing/ModelRouter.d.ts +157 -0
  310. package/dist/core/llm/routing/ModelRouter.d.ts.map +1 -0
  311. package/dist/core/llm/routing/ModelRouter.js +190 -0
  312. package/dist/core/llm/routing/ModelRouter.js.map +1 -0
  313. package/dist/core/llm/streaming/StreamingBatcher.d.ts +54 -0
  314. package/dist/core/llm/streaming/StreamingBatcher.d.ts.map +1 -0
  315. package/dist/core/llm/streaming/StreamingBatcher.js +173 -0
  316. package/dist/core/llm/streaming/StreamingBatcher.js.map +1 -0
  317. package/dist/core/llm/streaming/StreamingReconstructor.d.ts +69 -0
  318. package/dist/core/llm/streaming/StreamingReconstructor.d.ts.map +1 -0
  319. package/dist/core/llm/streaming/StreamingReconstructor.js +102 -0
  320. package/dist/core/llm/streaming/StreamingReconstructor.js.map +1 -0
  321. package/dist/core/marketplace/IMarketplace.d.ts +500 -0
  322. package/dist/core/marketplace/IMarketplace.d.ts.map +1 -0
  323. package/dist/core/marketplace/IMarketplace.js +10 -0
  324. package/dist/core/marketplace/IMarketplace.js.map +1 -0
  325. package/dist/core/marketplace/Marketplace.d.ts +122 -0
  326. package/dist/core/marketplace/Marketplace.d.ts.map +1 -0
  327. package/dist/core/marketplace/Marketplace.js +591 -0
  328. package/dist/core/marketplace/Marketplace.js.map +1 -0
  329. package/dist/core/marketplace/index.d.ts +8 -0
  330. package/dist/core/marketplace/index.d.ts.map +1 -0
  331. package/dist/core/marketplace/index.js +8 -0
  332. package/dist/core/marketplace/index.js.map +1 -0
  333. package/dist/core/observability/ITracer.d.ts +317 -0
  334. package/dist/core/observability/ITracer.d.ts.map +1 -0
  335. package/dist/core/observability/ITracer.js +55 -0
  336. package/dist/core/observability/ITracer.js.map +1 -0
  337. package/dist/core/observability/Tracer.d.ts +76 -0
  338. package/dist/core/observability/Tracer.d.ts.map +1 -0
  339. package/dist/core/observability/Tracer.js +360 -0
  340. package/dist/core/observability/Tracer.js.map +1 -0
  341. package/dist/core/observability/index.d.ts +9 -0
  342. package/dist/core/observability/index.d.ts.map +1 -0
  343. package/dist/core/observability/index.js +8 -0
  344. package/dist/core/observability/index.js.map +1 -0
  345. package/dist/core/orchestration/AgentOrchestrator.d.ts +243 -0
  346. package/dist/core/orchestration/AgentOrchestrator.d.ts.map +1 -0
  347. package/dist/core/orchestration/AgentOrchestrator.js +648 -0
  348. package/dist/core/orchestration/AgentOrchestrator.js.map +1 -0
  349. package/dist/core/orchestration/IAgentOrchestrator.d.ts +44 -0
  350. package/dist/core/orchestration/IAgentOrchestrator.d.ts.map +1 -0
  351. package/dist/core/orchestration/IAgentOrchestrator.js +4 -0
  352. package/dist/core/orchestration/IAgentOrchestrator.js.map +1 -0
  353. package/dist/core/orchestration/helpers.d.ts +12 -0
  354. package/dist/core/orchestration/helpers.d.ts.map +1 -0
  355. package/dist/core/orchestration/helpers.js +36 -0
  356. package/dist/core/orchestration/helpers.js.map +1 -0
  357. package/dist/core/planning/IPlanningEngine.d.ts +524 -0
  358. package/dist/core/planning/IPlanningEngine.d.ts.map +1 -0
  359. package/dist/core/planning/IPlanningEngine.js +32 -0
  360. package/dist/core/planning/IPlanningEngine.js.map +1 -0
  361. package/dist/core/planning/PlanningEngine.d.ts +161 -0
  362. package/dist/core/planning/PlanningEngine.d.ts.map +1 -0
  363. package/dist/core/planning/PlanningEngine.js +783 -0
  364. package/dist/core/planning/PlanningEngine.js.map +1 -0
  365. package/dist/core/planning/index.d.ts +25 -0
  366. package/dist/core/planning/index.d.ts.map +1 -0
  367. package/dist/core/planning/index.js +25 -0
  368. package/dist/core/planning/index.js.map +1 -0
  369. package/dist/core/sandbox/CodeSandbox.d.ts +86 -0
  370. package/dist/core/sandbox/CodeSandbox.d.ts.map +1 -0
  371. package/dist/core/sandbox/CodeSandbox.js +475 -0
  372. package/dist/core/sandbox/CodeSandbox.js.map +1 -0
  373. package/dist/core/sandbox/ICodeSandbox.d.ts +249 -0
  374. package/dist/core/sandbox/ICodeSandbox.d.ts.map +1 -0
  375. package/dist/core/sandbox/ICodeSandbox.js +24 -0
  376. package/dist/core/sandbox/ICodeSandbox.js.map +1 -0
  377. package/dist/core/sandbox/index.d.ts +9 -0
  378. package/dist/core/sandbox/index.d.ts.map +1 -0
  379. package/dist/core/sandbox/index.js +8 -0
  380. package/dist/core/sandbox/index.js.map +1 -0
  381. package/dist/core/storage/IStorageAdapter.d.ts +483 -0
  382. package/dist/core/storage/IStorageAdapter.d.ts.map +1 -0
  383. package/dist/core/storage/IStorageAdapter.js +19 -0
  384. package/dist/core/storage/IStorageAdapter.js.map +1 -0
  385. package/dist/core/storage/InMemoryStorageAdapter.d.ts +192 -0
  386. package/dist/core/storage/InMemoryStorageAdapter.d.ts.map +1 -0
  387. package/dist/core/storage/InMemoryStorageAdapter.js +343 -0
  388. package/dist/core/storage/InMemoryStorageAdapter.js.map +1 -0
  389. package/dist/core/storage/SqlStorageAdapter.d.ts +262 -0
  390. package/dist/core/storage/SqlStorageAdapter.d.ts.map +1 -0
  391. package/dist/core/storage/SqlStorageAdapter.js +485 -0
  392. package/dist/core/storage/SqlStorageAdapter.js.map +1 -0
  393. package/dist/core/storage/index.d.ts +14 -0
  394. package/dist/core/storage/index.d.ts.map +1 -0
  395. package/dist/core/storage/index.js +14 -0
  396. package/dist/core/storage/index.js.map +1 -0
  397. package/dist/core/streaming/IStreamClient.d.ts +72 -0
  398. package/dist/core/streaming/IStreamClient.d.ts.map +1 -0
  399. package/dist/core/streaming/IStreamClient.js +12 -0
  400. package/dist/core/streaming/IStreamClient.js.map +1 -0
  401. package/dist/core/streaming/StreamingManager.d.ts +242 -0
  402. package/dist/core/streaming/StreamingManager.d.ts.map +1 -0
  403. package/dist/core/streaming/StreamingManager.js +282 -0
  404. package/dist/core/streaming/StreamingManager.js.map +1 -0
  405. package/dist/core/structured/IStructuredOutputManager.d.ts +701 -0
  406. package/dist/core/structured/IStructuredOutputManager.d.ts.map +1 -0
  407. package/dist/core/structured/IStructuredOutputManager.js +74 -0
  408. package/dist/core/structured/IStructuredOutputManager.js.map +1 -0
  409. package/dist/core/structured/StructuredOutputManager.d.ts +140 -0
  410. package/dist/core/structured/StructuredOutputManager.d.ts.map +1 -0
  411. package/dist/core/structured/StructuredOutputManager.js +1015 -0
  412. package/dist/core/structured/StructuredOutputManager.js.map +1 -0
  413. package/dist/core/structured/index.d.ts +34 -0
  414. package/dist/core/structured/index.d.ts.map +1 -0
  415. package/dist/core/structured/index.js +34 -0
  416. package/dist/core/structured/index.js.map +1 -0
  417. package/dist/core/tools/ITool.d.ts +228 -0
  418. package/dist/core/tools/ITool.d.ts.map +1 -0
  419. package/dist/core/tools/ITool.js +11 -0
  420. package/dist/core/tools/ITool.js.map +1 -0
  421. package/dist/core/tools/IToolOrchestrator.d.ts +131 -0
  422. package/dist/core/tools/IToolOrchestrator.d.ts.map +1 -0
  423. package/dist/core/tools/IToolOrchestrator.js +14 -0
  424. package/dist/core/tools/IToolOrchestrator.js.map +1 -0
  425. package/dist/core/tools/ToolExecutor.d.ts +143 -0
  426. package/dist/core/tools/ToolExecutor.d.ts.map +1 -0
  427. package/dist/core/tools/ToolExecutor.js +364 -0
  428. package/dist/core/tools/ToolExecutor.js.map +1 -0
  429. package/dist/core/tools/ToolOrchestrator.d.ts +142 -0
  430. package/dist/core/tools/ToolOrchestrator.d.ts.map +1 -0
  431. package/dist/core/tools/ToolOrchestrator.js +373 -0
  432. package/dist/core/tools/ToolOrchestrator.js.map +1 -0
  433. package/dist/core/tools/permissions/IToolPermissionManager.d.ts +195 -0
  434. package/dist/core/tools/permissions/IToolPermissionManager.d.ts.map +1 -0
  435. package/dist/core/tools/permissions/IToolPermissionManager.js +14 -0
  436. package/dist/core/tools/permissions/IToolPermissionManager.js.map +1 -0
  437. package/dist/core/tools/permissions/ToolPermissionManager.d.ts +203 -0
  438. package/dist/core/tools/permissions/ToolPermissionManager.d.ts.map +1 -0
  439. package/dist/core/tools/permissions/ToolPermissionManager.js +298 -0
  440. package/dist/core/tools/permissions/ToolPermissionManager.js.map +1 -0
  441. package/dist/core/ui/IUIComponent.d.ts +11 -0
  442. package/dist/core/ui/IUIComponent.d.ts.map +1 -0
  443. package/dist/core/ui/IUIComponent.js +2 -0
  444. package/dist/core/ui/IUIComponent.js.map +1 -0
  445. package/dist/core/usage/UsageLedger.d.ts +81 -0
  446. package/dist/core/usage/UsageLedger.d.ts.map +1 -0
  447. package/dist/core/usage/UsageLedger.js +135 -0
  448. package/dist/core/usage/UsageLedger.js.map +1 -0
  449. package/dist/core/workflows/IWorkflowEngine.d.ts +42 -0
  450. package/dist/core/workflows/IWorkflowEngine.d.ts.map +1 -0
  451. package/dist/core/workflows/IWorkflowEngine.js +2 -0
  452. package/dist/core/workflows/IWorkflowEngine.js.map +1 -0
  453. package/dist/core/workflows/WorkflowEngine.d.ts +28 -0
  454. package/dist/core/workflows/WorkflowEngine.d.ts.map +1 -0
  455. package/dist/core/workflows/WorkflowEngine.js +309 -0
  456. package/dist/core/workflows/WorkflowEngine.js.map +1 -0
  457. package/dist/core/workflows/WorkflowTypes.d.ts +180 -0
  458. package/dist/core/workflows/WorkflowTypes.d.ts.map +1 -0
  459. package/dist/core/workflows/WorkflowTypes.js +26 -0
  460. package/dist/core/workflows/WorkflowTypes.js.map +1 -0
  461. package/dist/core/workflows/runtime/WorkflowRuntime.d.ts +70 -0
  462. package/dist/core/workflows/runtime/WorkflowRuntime.d.ts.map +1 -0
  463. package/dist/core/workflows/runtime/WorkflowRuntime.js +566 -0
  464. package/dist/core/workflows/runtime/WorkflowRuntime.js.map +1 -0
  465. package/dist/core/workflows/storage/IWorkflowStore.d.ts +75 -0
  466. package/dist/core/workflows/storage/IWorkflowStore.d.ts.map +1 -0
  467. package/dist/core/workflows/storage/IWorkflowStore.js +2 -0
  468. package/dist/core/workflows/storage/IWorkflowStore.js.map +1 -0
  469. package/dist/core/workflows/storage/InMemoryWorkflowStore.d.ts +14 -0
  470. package/dist/core/workflows/storage/InMemoryWorkflowStore.d.ts.map +1 -0
  471. package/dist/core/workflows/storage/InMemoryWorkflowStore.js +130 -0
  472. package/dist/core/workflows/storage/InMemoryWorkflowStore.js.map +1 -0
  473. package/dist/extensions/ExtensionLoader.d.ts +119 -0
  474. package/dist/extensions/ExtensionLoader.d.ts.map +1 -0
  475. package/dist/extensions/ExtensionLoader.js +297 -0
  476. package/dist/extensions/ExtensionLoader.js.map +1 -0
  477. package/dist/extensions/ExtensionManager.d.ts +49 -0
  478. package/dist/extensions/ExtensionManager.d.ts.map +1 -0
  479. package/dist/extensions/ExtensionManager.js +197 -0
  480. package/dist/extensions/ExtensionManager.js.map +1 -0
  481. package/dist/extensions/ExtensionRegistry.d.ts +39 -0
  482. package/dist/extensions/ExtensionRegistry.d.ts.map +1 -0
  483. package/dist/extensions/ExtensionRegistry.js +103 -0
  484. package/dist/extensions/ExtensionRegistry.js.map +1 -0
  485. package/dist/extensions/MultiRegistryLoader.d.ts +61 -0
  486. package/dist/extensions/MultiRegistryLoader.d.ts.map +1 -0
  487. package/dist/extensions/MultiRegistryLoader.js +169 -0
  488. package/dist/extensions/MultiRegistryLoader.js.map +1 -0
  489. package/dist/extensions/RegistryConfig.d.ts +86 -0
  490. package/dist/extensions/RegistryConfig.d.ts.map +1 -0
  491. package/dist/extensions/RegistryConfig.js +99 -0
  492. package/dist/extensions/RegistryConfig.js.map +1 -0
  493. package/dist/extensions/events.d.ts +19 -0
  494. package/dist/extensions/events.d.ts.map +1 -0
  495. package/dist/extensions/events.js +2 -0
  496. package/dist/extensions/events.js.map +1 -0
  497. package/dist/extensions/index.d.ts +9 -0
  498. package/dist/extensions/index.d.ts.map +1 -0
  499. package/dist/extensions/index.js +9 -0
  500. package/dist/extensions/index.js.map +1 -0
  501. package/dist/extensions/manifest.d.ts +52 -0
  502. package/dist/extensions/manifest.d.ts.map +1 -0
  503. package/dist/extensions/manifest.js +2 -0
  504. package/dist/extensions/manifest.js.map +1 -0
  505. package/dist/extensions/types.d.ts +294 -0
  506. package/dist/extensions/types.d.ts.map +1 -0
  507. package/dist/extensions/types.js +12 -0
  508. package/dist/extensions/types.js.map +1 -0
  509. package/dist/index.d.ts +49 -0
  510. package/dist/index.d.ts.map +1 -0
  511. package/dist/index.js +59 -0
  512. package/dist/index.js.map +1 -0
  513. package/dist/logging/ILogger.d.ts +8 -0
  514. package/dist/logging/ILogger.d.ts.map +1 -0
  515. package/dist/logging/ILogger.js +2 -0
  516. package/dist/logging/ILogger.js.map +1 -0
  517. package/dist/logging/PinoLogger.d.ts +12 -0
  518. package/dist/logging/PinoLogger.d.ts.map +1 -0
  519. package/dist/logging/PinoLogger.js +22 -0
  520. package/dist/logging/PinoLogger.js.map +1 -0
  521. package/dist/logging/loggerFactory.d.ts +6 -0
  522. package/dist/logging/loggerFactory.d.ts.map +1 -0
  523. package/dist/logging/loggerFactory.js +14 -0
  524. package/dist/logging/loggerFactory.js.map +1 -0
  525. package/dist/rag/EmbeddingManager.d.ts +81 -0
  526. package/dist/rag/EmbeddingManager.d.ts.map +1 -0
  527. package/dist/rag/EmbeddingManager.js +412 -0
  528. package/dist/rag/EmbeddingManager.js.map +1 -0
  529. package/dist/rag/IEmbeddingManager.d.ts +277 -0
  530. package/dist/rag/IEmbeddingManager.d.ts.map +1 -0
  531. package/dist/rag/IEmbeddingManager.js +19 -0
  532. package/dist/rag/IEmbeddingManager.js.map +1 -0
  533. package/dist/rag/IRetrievalAugmentor.d.ts +208 -0
  534. package/dist/rag/IRetrievalAugmentor.d.ts.map +1 -0
  535. package/dist/rag/IRetrievalAugmentor.js +21 -0
  536. package/dist/rag/IRetrievalAugmentor.js.map +1 -0
  537. package/dist/rag/IVectorStore.d.ts +351 -0
  538. package/dist/rag/IVectorStore.d.ts.map +1 -0
  539. package/dist/rag/IVectorStore.js +15 -0
  540. package/dist/rag/IVectorStore.js.map +1 -0
  541. package/dist/rag/IVectorStoreManager.d.ts +121 -0
  542. package/dist/rag/IVectorStoreManager.d.ts.map +1 -0
  543. package/dist/rag/IVectorStoreManager.js +13 -0
  544. package/dist/rag/IVectorStoreManager.js.map +1 -0
  545. package/dist/rag/RetrievalAugmentor.d.ts +99 -0
  546. package/dist/rag/RetrievalAugmentor.d.ts.map +1 -0
  547. package/dist/rag/RetrievalAugmentor.js +674 -0
  548. package/dist/rag/RetrievalAugmentor.js.map +1 -0
  549. package/dist/rag/VectorStoreManager.d.ts +90 -0
  550. package/dist/rag/VectorStoreManager.d.ts.map +1 -0
  551. package/dist/rag/VectorStoreManager.js +283 -0
  552. package/dist/rag/VectorStoreManager.js.map +1 -0
  553. package/dist/rag/implementations/index.d.ts +9 -0
  554. package/dist/rag/implementations/index.d.ts.map +1 -0
  555. package/dist/rag/implementations/index.js +9 -0
  556. package/dist/rag/implementations/index.js.map +1 -0
  557. package/dist/rag/implementations/vector_stores/InMemoryVectorStore.d.ts +132 -0
  558. package/dist/rag/implementations/vector_stores/InMemoryVectorStore.d.ts.map +1 -0
  559. package/dist/rag/implementations/vector_stores/InMemoryVectorStore.js +539 -0
  560. package/dist/rag/implementations/vector_stores/InMemoryVectorStore.js.map +1 -0
  561. package/dist/rag/implementations/vector_stores/SqlVectorStore.d.ts +265 -0
  562. package/dist/rag/implementations/vector_stores/SqlVectorStore.d.ts.map +1 -0
  563. package/dist/rag/implementations/vector_stores/SqlVectorStore.js +755 -0
  564. package/dist/rag/implementations/vector_stores/SqlVectorStore.js.map +1 -0
  565. package/dist/rag/implementations/vector_stores/index.d.ts +10 -0
  566. package/dist/rag/implementations/vector_stores/index.d.ts.map +1 -0
  567. package/dist/rag/implementations/vector_stores/index.js +12 -0
  568. package/dist/rag/implementations/vector_stores/index.js.map +1 -0
  569. package/dist/rag/index.d.ts +95 -0
  570. package/dist/rag/index.d.ts.map +1 -0
  571. package/dist/rag/index.js +97 -0
  572. package/dist/rag/index.js.map +1 -0
  573. package/dist/services/user_auth/AuthService.d.ts +13 -0
  574. package/dist/services/user_auth/AuthService.d.ts.map +1 -0
  575. package/dist/services/user_auth/AuthService.js +24 -0
  576. package/dist/services/user_auth/AuthService.js.map +1 -0
  577. package/dist/services/user_auth/SubscriptionService.d.ts +14 -0
  578. package/dist/services/user_auth/SubscriptionService.d.ts.map +1 -0
  579. package/dist/services/user_auth/SubscriptionService.js +34 -0
  580. package/dist/services/user_auth/SubscriptionService.js.map +1 -0
  581. package/dist/services/user_auth/types.d.ts +30 -0
  582. package/dist/services/user_auth/types.d.ts.map +1 -0
  583. package/dist/services/user_auth/types.js +2 -0
  584. package/dist/services/user_auth/types.js.map +1 -0
  585. package/dist/stubs/prismaClient.d.ts +35 -0
  586. package/dist/stubs/prismaClient.d.ts.map +1 -0
  587. package/dist/stubs/prismaClient.js +47 -0
  588. package/dist/stubs/prismaClient.js.map +1 -0
  589. package/dist/types/rateLimitTypes.d.ts +70 -0
  590. package/dist/types/rateLimitTypes.d.ts.map +1 -0
  591. package/dist/types/rateLimitTypes.js +55 -0
  592. package/dist/types/rateLimitTypes.js.map +1 -0
  593. package/dist/utils/errors.d.ts +80 -0
  594. package/dist/utils/errors.d.ts.map +1 -0
  595. package/dist/utils/errors.js +201 -0
  596. package/dist/utils/errors.js.map +1 -0
  597. package/dist/utils/uuid.d.ts +11 -0
  598. package/dist/utils/uuid.d.ts.map +1 -0
  599. package/dist/utils/uuid.js +64 -0
  600. package/dist/utils/uuid.js.map +1 -0
  601. package/package.json +84 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @fileoverview Implements the `IAgentFactory` interface, providing a robust
3
+ * mechanism for creating and managing agent instances within AgentOS.
4
+ * This factory is responsible for:
5
+ * - Loading and storing agent configurations (`AgentConfig`).
6
+ * - Mapping agent type identifiers (from `AgentConfig.type`) to their corresponding
7
+ * agent class constructors (`AgentClassConstructor`).
8
+ * - Instantiating agents by their unique IDs, ensuring all necessary dependencies
9
+ * (like `IPromptEngine`, `AIModelProviderManager`, `IUtilityAI`, and the `IAgentFactory` itself)
10
+ * are correctly injected.
11
+ * - Handling the initialization lifecycle of newly created agents.
12
+ * - Allowing dynamic registration of new agent types.
13
+ *
14
+ * This centralized approach to agent creation promotes modularity, testability,
15
+ * and simplifies the process of extending the system with new agent types.
16
+ * @module backend/agentos/core/agents/AgentFactory
17
+ */
18
+ import { IAgentFactory, AgentDependencies, AgentClassConstructor } from './IAgentFactory';
19
+ import { IAgent } from './IAgent';
20
+ import { AgentConfig } from './AgentCore';
21
+ /**
22
+ * Custom error class for issues specific to agent instantiation or configuration
23
+ * within the `AgentFactory`. This helps in distinguishing factory-related errors
24
+ * from other system errors.
25
+ * @class AgentFactoryError
26
+ * @extends {Error}
27
+ */
28
+ export declare class AgentFactoryError extends Error {
29
+ /**
30
+ * A specific error code related to AgentFactory operations.
31
+ * @type {string}
32
+ */
33
+ readonly code: string;
34
+ /**
35
+ * The ID of the agent involved in the error, if applicable.
36
+ * @type {string | undefined}
37
+ * @optional
38
+ */
39
+ readonly agentId?: string;
40
+ /**
41
+ * The underlying error that caused this factory error, if any.
42
+ * @type {Error | undefined}
43
+ * @optional
44
+ */
45
+ readonly underlyingError?: Error;
46
+ /**
47
+ * Creates an instance of `AgentFactoryError`.
48
+ * @param {string} message - The human-readable error message.
49
+ * @param {string} code - A unique code for the error type (e.g., 'CONFIG_NOT_FOUND', 'CLASS_NOT_REGISTERED', 'INSTANTIATION_FAILED').
50
+ * @param {string} [agentId] - Optional. The ID of the agent associated with this error.
51
+ * @param {Error} [underlyingError] - Optional. The original error that was caught and wrapped.
52
+ */
53
+ constructor(message: string, code: string, agentId?: string, underlyingError?: Error);
54
+ }
55
+ /**
56
+ * A concrete implementation of `IAgentFactory`.
57
+ * This class is responsible for instantiating `IAgent` implementations based on
58
+ * loaded `AgentConfig` data and a map of registered agent classes. It ensures
59
+ * that agents are created with all their required dependencies.
60
+ *
61
+ * @class AgentFactory
62
+ * @implements {IAgentFactory}
63
+ */
64
+ export declare class AgentFactory implements IAgentFactory {
65
+ /**
66
+ * Stores agent configurations, keyed by their unique agent ID.
67
+ * @private
68
+ * @type {Record<string, AgentConfig>}
69
+ */
70
+ private agentConfigs;
71
+ /**
72
+ * Maps agent type identifiers (strings) to their corresponding class constructors.
73
+ * @private
74
+ * @type {Record<string, AgentClassConstructor<any>>}
75
+ */
76
+ private agentClassMap;
77
+ /**
78
+ * Flag indicating whether the factory has been successfully initialized.
79
+ * @private
80
+ * @type {boolean}
81
+ */
82
+ private isInitialized;
83
+ /**
84
+ * Constructs an `AgentFactory`.
85
+ * Initialization (loading configs and classes) is performed via the `initialize` method.
86
+ */
87
+ constructor();
88
+ /**
89
+ * Ensures that the factory has been initialized before any operational methods are called.
90
+ * @private
91
+ * @throws {AgentFactoryError} If the factory is not initialized.
92
+ */
93
+ private ensureInitialized;
94
+ /**
95
+ * @inheritdoc
96
+ * Initializes the `AgentFactory` by loading agent configurations and mapping agent types
97
+ * to their respective class constructors.
98
+ * @throws {AgentFactoryError} If `agentConfigs` or `agentClassMap` is null/undefined.
99
+ */
100
+ initialize(agentConfigs: Record<string, AgentConfig>, agentClassMap: Record<string, AgentClassConstructor<any>>): Promise<void>;
101
+ /**
102
+ * @inheritdoc
103
+ * Dynamically registers an agent type and its constructor with the factory.
104
+ * This allows for adding new agent implementations at runtime or via a plugin system.
105
+ * @throws {AgentFactoryError} If `agentType` or `constructor` is invalid, or if an agent type is already registered and overwrite is not intended.
106
+ */
107
+ registerAgentClass(agentType: string, constructor: AgentClassConstructor<any>): Promise<void>;
108
+ /**
109
+ * @inheritdoc
110
+ * Retrieves (and typically creates and initializes) an agent instance by its ID.
111
+ * It resolves the agent's primary LLM provider using the `AIModelProviderManager` from `dependencies`.
112
+ * @throws {AgentFactoryError} If critical errors occur during instantiation, such as missing configuration,
113
+ * unregistered class, or failure to resolve the LLM provider.
114
+ */
115
+ getAgent(agentId: string, dependencies: AgentDependencies): Promise<IAgent | undefined>;
116
+ /**
117
+ * @inheritdoc
118
+ * Lists all available agent configurations known to the factory.
119
+ * Returns deep copies of the configurations to prevent external modification.
120
+ */
121
+ listAvailableAgentConfigs(): Promise<Readonly<AgentConfig[]>>;
122
+ }
123
+ //# sourceMappingURL=AgentFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentFactory.d.ts","sourceRoot":"","sources":["../../../src/core/agents/AgentFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C;;;OAGG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;;;OAIG;IACH,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;IACH,SAAgB,eAAe,CAAC,EAAE,KAAK,CAAC;IAExC;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,KAAK;CAYrF;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD;;;;OAIG;IACH,OAAO,CAAC,YAAY,CAAmC;IAEvD;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAAkD;IAEvE;;;;OAIG;IACH,OAAO,CAAC,aAAa,CAAkB;IAEvC;;;OAGG;;IAKH;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;;;OAKG;IACU,UAAU,CACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACzC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,GACxD,OAAO,CAAC,IAAI,CAAC;IA8BhB;;;;;OAKG;IACU,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB1G;;;;;;OAMG;IACU,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAkGpG;;;;OAIG;IACU,yBAAyB,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;CAkB3E"}
@@ -0,0 +1,232 @@
1
+ /**
2
+ * @fileoverview Implements the `IAgentFactory` interface, providing a robust
3
+ * mechanism for creating and managing agent instances within AgentOS.
4
+ * This factory is responsible for:
5
+ * - Loading and storing agent configurations (`AgentConfig`).
6
+ * - Mapping agent type identifiers (from `AgentConfig.type`) to their corresponding
7
+ * agent class constructors (`AgentClassConstructor`).
8
+ * - Instantiating agents by their unique IDs, ensuring all necessary dependencies
9
+ * (like `IPromptEngine`, `AIModelProviderManager`, `IUtilityAI`, and the `IAgentFactory` itself)
10
+ * are correctly injected.
11
+ * - Handling the initialization lifecycle of newly created agents.
12
+ * - Allowing dynamic registration of new agent types.
13
+ *
14
+ * This centralized approach to agent creation promotes modularity, testability,
15
+ * and simplifies the process of extending the system with new agent types.
16
+ * @module backend/agentos/core/agents/AgentFactory
17
+ */
18
+ import { AgentType } from './AgentCore.js'; // AgentConfig and AgentType
19
+ /**
20
+ * Custom error class for issues specific to agent instantiation or configuration
21
+ * within the `AgentFactory`. This helps in distinguishing factory-related errors
22
+ * from other system errors.
23
+ * @class AgentFactoryError
24
+ * @extends {Error}
25
+ */
26
+ export class AgentFactoryError extends Error {
27
+ /**
28
+ * Creates an instance of `AgentFactoryError`.
29
+ * @param {string} message - The human-readable error message.
30
+ * @param {string} code - A unique code for the error type (e.g., 'CONFIG_NOT_FOUND', 'CLASS_NOT_REGISTERED', 'INSTANTIATION_FAILED').
31
+ * @param {string} [agentId] - Optional. The ID of the agent associated with this error.
32
+ * @param {Error} [underlyingError] - Optional. The original error that was caught and wrapped.
33
+ */
34
+ constructor(message, code, agentId, underlyingError) {
35
+ super(message);
36
+ this.name = "AgentFactoryError";
37
+ this.code = code;
38
+ this.agentId = agentId;
39
+ this.underlyingError = underlyingError;
40
+ if (underlyingError && underlyingError.stack) {
41
+ this.stack = `${this.message}\nCaused by: ${underlyingError.stack}`;
42
+ }
43
+ Object.setPrototypeOf(this, AgentFactoryError.prototype);
44
+ }
45
+ }
46
+ /**
47
+ * A concrete implementation of `IAgentFactory`.
48
+ * This class is responsible for instantiating `IAgent` implementations based on
49
+ * loaded `AgentConfig` data and a map of registered agent classes. It ensures
50
+ * that agents are created with all their required dependencies.
51
+ *
52
+ * @class AgentFactory
53
+ * @implements {IAgentFactory}
54
+ */
55
+ export class AgentFactory {
56
+ /**
57
+ * Constructs an `AgentFactory`.
58
+ * Initialization (loading configs and classes) is performed via the `initialize` method.
59
+ */
60
+ constructor() {
61
+ /**
62
+ * Stores agent configurations, keyed by their unique agent ID.
63
+ * @private
64
+ * @type {Record<string, AgentConfig>}
65
+ */
66
+ this.agentConfigs = {};
67
+ /**
68
+ * Maps agent type identifiers (strings) to their corresponding class constructors.
69
+ * @private
70
+ * @type {Record<string, AgentClassConstructor<any>>}
71
+ */
72
+ this.agentClassMap = {};
73
+ /**
74
+ * Flag indicating whether the factory has been successfully initialized.
75
+ * @private
76
+ * @type {boolean}
77
+ */
78
+ this.isInitialized = false;
79
+ // console.log("AgentFactory instance created. Awaiting initialization.");
80
+ }
81
+ /**
82
+ * Ensures that the factory has been initialized before any operational methods are called.
83
+ * @private
84
+ * @throws {AgentFactoryError} If the factory is not initialized.
85
+ */
86
+ ensureInitialized() {
87
+ if (!this.isInitialized) {
88
+ throw new AgentFactoryError("AgentFactory is not initialized. Call initialize() with agent configurations and class map first.", 'FACTORY_NOT_INITIALIZED');
89
+ }
90
+ }
91
+ /**
92
+ * @inheritdoc
93
+ * Initializes the `AgentFactory` by loading agent configurations and mapping agent types
94
+ * to their respective class constructors.
95
+ * @throws {AgentFactoryError} If `agentConfigs` or `agentClassMap` is null/undefined.
96
+ */
97
+ async initialize(agentConfigs, agentClassMap) {
98
+ if (this.isInitialized) {
99
+ console.warn("AgentFactory is already initialized. Re-initializing will overwrite existing configurations and class mappings.");
100
+ // Resetting state for re-initialization
101
+ this.agentConfigs = {};
102
+ this.agentClassMap = {};
103
+ }
104
+ if (!agentConfigs) {
105
+ throw new AgentFactoryError("Agent configurations (agentConfigs) must be provided for initialization.", 'INIT_NO_CONFIGS');
106
+ }
107
+ if (!agentClassMap) {
108
+ throw new AgentFactoryError("Agent class map (agentClassMap) must be provided for initialization.", 'INIT_NO_CLASSMAP');
109
+ }
110
+ // Store copies to prevent external modification of the provided objects.
111
+ this.agentConfigs = { ...agentConfigs };
112
+ this.agentClassMap = { ...agentClassMap };
113
+ this.isInitialized = true;
114
+ const configCount = Object.keys(this.agentConfigs).length;
115
+ const classCount = Object.keys(this.agentClassMap).length;
116
+ if (configCount > 0 || classCount > 0) {
117
+ // console.log(`AgentFactory initialized successfully with ${configCount} agent configurations and ${classCount} registered agent classes.`);
118
+ }
119
+ else {
120
+ console.warn("AgentFactory initialized, but no agent configurations or agent classes were provided. The factory may not be able to create agents.");
121
+ }
122
+ }
123
+ /**
124
+ * @inheritdoc
125
+ * Dynamically registers an agent type and its constructor with the factory.
126
+ * This allows for adding new agent implementations at runtime or via a plugin system.
127
+ * @throws {AgentFactoryError} If `agentType` or `constructor` is invalid, or if an agent type is already registered and overwrite is not intended.
128
+ */
129
+ async registerAgentClass(agentType, constructor) {
130
+ this.ensureInitialized();
131
+ if (!agentType || typeof agentType !== 'string' || agentType.trim() === '') {
132
+ throw new AgentFactoryError("Invalid agentType: Must be a non-empty string.", 'REGISTER_INVALID_AGENT_TYPE');
133
+ }
134
+ if (!constructor || typeof constructor !== 'function') {
135
+ throw new AgentFactoryError(`Invalid constructor provided for agentType '${agentType}'. Must be a class constructor.`, 'REGISTER_INVALID_CONSTRUCTOR', agentType);
136
+ }
137
+ if (this.agentClassMap[agentType]) {
138
+ console.warn(`AgentFactory: Agent type '${agentType}' is already registered. The existing constructor will be overwritten.`);
139
+ }
140
+ this.agentClassMap[agentType] = constructor;
141
+ // console.log(`AgentFactory: Agent type '${agentType}' registered successfully.`);
142
+ }
143
+ /**
144
+ * @inheritdoc
145
+ * Retrieves (and typically creates and initializes) an agent instance by its ID.
146
+ * It resolves the agent's primary LLM provider using the `AIModelProviderManager` from `dependencies`.
147
+ * @throws {AgentFactoryError} If critical errors occur during instantiation, such as missing configuration,
148
+ * unregistered class, or failure to resolve the LLM provider.
149
+ */
150
+ async getAgent(agentId, dependencies) {
151
+ this.ensureInitialized();
152
+ if (!agentId) {
153
+ throw new AgentFactoryError("agentId must be provided to getAgent.", 'GET_AGENT_NO_ID');
154
+ }
155
+ if (!dependencies || !dependencies.promptEngine || !dependencies.providerManager) {
156
+ throw new AgentFactoryError("Missing critical dependencies (promptEngine, providerManager) required to create agent.", 'GET_AGENT_MISSING_DEPS', agentId);
157
+ }
158
+ // Destructure all dependencies for clarity
159
+ const { promptEngine, providerManager, utilityAI, agentFactory: selfFactory } = dependencies;
160
+ const config = this.agentConfigs[agentId];
161
+ if (!config) {
162
+ console.warn(`AgentFactory: No AgentConfig found for agentId '${agentId}'. Cannot create agent.`);
163
+ return undefined; // Gracefully return undefined if config not found
164
+ }
165
+ // Determine the agent's primary LLM provider using modelTargetInfo from its config
166
+ const providerIdToUse = config.modelTargetInfo?.providerId;
167
+ if (!providerIdToUse) {
168
+ throw new AgentFactoryError(`AgentConfig for '${agentId}' is missing 'modelTargetInfo.providerId'. Cannot determine primary LLM provider.`, 'GET_AGENT_NO_PROVIDER_ID', agentId);
169
+ }
170
+ const agentPrimaryProvider = providerManager.getProvider(providerIdToUse);
171
+ if (!agentPrimaryProvider) {
172
+ throw new AgentFactoryError(`Could not resolve primary LLM provider '${providerIdToUse}' for agent '${agentId}' using the provided AIModelProviderManager. Ensure the provider is configured and initialized in the manager.`, 'GET_AGENT_PROVIDER_RESOLUTION_FAILED', agentId);
173
+ }
174
+ // Determine the AgentClass constructor to use.
175
+ // `config.type` (e.g., AgentType.POOL) is the key for agentClassMap.
176
+ const agentTypeKey = config.type || AgentType.STANDARD; // Default to STANDARD if type not specified
177
+ const AgentClass = this.agentClassMap[agentTypeKey];
178
+ if (!AgentClass) {
179
+ throw new AgentFactoryError(`No implementing class registered for agent type '${agentTypeKey}' (referenced by agentId '${agentId}'). Agent cannot be created. Ensure the class is registered with the factory using registerAgentClass(). Known types: [${Object.keys(this.agentClassMap).join(', ')}].`, 'GET_AGENT_CLASS_NOT_REGISTERED', agentId);
180
+ }
181
+ let agentInstance;
182
+ try {
183
+ // Instantiate the agent, passing all resolved dependencies.
184
+ // Note: `selfFactory` (which is `dependencies.agentFactory`) is passed here.
185
+ agentInstance = new AgentClass(config, promptEngine, agentPrimaryProvider, utilityAI, selfFactory);
186
+ }
187
+ catch (error) {
188
+ console.error(`AgentFactory: Error during instantiation of agent '${agentId}' (type '${agentTypeKey}'): ${error.message}`, error);
189
+ throw new AgentFactoryError(`Failed to instantiate agent '${agentId}' of type '${agentTypeKey}'. Constructor threw an error: ${error.message}`, 'GET_AGENT_CONSTRUCTION_FAILED', agentId, error);
190
+ }
191
+ // Give the agent a chance to capture the dependency bundle if it supports it.
192
+ if (typeof agentInstance.setAgentDependencies === 'function') {
193
+ try {
194
+ agentInstance.setAgentDependencies(dependencies);
195
+ }
196
+ catch (depError) {
197
+ console.warn(`AgentFactory: Agent '${agentId}' threw while receiving dependencies: ${depError.message}`, depError);
198
+ }
199
+ }
200
+ // Call the agent's own initialize method, if it exists and is a function.
201
+ // This allows the agent to perform any specific asynchronous setup post-construction.
202
+ if (typeof agentInstance.initialize === 'function') {
203
+ try {
204
+ await agentInstance.initialize();
205
+ }
206
+ catch (initError) {
207
+ console.error(`AgentFactory: Error during agent.initialize() for '${agentId}': ${initError.message}`, initError);
208
+ throw new AgentFactoryError(`Agent '${agentId}' was instantiated but failed during its own initialize() method: ${initError.message}`, 'GET_AGENT_INITIALIZATION_FAILED', agentId, initError);
209
+ }
210
+ }
211
+ // console.log(`AgentFactory: Successfully created and initialized agent '${agentId}' of type '${agentTypeKey}'.`);
212
+ return agentInstance;
213
+ }
214
+ /**
215
+ * @inheritdoc
216
+ * Lists all available agent configurations known to the factory.
217
+ * Returns deep copies of the configurations to prevent external modification.
218
+ */
219
+ async listAvailableAgentConfigs() {
220
+ this.ensureInitialized();
221
+ // Return deep copies to ensure immutability of the factory's internal state.
222
+ // JSON.parse(JSON.stringify(...)) is a common way to deep copy plain objects.
223
+ try {
224
+ return Object.freeze(Object.values(this.agentConfigs).map(config => JSON.parse(JSON.stringify(config))));
225
+ }
226
+ catch (error) {
227
+ console.error("AgentFactory: Failed to deep copy agent configurations for listing.", error);
228
+ throw new AgentFactoryError(`Failed to list available agent configurations due to a cloning error: ${error.message}`, 'LIST_CONFIGS_CLONE_FAILED', undefined, error);
229
+ }
230
+ }
231
+ }
232
+ //# sourceMappingURL=AgentFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentFactory.js","sourceRoot":"","sources":["../../../src/core/agents/AgentFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC,CAAC,4BAA4B;AAElF;;;;;;GAMG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAqB1C;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,IAAY,EAAE,OAAgB,EAAE,eAAuB;QAClF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,IAAI,eAAe,IAAI,eAAe,CAAC,KAAK,EAAE,CAAC;YAC7C,IAAI,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ACxB,OAAO,CAAC,KAAK,CAAC,sDAAsD,OAAO,MAAM,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;gBACjH,MAAM,IAAI,iBAAiB,CACzB,UAAU,OAAO,qEAAqE,SAAS,CAAC,OAAO,EAAE,EACzG,iCAAiC,EACjC,OAAO,EACP,SAAS,CACV,CAAC;YACJ,CAAC;QACH,CAAC;QACD,mHAAmH;QACnH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,yBAAyB;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,6EAA6E;QAC7E,8EAA8E;QAC9E,IAAI,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CACrF,CAAC;QACN,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,qEAAqE,EAAE,KAAK,CAAC,CAAC;YAC5F,MAAM,IAAI,iBAAiB,CACvB,yEAAyE,KAAK,CAAC,OAAO,EAAE,EACxF,2BAA2B,EAC3B,SAAS,EACT,KAAK,CACR,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,244 @@
1
+ /**
2
+ * @fileoverview Implements the `AgentPoolAgent`, a specialized type of `AgentCore`
3
+ * that functions as a manager or orchestrator for a collection of other "sub-agents".
4
+ * This agent embodies strategies like routing requests to the most suitable sub-agent,
5
+ * synthesizing responses from multiple sub-agents (mixture of experts), or delegating
6
+ * tasks directly.
7
+ *
8
+ * The `AgentPoolAgent` uses an `IAgentFactory` to instantiate its sub-agents based on
9
+ * IDs provided in its `AgentPoolConfig`. Its behavior is primarily dictated by the
10
+ * `AgentPoolStrategy` defined in its configuration.
11
+ *
12
+ * Key functionalities:
13
+ * - Loads and initializes a set of sub-agents.
14
+ * - Implements various strategies for sub-agent interaction and output generation.
15
+ * - Can maintain a "unified persona" for user-facing interactions, even if sub-agents
16
+ * have distinct characteristics.
17
+ * - Utilizes its own LLM provider and prompt engine for meta-tasks like routing
18
+ * decisions or synthesizing sub-agent outputs.
19
+ * @module backend/agentos/core/agents/AgentPoolAgent
20
+ */
21
+ import { AgentCore, AgentConfig, AgentType } from './AgentCore';
22
+ import { IAgent, AgentOutput } from './IAgent';
23
+ import { AgentPoolConfig } from './AgentPoolConfig';
24
+ import { ConversationContext } from '../conversation/ConversationContext';
25
+ import { IProvider } from '../llm/providers/IProvider';
26
+ import { IPromptEngine } from '../llm/IPromptEngine';
27
+ import { Tool } from './tools/Tool';
28
+ import { IUtilityAI } from '../ai_utilities/IUtilityAI';
29
+ import { IAgentFactory, AgentDependencies } from './IAgentFactory';
30
+ /**
31
+ * Configuration specific to an `AgentPoolAgent`.
32
+ * It extends the base `AgentConfig` and mandates that the `type` is `AgentType.POOL`,
33
+ * and that `agentPoolOptions` (defined by `AgentPoolConfig`) are provided.
34
+ * @interface AgentPoolAgentConfig
35
+ * @extends {AgentConfig}
36
+ */
37
+ export interface AgentPoolAgentConfig extends AgentConfig {
38
+ /**
39
+ * Specifies the type of this agent, which must be `AgentType.POOL`.
40
+ * @type {AgentType.POOL}
41
+ */
42
+ type: AgentType.POOL;
43
+ /**
44
+ * Configuration settings specific to the agent pool's operation,
45
+ * including sub-agent IDs and interaction strategy.
46
+ * @type {AgentPoolConfig}
47
+ */
48
+ agentPoolOptions: AgentPoolConfig;
49
+ }
50
+ /**
51
+ * A concrete agent implementation that acts as an intelligent coordinator or router
52
+ * for a collection of sub-agents. It encapsulates the logic for selecting,
53
+ * dispatching tasks to, and synthesizing results from its managed sub-agents,
54
+ * all based on a configured `AgentPoolStrategy`.
55
+ *
56
+ * @class AgentPoolAgent
57
+ * @extends {AgentCore}
58
+ * @implements {IAgent}
59
+ */
60
+ export declare class AgentPoolAgent extends AgentCore implements IAgent {
61
+ /**
62
+ * The specific configuration for this agent pool's operations.
63
+ * @private
64
+ * @type {AgentPoolConfig}
65
+ */
66
+ private readonly poolConfig;
67
+ /**
68
+ * A map storing the instantiated sub-agent instances, keyed by their agent IDs.
69
+ * @private
70
+ * @type {Map<string, IAgent>}
71
+ */
72
+ private subAgents;
73
+ /**
74
+ * Snapshot of the dependencies originally supplied by the orchestrator/factory.
75
+ * Needed so the pool can instantiate sub-agents with the same services.
76
+ */
77
+ private agentDependencies?;
78
+ /**
79
+ * Stores tools that are available to the pool agent itself. These might be
80
+ * different from tools available to individual sub-agents.
81
+ * @private
82
+ * @type {Tool[]}
83
+ */
84
+ private availablePoolTools;
85
+ /**
86
+ * Constructs an `AgentPoolAgent` instance.
87
+ *
88
+ * @param {AgentPoolAgentConfig} config - The configuration for this agent pool.
89
+ * Must specify `type` as `AgentType.POOL` and include `agentPoolOptions`.
90
+ * @param {IPromptEngine} promptEngine - An instance of the `IPromptEngine`.
91
+ * @param {IProvider} llmProvider - The primary AI model provider for the pool agent's
92
+ * own meta-tasks (e.g., routing, synthesis).
93
+ * @param {IUtilityAI | undefined} utilityAI - Optional. An instance of an `IUtilityAI` service.
94
+ * @param {IAgentFactory} agentFactory - The `IAgentFactory` instance, which is **required**
95
+ * for the `AgentPoolAgent` to load and instantiate its sub-agents.
96
+ * @throws {AgentCoreError} If the configuration is invalid (e.g., missing `agentPoolOptions`)
97
+ * or if the `agentFactory` dependency is not provided.
98
+ */
99
+ constructor(config: AgentPoolAgentConfig, promptEngine: IPromptEngine, llmProvider: IProvider, utilityAI: IUtilityAI | undefined, agentFactory: IAgentFactory);
100
+ /**
101
+ * Allows the orchestrator/factory to provide the dependency bundle that was used
102
+ * to construct this pool agent so it can reuse them when instantiating sub-agents.
103
+ */
104
+ setAgentDependencies(dependencies: AgentDependencies): void;
105
+ /**
106
+ * Initializes the `AgentPoolAgent`. This involves:
107
+ * 1. Calling the base class `initialize` method.
108
+ * 2. Using the injected `IAgentFactory` to load and initialize all sub-agents
109
+ * specified in `this.poolConfig.subAgentIds`.
110
+ *
111
+ * @override
112
+ * @param {Record<string, any>} [configOverrides] - Optional configuration overrides applied during initialization.
113
+ * @returns {Promise<void>}
114
+ * @throws {AgentCoreError} If the `agentFactory` is missing or if any sub-agent fails to load or initialize.
115
+ */
116
+ initialize(configOverrides?: Record<string, any>): Promise<void>;
117
+ /**
118
+ * Resets the `AgentPoolAgent`'s internal state and propagates the reset call
119
+ * to all its managed sub-agents.
120
+ * @override
121
+ */
122
+ reset(): void;
123
+ /**
124
+ * Overrides the `processTurn` method from `AgentCore` to implement the specific
125
+ * orchestration logic of the `AgentPoolAgent` based on its configured strategy.
126
+ * This method will route tasks to, or synthesize results from, its sub-agents.
127
+ *
128
+ * @override
129
+ * @param {string | null} userInput - The latest input from the user.
130
+ * @param {ConversationContext} conversationContext - The current conversation context.
131
+ * @param {Tool[]} [availableTools] - Tools available to the pool agent itself (these might also
132
+ * be passed down to sub-agents depending on the strategy and sub-agent capabilities).
133
+ * @returns {Promise<AgentOutput>} The agent's response and actions, which could be a direct
134
+ * response, a synthesized response from sub-agents, or tool calls.
135
+ * @throws {AgentCoreError} If an unhandled error occurs within the chosen strategy.
136
+ */
137
+ processTurn(userInput: string | null, conversationContext: ConversationContext, availableTools?: Tool[]): Promise<AgentOutput>;
138
+ /**
139
+ * Implements the `UNIFIED_PERSONA_ROUTING` strategy.
140
+ * This involves using an LLM (the pool agent's own) to select the most appropriate sub-agent
141
+ * based on the user input and sub-agent descriptions. The selected sub-agent's output
142
+ * is then rephrased by the pool agent to maintain a consistent unified persona.
143
+ *
144
+ * @private
145
+ * @param {string | null} userInput - The user's input.
146
+ * @param {ConversationContext} conversationContext - The current conversation context.
147
+ * @returns {Promise<AgentOutput>} The synthesized and persona-aligned output.
148
+ */
149
+ private handleUnifiedPersonaRouting;
150
+ /**
151
+ * Implements the `MIXTURE_OF_EXPERTS_SYNTHESIS` strategy.
152
+ * Consults multiple (or all) sub-agents and then uses the pool's LLM to synthesize
153
+ * their contributions into a single, coherent response.
154
+ *
155
+ * @private
156
+ * @param {string | null} userInput - The user's input.
157
+ * @param {ConversationContext} conversationContext - The current conversation context.
158
+ * @returns {Promise<AgentOutput>} The synthesized output from the mixture of experts.
159
+ */
160
+ private handleMixtureOfExpertsSynthesis;
161
+ /**
162
+ * Implements the `DIRECT_DELEGATION` strategy.
163
+ * Selects a single sub-agent (e.g., based on simple routing logic or configuration)
164
+ * and directly forwards its response without significant modification by the pool agent.
165
+ *
166
+ * @private
167
+ * @param {string | null} userInput - The user's input.
168
+ * @param {ConversationContext} conversationContext - The current conversation context.
169
+ * @returns {Promise<AgentOutput>} The output from the delegated sub-agent.
170
+ */
171
+ private handleDirectDelegation;
172
+ /**
173
+ * Implements the `EXPLORATORY_GENERATION` strategy. (Placeholder - complex to fully implement here)
174
+ * Spawns sub-agents to explore different approaches for a problem, then evaluates
175
+ * and synthesizes their outputs. This is a more advanced strategy.
176
+ *
177
+ * @private
178
+ * @param {string | null} userInput - The user's input.
179
+ * @param {ConversationContext} conversationContext - The current conversation context.
180
+ * @returns {Promise<AgentOutput>} The synthesized result of the exploratory generation.
181
+ */
182
+ private handleExploratoryGeneration;
183
+ /**
184
+ * Generates a prompt for the pool agent's internal LLM to perform routing to a sub-agent.
185
+ * The prompt includes descriptions of available sub-agents and the user's query.
186
+ *
187
+ * @private
188
+ * @param {string | null} userInput - The user's current input.
189
+ * @param {ConversationContext} conversationContext - For history and broader context.
190
+ * @param {IAgent[]} subAgents - The list of available sub-agents to choose from.
191
+ * @returns {Partial<PromptComponents>} The components for constructing the routing prompt.
192
+ */
193
+ private generateRoutingPrompt;
194
+ /**
195
+ * Parses the LLM's response when it was tasked with routing, expecting just an agent ID or "NONE".
196
+ *
197
+ * @private
198
+ * @param {ModelCompletionResponse} llmResponse - The response from the routing LLM call.
199
+ * @param {string[]} validAgentIds - An array of valid sub-agent IDs for validation.
200
+ * @returns {string | null} The chosen agent ID, or `null` if parsing fails or "NONE" is returned.
201
+ */
202
+ private parseLLMResponseForRouting;
203
+ /**
204
+ * Generates a prompt for the pool agent's internal LLM to synthesize outputs from multiple expert sub-agents.
205
+ *
206
+ * @private
207
+ * @param {string | null} originalUserInput - The initial user input that led to expert consultation.
208
+ * @param {ConversationContext} conversationContext - For overall context.
209
+ * @param {Array<{ agentId: string; agentName: string; agentDescription: string; output: AgentOutput; }>} expertResults - The outputs from consulted sub-agents.
210
+ * @returns {Partial<PromptComponents>} The components for constructing the synthesis prompt.
211
+ */
212
+ private generateSynthesisPrompt;
213
+ /**
214
+ * A helper method to potentially rephrase or wrap a sub-agent's output to align
215
+ * with the pool's unified persona, if one is configured. Also finalizes metadata.
216
+ *
217
+ * @private
218
+ * @param {AgentOutput} subAgentOutput - The output from the sub-agent.
219
+ * @param {IAgent} sourceAgent - The sub-agent that produced the output.
220
+ * @param {ConversationContext} conversationContext - For context if rephrasing LLM call is needed.
221
+ * @param {string} internalActionDescription - Description of the pool's internal action (e.g., "Routed to expert").
222
+ * @param {boolean} [isDirectDelegation=false] - If true, rephrasing might be lighter or skipped.
223
+ * @returns {Promise<AgentOutput>} The finalized (potentially rephrased) `AgentOutput`.
224
+ */
225
+ private synthesizeAndFinalizeOutput;
226
+ /**
227
+ * Overrides `handleToolResult` from `AgentCore`.
228
+ * This method is called when a tool initiated by the `AgentPoolAgent` itself completes.
229
+ * (Tools initiated by sub-agents are handled by their respective `handleToolResult` methods,
230
+ * and the orchestrator delivers the result to that sub-agent).
231
+ *
232
+ * The `AgentPoolAgent` might use tools for its meta-tasks, like a "SubAgentSelectionTool"
233
+ * or a "ContentAnalysisTool" to help in routing or synthesis.
234
+ *
235
+ * @override
236
+ * @param {string} toolCallId - The ID of the tool call this result pertains to.
237
+ * @param {any} toolOutput - The output from the tool execution.
238
+ * @param {string} toolName - The name of the tool that was called.
239
+ * @param {ConversationContext} conversationContext - The current conversation context.
240
+ * @returns {Promise<AgentOutput>} The pool agent's subsequent output after processing its own tool's result.
241
+ */
242
+ handleToolResult(toolCallId: string, toolOutput: any, toolName: string, conversationContext: ConversationContext): Promise<AgentOutput>;
243
+ }
244
+ //# sourceMappingURL=AgentPoolAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentPoolAgent.d.ts","sourceRoot":"","sources":["../../../src/core/agents/AgentPoolAgent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAqB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,SAAS,EAA2B,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGnE;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;;OAGG;IACH,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC;IAErB;;;;OAIG;IACH,gBAAgB,EAAE,eAAe,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,SAAU,YAAW,MAAM;IAC7D;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAE7C;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAkC;IAEnD;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAE9C;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB,CAAc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