keyring-agent-core 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6692 -27
- package/dist/index.js +877 -70
- package/package.json +6 -4
- package/dist/agent/AgentCore.d.ts +0 -256
- package/dist/agent/AgentCore.d.ts.map +0 -1
- package/dist/agent/AgentCore.js +0 -1093
- package/dist/agent/AgentCore.js.map +0 -1
- package/dist/agent/QueryRewriter.d.ts +0 -84
- package/dist/agent/QueryRewriter.d.ts.map +0 -1
- package/dist/agent/QueryRewriter.js +0 -306
- package/dist/agent/QueryRewriter.js.map +0 -1
- package/dist/agent/Router.d.ts +0 -33
- package/dist/agent/Router.d.ts.map +0 -1
- package/dist/agent/Router.js +0 -229
- package/dist/agent/Router.js.map +0 -1
- package/dist/agent/Subagent.d.ts +0 -80
- package/dist/agent/Subagent.d.ts.map +0 -1
- package/dist/agent/Subagent.js +0 -272
- package/dist/agent/Subagent.js.map +0 -1
- package/dist/agent/Synthesizer.d.ts +0 -11
- package/dist/agent/Synthesizer.d.ts.map +0 -1
- package/dist/agent/Synthesizer.js +0 -86
- package/dist/agent/Synthesizer.js.map +0 -1
- package/dist/agent/chatGraph.d.ts +0 -364
- package/dist/agent/chatGraph.d.ts.map +0 -1
- package/dist/agent/chatGraph.js +0 -184
- package/dist/agent/chatGraph.js.map +0 -1
- package/dist/agent/index.d.ts +0 -10
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js +0 -24
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/subagents/AiAgent.d.ts +0 -6
- package/dist/agent/subagents/AiAgent.d.ts.map +0 -1
- package/dist/agent/subagents/AiAgent.js +0 -52
- package/dist/agent/subagents/AiAgent.js.map +0 -1
- package/dist/agent/subagents/NftAgent.d.ts +0 -6
- package/dist/agent/subagents/NftAgent.d.ts.map +0 -1
- package/dist/agent/subagents/NftAgent.js +0 -79
- package/dist/agent/subagents/NftAgent.js.map +0 -1
- package/dist/agent/subagents/PoolAgent.d.ts +0 -6
- package/dist/agent/subagents/PoolAgent.d.ts.map +0 -1
- package/dist/agent/subagents/PoolAgent.js +0 -184
- package/dist/agent/subagents/PoolAgent.js.map +0 -1
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts +0 -6
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts.map +0 -1
- package/dist/agent/subagents/PoolSubgraphAgent.js +0 -117
- package/dist/agent/subagents/PoolSubgraphAgent.js.map +0 -1
- package/dist/agent/subagents/TokenAgent.d.ts +0 -6
- package/dist/agent/subagents/TokenAgent.d.ts.map +0 -1
- package/dist/agent/subagents/TokenAgent.js +0 -76
- package/dist/agent/subagents/TokenAgent.js.map +0 -1
- package/dist/agent/subagents/WalletActionAgent.d.ts +0 -6
- package/dist/agent/subagents/WalletActionAgent.d.ts.map +0 -1
- package/dist/agent/subagents/WalletActionAgent.js +0 -55
- package/dist/agent/subagents/WalletActionAgent.js.map +0 -1
- package/dist/agent/subagents/WalletAgent.d.ts +0 -6
- package/dist/agent/subagents/WalletAgent.d.ts.map +0 -1
- package/dist/agent/subagents/WalletAgent.js +0 -93
- package/dist/agent/subagents/WalletAgent.js.map +0 -1
- package/dist/agent/subagents/index.d.ts +0 -34
- package/dist/agent/subagents/index.d.ts.map +0 -1
- package/dist/agent/subagents/index.js +0 -69
- package/dist/agent/subagents/index.js.map +0 -1
- package/dist/constants/abi.d.ts +0 -551
- package/dist/constants/abi.d.ts.map +0 -1
- package/dist/constants/abi.js +0 -690
- package/dist/constants/abi.js.map +0 -1
- package/dist/functions/pool.d.ts +0 -25
- package/dist/functions/pool.d.ts.map +0 -1
- package/dist/functions/pool.js +0 -151
- package/dist/functions/pool.js.map +0 -1
- package/dist/functions/web3.d.ts +0 -31
- package/dist/functions/web3.d.ts.map +0 -1
- package/dist/functions/web3.js +0 -232
- package/dist/functions/web3.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/llm/GeminiProvider.d.ts +0 -16
- package/dist/llm/GeminiProvider.d.ts.map +0 -1
- package/dist/llm/GeminiProvider.js +0 -329
- package/dist/llm/GeminiProvider.js.map +0 -1
- package/dist/llm/index.d.ts +0 -2
- package/dist/llm/index.d.ts.map +0 -1
- package/dist/llm/index.js +0 -6
- package/dist/llm/index.js.map +0 -1
- package/dist/memory/ChatHistory.d.ts +0 -83
- package/dist/memory/ChatHistory.d.ts.map +0 -1
- package/dist/memory/ChatHistory.js +0 -143
- package/dist/memory/ChatHistory.js.map +0 -1
- package/dist/memory/KnowledgeBase.d.ts +0 -38
- package/dist/memory/KnowledgeBase.d.ts.map +0 -1
- package/dist/memory/KnowledgeBase.js +0 -139
- package/dist/memory/KnowledgeBase.js.map +0 -1
- package/dist/memory/Summarizer.d.ts +0 -12
- package/dist/memory/Summarizer.d.ts.map +0 -1
- package/dist/memory/Summarizer.js +0 -39
- package/dist/memory/Summarizer.js.map +0 -1
- package/dist/memory/UpstashKnowledgeBase.d.ts +0 -124
- package/dist/memory/UpstashKnowledgeBase.d.ts.map +0 -1
- package/dist/memory/UpstashKnowledgeBase.js +0 -152
- package/dist/memory/UpstashKnowledgeBase.js.map +0 -1
- package/dist/memory/historyUtils.d.ts +0 -58
- package/dist/memory/historyUtils.d.ts.map +0 -1
- package/dist/memory/historyUtils.js +0 -190
- package/dist/memory/historyUtils.js.map +0 -1
- package/dist/memory/index.d.ts +0 -7
- package/dist/memory/index.d.ts.map +0 -1
- package/dist/memory/index.js +0 -12
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/ingestKnowledgeBase.d.ts +0 -17
- package/dist/memory/ingestKnowledgeBase.d.ts.map +0 -1
- package/dist/memory/ingestKnowledgeBase.js +0 -35
- package/dist/memory/ingestKnowledgeBase.js.map +0 -1
- package/dist/services/MoralisService.d.ts +0 -1328
- package/dist/services/MoralisService.d.ts.map +0 -1
- package/dist/services/MoralisService.js +0 -1239
- package/dist/services/MoralisService.js.map +0 -1
- package/dist/services/PantographService.d.ts +0 -98
- package/dist/services/PantographService.d.ts.map +0 -1
- package/dist/services/PantographService.js +0 -451
- package/dist/services/PantographService.js.map +0 -1
- package/dist/services/PoolService.d.ts +0 -238
- package/dist/services/PoolService.d.ts.map +0 -1
- package/dist/services/PoolService.js +0 -485
- package/dist/services/PoolService.js.map +0 -1
- package/dist/services/UniswapService.d.ts +0 -289
- package/dist/services/UniswapService.d.ts.map +0 -1
- package/dist/services/UniswapService.js +0 -585
- package/dist/services/UniswapService.js.map +0 -1
- package/dist/services/UniswapSubgraphService.d.ts +0 -144
- package/dist/services/UniswapSubgraphService.d.ts.map +0 -1
- package/dist/services/UniswapSubgraphService.js +0 -606
- package/dist/services/UniswapSubgraphService.js.map +0 -1
- package/dist/services/rpc.d.ts +0 -35
- package/dist/services/rpc.d.ts.map +0 -1
- package/dist/services/rpc.js +0 -110
- package/dist/services/rpc.js.map +0 -1
- package/dist/services/swap/BaseSwapService.d.ts +0 -17
- package/dist/services/swap/BaseSwapService.d.ts.map +0 -1
- package/dist/services/swap/BaseSwapService.js +0 -19
- package/dist/services/swap/BaseSwapService.js.map +0 -1
- package/dist/services/swap/DebridgeAdapter.d.ts +0 -37
- package/dist/services/swap/DebridgeAdapter.d.ts.map +0 -1
- package/dist/services/swap/DebridgeAdapter.js +0 -243
- package/dist/services/swap/DebridgeAdapter.js.map +0 -1
- package/dist/services/swap/RelayAdapter.d.ts +0 -19
- package/dist/services/swap/RelayAdapter.d.ts.map +0 -1
- package/dist/services/swap/RelayAdapter.js +0 -189
- package/dist/services/swap/RelayAdapter.js.map +0 -1
- package/dist/services/swap/SwapServiceFactory.d.ts +0 -25
- package/dist/services/swap/SwapServiceFactory.d.ts.map +0 -1
- package/dist/services/swap/SwapServiceFactory.js +0 -79
- package/dist/services/swap/SwapServiceFactory.js.map +0 -1
- package/dist/services/swap/addresses.d.ts +0 -3
- package/dist/services/swap/addresses.d.ts.map +0 -1
- package/dist/services/swap/addresses.js +0 -68
- package/dist/services/swap/addresses.js.map +0 -1
- package/dist/services/swap/affiliate.d.ts +0 -17
- package/dist/services/swap/affiliate.d.ts.map +0 -1
- package/dist/services/swap/affiliate.js +0 -126
- package/dist/services/swap/affiliate.js.map +0 -1
- package/dist/services/swap/config.d.ts +0 -9
- package/dist/services/swap/config.d.ts.map +0 -1
- package/dist/services/swap/config.js +0 -19
- package/dist/services/swap/config.js.map +0 -1
- package/dist/services/swap/index.d.ts +0 -10
- package/dist/services/swap/index.d.ts.map +0 -1
- package/dist/services/swap/index.js +0 -22
- package/dist/services/swap/index.js.map +0 -1
- package/dist/services/swap/types.d.ts +0 -89
- package/dist/services/swap/types.d.ts.map +0 -1
- package/dist/services/swap/types.js +0 -6
- package/dist/services/swap/types.js.map +0 -1
- package/dist/tools/BaseTool.d.ts +0 -15
- package/dist/tools/BaseTool.d.ts.map +0 -1
- package/dist/tools/BaseTool.js +0 -35
- package/dist/tools/BaseTool.js.map +0 -1
- package/dist/tools/ToolRegistry.d.ts +0 -27
- package/dist/tools/ToolRegistry.d.ts.map +0 -1
- package/dist/tools/ToolRegistry.js +0 -80
- package/dist/tools/ToolRegistry.js.map +0 -1
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts +0 -36
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts.map +0 -1
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js +0 -91
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js.map +0 -1
- package/dist/tools/builtin/ai/index.d.ts +0 -3
- package/dist/tools/builtin/ai/index.d.ts.map +0 -1
- package/dist/tools/builtin/ai/index.js +0 -6
- package/dist/tools/builtin/ai/index.js.map +0 -1
- package/dist/tools/builtin/index.d.ts +0 -8
- package/dist/tools/builtin/index.d.ts.map +0 -1
- package/dist/tools/builtin/index.js +0 -24
- package/dist/tools/builtin/index.js.map +0 -1
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts +0 -35
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts.map +0 -1
- package/dist/tools/builtin/nft/BaseNftMessageTool.js +0 -45
- package/dist/tools/builtin/nft/BaseNftMessageTool.js.map +0 -1
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +0 -15
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +0 -1
- package/dist/tools/builtin/nft/NFTContractInfoTool.js +0 -19
- package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +0 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +0 -15
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +0 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.js +0 -20
- package/dist/tools/builtin/nft/NFTMetadataTool.js.map +0 -1
- package/dist/tools/builtin/nft/SendNftTool.d.ts +0 -14
- package/dist/tools/builtin/nft/SendNftTool.d.ts.map +0 -1
- package/dist/tools/builtin/nft/SendNftTool.js +0 -20
- package/dist/tools/builtin/nft/SendNftTool.js.map +0 -1
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +0 -15
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +0 -1
- package/dist/tools/builtin/nft/WalletNFTsTool.js +0 -20
- package/dist/tools/builtin/nft/WalletNFTsTool.js.map +0 -1
- package/dist/tools/builtin/nft/index.d.ts +0 -7
- package/dist/tools/builtin/nft/index.d.ts.map +0 -1
- package/dist/tools/builtin/nft/index.js +0 -10
- package/dist/tools/builtin/nft/index.js.map +0 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts +0 -124
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +0 -236
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +0 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +0 -128
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +0 -520
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +0 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.d.ts +0 -127
- package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.js +0 -238
- package/dist/tools/builtin/pool/PoolByAddressTool.js.map +0 -1
- package/dist/tools/builtin/pool/PoolDetailTool.d.ts +0 -127
- package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/PoolDetailTool.js +0 -273
- package/dist/tools/builtin/pool/PoolDetailTool.js.map +0 -1
- package/dist/tools/builtin/pool/PoolSearchTool.d.ts +0 -50
- package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/PoolSearchTool.js +0 -160
- package/dist/tools/builtin/pool/PoolSearchTool.js.map +0 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +0 -124
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +0 -382
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +0 -1
- package/dist/tools/builtin/pool/TopPoolsTool.d.ts +0 -68
- package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool/TopPoolsTool.js +0 -159
- package/dist/tools/builtin/pool/TopPoolsTool.js.map +0 -1
- package/dist/tools/builtin/pool/index.d.ts +0 -15
- package/dist/tools/builtin/pool/index.d.ts.map +0 -1
- package/dist/tools/builtin/pool/index.js +0 -18
- package/dist/tools/builtin/pool/index.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts +0 -54
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js +0 -98
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts +0 -63
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js +0 -82
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts +0 -79
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js +0 -97
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts +0 -77
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js +0 -190
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts +0 -107
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js +0 -92
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts +0 -56
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js +0 -94
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js.map +0 -1
- package/dist/tools/builtin/pool-subgraph/index.d.ts +0 -13
- package/dist/tools/builtin/pool-subgraph/index.d.ts.map +0 -1
- package/dist/tools/builtin/pool-subgraph/index.js +0 -18
- package/dist/tools/builtin/pool-subgraph/index.js.map +0 -1
- package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts +0 -71
- package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TokenAnalyticsTool.js +0 -147
- package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +0 -1
- package/dist/tools/builtin/token/TokenHoldersTool.d.ts +0 -81
- package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TokenHoldersTool.js +0 -139
- package/dist/tools/builtin/token/TokenHoldersTool.js.map +0 -1
- package/dist/tools/builtin/token/TokenInfoTool.d.ts +0 -40
- package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TokenInfoTool.js +0 -221
- package/dist/tools/builtin/token/TokenInfoTool.js.map +0 -1
- package/dist/tools/builtin/token/TokenScoreTool.d.ts +0 -63
- package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TokenScoreTool.js +0 -148
- package/dist/tools/builtin/token/TokenScoreTool.js.map +0 -1
- package/dist/tools/builtin/token/TopGainersTool.d.ts +0 -37
- package/dist/tools/builtin/token/TopGainersTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TopGainersTool.js +0 -100
- package/dist/tools/builtin/token/TopGainersTool.js.map +0 -1
- package/dist/tools/builtin/token/TopLosersTool.d.ts +0 -66
- package/dist/tools/builtin/token/TopLosersTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TopLosersTool.js +0 -129
- package/dist/tools/builtin/token/TopLosersTool.js.map +0 -1
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts +0 -39
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +0 -1
- package/dist/tools/builtin/token/TrendingTokensTool.js +0 -83
- package/dist/tools/builtin/token/TrendingTokensTool.js.map +0 -1
- package/dist/tools/builtin/token/index.d.ts +0 -13
- package/dist/tools/builtin/token/index.d.ts.map +0 -1
- package/dist/tools/builtin/token/index.js +0 -16
- package/dist/tools/builtin/token/index.js.map +0 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts +0 -70
- package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.js +0 -111
- package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts +0 -107
- package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js +0 -164
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts +0 -61
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +0 -100
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts +0 -68
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +0 -115
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts +0 -50
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +0 -80
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts +0 -31
- package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.js +0 -154
- package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts +0 -44
- package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js +0 -122
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts +0 -86
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +0 -265
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts +0 -43
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +0 -89
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.d.ts +0 -43
- package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.js +0 -175
- package/dist/tools/builtin/wallet/WalletPnlTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts +0 -35
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +0 -68
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +0 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts +0 -109
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +0 -354
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +0 -1
- package/dist/tools/builtin/wallet/index.d.ts +0 -28
- package/dist/tools/builtin/wallet/index.d.ts.map +0 -1
- package/dist/tools/builtin/wallet/index.js +0 -32
- package/dist/tools/builtin/wallet/index.js.map +0 -1
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts +0 -25
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js +0 -98
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts +0 -211
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js +0 -499
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts +0 -240
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js +0 -1257
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts +0 -41
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/SendNativeTool.js +0 -127
- package/dist/tools/builtin/wallet-action/SendNativeTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts +0 -63
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/SendTokenTool.js +0 -294
- package/dist/tools/builtin/wallet-action/SendTokenTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts +0 -247
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js +0 -1258
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts +0 -20
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js +0 -36
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts +0 -23
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js +0 -54
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js.map +0 -1
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts +0 -62
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/amountSpec.js +0 -93
- package/dist/tools/builtin/wallet-action/amountSpec.js.map +0 -1
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts +0 -42
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/gasReserve.js +0 -103
- package/dist/tools/builtin/wallet-action/gasReserve.js.map +0 -1
- package/dist/tools/builtin/wallet-action/index.d.ts +0 -9
- package/dist/tools/builtin/wallet-action/index.d.ts.map +0 -1
- package/dist/tools/builtin/wallet-action/index.js +0 -20
- package/dist/tools/builtin/wallet-action/index.js.map +0 -1
- package/dist/tools/chainResolver.d.ts +0 -98
- package/dist/tools/chainResolver.d.ts.map +0 -1
- package/dist/tools/chainResolver.js +0 -302
- package/dist/tools/chainResolver.js.map +0 -1
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -23
- package/dist/tools/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -777
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +0 -1
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GeminiProvider = void 0;
|
|
4
|
-
const PARAM_TYPE_MAP = {
|
|
5
|
-
string: 'STRING',
|
|
6
|
-
number: 'NUMBER',
|
|
7
|
-
boolean: 'BOOLEAN',
|
|
8
|
-
object: 'OBJECT',
|
|
9
|
-
array: 'ARRAY',
|
|
10
|
-
};
|
|
11
|
-
const DEFAULT_BASE_URL = 'https://nft-demo.keyring.app/api/gemini-stable';
|
|
12
|
-
/**
|
|
13
|
-
* HTTP statuses worth retrying — transient overload / rate-limit / gateway
|
|
14
|
-
* errors that usually clear on their own. Everything else (400/401/403/404 …)
|
|
15
|
-
* is a permanent client error: retrying only wastes time, so we fail fast.
|
|
16
|
-
*/
|
|
17
|
-
const RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
|
|
18
|
-
/** Hard cap on any single backoff wait so a request never hangs too long. */
|
|
19
|
-
const MAX_BACKOFF_MS = 30_000;
|
|
20
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
21
|
-
/**
|
|
22
|
-
* Exponential backoff with jitter. `attempt` is 1-based: the slot grows
|
|
23
|
-
* 1×, 2×, 4×, … of `baseMs` (capped at {@link MAX_BACKOFF_MS}), and the actual
|
|
24
|
-
* wait is randomized within the upper half of the slot — enough jitter to avoid
|
|
25
|
-
* synchronized retries hammering an overloaded server, while still guaranteeing
|
|
26
|
-
* a sensible minimum wait. An explicit `Retry-After` hint always wins.
|
|
27
|
-
*/
|
|
28
|
-
function backoffDelayMs(attempt, baseMs, retryAfterMs) {
|
|
29
|
-
if (retryAfterMs != null && retryAfterMs > 0)
|
|
30
|
-
return Math.min(retryAfterMs, MAX_BACKOFF_MS);
|
|
31
|
-
const slot = Math.min(baseMs * 2 ** (attempt - 1), MAX_BACKOFF_MS);
|
|
32
|
-
return slot / 2 + Math.random() * (slot / 2);
|
|
33
|
-
}
|
|
34
|
-
/** Parse a `Retry-After` header (delta-seconds or HTTP-date) → ms, or null. */
|
|
35
|
-
function parseRetryAfterMs(header) {
|
|
36
|
-
if (!header)
|
|
37
|
-
return null;
|
|
38
|
-
const secs = Number(header);
|
|
39
|
-
if (Number.isFinite(secs))
|
|
40
|
-
return Math.max(0, secs * 1000);
|
|
41
|
-
const dateMs = Date.parse(header);
|
|
42
|
-
if (!Number.isNaN(dateMs))
|
|
43
|
-
return Math.max(0, dateMs - Date.now());
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* LLM provider that calls the Gemini-compatible proxy via fetch.
|
|
48
|
-
* No API key required — the proxy handles authentication.
|
|
49
|
-
*/
|
|
50
|
-
class GeminiProvider {
|
|
51
|
-
model;
|
|
52
|
-
maxTokens;
|
|
53
|
-
temperature;
|
|
54
|
-
baseUrl;
|
|
55
|
-
constructor(config) {
|
|
56
|
-
this.model = config.model ?? 'gemini-2.5-flash-lite';
|
|
57
|
-
this.maxTokens = config.maxTokens ?? 4096;
|
|
58
|
-
this.temperature = config.temperature ?? 1;
|
|
59
|
-
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
60
|
-
}
|
|
61
|
-
async chat(messages, tools, options) {
|
|
62
|
-
const { systemInstruction, contents } = this.toContents(messages);
|
|
63
|
-
const { maxRetries = 5, retryDelayMs = 1000 } = options ?? {};
|
|
64
|
-
// Gemini rejects empty `contents`. If the caller only sent system
|
|
65
|
-
// message(s), synthesize a minimal user turn so the request is valid.
|
|
66
|
-
const safeContents = contents.length > 0 ? contents : [{ role: 'user', parts: [{ text: '(continue)' }] }];
|
|
67
|
-
// Debug: log the exact turn sequence so ordering violations are visible.
|
|
68
|
-
if (options?.['_debug']) {
|
|
69
|
-
console.log('[GeminiProvider] turn sequence:');
|
|
70
|
-
for (const c of safeContents) {
|
|
71
|
-
const partSummary = c.parts
|
|
72
|
-
.map((p) => p.functionCall
|
|
73
|
-
? `fc:${p.functionCall.name}`
|
|
74
|
-
: p.functionResponse
|
|
75
|
-
? `fr:${p.functionResponse.name}`
|
|
76
|
-
: `text:${(p.text ?? '').slice(0, 40)}`)
|
|
77
|
-
.join(', ');
|
|
78
|
-
console.log(` ${c.role}: [${partSummary}]`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const body = {
|
|
82
|
-
contents: safeContents,
|
|
83
|
-
generationConfig: {
|
|
84
|
-
maxOutputTokens: this.maxTokens,
|
|
85
|
-
temperature: this.temperature,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
if (systemInstruction) {
|
|
89
|
-
body.systemInstruction = systemInstruction;
|
|
90
|
-
}
|
|
91
|
-
if (tools?.length) {
|
|
92
|
-
body.tools = [{ functionDeclarations: this.toFunctionDeclarations(tools) }];
|
|
93
|
-
}
|
|
94
|
-
else if (options?.googleSearch) {
|
|
95
|
-
body.tools = [{ googleSearch: {} }];
|
|
96
|
-
}
|
|
97
|
-
const url = `${this.baseUrl}/v1beta/models/${this.model}:generateContent`;
|
|
98
|
-
let lastError = 'Unknown error';
|
|
99
|
-
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
100
|
-
// --- Transport: network/fetch failures are transient → backoff + retry --
|
|
101
|
-
let res;
|
|
102
|
-
try {
|
|
103
|
-
res = await fetch(url, {
|
|
104
|
-
method: 'POST',
|
|
105
|
-
headers: { 'Content-Type': 'application/json' },
|
|
106
|
-
body: JSON.stringify(body),
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
lastError = error instanceof Error ? error.message : String(error);
|
|
111
|
-
if (attempt >= maxRetries)
|
|
112
|
-
break;
|
|
113
|
-
await sleep(backoffDelayMs(attempt, retryDelayMs));
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
// --- HTTP status: only retry transient (429/503/…); fail fast on 4xx ----
|
|
117
|
-
if (!res.ok) {
|
|
118
|
-
const errText = await res.text().catch(() => res.statusText);
|
|
119
|
-
lastError = `Gemini proxy error ${res.status}: ${errText}`;
|
|
120
|
-
// Permanent client errors (bad request, auth, not found) won't fix
|
|
121
|
-
// themselves — surface immediately instead of burning retries.
|
|
122
|
-
if (!RETRYABLE_STATUSES.has(res.status))
|
|
123
|
-
throw new Error(lastError);
|
|
124
|
-
if (attempt >= maxRetries)
|
|
125
|
-
break;
|
|
126
|
-
const retryAfterMs = parseRetryAfterMs(res.headers.get('retry-after'));
|
|
127
|
-
await sleep(backoffDelayMs(attempt, retryDelayMs, retryAfterMs));
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
// --- Body: malformed JSON is transient (truncated/proxy hiccup) ---------
|
|
131
|
-
let data;
|
|
132
|
-
try {
|
|
133
|
-
data = (await res.json());
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
lastError = `Gemini proxy returned invalid JSON: ${error instanceof Error ? error.message : String(error)}`;
|
|
137
|
-
if (attempt >= maxRetries)
|
|
138
|
-
break;
|
|
139
|
-
await sleep(backoffDelayMs(attempt, retryDelayMs));
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
const candidate = data.candidates?.[0];
|
|
143
|
-
if (!candidate) {
|
|
144
|
-
return { text: '', toolCalls: [] };
|
|
145
|
-
}
|
|
146
|
-
let text = '';
|
|
147
|
-
const toolCalls = [];
|
|
148
|
-
// A candidate can finish without any `content.parts` — e.g. when the
|
|
149
|
-
// model is cut off by MAX_TOKENS or stopped by a SAFETY/RECITATION
|
|
150
|
-
// filter. Iterating `undefined` here is what throws
|
|
151
|
-
// "candidate.content.parts is not iterable". Treat it as an empty turn.
|
|
152
|
-
const parts = candidate.content?.parts;
|
|
153
|
-
if (!Array.isArray(parts) || parts.length === 0) {
|
|
154
|
-
const reason = candidate.finishReason;
|
|
155
|
-
// An empty turn with no `parts`. Seen as:
|
|
156
|
-
// • MAX_TOKENS — cut off mid output (esp. while building a tool call)
|
|
157
|
-
// • STOP with zero candidatesTokenCount — flash-lite occasionally
|
|
158
|
-
// returns a valid-but-empty turn for no useful reason
|
|
159
|
-
// • SAFETY / RECITATION — content was filtered (do NOT retry)
|
|
160
|
-
// The first two are transient: a fresh attempt usually produces real
|
|
161
|
-
// content, so retry. Filter stops are deterministic — give up.
|
|
162
|
-
const filtered = reason === 'SAFETY' || reason === 'RECITATION';
|
|
163
|
-
if (!filtered && attempt < maxRetries) {
|
|
164
|
-
lastError = `Gemini returned an empty turn (finishReason=${reason ?? 'none'})`;
|
|
165
|
-
await sleep(backoffDelayMs(attempt, retryDelayMs));
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
return { text: '', toolCalls: [] };
|
|
169
|
-
}
|
|
170
|
-
for (const part of parts) {
|
|
171
|
-
if (part.text) {
|
|
172
|
-
text += part.text;
|
|
173
|
-
}
|
|
174
|
-
if (part.functionCall) {
|
|
175
|
-
toolCalls.push({
|
|
176
|
-
toolName: part.functionCall.name,
|
|
177
|
-
args: part.functionCall.args ?? {},
|
|
178
|
-
callId: part.functionCall.id ?? `call_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
const usage = data.usageMetadata
|
|
183
|
-
? {
|
|
184
|
-
promptTokens: data.usageMetadata.promptTokenCount ?? 0,
|
|
185
|
-
completionTokens: data.usageMetadata.candidatesTokenCount ?? 0,
|
|
186
|
-
totalTokens: data.usageMetadata.totalTokenCount ?? 0,
|
|
187
|
-
}
|
|
188
|
-
: undefined;
|
|
189
|
-
return { text, toolCalls, usage };
|
|
190
|
-
}
|
|
191
|
-
throw new Error(lastError);
|
|
192
|
-
}
|
|
193
|
-
// ---- helpers ----
|
|
194
|
-
toContents(messages) {
|
|
195
|
-
const systemParts = [];
|
|
196
|
-
const raw = [];
|
|
197
|
-
for (const msg of messages) {
|
|
198
|
-
if (msg.role === 'system') {
|
|
199
|
-
systemParts.push(msg.content);
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (msg.role === 'tool') {
|
|
203
|
-
raw.push({
|
|
204
|
-
role: 'function',
|
|
205
|
-
parts: [
|
|
206
|
-
{
|
|
207
|
-
functionResponse: {
|
|
208
|
-
name: msg.toolName ?? 'unknown',
|
|
209
|
-
response: { result: msg.content },
|
|
210
|
-
...(msg.toolCallId ? { id: msg.toolCallId } : {}),
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
});
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
if (msg.role === 'assistant' && msg.toolCalls?.length) {
|
|
218
|
-
// functionCall parts MUST be in their own model turn — never merged
|
|
219
|
-
// with text parts, because Gemini requires functionCall to be the
|
|
220
|
-
// only content in that turn.
|
|
221
|
-
raw.push({
|
|
222
|
-
role: 'model',
|
|
223
|
-
parts: msg.toolCalls.map((tc) => ({
|
|
224
|
-
functionCall: {
|
|
225
|
-
name: tc.toolName,
|
|
226
|
-
args: tc.args,
|
|
227
|
-
...(tc.callId ? { id: tc.callId } : {}),
|
|
228
|
-
},
|
|
229
|
-
})),
|
|
230
|
-
});
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
raw.push({
|
|
234
|
-
role: msg.role === 'assistant' ? 'model' : 'user',
|
|
235
|
-
parts: [{ text: msg.content }],
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
// Merge consecutive messages with the same role (Gemini rejects them),
|
|
239
|
-
// BUT never merge a functionCall model turn with a plain text model turn —
|
|
240
|
-
// Gemini requires functionCall to be the sole content in its turn.
|
|
241
|
-
const merged = [];
|
|
242
|
-
for (const item of raw) {
|
|
243
|
-
const last = merged[merged.length - 1];
|
|
244
|
-
const itemHasFunctionCall = item.parts.some((p) => p.functionCall);
|
|
245
|
-
const lastHasFunctionCall = last?.parts.some((p) => p.functionCall);
|
|
246
|
-
if (last && last.role === item.role && !itemHasFunctionCall && !lastHasFunctionCall) {
|
|
247
|
-
last.parts.push(...item.parts);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
merged.push({ ...item, parts: [...item.parts] });
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// Enforce Gemini turn-order rules by dropping invalid messages:
|
|
254
|
-
// 1. A 'function' turn must be immediately preceded by a 'model' turn
|
|
255
|
-
// that contains functionCall parts.
|
|
256
|
-
// 2. A 'model' turn with functionCall must not be the last turn
|
|
257
|
-
// (the LLM needs to respond after, not hang).
|
|
258
|
-
// We fix violations by dropping the offending message rather than
|
|
259
|
-
// crashing — the LLM will work with less context instead of erroring.
|
|
260
|
-
const contents = [];
|
|
261
|
-
for (let i = 0; i < merged.length; i++) {
|
|
262
|
-
const item = merged[i];
|
|
263
|
-
const prev = contents[contents.length - 1];
|
|
264
|
-
if (item.role === 'function') {
|
|
265
|
-
const prevHasFunctionCall = prev?.parts.some((p) => p.functionCall);
|
|
266
|
-
if (!prevHasFunctionCall) {
|
|
267
|
-
// Orphan function response — drop it to avoid 400
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (item.role === 'model') {
|
|
272
|
-
const hasFunctionCall = item.parts.some((p) => p.functionCall);
|
|
273
|
-
if (hasFunctionCall) {
|
|
274
|
-
// Look ahead: if no function response follows, drop this turn
|
|
275
|
-
// because an unanswered functionCall at the end of history is invalid.
|
|
276
|
-
const nextIsFunctionResponse = merged[i + 1]?.role === 'function';
|
|
277
|
-
if (!nextIsFunctionResponse) {
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
contents.push(item);
|
|
283
|
-
}
|
|
284
|
-
// Gemini requires the last turn to be 'user' or 'function'.
|
|
285
|
-
// If the last content is a 'model' text turn, it's safe to keep (the API
|
|
286
|
-
// will respond to it). But a trailing 'model(functionCall)' was already
|
|
287
|
-
// dropped above. No further action needed.
|
|
288
|
-
// Gemini requires contents[0] to be 'user'. If the history slice starts
|
|
289
|
-
// with model/function turns (e.g. when a history window starts mid tool
|
|
290
|
-
// exchange), drop leading turns until we reach the first 'user' turn.
|
|
291
|
-
while (contents.length > 0 && contents[0].role !== 'user') {
|
|
292
|
-
contents.shift();
|
|
293
|
-
}
|
|
294
|
-
const systemInstruction = systemParts.length ? { role: 'user', parts: [{ text: systemParts.join('\n') }] } : null;
|
|
295
|
-
return { systemInstruction, contents };
|
|
296
|
-
}
|
|
297
|
-
toFunctionDeclarations(tools) {
|
|
298
|
-
return tools.map((tool) => {
|
|
299
|
-
const properties = {};
|
|
300
|
-
const required = [];
|
|
301
|
-
for (const param of tool.parameters) {
|
|
302
|
-
const prop = {
|
|
303
|
-
type: PARAM_TYPE_MAP[param.type] ?? 'STRING',
|
|
304
|
-
description: param.description,
|
|
305
|
-
};
|
|
306
|
-
if (param.type === 'array') {
|
|
307
|
-
prop.items = {
|
|
308
|
-
type: PARAM_TYPE_MAP[param.items?.type ?? 'string'] ?? 'STRING',
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
properties[param.name] = prop;
|
|
312
|
-
if (param.required) {
|
|
313
|
-
required.push(param.name);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return {
|
|
317
|
-
name: tool.name,
|
|
318
|
-
description: tool.description,
|
|
319
|
-
parameters: {
|
|
320
|
-
type: 'OBJECT',
|
|
321
|
-
properties,
|
|
322
|
-
required,
|
|
323
|
-
},
|
|
324
|
-
};
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
exports.GeminiProvider = GeminiProvider;
|
|
329
|
-
//# sourceMappingURL=GeminiProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiProvider.js","sourceRoot":"","sources":["../../src/llm/GeminiProvider.ts"],"names":[],"mappings":";;;AAUA,MAAM,cAAc,GAA2B;IAC7C,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACf,CAAC;AA4BF,MAAM,gBAAgB,GAAG,gDAAgD,CAAC;AAE1E;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CA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index.d.ts
DELETED
package/dist/llm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/llm/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GeminiProvider = void 0;
|
|
4
|
-
var GeminiProvider_1 = require("./GeminiProvider");
|
|
5
|
-
Object.defineProperty(exports, "GeminiProvider", { enumerable: true, get: function () { return GeminiProvider_1.GeminiProvider; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
package/dist/llm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { ChatMessage } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Manages conversation history for a single session.
|
|
4
|
-
*
|
|
5
|
-
* Two parallel stores:
|
|
6
|
-
* - `messages` — working window for the LLM (gets compacted when too long)
|
|
7
|
-
* - `fullMessages` — append-only log of every message (never truncated, for UI export)
|
|
8
|
-
*
|
|
9
|
-
* Summary is kept separately so it never conflicts with component system prompts.
|
|
10
|
-
*/
|
|
11
|
-
export declare class ChatHistory {
|
|
12
|
-
private messages;
|
|
13
|
-
private fullMessages;
|
|
14
|
-
private summary;
|
|
15
|
-
private maxMessages;
|
|
16
|
-
constructor(maxMessages?: number);
|
|
17
|
-
/** Add a message to the history. */
|
|
18
|
-
add(message: ChatMessage): void;
|
|
19
|
-
/** Add multiple messages. */
|
|
20
|
-
addMany(messages: ChatMessage[]): void;
|
|
21
|
-
/**
|
|
22
|
-
* Add a message to the UI log only — does NOT enter the working window.
|
|
23
|
-
* Use for KB-answered turns: the user still sees them in the chat UI, but
|
|
24
|
-
* they never pollute the LLM context that subagents and the router analyze.
|
|
25
|
-
*/
|
|
26
|
-
addUIOnly(message: ChatMessage): void;
|
|
27
|
-
/**
|
|
28
|
-
* Remove the last message from the working window without touching fullMessages.
|
|
29
|
-
* Used to roll back an addUserMessage() when the turn is handled by KB and
|
|
30
|
-
* should not enter the LLM working context.
|
|
31
|
-
*/
|
|
32
|
-
rollbackLastWorkingMessage(): void;
|
|
33
|
-
/** Get the working message window (may be compacted). */
|
|
34
|
-
getAll(): ChatMessage[];
|
|
35
|
-
/** Get the complete untruncated message history (for UI export). */
|
|
36
|
-
getAllFull(): ChatMessage[];
|
|
37
|
-
/** Get the last N messages. */
|
|
38
|
-
getRecent(n: number): ChatMessage[];
|
|
39
|
-
/**
|
|
40
|
-
* Get conversation messages for LLM consumption.
|
|
41
|
-
* Prepends summary (if any) as a system message, then the working window.
|
|
42
|
-
*/
|
|
43
|
-
getConversation(): ChatMessage[];
|
|
44
|
-
/** Total message count (working window). */
|
|
45
|
-
get length(): number;
|
|
46
|
-
/**
|
|
47
|
-
* Whether the history should be summarized.
|
|
48
|
-
*
|
|
49
|
-
* Counts logical turns (user messages) rather than raw message count.
|
|
50
|
-
* Tool call/response pairs and _intermediate bridge messages inflate the
|
|
51
|
-
* raw count significantly per turn, so checking messages.length would
|
|
52
|
-
* trigger compaction far too early.
|
|
53
|
-
*/
|
|
54
|
-
needsSummary(): boolean;
|
|
55
|
-
/** Current summary text (if any). */
|
|
56
|
-
getSummary(): string | null;
|
|
57
|
-
/**
|
|
58
|
-
* Compact the working window: keep only the last N messages and store the
|
|
59
|
-
* summary. fullMessages is never touched.
|
|
60
|
-
*/
|
|
61
|
-
compact(summary: string, keepLast?: number): void;
|
|
62
|
-
/**
|
|
63
|
-
* Compact using an explicit tail slice — the caller has already decided
|
|
64
|
-
* which messages to keep (e.g. to avoid splitting a tool-call group).
|
|
65
|
-
* fullMessages is never touched.
|
|
66
|
-
*/
|
|
67
|
-
compactWith(summary: string, keepTail: ChatMessage[]): void;
|
|
68
|
-
/** Clear all history and summary (both working window and full log). */
|
|
69
|
-
clear(): void;
|
|
70
|
-
/** Serialise to JSON-safe object (for persistence). */
|
|
71
|
-
serialise(): {
|
|
72
|
-
messages: ChatMessage[];
|
|
73
|
-
summary: string | null;
|
|
74
|
-
fullMessages: ChatMessage[];
|
|
75
|
-
};
|
|
76
|
-
/** Restore from a serialised object. */
|
|
77
|
-
restore(data: {
|
|
78
|
-
messages: ChatMessage[];
|
|
79
|
-
summary?: string | null;
|
|
80
|
-
fullMessages?: ChatMessage[];
|
|
81
|
-
} | ChatMessage[]): void;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=ChatHistory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChatHistory.d.ts","sourceRoot":"","sources":["../../src/memory/ChatHistory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,WAAW,CAAS;gBAEhB,WAAW,SAAK;IAI5B,oCAAoC;IACpC,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAK/B,6BAA6B;IAC7B,OAAO,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAKtC;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIrC;;;;OAIG;IACH,0BAA0B,IAAI,IAAI;IAIlC,yDAAyD;IACzD,MAAM,IAAI,WAAW,EAAE;IAIvB,oEAAoE;IACpE,UAAU,IAAI,WAAW,EAAE;IAI3B,+BAA+B;IAC/B,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE;IAInC;;;OAGG;IACH,eAAe,IAAI,WAAW,EAAE;IAahC,4CAA4C;IAC5C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;;OAOG;IACH,YAAY,IAAI,OAAO;IAKvB,qCAAqC;IACrC,UAAU,IAAI,MAAM,GAAG,IAAI;IAI3B;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG,IAAI;IAK7C;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAK3D,wEAAwE;IACxE,KAAK,IAAI,IAAI;IAMb,uDAAuD;IACvD,SAAS,IAAI;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,WAAW,EAAE,CAAA;KAAE;IAQ7F,wCAAwC;IACxC,OAAO,CACL,IAAI,EAAE;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;KAAE,GAAG,WAAW,EAAE,GACvG,IAAI;CAaR"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChatHistory = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Manages conversation history for a single session.
|
|
6
|
-
*
|
|
7
|
-
* Two parallel stores:
|
|
8
|
-
* - `messages` — working window for the LLM (gets compacted when too long)
|
|
9
|
-
* - `fullMessages` — append-only log of every message (never truncated, for UI export)
|
|
10
|
-
*
|
|
11
|
-
* Summary is kept separately so it never conflicts with component system prompts.
|
|
12
|
-
*/
|
|
13
|
-
class ChatHistory {
|
|
14
|
-
messages = [];
|
|
15
|
-
fullMessages = [];
|
|
16
|
-
summary = null;
|
|
17
|
-
maxMessages;
|
|
18
|
-
constructor(maxMessages = 50) {
|
|
19
|
-
this.maxMessages = maxMessages;
|
|
20
|
-
}
|
|
21
|
-
/** Add a message to the history. */
|
|
22
|
-
add(message) {
|
|
23
|
-
this.messages.push(message);
|
|
24
|
-
this.fullMessages.push(message);
|
|
25
|
-
}
|
|
26
|
-
/** Add multiple messages. */
|
|
27
|
-
addMany(messages) {
|
|
28
|
-
this.messages.push(...messages);
|
|
29
|
-
this.fullMessages.push(...messages);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Add a message to the UI log only — does NOT enter the working window.
|
|
33
|
-
* Use for KB-answered turns: the user still sees them in the chat UI, but
|
|
34
|
-
* they never pollute the LLM context that subagents and the router analyze.
|
|
35
|
-
*/
|
|
36
|
-
addUIOnly(message) {
|
|
37
|
-
this.fullMessages.push(message);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Remove the last message from the working window without touching fullMessages.
|
|
41
|
-
* Used to roll back an addUserMessage() when the turn is handled by KB and
|
|
42
|
-
* should not enter the LLM working context.
|
|
43
|
-
*/
|
|
44
|
-
rollbackLastWorkingMessage() {
|
|
45
|
-
this.messages.pop();
|
|
46
|
-
}
|
|
47
|
-
/** Get the working message window (may be compacted). */
|
|
48
|
-
getAll() {
|
|
49
|
-
return [...this.messages];
|
|
50
|
-
}
|
|
51
|
-
/** Get the complete untruncated message history (for UI export). */
|
|
52
|
-
getAllFull() {
|
|
53
|
-
return [...this.fullMessages];
|
|
54
|
-
}
|
|
55
|
-
/** Get the last N messages. */
|
|
56
|
-
getRecent(n) {
|
|
57
|
-
return this.messages.slice(-n);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get conversation messages for LLM consumption.
|
|
61
|
-
* Prepends summary (if any) as a system message, then the working window.
|
|
62
|
-
*/
|
|
63
|
-
getConversation() {
|
|
64
|
-
const out = [];
|
|
65
|
-
if (this.summary) {
|
|
66
|
-
out.push({
|
|
67
|
-
role: 'system',
|
|
68
|
-
content: `[Previous conversation summary]: ${this.summary}`,
|
|
69
|
-
timestamp: 0,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
out.push(...this.messages);
|
|
73
|
-
return out;
|
|
74
|
-
}
|
|
75
|
-
/** Total message count (working window). */
|
|
76
|
-
get length() {
|
|
77
|
-
return this.messages.length;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Whether the history should be summarized.
|
|
81
|
-
*
|
|
82
|
-
* Counts logical turns (user messages) rather than raw message count.
|
|
83
|
-
* Tool call/response pairs and _intermediate bridge messages inflate the
|
|
84
|
-
* raw count significantly per turn, so checking messages.length would
|
|
85
|
-
* trigger compaction far too early.
|
|
86
|
-
*/
|
|
87
|
-
needsSummary() {
|
|
88
|
-
const userTurns = this.messages.filter((m) => m.role === 'user').length;
|
|
89
|
-
return userTurns > this.maxMessages;
|
|
90
|
-
}
|
|
91
|
-
/** Current summary text (if any). */
|
|
92
|
-
getSummary() {
|
|
93
|
-
return this.summary;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Compact the working window: keep only the last N messages and store the
|
|
97
|
-
* summary. fullMessages is never touched.
|
|
98
|
-
*/
|
|
99
|
-
compact(summary, keepLast = 10) {
|
|
100
|
-
this.summary = summary;
|
|
101
|
-
this.messages = this.messages.slice(-keepLast);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Compact using an explicit tail slice — the caller has already decided
|
|
105
|
-
* which messages to keep (e.g. to avoid splitting a tool-call group).
|
|
106
|
-
* fullMessages is never touched.
|
|
107
|
-
*/
|
|
108
|
-
compactWith(summary, keepTail) {
|
|
109
|
-
this.summary = summary;
|
|
110
|
-
this.messages = [...keepTail];
|
|
111
|
-
}
|
|
112
|
-
/** Clear all history and summary (both working window and full log). */
|
|
113
|
-
clear() {
|
|
114
|
-
this.messages = [];
|
|
115
|
-
this.fullMessages = [];
|
|
116
|
-
this.summary = null;
|
|
117
|
-
}
|
|
118
|
-
/** Serialise to JSON-safe object (for persistence). */
|
|
119
|
-
serialise() {
|
|
120
|
-
return {
|
|
121
|
-
messages: [...this.messages],
|
|
122
|
-
summary: this.summary,
|
|
123
|
-
fullMessages: [...this.fullMessages],
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/** Restore from a serialised object. */
|
|
127
|
-
restore(data) {
|
|
128
|
-
if (Array.isArray(data)) {
|
|
129
|
-
// Backward compatible: plain array
|
|
130
|
-
this.messages = [...data];
|
|
131
|
-
this.fullMessages = [...data];
|
|
132
|
-
this.summary = null;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.messages = [...data.messages];
|
|
136
|
-
this.summary = data.summary ?? null;
|
|
137
|
-
// Backward compatible: if fullMessages not present, seed from messages
|
|
138
|
-
this.fullMessages = data.fullMessages ? [...data.fullMessages] : [...data.messages];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.ChatHistory = ChatHistory;
|
|
143
|
-
//# sourceMappingURL=ChatHistory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChatHistory.js","sourceRoot":"","sources":["../../src/memory/ChatHistory.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;GAQG;AACH,MAAa,WAAW;IACd,QAAQ,GAAkB,EAAE,CAAC;IAC7B,YAAY,GAAkB,EAAE,CAAC;IACjC,OAAO,GAAkB,IAAI,CAAC;IAC9B,WAAW,CAAS;IAE5B,YAAY,WAAW,GAAG,EAAE;QAC1B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,oCAAoC;IACpC,GAAG,CAAC,OAAoB;QACtB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,6BAA6B;IAC7B,OAAO,C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B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC;YACpC,uEAAuE;YACvE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;CACF;AAlJD,kCAkJC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { KBSearchResult, KnowledgeBaseEntry, KnowledgeBaseProvider, LLMProvider } from '../types';
|
|
2
|
-
export type { KBSearchResult };
|
|
3
|
-
/**
|
|
4
|
-
* Knowledge base with LLM-powered semantic matching.
|
|
5
|
-
* Supports cross-language queries and synonym understanding.
|
|
6
|
-
*
|
|
7
|
-
* Suitable for small KBs (≲ 50 entries) — every search sends the full FAQ
|
|
8
|
-
* list to the LLM. For larger KBs use `UpstashKnowledgeBase` (vector search).
|
|
9
|
-
*/
|
|
10
|
-
export declare class KnowledgeBase implements KnowledgeBaseProvider {
|
|
11
|
-
private entries;
|
|
12
|
-
private llm;
|
|
13
|
-
constructor(entries?: KnowledgeBaseEntry[]);
|
|
14
|
-
/** Attach an LLM provider for semantic matching. */
|
|
15
|
-
setLLM(llm: LLMProvider): void;
|
|
16
|
-
/** Replace all entries. */
|
|
17
|
-
setEntries(entries: KnowledgeBaseEntry[]): void;
|
|
18
|
-
/** Add entries without replacing existing ones. */
|
|
19
|
-
addEntries(entries: KnowledgeBaseEntry[]): void;
|
|
20
|
-
/** Snapshot of current entries (defensive copy). */
|
|
21
|
-
getEntries(): KnowledgeBaseEntry[];
|
|
22
|
-
/** Get total entry count. */
|
|
23
|
-
get size(): number;
|
|
24
|
-
/**
|
|
25
|
-
* Search for entries relevant to the user query using LLM semantic matching.
|
|
26
|
-
* Falls back to basic token matching if LLM is not available.
|
|
27
|
-
*/
|
|
28
|
-
search(query: string, maxResults?: number): Promise<KBSearchResult[]>;
|
|
29
|
-
/** LLM-based semantic search — handles any language + synonyms. */
|
|
30
|
-
private llmSearch;
|
|
31
|
-
/** Basic token-overlap search (fallback). */
|
|
32
|
-
private tokenSearch;
|
|
33
|
-
/** Tokenize text into a set of normalized words. */
|
|
34
|
-
private tokenize;
|
|
35
|
-
/** Jaccard similarity: |A ∩ B| / |A ∪ B| */
|
|
36
|
-
private jaccardSimilarity;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=KnowledgeBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KnowledgeBase.d.ts","sourceRoot":"","sources":["../../src/memory/KnowledgeBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,WAAW,EAAe,MAAM,UAAU,CAAC;AAGpH,YAAY,EAAE,cAAc,EAAE,CAAC;AAmB/B;;;;;;GAMG;AACH,qBAAa,aAAc,YAAW,qBAAqB;IACzD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,GAAG,CAA4B;gBAE3B,OAAO,CAAC,EAAE,kBAAkB,EAAE;IAI1C,oDAAoD;IACpD,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAI9B,2BAA2B;IAC3B,UAAU,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAI/C,mDAAmD;IACnD,UAAU,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAI/C,oDAAoD;IACpD,UAAU,IAAI,kBAAkB,EAAE;IAIlC,6BAA6B;IAC7B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,SAAI,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAWtE,mEAAmE;YACrD,SAAS;IAqCvB,6CAA6C;IAC7C,OAAO,CAAC,WAAW;IAmBnB,oDAAoD;IACpD,OAAO,CAAC,QAAQ;IAShB,4CAA4C;IAC5C,OAAO,CAAC,iBAAiB;CAW1B"}
|