keyring-agent-core 0.2.0 → 0.2.2

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 (417) hide show
  1. package/dist/index.d.ts +6692 -27
  2. package/dist/index.js +877 -70
  3. package/package.json +4 -3
  4. package/dist/agent/AgentCore.d.ts +0 -256
  5. package/dist/agent/AgentCore.d.ts.map +0 -1
  6. package/dist/agent/AgentCore.js +0 -1093
  7. package/dist/agent/AgentCore.js.map +0 -1
  8. package/dist/agent/QueryRewriter.d.ts +0 -84
  9. package/dist/agent/QueryRewriter.d.ts.map +0 -1
  10. package/dist/agent/QueryRewriter.js +0 -306
  11. package/dist/agent/QueryRewriter.js.map +0 -1
  12. package/dist/agent/Router.d.ts +0 -33
  13. package/dist/agent/Router.d.ts.map +0 -1
  14. package/dist/agent/Router.js +0 -229
  15. package/dist/agent/Router.js.map +0 -1
  16. package/dist/agent/Subagent.d.ts +0 -80
  17. package/dist/agent/Subagent.d.ts.map +0 -1
  18. package/dist/agent/Subagent.js +0 -272
  19. package/dist/agent/Subagent.js.map +0 -1
  20. package/dist/agent/Synthesizer.d.ts +0 -11
  21. package/dist/agent/Synthesizer.d.ts.map +0 -1
  22. package/dist/agent/Synthesizer.js +0 -86
  23. package/dist/agent/Synthesizer.js.map +0 -1
  24. package/dist/agent/chatGraph.d.ts +0 -364
  25. package/dist/agent/chatGraph.d.ts.map +0 -1
  26. package/dist/agent/chatGraph.js +0 -184
  27. package/dist/agent/chatGraph.js.map +0 -1
  28. package/dist/agent/index.d.ts +0 -10
  29. package/dist/agent/index.d.ts.map +0 -1
  30. package/dist/agent/index.js +0 -24
  31. package/dist/agent/index.js.map +0 -1
  32. package/dist/agent/subagents/AiAgent.d.ts +0 -6
  33. package/dist/agent/subagents/AiAgent.d.ts.map +0 -1
  34. package/dist/agent/subagents/AiAgent.js +0 -52
  35. package/dist/agent/subagents/AiAgent.js.map +0 -1
  36. package/dist/agent/subagents/NftAgent.d.ts +0 -6
  37. package/dist/agent/subagents/NftAgent.d.ts.map +0 -1
  38. package/dist/agent/subagents/NftAgent.js +0 -79
  39. package/dist/agent/subagents/NftAgent.js.map +0 -1
  40. package/dist/agent/subagents/PoolAgent.d.ts +0 -6
  41. package/dist/agent/subagents/PoolAgent.d.ts.map +0 -1
  42. package/dist/agent/subagents/PoolAgent.js +0 -184
  43. package/dist/agent/subagents/PoolAgent.js.map +0 -1
  44. package/dist/agent/subagents/PoolSubgraphAgent.d.ts +0 -6
  45. package/dist/agent/subagents/PoolSubgraphAgent.d.ts.map +0 -1
  46. package/dist/agent/subagents/PoolSubgraphAgent.js +0 -117
  47. package/dist/agent/subagents/PoolSubgraphAgent.js.map +0 -1
  48. package/dist/agent/subagents/TokenAgent.d.ts +0 -6
  49. package/dist/agent/subagents/TokenAgent.d.ts.map +0 -1
  50. package/dist/agent/subagents/TokenAgent.js +0 -76
  51. package/dist/agent/subagents/TokenAgent.js.map +0 -1
  52. package/dist/agent/subagents/WalletActionAgent.d.ts +0 -6
  53. package/dist/agent/subagents/WalletActionAgent.d.ts.map +0 -1
  54. package/dist/agent/subagents/WalletActionAgent.js +0 -55
  55. package/dist/agent/subagents/WalletActionAgent.js.map +0 -1
  56. package/dist/agent/subagents/WalletAgent.d.ts +0 -6
  57. package/dist/agent/subagents/WalletAgent.d.ts.map +0 -1
  58. package/dist/agent/subagents/WalletAgent.js +0 -93
  59. package/dist/agent/subagents/WalletAgent.js.map +0 -1
  60. package/dist/agent/subagents/index.d.ts +0 -34
  61. package/dist/agent/subagents/index.d.ts.map +0 -1
  62. package/dist/agent/subagents/index.js +0 -69
  63. package/dist/agent/subagents/index.js.map +0 -1
  64. package/dist/constants/abi.d.ts +0 -551
  65. package/dist/constants/abi.d.ts.map +0 -1
  66. package/dist/constants/abi.js +0 -690
  67. package/dist/constants/abi.js.map +0 -1
  68. package/dist/functions/pool.d.ts +0 -25
  69. package/dist/functions/pool.d.ts.map +0 -1
  70. package/dist/functions/pool.js +0 -151
  71. package/dist/functions/pool.js.map +0 -1
  72. package/dist/functions/web3.d.ts +0 -31
  73. package/dist/functions/web3.d.ts.map +0 -1
  74. package/dist/functions/web3.js +0 -232
  75. package/dist/functions/web3.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/llm/GeminiProvider.d.ts +0 -16
  79. package/dist/llm/GeminiProvider.d.ts.map +0 -1
  80. package/dist/llm/GeminiProvider.js +0 -329
  81. package/dist/llm/GeminiProvider.js.map +0 -1
  82. package/dist/llm/index.d.ts +0 -2
  83. package/dist/llm/index.d.ts.map +0 -1
  84. package/dist/llm/index.js +0 -6
  85. package/dist/llm/index.js.map +0 -1
  86. package/dist/memory/ChatHistory.d.ts +0 -83
  87. package/dist/memory/ChatHistory.d.ts.map +0 -1
  88. package/dist/memory/ChatHistory.js +0 -143
  89. package/dist/memory/ChatHistory.js.map +0 -1
  90. package/dist/memory/KnowledgeBase.d.ts +0 -38
  91. package/dist/memory/KnowledgeBase.d.ts.map +0 -1
  92. package/dist/memory/KnowledgeBase.js +0 -139
  93. package/dist/memory/KnowledgeBase.js.map +0 -1
  94. package/dist/memory/Summarizer.d.ts +0 -12
  95. package/dist/memory/Summarizer.d.ts.map +0 -1
  96. package/dist/memory/Summarizer.js +0 -39
  97. package/dist/memory/Summarizer.js.map +0 -1
  98. package/dist/memory/UpstashKnowledgeBase.d.ts +0 -124
  99. package/dist/memory/UpstashKnowledgeBase.d.ts.map +0 -1
  100. package/dist/memory/UpstashKnowledgeBase.js +0 -152
  101. package/dist/memory/UpstashKnowledgeBase.js.map +0 -1
  102. package/dist/memory/historyUtils.d.ts +0 -58
  103. package/dist/memory/historyUtils.d.ts.map +0 -1
  104. package/dist/memory/historyUtils.js +0 -190
  105. package/dist/memory/historyUtils.js.map +0 -1
  106. package/dist/memory/index.d.ts +0 -7
  107. package/dist/memory/index.d.ts.map +0 -1
  108. package/dist/memory/index.js +0 -12
  109. package/dist/memory/index.js.map +0 -1
  110. package/dist/memory/ingestKnowledgeBase.d.ts +0 -17
  111. package/dist/memory/ingestKnowledgeBase.d.ts.map +0 -1
  112. package/dist/memory/ingestKnowledgeBase.js +0 -35
  113. package/dist/memory/ingestKnowledgeBase.js.map +0 -1
  114. package/dist/services/MoralisService.d.ts +0 -1328
  115. package/dist/services/MoralisService.d.ts.map +0 -1
  116. package/dist/services/MoralisService.js +0 -1239
  117. package/dist/services/MoralisService.js.map +0 -1
  118. package/dist/services/PantographService.d.ts +0 -98
  119. package/dist/services/PantographService.d.ts.map +0 -1
  120. package/dist/services/PantographService.js +0 -451
  121. package/dist/services/PantographService.js.map +0 -1
  122. package/dist/services/PoolService.d.ts +0 -238
  123. package/dist/services/PoolService.d.ts.map +0 -1
  124. package/dist/services/PoolService.js +0 -485
  125. package/dist/services/PoolService.js.map +0 -1
  126. package/dist/services/UniswapService.d.ts +0 -289
  127. package/dist/services/UniswapService.d.ts.map +0 -1
  128. package/dist/services/UniswapService.js +0 -585
  129. package/dist/services/UniswapService.js.map +0 -1
  130. package/dist/services/UniswapSubgraphService.d.ts +0 -144
  131. package/dist/services/UniswapSubgraphService.d.ts.map +0 -1
  132. package/dist/services/UniswapSubgraphService.js +0 -606
  133. package/dist/services/UniswapSubgraphService.js.map +0 -1
  134. package/dist/services/rpc.d.ts +0 -35
  135. package/dist/services/rpc.d.ts.map +0 -1
  136. package/dist/services/rpc.js +0 -110
  137. package/dist/services/rpc.js.map +0 -1
  138. package/dist/services/swap/BaseSwapService.d.ts +0 -17
  139. package/dist/services/swap/BaseSwapService.d.ts.map +0 -1
  140. package/dist/services/swap/BaseSwapService.js +0 -19
  141. package/dist/services/swap/BaseSwapService.js.map +0 -1
  142. package/dist/services/swap/DebridgeAdapter.d.ts +0 -37
  143. package/dist/services/swap/DebridgeAdapter.d.ts.map +0 -1
  144. package/dist/services/swap/DebridgeAdapter.js +0 -243
  145. package/dist/services/swap/DebridgeAdapter.js.map +0 -1
  146. package/dist/services/swap/RelayAdapter.d.ts +0 -19
  147. package/dist/services/swap/RelayAdapter.d.ts.map +0 -1
  148. package/dist/services/swap/RelayAdapter.js +0 -189
  149. package/dist/services/swap/RelayAdapter.js.map +0 -1
  150. package/dist/services/swap/SwapServiceFactory.d.ts +0 -25
  151. package/dist/services/swap/SwapServiceFactory.d.ts.map +0 -1
  152. package/dist/services/swap/SwapServiceFactory.js +0 -79
  153. package/dist/services/swap/SwapServiceFactory.js.map +0 -1
  154. package/dist/services/swap/addresses.d.ts +0 -3
  155. package/dist/services/swap/addresses.d.ts.map +0 -1
  156. package/dist/services/swap/addresses.js +0 -68
  157. package/dist/services/swap/addresses.js.map +0 -1
  158. package/dist/services/swap/affiliate.d.ts +0 -17
  159. package/dist/services/swap/affiliate.d.ts.map +0 -1
  160. package/dist/services/swap/affiliate.js +0 -126
  161. package/dist/services/swap/affiliate.js.map +0 -1
  162. package/dist/services/swap/config.d.ts +0 -9
  163. package/dist/services/swap/config.d.ts.map +0 -1
  164. package/dist/services/swap/config.js +0 -19
  165. package/dist/services/swap/config.js.map +0 -1
  166. package/dist/services/swap/index.d.ts +0 -10
  167. package/dist/services/swap/index.d.ts.map +0 -1
  168. package/dist/services/swap/index.js +0 -22
  169. package/dist/services/swap/index.js.map +0 -1
  170. package/dist/services/swap/types.d.ts +0 -89
  171. package/dist/services/swap/types.d.ts.map +0 -1
  172. package/dist/services/swap/types.js +0 -6
  173. package/dist/services/swap/types.js.map +0 -1
  174. package/dist/tools/BaseTool.d.ts +0 -15
  175. package/dist/tools/BaseTool.d.ts.map +0 -1
  176. package/dist/tools/BaseTool.js +0 -35
  177. package/dist/tools/BaseTool.js.map +0 -1
  178. package/dist/tools/ToolRegistry.d.ts +0 -27
  179. package/dist/tools/ToolRegistry.d.ts.map +0 -1
  180. package/dist/tools/ToolRegistry.js +0 -80
  181. package/dist/tools/ToolRegistry.js.map +0 -1
  182. package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts +0 -36
  183. package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts.map +0 -1
  184. package/dist/tools/builtin/ai/GeminiSearchAiTool.js +0 -91
  185. package/dist/tools/builtin/ai/GeminiSearchAiTool.js.map +0 -1
  186. package/dist/tools/builtin/ai/index.d.ts +0 -3
  187. package/dist/tools/builtin/ai/index.d.ts.map +0 -1
  188. package/dist/tools/builtin/ai/index.js +0 -6
  189. package/dist/tools/builtin/ai/index.js.map +0 -1
  190. package/dist/tools/builtin/index.d.ts +0 -8
  191. package/dist/tools/builtin/index.d.ts.map +0 -1
  192. package/dist/tools/builtin/index.js +0 -24
  193. package/dist/tools/builtin/index.js.map +0 -1
  194. package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts +0 -35
  195. package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts.map +0 -1
  196. package/dist/tools/builtin/nft/BaseNftMessageTool.js +0 -45
  197. package/dist/tools/builtin/nft/BaseNftMessageTool.js.map +0 -1
  198. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +0 -15
  199. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +0 -1
  200. package/dist/tools/builtin/nft/NFTContractInfoTool.js +0 -19
  201. package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +0 -1
  202. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +0 -15
  203. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +0 -1
  204. package/dist/tools/builtin/nft/NFTMetadataTool.js +0 -20
  205. package/dist/tools/builtin/nft/NFTMetadataTool.js.map +0 -1
  206. package/dist/tools/builtin/nft/SendNftTool.d.ts +0 -14
  207. package/dist/tools/builtin/nft/SendNftTool.d.ts.map +0 -1
  208. package/dist/tools/builtin/nft/SendNftTool.js +0 -20
  209. package/dist/tools/builtin/nft/SendNftTool.js.map +0 -1
  210. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +0 -15
  211. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +0 -1
  212. package/dist/tools/builtin/nft/WalletNFTsTool.js +0 -20
  213. package/dist/tools/builtin/nft/WalletNFTsTool.js.map +0 -1
  214. package/dist/tools/builtin/nft/index.d.ts +0 -7
  215. package/dist/tools/builtin/nft/index.d.ts.map +0 -1
  216. package/dist/tools/builtin/nft/index.js +0 -10
  217. package/dist/tools/builtin/nft/index.js.map +0 -1
  218. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts +0 -124
  219. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +0 -1
  220. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +0 -236
  221. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +0 -1
  222. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +0 -128
  223. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +0 -1
  224. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +0 -520
  225. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +0 -1
  226. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts +0 -127
  227. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +0 -1
  228. package/dist/tools/builtin/pool/PoolByAddressTool.js +0 -238
  229. package/dist/tools/builtin/pool/PoolByAddressTool.js.map +0 -1
  230. package/dist/tools/builtin/pool/PoolDetailTool.d.ts +0 -127
  231. package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +0 -1
  232. package/dist/tools/builtin/pool/PoolDetailTool.js +0 -273
  233. package/dist/tools/builtin/pool/PoolDetailTool.js.map +0 -1
  234. package/dist/tools/builtin/pool/PoolSearchTool.d.ts +0 -50
  235. package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +0 -1
  236. package/dist/tools/builtin/pool/PoolSearchTool.js +0 -160
  237. package/dist/tools/builtin/pool/PoolSearchTool.js.map +0 -1
  238. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +0 -124
  239. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +0 -1
  240. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +0 -382
  241. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +0 -1
  242. package/dist/tools/builtin/pool/TopPoolsTool.d.ts +0 -68
  243. package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +0 -1
  244. package/dist/tools/builtin/pool/TopPoolsTool.js +0 -159
  245. package/dist/tools/builtin/pool/TopPoolsTool.js.map +0 -1
  246. package/dist/tools/builtin/pool/index.d.ts +0 -15
  247. package/dist/tools/builtin/pool/index.d.ts.map +0 -1
  248. package/dist/tools/builtin/pool/index.js +0 -18
  249. package/dist/tools/builtin/pool/index.js.map +0 -1
  250. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts +0 -54
  251. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts.map +0 -1
  252. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js +0 -98
  253. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js.map +0 -1
  254. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts +0 -63
  255. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts.map +0 -1
  256. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js +0 -82
  257. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js.map +0 -1
  258. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts +0 -79
  259. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts.map +0 -1
  260. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js +0 -97
  261. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js.map +0 -1
  262. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts +0 -77
  263. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts.map +0 -1
  264. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js +0 -190
  265. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js.map +0 -1
  266. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts +0 -107
  267. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts.map +0 -1
  268. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js +0 -92
  269. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js.map +0 -1
  270. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts +0 -56
  271. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts.map +0 -1
  272. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js +0 -94
  273. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js.map +0 -1
  274. package/dist/tools/builtin/pool-subgraph/index.d.ts +0 -13
  275. package/dist/tools/builtin/pool-subgraph/index.d.ts.map +0 -1
  276. package/dist/tools/builtin/pool-subgraph/index.js +0 -18
  277. package/dist/tools/builtin/pool-subgraph/index.js.map +0 -1
  278. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts +0 -71
  279. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +0 -1
  280. package/dist/tools/builtin/token/TokenAnalyticsTool.js +0 -147
  281. package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +0 -1
  282. package/dist/tools/builtin/token/TokenHoldersTool.d.ts +0 -81
  283. package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +0 -1
  284. package/dist/tools/builtin/token/TokenHoldersTool.js +0 -139
  285. package/dist/tools/builtin/token/TokenHoldersTool.js.map +0 -1
  286. package/dist/tools/builtin/token/TokenInfoTool.d.ts +0 -40
  287. package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +0 -1
  288. package/dist/tools/builtin/token/TokenInfoTool.js +0 -221
  289. package/dist/tools/builtin/token/TokenInfoTool.js.map +0 -1
  290. package/dist/tools/builtin/token/TokenScoreTool.d.ts +0 -63
  291. package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +0 -1
  292. package/dist/tools/builtin/token/TokenScoreTool.js +0 -148
  293. package/dist/tools/builtin/token/TokenScoreTool.js.map +0 -1
  294. package/dist/tools/builtin/token/TopGainersTool.d.ts +0 -37
  295. package/dist/tools/builtin/token/TopGainersTool.d.ts.map +0 -1
  296. package/dist/tools/builtin/token/TopGainersTool.js +0 -100
  297. package/dist/tools/builtin/token/TopGainersTool.js.map +0 -1
  298. package/dist/tools/builtin/token/TopLosersTool.d.ts +0 -66
  299. package/dist/tools/builtin/token/TopLosersTool.d.ts.map +0 -1
  300. package/dist/tools/builtin/token/TopLosersTool.js +0 -129
  301. package/dist/tools/builtin/token/TopLosersTool.js.map +0 -1
  302. package/dist/tools/builtin/token/TrendingTokensTool.d.ts +0 -39
  303. package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +0 -1
  304. package/dist/tools/builtin/token/TrendingTokensTool.js +0 -83
  305. package/dist/tools/builtin/token/TrendingTokensTool.js.map +0 -1
  306. package/dist/tools/builtin/token/index.d.ts +0 -13
  307. package/dist/tools/builtin/token/index.d.ts.map +0 -1
  308. package/dist/tools/builtin/token/index.js +0 -16
  309. package/dist/tools/builtin/token/index.js.map +0 -1
  310. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts +0 -70
  311. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +0 -1
  312. package/dist/tools/builtin/wallet/TransactionByHashTool.js +0 -111
  313. package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +0 -1
  314. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts +0 -107
  315. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +0 -1
  316. package/dist/tools/builtin/wallet/WalletApprovalsTool.js +0 -164
  317. package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +0 -1
  318. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts +0 -61
  319. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +0 -1
  320. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +0 -100
  321. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +0 -1
  322. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts +0 -68
  323. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +0 -1
  324. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +0 -115
  325. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +0 -1
  326. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts +0 -50
  327. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +0 -1
  328. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +0 -80
  329. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +0 -1
  330. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts +0 -31
  331. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +0 -1
  332. package/dist/tools/builtin/wallet/WalletHistoryTool.js +0 -154
  333. package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +0 -1
  334. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts +0 -44
  335. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts.map +0 -1
  336. package/dist/tools/builtin/wallet/WalletNetWorthTool.js +0 -122
  337. package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +0 -1
  338. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts +0 -86
  339. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +0 -1
  340. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +0 -265
  341. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +0 -1
  342. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts +0 -43
  343. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +0 -1
  344. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +0 -89
  345. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +0 -1
  346. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts +0 -43
  347. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +0 -1
  348. package/dist/tools/builtin/wallet/WalletPnlTool.js +0 -175
  349. package/dist/tools/builtin/wallet/WalletPnlTool.js.map +0 -1
  350. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts +0 -35
  351. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +0 -1
  352. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +0 -68
  353. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +0 -1
  354. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts +0 -109
  355. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +0 -1
  356. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +0 -354
  357. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +0 -1
  358. package/dist/tools/builtin/wallet/index.d.ts +0 -28
  359. package/dist/tools/builtin/wallet/index.d.ts.map +0 -1
  360. package/dist/tools/builtin/wallet/index.js +0 -32
  361. package/dist/tools/builtin/wallet/index.js.map +0 -1
  362. package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts +0 -25
  363. package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts.map +0 -1
  364. package/dist/tools/builtin/wallet-action/ApproveTokenTool.js +0 -98
  365. package/dist/tools/builtin/wallet-action/ApproveTokenTool.js.map +0 -1
  366. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts +0 -211
  367. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts.map +0 -1
  368. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js +0 -499
  369. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js.map +0 -1
  370. package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts +0 -240
  371. package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts.map +0 -1
  372. package/dist/tools/builtin/wallet-action/BuyTokenTool.js +0 -1257
  373. package/dist/tools/builtin/wallet-action/BuyTokenTool.js.map +0 -1
  374. package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts +0 -41
  375. package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts.map +0 -1
  376. package/dist/tools/builtin/wallet-action/SendNativeTool.js +0 -127
  377. package/dist/tools/builtin/wallet-action/SendNativeTool.js.map +0 -1
  378. package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts +0 -63
  379. package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts.map +0 -1
  380. package/dist/tools/builtin/wallet-action/SendTokenTool.js +0 -294
  381. package/dist/tools/builtin/wallet-action/SendTokenTool.js.map +0 -1
  382. package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts +0 -247
  383. package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts.map +0 -1
  384. package/dist/tools/builtin/wallet-action/SwapTokenTool.js +0 -1258
  385. package/dist/tools/builtin/wallet-action/SwapTokenTool.js.map +0 -1
  386. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts +0 -20
  387. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts.map +0 -1
  388. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js +0 -36
  389. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js.map +0 -1
  390. package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts +0 -23
  391. package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts.map +0 -1
  392. package/dist/tools/builtin/wallet-action/WrapNativeTool.js +0 -54
  393. package/dist/tools/builtin/wallet-action/WrapNativeTool.js.map +0 -1
  394. package/dist/tools/builtin/wallet-action/amountSpec.d.ts +0 -62
  395. package/dist/tools/builtin/wallet-action/amountSpec.d.ts.map +0 -1
  396. package/dist/tools/builtin/wallet-action/amountSpec.js +0 -93
  397. package/dist/tools/builtin/wallet-action/amountSpec.js.map +0 -1
  398. package/dist/tools/builtin/wallet-action/gasReserve.d.ts +0 -42
  399. package/dist/tools/builtin/wallet-action/gasReserve.d.ts.map +0 -1
  400. package/dist/tools/builtin/wallet-action/gasReserve.js +0 -103
  401. package/dist/tools/builtin/wallet-action/gasReserve.js.map +0 -1
  402. package/dist/tools/builtin/wallet-action/index.d.ts +0 -9
  403. package/dist/tools/builtin/wallet-action/index.d.ts.map +0 -1
  404. package/dist/tools/builtin/wallet-action/index.js +0 -20
  405. package/dist/tools/builtin/wallet-action/index.js.map +0 -1
  406. package/dist/tools/chainResolver.d.ts +0 -98
  407. package/dist/tools/chainResolver.d.ts.map +0 -1
  408. package/dist/tools/chainResolver.js +0 -302
  409. package/dist/tools/chainResolver.js.map +0 -1
  410. package/dist/tools/index.d.ts +0 -4
  411. package/dist/tools/index.d.ts.map +0 -1
  412. package/dist/tools/index.js +0 -23
  413. package/dist/tools/index.js.map +0 -1
  414. package/dist/types/index.d.ts +0 -777
  415. package/dist/types/index.d.ts.map +0 -1
  416. package/dist/types/index.js +0 -6
  417. package/dist/types/index.js.map +0 -1
