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,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KnowledgeBase = void 0;
4
- const KB_MATCH_PROMPT = `You are a strict FAQ matcher. Given a user query and a list of FAQ entries, determine which FAQ entries the user is SPECIFICALLY asking about.
5
-
6
- RULES:
7
- - Only match when the user's question is CLEARLY about the same topic as the FAQ entry.
8
- - Do NOT match loosely related topics. For example, if the user asks about "ETH price" and a FAQ is about "What is staking?", that is NOT a match — they are different topics.
9
- - Match by MEANING, not exact words. The user may ask in any language or use synonyms.
10
- - Return a JSON array of objects: [{"index": <0-based index>, "score": <0.0 to 1.0>}]
11
- - score >= 0.8 = the user is asking essentially the same question as the FAQ
12
- - score 0.6-0.8 = the FAQ directly addresses the user's question
13
- - score < 0.6 = NOT a match, do NOT include
14
- - If no entries match, return an empty array: []
15
- - When in doubt, do NOT match. Precision is more important than recall.
16
- - Return ONLY the JSON array, no other text.
17
-
18
- FAQ ENTRIES:
19
- `;
20
- /**
21
- * Knowledge base with LLM-powered semantic matching.
22
- * Supports cross-language queries and synonym understanding.
23
- *
24
- * Suitable for small KBs (≲ 50 entries) — every search sends the full FAQ
25
- * list to the LLM. For larger KBs use `UpstashKnowledgeBase` (vector search).
26
- */
27
- class KnowledgeBase {
28
- entries = [];
29
- llm = null;
30
- constructor(entries) {
31
- if (entries)
32
- this.entries = entries;
33
- }
34
- /** Attach an LLM provider for semantic matching. */
35
- setLLM(llm) {
36
- this.llm = llm;
37
- }
38
- /** Replace all entries. */
39
- setEntries(entries) {
40
- this.entries = entries;
41
- }
42
- /** Add entries without replacing existing ones. */
43
- addEntries(entries) {
44
- this.entries.push(...entries);
45
- }
46
- /** Snapshot of current entries (defensive copy). */
47
- getEntries() {
48
- return this.entries.slice();
49
- }
50
- /** Get total entry count. */
51
- get size() {
52
- return this.entries.length;
53
- }
54
- /**
55
- * Search for entries relevant to the user query using LLM semantic matching.
56
- * Falls back to basic token matching if LLM is not available.
57
- */
58
- async search(query, maxResults = 3) {
59
- if (this.entries.length === 0)
60
- return [];
61
- if (this.llm) {
62
- return this.llmSearch(query, maxResults);
63
- }
64
- // Fallback: basic token matching (same language only)
65
- return this.tokenSearch(query, maxResults, 0.25);
66
- }
67
- /** LLM-based semantic search — handles any language + synonyms. */
68
- async llmSearch(query, maxResults) {
69
- // Build FAQ list for the prompt (only questions, to keep it short)
70
- const faqList = this.entries.map((e, i) => `[${i}] ${e.question}`).join('\n');
71
- const messages = [
72
- {
73
- role: 'user',
74
- content: KB_MATCH_PROMPT + faqList + `\n\nUSER QUERY: ${query}`,
75
- timestamp: 0,
76
- },
77
- ];
78
- try {
79
- const response = await this.llm.chat(messages);
80
- const text = response.text.trim();
81
- // Extract JSON array from response
82
- const jsonMatch = text.match(/\[[\s\S]*\]/);
83
- if (!jsonMatch)
84
- return [];
85
- const matches = JSON.parse(jsonMatch[0]);
86
- const results = [];
87
- for (const m of matches) {
88
- if (m.index >= 0 && m.index < this.entries.length && m.score >= 0.6) {
89
- results.push({ entry: this.entries[m.index], score: m.score });
90
- }
91
- }
92
- results.sort((a, b) => b.score - a.score);
93
- return results.slice(0, maxResults);
94
- }
95
- catch {
96
- // If LLM fails, fall back to token search
97
- return this.tokenSearch(query, maxResults, 0.25);
98
- }
99
- }
100
- /** Basic token-overlap search (fallback). */
101
- tokenSearch(query, maxResults, threshold) {
102
- const queryTokens = this.tokenize(query);
103
- if (queryTokens.size === 0)
104
- return [];
105
- const scored = [];
106
- for (const entry of this.entries) {
107
- const entryTokens = this.tokenize(entry.question);
108
- const score = this.jaccardSimilarity(queryTokens, entryTokens);
109
- if (score >= threshold) {
110
- scored.push({ entry, score });
111
- }
112
- }
113
- scored.sort((a, b) => b.score - a.score);
114
- return scored.slice(0, maxResults);
115
- }
116
- /** Tokenize text into a set of normalized words. */
117
- tokenize(text) {
118
- const words = text
119
- .toLowerCase()
120
- .replace(/[^\p{L}\p{N}\s]/gu, ' ')
121
- .split(/\s+/)
122
- .filter((w) => w.length > 1);
123
- return new Set(words);
124
- }
125
- /** Jaccard similarity: |A ∩ B| / |A ∪ B| */
126
- jaccardSimilarity(a, b) {
127
- if (a.size === 0 || b.size === 0)
128
- return 0;
129
- let intersection = 0;
130
- for (const token of a) {
131
- if (b.has(token))
132
- intersection++;
133
- }
134
- const union = a.size + b.size - intersection;
135
- return union === 0 ? 0 : intersection / union;
136
- }
137
- }
138
- exports.KnowledgeBase = KnowledgeBase;
139
- //# sourceMappingURL=KnowledgeBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KnowledgeBase.js","sourceRoot":"","sources":["../../src/memory/KnowledgeBase.ts"],"names":[],"mappings":";;;AAKA,MAAM,eAAe,GAAG;;;;;;;;;;;;;;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,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,4CAA4C;IACpC,iBAAiB,CAAC,CAAc,EAAE,CAAc;QACtD,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAE3C,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,KAAK,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,YAAY,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC;QAC7C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,KAAK,CAAC;IAChD,CAAC;CACF;AAhID,sCAgIC"}
@@ -1,12 +0,0 @@
1
- import type { LLMProvider, ChatMessage } from '../types';
2
- /**
3
- * Uses the LLM to produce a compact summary of a conversation,
4
- * so old messages can be replaced with the summary to save tokens.
5
- */
6
- export declare class Summarizer {
7
- private llm;
8
- constructor(llm: LLMProvider);
9
- /** Summarise an array of messages into a short paragraph. */
10
- summarize(messages: ChatMessage[]): Promise<string>;
11
- }
12
- //# sourceMappingURL=Summarizer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Summarizer.d.ts","sourceRoot":"","sources":["../../src/memory/Summarizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAI5B,6DAA6D;IACvD,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA0B1D"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Summarizer = void 0;
4
- /**
5
- * Uses the LLM to produce a compact summary of a conversation,
6
- * so old messages can be replaced with the summary to save tokens.
7
- */
8
- class Summarizer {
9
- llm;
10
- constructor(llm) {
11
- this.llm = llm;
12
- }
13
- /** Summarise an array of messages into a short paragraph. */
14
- async summarize(messages) {
15
- // Only summarize user/assistant turns — skip system and tool messages
16
- const turns = messages.filter((m) => m.role === 'user' || m.role === 'assistant');
17
- if (turns.length === 0)
18
- return '';
19
- const formatted = turns.map((m) => `${m.role === 'user' ? 'User' : 'Assistant'}: ${m.content}`).join('\n');
20
- const prompt = [
21
- {
22
- role: 'system',
23
- content: 'You are a conversation summarizer. Produce a concise summary of the conversation below. ' +
24
- 'Keep key facts, decisions, and context that would be needed to continue the conversation. ' +
25
- 'Reply with only the summary, no extra commentary. Respond in the same language as the conversation.',
26
- timestamp: 0,
27
- },
28
- {
29
- role: 'user',
30
- content: `Summarise this conversation:\n\n${formatted}`,
31
- timestamp: Date.now(),
32
- },
33
- ];
34
- const response = await this.llm.chat(prompt);
35
- return response.text;
36
- }
37
- }
38
- exports.Summarizer = Summarizer;
39
- //# sourceMappingURL=Summarizer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Summarizer.js","sourceRoot":"","sources":["../../src/memory/Summarizer.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,UAAU;IACb,GAAG,CAAc;IAEzB,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,SAAS,CAAC,QAAuB;QACrC,sEAAsE;QACtE,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC;QAClF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAElC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3G,MAAM,MAAM,GAAkB;YAC5B;gBACE,IAAI,EAAE,QAAQ;gBACd,OAAO,EACL,0FAA0F;oBAC1F,4FAA4F;oBAC5F,qGAAqG;gBACvG,SAAS,EAAE,CAAC;aACb;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,mCAAmC,SAAS,EAAE;gBACvD,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB;SACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAlCD,gCAkCC"}
@@ -1,124 +0,0 @@
1
- import type { KBSearchResult, KnowledgeBaseEntry, KnowledgeBaseProvider } from '../types';
2
- /**
3
- * What gets sent to the embedding model on upsert.
4
- *
5
- * - `'question'` (default, recommended for FAQ): only the `question` is
6
- * embedded. User queries look like questions, so question↔question
7
- * similarity gives the highest, most reliable scores.
8
- * - `'question-and-answer'`: embed `question + "\n\n" + answer`. Useful when
9
- * answers contain dense keyword material a user might literally search
10
- * for (error codes, product names, transaction hashes). Trade-off: long
11
- * answers dilute the embedding and lower scores for genuine matches.
12
- */
13
- export type UpstashEmbedStrategy = 'question' | 'question-and-answer';
14
- /**
15
- * Score fusion algorithm for hybrid (dense + sparse) indexes.
16
- *
17
- * - `'DBSF'` (default here): Distribution-Based Score Fusion. Each component
18
- * score is z-score-normalized against the batch's own mean ± 3σ and then
19
- * summed across components. The final score is NOT clamped to [0, 1]:
20
- * strong outliers can produce ≈ 1.2–1.6, "near-mean" hits sit close to 0,
21
- * and weak hits can go negative. Practical reading on a 2-component hybrid
22
- * index: ≳ 1.0 = strong match, ~0.6–1.0 = decent, ~0 = noise.
23
- * - `'RRF'`: Reciprocal Rank Fusion (Upstash's default). Score is
24
- * `Σ 1/(k+rank)` with k=60, so on a 2-component hybrid index the BEST
25
- * possible match scores ≈ 0.033. Set this only if you intentionally want
26
- * rank-based fusion — and remember to drop `minScore` to ≈ 0.015–0.02.
27
- *
28
- * Ignored on dense-only / sparse-only indexes (the underlying score is then
29
- * a plain cosine similarity in [0, 1]).
30
- */
31
- export type UpstashFusionAlgorithm = 'DBSF' | 'RRF';
32
- export interface UpstashKnowledgeBaseConfig {
33
- /**
34
- * Upstash Vector REST URL. If omitted, falls back to
35
- * `process.env.UPSTASH_VECTOR_REST_URL`.
36
- */
37
- url?: string;
38
- /**
39
- * Upstash Vector REST token. If omitted, falls back to
40
- * `process.env.UPSTASH_VECTOR_REST_TOKEN`.
41
- */
42
- token?: string;
43
- /**
44
- * Optional namespace for multi-tenant isolation. Use one namespace per
45
- * tenant / language / domain so a query never crosses boundaries.
46
- */
47
- namespace?: string;
48
- /**
49
- * Minimum score for a match to be returned. Below this threshold the result
50
- * is dropped. Defaults to 1.3 — kept low so router/synthesiser still gets
51
- * context-quality hits; the stricter "answer-from-KB" cut is a separate
52
- * threshold on the AgentCore side.
53
- *
54
- * Score range depends on `fusionAlgorithm`:
55
- * - DBSF (default): unbounded; ≳ 1.3 = strong, 0.6–1.0 = decent, ~0 = noise.
56
- * - RRF: ≤ ~0.033 on a 2-component hybrid index.
57
- * - Dense-only index: cosine in [0, 1].
58
- */
59
- minScore?: number;
60
- /** Default top-K when caller doesn't specify. Defaults to 3. */
61
- defaultTopK?: number;
62
- /** What to embed at upsert time. Default `'question'`. */
63
- embedStrategy?: UpstashEmbedStrategy;
64
- /**
65
- * Fusion algorithm for hybrid indexes. Default `'DBSF'` so scores look
66
- * like cosine similarity (0..1). Use `'RRF'` if you specifically need
67
- * Upstash's default rank-based fusion (and lower `minScore` accordingly).
68
- */
69
- fusionAlgorithm?: UpstashFusionAlgorithm;
70
- /** Enable debug logging. */
71
- debug?: boolean;
72
- }
73
- /** Optional fields a caller can attach when ingesting. */
74
- export interface UpstashKBUpsertEntry extends KnowledgeBaseEntry {
75
- /** Stable identifier. If omitted, derived from a sha256 hash of the question. */
76
- id?: string;
77
- /** Extra metadata to store alongside the entry (tags, source, lang…). */
78
- metadata?: Record<string, unknown>;
79
- }
80
- /**
81
- * Knowledge base backed by Upstash Vector.
82
- *
83
- * The Upstash index must be created with a built-in embedding model
84
- * (e.g. `BAAI/bge-m3`) so that uploading raw `data` strings — instead of
85
- * pre-computed vectors — embeds them server-side. This class assumes that
86
- * setup; callers who need client-side embeddings should subclass and
87
- * override the upsert/query payloads.
88
- *
89
- * @see https://upstash.com/docs/vector/features/embeddingmodels
90
- */
91
- export declare class UpstashKnowledgeBase implements KnowledgeBaseProvider {
92
- private readonly index;
93
- private readonly namespace?;
94
- private readonly minScore;
95
- private readonly defaultTopK;
96
- private readonly embedStrategy;
97
- private readonly fusionAlgorithm;
98
- private readonly debug;
99
- constructor(config?: UpstashKnowledgeBaseConfig);
100
- search(query: string, maxResults?: number): Promise<KBSearchResult[]>;
101
- /**
102
- * Upsert one or more entries. Idempotent — same `id` overwrites the
103
- * existing record. When `id` is omitted, a stable hash of the question
104
- * is used so re-running ingestion does not duplicate entries.
105
- *
106
- * The text sent to the embedding model is determined by `embedStrategy`
107
- * (default `'question'` — recommended for FAQ where user queries match
108
- * questions, not full Q+A documents).
109
- */
110
- upsert(entries: UpstashKBUpsertEntry[]): Promise<{
111
- count: number;
112
- }>;
113
- private buildEmbedText;
114
- /** Delete entries by id. */
115
- delete(ids: string[]): Promise<{
116
- deleted: number;
117
- }>;
118
- /** Wipe the namespace (or whole index if no namespace). Destructive. */
119
- reset(): Promise<void>;
120
- /** Total vectors in the namespace (best-effort — Upstash returns index-wide totals). */
121
- size(): Promise<number>;
122
- private deriveId;
123
- }
124
- //# sourceMappingURL=UpstashKnowledgeBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpstashKnowledgeBase.d.ts","sourceRoot":"","sources":["../../src/memory/UpstashKnowledgeBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAM1F;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,qBAAqB,CAAC;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,KAAK,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC;;;;OAIG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,4BAA4B;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AASD,0DAA0D;AAC1D,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,iFAAiF;IACjF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAChE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuB;IACrD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,MAAM,GAAE,0BAA+B;IAqB7C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAiD3E;;;;;;;;OAQG;IACG,MAAM,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IA4BzE,OAAO,CAAC,cAAc;IAOtB,4BAA4B;IACtB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAOzD,wEAAwE;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,wFAAwF;IAClF,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;YAWf,QAAQ;CAQvB"}
@@ -1,152 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpstashKnowledgeBase = void 0;
4
- const vector_1 = require("@upstash/vector");
5
- const DEFAULT_UPSTASH_URL = 'https://perfect-octopus-59684-us1-vector.upstash.io';
6
- const DEFAULT_UPSTASH_TOKEN = 'ABkFMHBlcmZlY3Qtb2N0b3B1cy01OTY4NC11czFhZG1pbk56WXdOV0k0T0RndFpUaGtOeTAwWWpjMkxXRmtNRFV0WW1WaU9UaGtOMlV5T0ROaQ==';
7
- /**
8
- * Knowledge base backed by Upstash Vector.
9
- *
10
- * The Upstash index must be created with a built-in embedding model
11
- * (e.g. `BAAI/bge-m3`) so that uploading raw `data` strings — instead of
12
- * pre-computed vectors — embeds them server-side. This class assumes that
13
- * setup; callers who need client-side embeddings should subclass and
14
- * override the upsert/query payloads.
15
- *
16
- * @see https://upstash.com/docs/vector/features/embeddingmodels
17
- */
18
- class UpstashKnowledgeBase {
19
- index;
20
- namespace;
21
- minScore;
22
- defaultTopK;
23
- embedStrategy;
24
- fusionAlgorithm;
25
- debug;
26
- constructor(config = {}) {
27
- const url = config.url ??
28
- (typeof process !== 'undefined' ? process.env.UPSTASH_VECTOR_REST_URL : undefined) ??
29
- DEFAULT_UPSTASH_URL;
30
- const token = config.token ??
31
- (typeof process !== 'undefined' ? process.env.UPSTASH_VECTOR_REST_TOKEN : undefined) ??
32
- DEFAULT_UPSTASH_TOKEN;
33
- this.index = new vector_1.Index({ url, token });
34
- this.namespace = config.namespace;
35
- this.minScore = config.minScore ?? 1.3;
36
- this.defaultTopK = config.defaultTopK ?? 3;
37
- this.embedStrategy = config.embedStrategy ?? 'question';
38
- this.fusionAlgorithm = config.fusionAlgorithm === 'RRF' ? vector_1.FusionAlgorithm.RRF : vector_1.FusionAlgorithm.DBSF;
39
- this.debug = config.debug ?? false;
40
- }
41
- // ---- Search (KnowledgeBaseProvider) ----
42
- async search(query, maxResults) {
43
- const topK = maxResults ?? this.defaultTopK;
44
- if (!query.trim())
45
- return [];
46
- const target = this.namespace ? this.index.namespace(this.namespace) : this.index;
47
- let raw;
48
- try {
49
- raw = await target.query({
50
- data: query,
51
- topK,
52
- includeMetadata: true,
53
- fusionAlgorithm: this.fusionAlgorithm,
54
- });
55
- }
56
- catch (err) {
57
- if (this.debug) {
58
- console.warn('[UpstashKnowledgeBase] query failed:', err);
59
- }
60
- return [];
61
- }
62
- const results = [];
63
- for (const hit of raw) {
64
- if (hit.score < this.minScore)
65
- continue;
66
- const meta = hit.metadata;
67
- if (!meta?.question || !meta?.answer)
68
- continue;
69
- results.push({
70
- entry: { question: meta.question, answer: meta.answer },
71
- score: hit.score,
72
- });
73
- }
74
- if (this.debug) {
75
- console.log(`[UpstashKnowledgeBase] query="${query}" → ${results.length}/${raw.length} hit(s) above ${this.minScore}` +
76
- (results[0] ? ` (top: ${results[0].score.toFixed(3)})` : ''));
77
- }
78
- return results;
79
- }
80
- // ---- Ingestion ----
81
- /**
82
- * Upsert one or more entries. Idempotent — same `id` overwrites the
83
- * existing record. When `id` is omitted, a stable hash of the question
84
- * is used so re-running ingestion does not duplicate entries.
85
- *
86
- * The text sent to the embedding model is determined by `embedStrategy`
87
- * (default `'question'` — recommended for FAQ where user queries match
88
- * questions, not full Q+A documents).
89
- */
90
- async upsert(entries) {
91
- if (entries.length === 0)
92
- return { count: 0 };
93
- const target = this.namespace ? this.index.namespace(this.namespace) : this.index;
94
- const payload = await Promise.all(entries.map(async (e) => ({
95
- id: e.id ?? (await this.deriveId(e.question)),
96
- data: this.buildEmbedText(e),
97
- metadata: {
98
- question: e.question,
99
- answer: e.answer,
100
- ...(e.metadata ?? {}),
101
- },
102
- })));
103
- await target.upsert(payload);
104
- if (this.debug) {
105
- console.log(`[UpstashKnowledgeBase] upserted ${payload.length} entr${payload.length === 1 ? 'y' : 'ies'} (strategy=${this.embedStrategy})`);
106
- }
107
- return { count: payload.length };
108
- }
109
- buildEmbedText(entry) {
110
- if (this.embedStrategy === 'question-and-answer') {
111
- return `${entry.question}\n\n${entry.answer}`;
112
- }
113
- return entry.question;
114
- }
115
- /** Delete entries by id. */
116
- async delete(ids) {
117
- if (ids.length === 0)
118
- return { deleted: 0 };
119
- const target = this.namespace ? this.index.namespace(this.namespace) : this.index;
120
- const res = await target.delete(ids);
121
- return { deleted: res.deleted };
122
- }
123
- /** Wipe the namespace (or whole index if no namespace). Destructive. */
124
- async reset() {
125
- if (this.namespace) {
126
- await this.index.reset({ namespace: this.namespace });
127
- }
128
- else {
129
- await this.index.reset();
130
- }
131
- }
132
- /** Total vectors in the namespace (best-effort — Upstash returns index-wide totals). */
133
- async size() {
134
- const info = await this.index.info();
135
- if (this.namespace) {
136
- const ns = info.namespaces?.[this.namespace];
137
- return ns?.vectorCount ?? 0;
138
- }
139
- return info.vectorCount ?? 0;
140
- }
141
- // ---- Internals ----
142
- async deriveId(question) {
143
- const data = new TextEncoder().encode(question.trim().toLowerCase());
144
- const buf = await globalThis.crypto.subtle.digest('SHA-256', data);
145
- return Array.from(new Uint8Array(buf))
146
- .map((b) => b.toString(16).padStart(2, '0'))
147
- .join('')
148
- .slice(0, 32);
149
- }
150
- }
151
- exports.UpstashKnowledgeBase = UpstashKnowledgeBase;
152
- //# sourceMappingURL=UpstashKnowledgeBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UpstashKnowledgeBase.js","sourceRoot":"","sources":["../../src/memory/UpstashKnowledgeBase.ts"],"names":[],"mappings":";;;AAAA,4CAAyD;AAGzD,MAAM,mBAAmB,GAAG,qDAAqD,CAAC;AAClF,MAAM,qBAAqB,GACzB,kHAAkH,CAAC;AA2FrH;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IACd,KAAK,CAAoB;IACzB,SAAS,CAAU;IACnB,QAAQ,CAAS;IACjB,WAAW,CAAS;IACpB,aAAa,CAAuB;IACpC,eAAe,CAAkB;IACjC,KAAK,CAAU;IAEhC,YAAY,SAAqC,EAAE;QACjD,MAAM,GAAG,GACP,MAAM,CAAC,GAAG;YACV,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;YAClF,mBAAmB,CAAC;QACtB,MAAM,KAAK,GACT,MAAM,CAAC,KAAK;YACZ,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC;YACpF,qBAAqB,CAAC;QAExB,IAAI,CAAC,KAAK,GAAG,IAAI,cAAK,CAAa,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,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AE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;aAC3C,IAAI,CAAC,EAAE,CAAC;aACR,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClB,CAAC;CACF;AAhKD,oDAgKC"}
@@ -1,58 +0,0 @@
1
- import type { ChatMessage } from '../types';
2
- /**
3
- * Strip tool-related messages (assistant-with-toolCalls, role:'tool' results,
4
- * and internal bridge assistant messages) from a history slice. Use this when
5
- * feeding history to an LLM call that does NOT declare tool schemas — otherwise
6
- * Gemini sees `functionResponse` parts without matching `functionDeclarations`
7
- * and errors out.
8
- *
9
- * Also strips `_intermediate` assistant messages: these are the bridging turns
10
- * that `persistToolMessages` injects after each subagent tool exchange to
11
- * satisfy Gemini's turn-order rule. They must not appear in synthesiser or
12
- * direct-LLM history because the final synthesised answer is added separately
13
- * via `finaliseAnswer`, and having both would create duplicate model turns.
14
- */
15
- export declare function stripToolMessages(messages: ChatMessage[]): ChatMessage[];
16
- /**
17
- * Keep only tool messages whose tool name is owned by the current subagent.
18
- * Drops the paired assistant-with-toolCalls message as well, so the remaining
19
- * history stays internally consistent (no orphan functionResponse parts).
20
- *
21
- * Any dropped tool data is replaced with a short text observation so the
22
- * subagent still has a hint that prior data existed.
23
- */
24
- export declare function filterToolMessagesForSubagent(messages: ChatMessage[], ownedToolNames: Set<string>): ChatMessage[];
25
- /**
26
- * Return the last N messages from the slice, but never split a
27
- * [assistant-with-toolCalls, tool, tool, ...] group. If the slice would start
28
- * with an orphan `role:'tool'` message, walk back until we include its
29
- * parent assistant message (or drop the orphan entirely).
30
- */
31
- export declare function sliceRecentKeepingToolPairs(messages: ChatMessage[], n: number): ChatMessage[];
32
- /**
33
- * Trim a history array down to at most `keepLast` messages WITHOUT splitting
34
- * a tool-call group. Used by `compactHistory` so the working window never
35
- * ends up with an orphan `functionResponse`.
36
- */
37
- export declare function trimPreservingToolPairs(messages: ChatMessage[], keepLast: number): ChatMessage[];
38
- /**
39
- * Return the `subagents` tag from the most recent user-facing assistant
40
- * message (i.e. not the intermediate assistant-with-toolCalls messages).
41
- * Used by QueryRewriter + Router to resolve follow-ups like "more", "tiếp",
42
- * "yes" against the domain that handled the previous turn.
43
- */
44
- export declare function getLastAssistantSubagents(messages: ChatMessage[]): string[];
45
- /**
46
- * Extract a plain-text summary of key data from recent tool results so the
47
- * QueryRewriter can resolve follow-up references (e.g. "details of this tx",
48
- * "next page") WITHOUT receiving raw role:'tool' messages that would cause
49
- * Gemini functionResponse errors.
50
- *
51
- * Scans the last `maxToolMessages` tool messages and extracts:
52
- * - Transaction hashes from wallet history / transfers
53
- * - Pagination cursors
54
- * Returns a compact string to inject as a hint into the QueryRewriter prompt,
55
- * or an empty string if nothing relevant is found.
56
- */
57
- export declare function extractRecentToolDataHint(messages: ChatMessage[], maxToolMessages?: number): string;
58
- //# sourceMappingURL=historyUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/memory/historyUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAIxE;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,EAAE,CA0CjH;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAwB7F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAEhG;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAS3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,eAAe,SAAI,GAAG,MAAM,CAgD9F"}