@@ -1,229 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Router = void 0;
4
- const historyUtils_1 = require("../memory/historyUtils");
5
- const ROUTER_SYSTEM_PROMPT = `You are a ROUTER.
6
-
7
- The incoming user query has ALREADY been contextualized upstream — it is a
8
- self-contained, standalone question. Your ONLY job: decide which subagent(s)
9
- to call. You MUST NOT answer the user — output JSON only.
10
-
11
- ## OUTPUT FORMAT
12
-
13
- {
14
- "analysis": "<one-line intent summary in user's language>",
15
- "assignments": [
16
- {
17
- "subagent": "<exact subagent name>",
18
- "query": "<focused sub-query for that subagent, user's language>",
19
- "reasoning": "<one-line reason>"
20
- }
21
- ]
22
- }
23
-
24
- ## HOW TO DECIDE
25
-
26
- Read each subagent's description carefully — they fully define what each agent handles and what it does NOT handle.
27
- Apply this priority order:
28
-
29
- 1. Does the query match a specific subagent's described scope? → assign it.
30
- 2. Does it span multiple subagent scopes? → emit MULTIPLE assignments (they run in PARALLEL).
31
- 3. No specific subagent matches BUT the query is about blockchain / crypto / token / NFT / wallet / DeFi / on-chain data / smart contracts / any supported EVM chain → assign "ai-agent" with the user's original query.
32
- 4. Only return "assignments": [] for pure general knowledge, small-talk, or clearly non-crypto queries.
33
-
34
- NOTE: wallet-agent / token-agent / nft-agent each have an internal AI Cortex fallback,
35
- so it is safe to route a wallet/token/NFT-shaped query to its matching domain agent even
36
- if no specific structured tool obviously fits — the agent will fall back to Cortex on its own.
37
-
38
- ## HARD RULES
39
-
40
- - ONLY use subagent names from the provided list. NEVER invent names.
41
- - Keep each "query" focused and concise — do not copy the full user message if only part belongs to that subagent.
42
- - Do NOT include tool names, chain ids, or implementation details in the query field.
43
- - Match the user's language in all fields.`;
44
- /**
45
- * Router — top-level orchestrator in the Router → Subagent → Tool architecture.
46
- *
47
- * The router's LLM sees only subagent "cards" (name + one-liner), which keeps
48
- * the planning prompt small and predictable regardless of how many tools
49
- * each subagent owns.
50
- */
51
- class Router {
52
- llm;
53
- historyMessages;
54
- debug;
55
- constructor(llm, options) {
56
- this.llm = llm;
57
- // Wider default window so follow-ups ("the first one", "yes") can still
58
- // see the previous assistant reply even after a couple of short turns.
59
- this.historyMessages = options?.historyMessages ?? 10;
60
- this.debug = options?.debug ?? false;
61
- }
62
- /**
63
- * Ask the LLM to decide which subagent(s) should handle the query.
64
- * Returns `{ assignments: [] }` when no subagent is needed.
65
- *
66
- * @param lastSubagents Subagent(s) that handled the previous assistant
67
- * turn. Passed as a "sticky" hint — useful for short follow-ups.
68
- */
69
- async route(userQuery, conversationHistory, cards, userContext, lastSubagents = []) {
70
- const cardsText = cards.map((c) => `### ${c.name} (domain: ${c.domain})\n${c.description}`).join('\n\n');
71
- const contextParts = [];
72
- if (userContext?.walletAddress)
73
- contextParts.push(`Connected wallet: ${userContext.walletAddress}`);
74
- if (userContext?.chain)
75
- contextParts.push(`Current chain: ${userContext.chain}`);
76
- const contextSection = contextParts.length > 0 ? `\n\nUser context:\n${contextParts.join('\n')}` : '';
77
- // Sticky-routing hint: if the previous turn was handled by subagent X,
78
- // a follow-up very likely belongs to X too. The router is free to
79
- // override when the query clearly belongs elsewhere.
80
- const stickyHint = lastSubagents.length > 0
81
- ? `\n\nPrevious turn handled by: ${lastSubagents.join(', ')}. ` +
82
- `If this query is a natural continuation (same topic), prefer the same subagent(s). ` +
83
- `Override only if the query clearly belongs to a different domain.`
84
- : '';
85
- // Router has NO tools declared, so strip tool messages (otherwise Gemini
86
- // sees orphan functionResponse parts). Then keep the recent window
87
- // without splitting any remaining tool-call group.
88
- const cleanHistory = (0, historyUtils_1.stripToolMessages)(conversationHistory);
89
- const windowed = (0, historyUtils_1.sliceRecentKeepingToolPairs)(cleanHistory, this.historyMessages);
90
- if (this.debug) {
91
- console.log(`\n[Router] history window (${windowed.length} msg${windowed.length === 1 ? '' : 's'}):`);
92
- console.log(`[Router] user query: "${userQuery}"`);
93
- }
94
- const messages = [
95
- { role: 'system', content: ROUTER_SYSTEM_PROMPT, timestamp: 0 },
96
- ...windowed,
97
- {
98
- role: 'user',
99
- content: `Available subagents:\n${cardsText}${contextSection}${stickyHint}\n\nUser query: ${userQuery}`,
100
- timestamp: Date.now(),
101
- },
102
- ];
103
- const t0 = Date.now();
104
- // The router LLM occasionally answers in prose ("I can help you send USDC…")
105
- // instead of the required JSON. Retry once, re-prompting it to emit ONLY
106
- // JSON, before giving up and falling back to a direct answer.
107
- let parsed = null;
108
- let lastRaw = '';
109
- let lastErr = null;
110
- for (let attempt = 1; attempt <= 2; attempt++) {
111
- const response = await this.llm.chat(messages);
112
- lastRaw = response.text;
113
- try {
114
- parsed = this.parseJSON(response.text);
115
- break;
116
- }
117
- catch (err) {
118
- lastErr = err;
119
- if (attempt < 2) {
120
- if (this.debug)
121
- console.log(`[Router] JSON parse failed (attempt ${attempt}) — re-prompting for JSON`);
122
- messages.push({ role: 'assistant', content: response.text || '', timestamp: Date.now() });
123
- messages.push({
124
- role: 'user',
125
- content: 'That response was not valid JSON. Do NOT answer the user and do NOT ask any questions. ' +
126
- 'Reply with ONLY the routing JSON object ' +
127
- '({"analysis": "...", "assignments": [...]}) and nothing else.',
128
- timestamp: Date.now(),
129
- });
130
- }
131
- }
132
- }
133
- const routerMs = Date.now() - t0;
134
- if (!parsed) {
135
- if (this.debug) {
136
- console.log(`[Router] JSON parse failed after retry: ${lastErr}`);
137
- console.log(`[Router] raw response: ${lastRaw.slice(0, 300)}`);
138
- }
139
- return { analysis: 'Router could not parse response.', assignments: [] };
140
- }
141
- const validNames = new Set(cards.map((c) => c.name));
142
- const assignments = Array.isArray(parsed.assignments)
143
- ? parsed.assignments
144
- .filter((a) => !!a && typeof a.subagent === 'string')
145
- .filter((a) => validNames.has(a.subagent))
146
- .map((a) => ({
147
- subagent: a.subagent,
148
- query: typeof a.query === 'string' && a.query ? a.query : userQuery,
149
- reasoning: typeof a.reasoning === 'string' ? a.reasoning : '',
150
- }))
151
- : [];
152
- if (this.debug) {
153
- const label = assignments.length > 0 ? assignments.map((a) => a.subagent).join(', ') : '(none — direct answer)';
154
- console.log(`\n[Router] (${routerMs}ms)`);
155
- console.log(` analysis : ${parsed.analysis ?? ''}`);
156
- console.log(` dispatch : ${label}`);
157
- if (assignments.length > 0) {
158
- for (const a of assignments) {
159
- console.log(` → ${a.subagent}: "${a.query}"`);
160
- console.log(` reason: ${a.reasoning}`);
161
- }
162
- }
163
- }
164
- return {
165
- analysis: typeof parsed.analysis === 'string' ? parsed.analysis : '',
166
- assignments,
167
- };
168
- }
169
- /**
170
- * Dispatch assignments to the matching subagents in parallel.
171
- * Each subagent runs its own ReAct loop and returns a SubagentResult.
172
- */
173
- async dispatch(decision, subagents, conversationHistory, userContext) {
174
- if (decision.assignments.length === 0)
175
- return [];
176
- if (this.debug) {
177
- console.log(`\n[Router] dispatching ${decision.assignments.length} subagent(s) in parallel…`);
178
- }
179
- const t0 = Date.now();
180
- const runs = decision.assignments.map(async (a) => {
181
- const agent = subagents.get(a.subagent);
182
- if (!agent) {
183
- if (this.debug)
184
- console.log(`[Router] WARN: subagent "${a.subagent}" not registered`);
185
- return {
186
- subagentName: a.subagent,
187
- steps: [],
188
- finalAnswer: `Subagent "${a.subagent}" is not registered.`,
189
- toolResults: [],
190
- toolMessages: [],
191
- };
192
- }
193
- const t1 = Date.now();
194
- const result = await agent.run({ query: a.query, reasoning: a.reasoning }, conversationHistory, userContext);
195
- if (this.debug) {
196
- const toolNames = result.toolResults.map((r) => r.toolName).join(', ') || '—';
197
- console.log(`[Router] ${a.subagent} done in ${Date.now() - t1}ms | tools: ${toolNames}`);
198
- }
199
- return result;
200
- });
201
- const results = await Promise.all(runs);
202
- if (this.debug) {
203
- console.log(`[Router] all subagents done in ${Date.now() - t0}ms total`);
204
- }
205
- return results;
206
- }
207
- parseJSON(text) {
208
- let clean = text.trim();
209
- if (clean.startsWith('```')) {
210
- clean = clean
211
- .replace(/^```(?:json)?\s*/, '')
212
- .replace(/```\s*$/, '')
213
- .trim();
214
- }
215
- try {
216
- return JSON.parse(clean);
217
- }
218
- catch (err) {
219
- // Salvage a JSON object embedded in prose (model prepended a sentence
220
- // before the object). Grab from the first "{" to the last "}".
221
- const match = clean.match(/\{[\s\S]*\}/);
222
- if (match)
223
- return JSON.parse(match[0]);
224
- throw err;
225
- }
226
- }
227
- }
228
- exports.Router = Router;
229
- //# sourceMappingURL=Router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../src/agent/Router.ts"],"names":[],"mappings":";;;AAUA,yDAAwF;AAExF,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAsCc,CAAC;AAE5C;;;;;;GAMG;AACH,MAAa,MAAM;IACT,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;iBACtB,IAAI,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,sEAAsE;YACtE,+DAA+D;YAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YACzC,IAAI,KAAK;gBAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACvC,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAvMD,wBAuMC"}
@@ -1,80 +0,0 @@
1
- import type { ChatMessage, LLMProvider, SubagentCard, SubagentResult, SubagentTask, UserContext } from '../types';
2
- import type { ToolRegistry } from '../tools/ToolRegistry';
3
- export interface SubagentOptions {
4
- /** Max number of tool calls inside one run (budget). Default: 5 */
5
- maxToolCalls?: number;
6
- /** Max tokens of recent conversation history to include. Default: 6 messages */
7
- historyMessages?: number;
8
- /** Enable debug logging */
9
- debug?: boolean;
10
- /**
11
- * Website link for adding liquidity / creating a pool, sourced from
12
- * `AgentConfig.subgraph.linkAddLiquidity`. Only the `pool-subgraph` subagent
13
- * uses it: when set, its prompt is told to append this URL whenever the user
14
- * asks to add liquidity. Ignored by every other subagent.
15
- */
16
- linkAddLiquidity?: string;
17
- }
18
- export interface SubagentParams {
19
- /** Unique id, e.g. "wallet-agent" */
20
- name: string;
21
- /** Capability description shown to the router LLM (dense, one-liner) */
22
- description: string;
23
- /** Domain tag, e.g. "wallet" */
24
- domain: string;
25
- /** Tool names this subagent is allowed to invoke. */
26
- toolNames: string[];
27
- /** Domain-expert system prompt */
28
- systemPrompt: string;
29
- /**
30
- * Optional Cortex AI fallback tool name. When set, if the first LLM turn
31
- * returns no tool calls, the subagent re-prompts the LLM and forces it to
32
- * call this tool — guaranteeing the user's query goes to Cortex instead of
33
- * being answered by the LLM's own knowledge with no on-chain data.
34
- */
35
- cortexFallbackTool?: string;
36
- /**
37
- * When true, this subagent must act via a tool on every routed query — it
38
- * may never answer with plain text on the first turn. If the LLM tries to
39
- * (e.g. asks "which token?" instead of opening the form), the subagent
40
- * re-prompts once forcing it to pick the matching tool. Used by the
41
- * wallet-action agent, whose whole job is to emit a form. Ignored when
42
- * `cortexFallbackTool` is set (that path already forces a tool).
43
- */
44
- mustCallTool?: boolean;
45
- llm: LLMProvider;
46
- registry: ToolRegistry;
47
- options?: SubagentOptions;
48
- }
49
- /**
50
- * Domain-specialised worker in the Router → Subagent → Tool architecture.
51
- *
52
- * Each subagent:
53
- * - owns a narrow subset of tools (by name)
54
- * - runs its own ReAct loop via native function calling
55
- * - produces a domain-scoped summary + the raw tool results
56
- *
57
- * Keeping each subagent's tool surface small is the main token-cost win:
58
- * the LLM receives only ~5 tool schemas instead of ~23.
59
- */
60
- export declare class Subagent {
61
- readonly name: string;
62
- readonly description: string;
63
- readonly domain: string;
64
- private readonly toolNames;
65
- private readonly systemPrompt;
66
- private readonly cortexFallbackTool?;
67
- private readonly mustCallTool;
68
- private readonly llm;
69
- private readonly registry;
70
- private readonly maxToolCalls;
71
- private readonly historyMessages;
72
- private readonly debug;
73
- constructor(params: SubagentParams);
74
- /** Card shown to the router for selection. */
75
- getCard(): SubagentCard;
76
- /** Only the tools this subagent owns, resolved from the shared registry. */
77
- private getTools;
78
- run(task: SubagentTask, conversationHistory: ChatMessage[], userContext?: UserContext): Promise<SubagentResult>;
79
- }
80
- //# sourceMappingURL=Subagent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Subagent.d.ts","sourceRoot":"","sources":["../../src/agent/Subagent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EAEX,YAAY,EACZ,cAAc,EACd,YAAY,EAGZ,WAAW,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,MAAM,W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CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,MAAM,EAAE,cAAc;IAsBlC,8CAA8C;IAC9C,OAAO,IAAI,YAAY;IAIvB,4EAA4E;IAC5E,OAAO,CAAC,QAAQ;IAIV,GAAG,CACP,IAAI,EAAE,YAAY,EAClB,mBAAmB,EAAE,WAAW,EAAE,EAClC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,cAAc,CAAC;CAgP3B"}
@@ -1,272 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Subagent = void 0;
4
- const historyUtils_1 = require("../memory/historyUtils");
5
- /**
6
- * Domain-specialised worker in the Router → Subagent → Tool architecture.
7
- *
8
- * Each subagent:
9
- * - owns a narrow subset of tools (by name)
10
- * - runs its own ReAct loop via native function calling
11
- * - produces a domain-scoped summary + the raw tool results
12
- *
13
- * Keeping each subagent's tool surface small is the main token-cost win:
14
- * the LLM receives only ~5 tool schemas instead of ~23.
15
- */
16
- class Subagent {
17
- name;
18
- description;
19
- domain;
20
- toolNames;
21
- systemPrompt;
22
- cortexFallbackTool;
23
- mustCallTool;
24
- llm;
25
- registry;
26
- maxToolCalls;
27
- historyMessages;
28
- debug;
29
- constructor(params) {
30
- this.name = params.name;
31
- this.description = params.description;
32
- this.domain = params.domain;
33
- this.toolNames = new Set(params.toolNames);
34
- this.systemPrompt = params.systemPrompt;
35
- this.cortexFallbackTool = params.cortexFallbackTool;
36
- this.mustCallTool = params.mustCallTool ?? false;
37
- if (this.cortexFallbackTool && !this.toolNames.has(this.cortexFallbackTool)) {
38
- throw new Error(`Subagent "${params.name}": cortexFallbackTool "${this.cortexFallbackTool}" must be in toolNames.`);
39
- }
40
- this.llm = params.llm;
41
- this.registry = params.registry;
42
- this.maxToolCalls = params.options?.maxToolCalls ?? 5;
43
- // Wider default window so follow-up turns ("detail the first one", "more")
44
- // can still see the previous assistant reply + tool results they reference.
45
- this.historyMessages = params.options?.historyMessages ?? 10;
46
- this.debug = params.options?.debug ?? false;
47
- }
48
- /** Card shown to the router for selection. */
49
- getCard() {
50
- return { name: this.name, description: this.description, domain: this.domain };
51
- }
52
- /** Only the tools this subagent owns, resolved from the shared registry. */
53
- getTools() {
54
- return this.registry.getDefinitions().filter((t) => this.toolNames.has(t.name));
55
- }
56
- async run(task, conversationHistory, userContext) {
57
- const tools = this.getTools();
58
- if (this.debug) {
59
- console.log(`\n [${this.name}] query: "${task.query}"`);
60
- console.log(` [${this.name}] tools available: ${tools.map((t) => t.name).join(', ')}`);
61
- }
62
- if (tools.length === 0) {
63
- return {
64
- subagentName: this.name,
65
- steps: [],
66
- finalAnswer: `Subagent "${this.name}" has no registered tools available.`,
67
- toolResults: [],
68
- toolMessages: [],
69
- };
70
- }
71
- const trace = [];
72
- const toolResults = [];
73
- // Interleaved assistant+toolCalls / role:'tool' messages for ChatHistory
74
- const toolMessages = [];
75
- const calledKeys = new Set();
76
- let toolCallCount = 0;
77
- // Guards the one-shot "you must call a tool" re-prompt (see mustCallTool).
78
- let forcedToolRetry = false;
79
- const contextParts = [];
80
- if (userContext?.walletAddress)
81
- contextParts.push(`Connected wallet: ${userContext.walletAddress}`);
82
- if (userContext?.chain)
83
- contextParts.push(`Current chain: ${userContext.chain}`);
84
- const contextSection = contextParts.length > 0 ? `User context:\n${contextParts.join('\n')}` : '';
85
- // Tell the LLM the exact language of the current turn. The Routed query is
86
- // already in the user's language, but short/normalized queries can read as
87
- // English and make the model default any generated strings (e.g. localized
88
- // tool arguments like action-button prompts) to English. Stating the tag
89
- // explicitly removes that ambiguity.
90
- const languageLine = task.language
91
- ? `The user's current language is "${task.language}" (BCP-47). Write every user-facing string ` +
92
- `you produce — replies AND any localized tool arguments — in this language.`
93
- : '';
94
- const userContent = [
95
- contextSection,
96
- languageLine,
97
- `Routed query: ${task.query}`,
98
- task.reasoning ? `Router reasoning: ${task.reasoning}` : '',
99
- "Use only the tools you own. If you already have enough information, respond directly in the user's language.",
100
- ]
101
- .filter(Boolean)
102
- .join('\n\n');
103
- // Filter history so only tool messages this subagent owns survive (orphan
104
- // functionResponse parts would confuse Gemini since its tool schema only
105
- // contains this subagent's tools). Then keep a recent window without
106
- // splitting any remaining tool-call group.
107
- const filteredHistory = (0, historyUtils_1.filterToolMessagesForSubagent)(conversationHistory, this.toolNames);
108
- const windowed = (0, historyUtils_1.sliceRecentKeepingToolPairs)(filteredHistory, this.historyMessages);
109
- const messages = [
110
- { role: 'system', content: this.systemPrompt, timestamp: 0 },
111
- ...windowed,
112
- { role: 'user', content: userContent, timestamp: Date.now() },
113
- ];
114
- // Max chars stored per tool result in history.
115
- // Must be large enough to preserve: transaction hashes (66 chars each),
116
- // pagination cursors (100–300 chars), and enough transactions for
117
- // follow-up lookups ("details of this tx"). 6000 chars ≈ 5–6 transactions
118
- // with full ERC-20 transfer data while keeping context cost acceptable.
119
- const TOOL_RESULT_MAX_CHARS = 6000;
120
- const maxIterations = this.maxToolCalls + 2;
121
- for (let i = 0; i < maxIterations; i++) {
122
- const budgetLeft = toolCallCount < this.maxToolCalls;
123
- const toolsThisTurn = budgetLeft ? tools : undefined;
124
- const response = await this.llm.chat(messages, toolsThisTurn);
125
- if (response.toolCalls.length === 0) {
126
- // First-turn safety net: the subagent owns tools but the LLM tried to
127
- // answer from its own knowledge. If a Cortex fallback is declared,
128
- // re-prompt the LLM and force it to call Cortex with the user's query.
129
- // This guarantees on-chain-shaped questions never get a hallucinated
130
- // answer with zero tool calls.
131
- if (toolCallCount === 0 && this.cortexFallbackTool && budgetLeft) {
132
- if (this.debug) {
133
- console.log(` [${this.name}] no tool called — forcing fallback to ${this.cortexFallbackTool}`);
134
- }
135
- messages.push({
136
- role: 'user',
137
- content: `You answered without calling any tool. This is not allowed for on-chain queries. ` +
138
- `Call "${this.cortexFallbackTool}" now with a clear, well-formed English prompt that captures the user's intent. ` +
139
- `Resolve ambiguity with sensible defaults (chain: Ethereum unless specified; result count: top 10; ` +
140
- `time window: last 24h; sort key: 24h volume for "top/best/trending" queries). ` +
141
- `Do NOT answer in text — call the tool.`,
142
- timestamp: Date.now(),
143
- });
144
- continue;
145
- }
146
- // Action subagents (mustCallTool) must open a form via a tool — they may
147
- // never stop to ask the user for missing fields. Force one retry where
148
- // the LLM picks the matching tool itself.
149
- if (toolCallCount === 0 && this.mustCallTool && budgetLeft && !forcedToolRetry) {
150
- forcedToolRetry = true;
151
- if (this.debug) {
152
- console.log(` [${this.name}] no tool called — forcing the LLM to pick a tool`);
153
- }
154
- messages.push({
155
- role: 'user',
156
- content: `You answered in text without calling any tool. That is not allowed here: this request needs you to open a form. ` +
157
- `Call exactly ONE of your tools that matches the user's intent now. Pass only the fields the user actually gave; ` +
158
- `leave everything else blank — the tool/form collects the rest (including a token/amount picker when needed). ` +
159
- `Do NOT ask the user for missing fields. Do NOT answer in text — call the tool.`,
160
- timestamp: Date.now(),
161
- });
162
- continue;
163
- }
164
- if (this.debug) {
165
- console.log(` [${this.name}] done — ${toolCallCount} tool call(s), answer: "${response.text.slice(0, 80)}…"`);
166
- }
167
- return { subagentName: this.name, steps: trace, finalAnswer: response.text, toolResults, toolMessages };
168
- }
169
- // The assistant message sent to Gemini for this iteration.
170
- // We push it to `messages` now and will push to `toolMessages` only if
171
- // at least one valid tool call succeeds in this iteration.
172
- const assistantMsg = {
173
- role: 'assistant',
174
- content: response.text || '',
175
- toolCalls: response.toolCalls,
176
- timestamp: Date.now(),
177
- };
178
- messages.push(assistantMsg);
179
- // Collect per-iteration valid tool results before deciding what to store.
180
- const iterationToolMsgs = [];
181
- for (const tc of response.toolCalls) {
182
- if (!this.toolNames.has(tc.toolName)) {
183
- const err = `Tool "${tc.toolName}" is not owned by ${this.name}`;
184
- if (this.debug)
185
- console.log(` [${this.name}] WARN: ${err}`);
186
- trace.push({ phase: 'observe', content: err, timestamp: Date.now() });
187
- messages.push({
188
- role: 'tool',
189
- content: err,
190
- toolName: tc.toolName,
191
- toolCallId: tc.callId,
192
- timestamp: Date.now(),
193
- });
194
- continue;
195
- }
196
- const key = `${tc.toolName}::${JSON.stringify(tc.args)}`;
197
- if (calledKeys.has(key)) {
198
- const skip = `Skipped duplicate call: ${tc.toolName}`;
199
- if (this.debug)
200
- console.log(` [${this.name}] SKIP duplicate: ${tc.toolName}`);
201
- trace.push({ phase: 'observe', content: skip, timestamp: Date.now() });
202
- messages.push({
203
- role: 'tool',
204
- content: skip,
205
- toolName: tc.toolName,
206
- toolCallId: tc.callId,
207
- timestamp: Date.now(),
208
- });
209
- continue;
210
- }
211
- calledKeys.add(key);
212
- toolCallCount++;
213
- if (this.debug) {
214
- console.log(` [${this.name}] call #${toolCallCount}: ${tc.toolName} ${JSON.stringify(tc.args)}`);
215
- }
216
- trace.push({ phase: 'think', content: response.text || `Calling ${tc.toolName}`, timestamp: Date.now() });
217
- trace.push({
218
- phase: 'act',
219
- content: `Calling tool: ${tc.toolName}`,
220
- toolCall: { toolName: tc.toolName, args: tc.args },
221
- timestamp: Date.now(),
222
- });
223
- const t0 = Date.now();
224
- const result = await this.registry.execute(tc.toolName, tc.args, userContext);
225
- toolResults.push(result);
226
- const observation = result.success ? JSON.stringify(result.data) : `Error: ${result.error}`;
227
- if (this.debug) {
228
- const status = result.success ? 'OK' : 'ERR';
229
- const preview = result.success
230
- ? `${observation.slice(0, 120)}${observation.length > 120 ? '…' : ''}`
231
- : result.error;
232
- console.log(` [${this.name}] ${status} (${Date.now() - t0}ms): ${preview}`);
233
- }
234
- trace.push({ phase: 'observe', content: observation, toolResult: result, timestamp: Date.now() });
235
- const toolMsg = {
236
- role: 'tool',
237
- content: observation,
238
- toolName: tc.toolName,
239
- toolCallId: tc.callId,
240
- timestamp: Date.now(),
241
- };
242
- messages.push(toolMsg);
243
- // Store a size-capped version in history so cursors + key data survive
244
- // across turns without ballooning the context window.
245
- iterationToolMsgs.push({
246
- ...toolMsg,
247
- content: observation.length > TOOL_RESULT_MAX_CHARS
248
- ? observation.slice(0, TOOL_RESULT_MAX_CHARS) + '…[truncated]'
249
- : observation,
250
- });
251
- }
252
- // If any valid tool was called this iteration, persist the assistant
253
- // function-call message + truncated results into toolMessages.
254
- if (iterationToolMsgs.length > 0) {
255
- toolMessages.push(assistantMsg);
256
- toolMessages.push(...iterationToolMsgs);
257
- }
258
- }
259
- if (this.debug) {
260
- console.log(` [${this.name}] budget exhausted after ${toolCallCount} calls, forcing final answer`);
261
- }
262
- messages.push({
263
- role: 'user',
264
- content: 'Tool budget reached. Give your best answer now based on the data gathered.',
265
- timestamp: Date.now(),
266
- });
267
- const final = await this.llm.chat(messages);
268
- return { subagentName: this.name, steps: trace, finalAnswer: final.text, toolResults, toolMessages };
269
- }
270
- }
271
- exports.Subagent = Subagent;
272
- //# sourceMappingURL=Subagent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Subagent.js","sourceRoot":"","sources":["../../src/agent/Subagent.ts"],"names":[],"mappings":";;;AAYA,yDAAoG;AAkDpG;;;;;;;;;;GAUG;AACH,MAAa,QAAQ;IACV,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,MAAM,CAAS;IACP,SAAS,CAAc;IACvB,YAAY,CAAS;IACrB,kBAAkB,CAAU;IAC5B,YAAY,CAAU;IACtB,GAAG,CAAc;IACjB,QAAQ,CAAe;IACvB,YAAY,CAAS;IACrB,eAAe,CAAS;IACxB,KAAK,CAAU;IAEhC,YAAY,MAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;QACpD,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAA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AAC,GAAG,iBAAiB,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,4BAA4B,aAAa,8BAA8B,CAAC,CAAC;QACtG,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,4EAA4E;YACrF,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IACvG,CAAC;CACF;AAlSD,4BAkSC"}
@@ -1,11 +0,0 @@
1
- import type { ChatMessage, LLMProvider, ReActTrace } from '../types';
2
- /**
3
- * Takes the ReAct execution trace and produces a polished
4
- * final response suitable for the end user.
5
- */
6
- export declare class Synthesizer {
7
- private llm;
8
- constructor(llm: LLMProvider);
9
- synthesise(userQuery: string, trace: ReActTrace, conversationHistory: ChatMessage[], language?: string): Promise<string>;
10
- }
11
- //# sourceMappingURL=Synthesizer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Synthesizer.d.ts","sourceRoot":"","sources":["../../src/agent/Synthesizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAcrE;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAItB,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,UAAU,EACjB,mBAAmB,EAAE,WAAW,EAAE,EAClC,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC;CAoDnB"}