keyring-chatbot-agent 1.0.25 → 1.0.49

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/lib.d.ts CHANGED
@@ -1,10 +1,58 @@
1
+ import { AgentConfig } from 'keyring-agent-core';
2
+ import { AgentCore } from 'keyring-agent-core';
3
+ import { AgentResponse } from 'keyring-agent-core';
4
+ import { Chain } from 'viem/chains';
5
+ import { CSSProperties } from 'react';
6
+ import { Dispatch } from 'react';
1
7
  import { JSX } from 'react/jsx-runtime';
8
+ import { ReactNode } from 'react';
9
+ import { SetStateAction } from 'react';
2
10
 
3
11
  export declare interface Account {
4
12
  address: string;
5
13
  chainId: number | string;
6
14
  }
7
15
 
16
+ export declare const ActionForm: ({ action, initialValues, onSubmit, onCancel, isSubmitting, tokenInfo, nftInfo, disabled, language, validateGas, }: ActionFormProps) => JSX.Element | null;
17
+
18
+ declare interface ActionFormProps {
19
+ action: AgentActionType;
20
+ disabled?: boolean;
21
+ initialValues: Record<string, string>;
22
+ onSubmit: (action: AgentActionType, values: Record<string, string>) => void;
23
+ onCancel: () => void;
24
+ isSubmitting?: boolean;
25
+ tokenInfo?: MessageTokenInfo;
26
+ nftInfo?: MessageNftInfo;
27
+ /** BCP-47 tag core stamped on this action; the form translates against it. */
28
+ language?: string;
29
+ /**
30
+ * Pre-flight check that the connected wallet has enough native balance to
31
+ * cover `gasLimit × gasPrice + value` for the tx that will be built from
32
+ * `values`. Called on submit BEFORE `onSubmit`. When `{ok:false}` is
33
+ * returned, the form shows `message` as an inline error above the submit
34
+ * button and does NOT proceed. Optional — when omitted, submit proceeds
35
+ * directly (a deeper check in the host stays as the safety net).
36
+ */
37
+ validateGas?: (values: Record<string, string>) => Promise<{
38
+ ok: true;
39
+ } | {
40
+ ok: false;
41
+ message: string;
42
+ }>;
43
+ }
44
+
45
+ declare interface AddMessageOptions {
46
+ walletActions?: MessageWalletAction[];
47
+ actionButtons?: MessageActionButton[];
48
+ }
49
+
50
+ export declare type AgentActionType = 'send_native' | 'send_token' | 'swap_token' | 'approve_token' | 'wrap_native' | 'unwrap_native' | 'send_nft' | 'view_nfts' | 'view_balances' | 'check_balance' | 'token_info' | 'chat';
51
+
52
+ export { AgentConfig }
53
+
54
+ export { AgentResponse }
55
+
8
56
  export declare interface ChatUICustomization {
9
57
  chatTitle?: string;
10
58
  welcomeMessage?: string;
@@ -14,46 +62,7 @@ export declare interface ChatUICustomization {
14
62
  chatIcon?: string;
15
63
  }
16
64
 
17
- /**
18
- * `ChatWidget` is the main entry point for embedding the Keyring AI chat assistant
19
- * into your dApp. It renders a floating chat button that opens a full-featured
20
- * chat modal with AI-powered responses, token/NFT lookups, and on-chain transaction support.
21
- *
22
- * @example
23
- * ```tsx
24
- * import { ChatWidget } from '@keyringpro/chatbot-agent-sdk';
25
- *
26
- * function App() {
27
- * const { account, sendTransaction } = useWallet(); // your wallet hook
28
- *
29
- * return (
30
- * <ChatWidget
31
- * account={{ address: account.address, chainId: account.chainId }}
32
- * onTransaction={sendTransaction}
33
- * language="en"
34
- * position="bottom-right"
35
- * theme={{ primaryColor: '#6366f1', buttonSize: 56 }}
36
- * rpcUrls={{ 1: 'https://mainnet.infura.io/v3/YOUR_KEY' }}
37
- * />
38
- * );
39
- * }
40
- * ```
41
- *
42
- * @param position - Corner to anchor the widget. `'bottom-right'` (default) or `'bottom-left'`.
43
- * @param theme - Visual customisation: `primaryColor` (hex/CSS), `buttonSize` (px), `zIndex`.
44
- * @param defaultOpen - If `true`, the chat modal is open on first render. Defaults to `false`.
45
- * @param onOpen - Callback fired when the chat modal opens.
46
- * @param onClose - Callback fired when the chat modal closes.
47
- * @param account - Connected wallet info (`address` + `chainId`). Pass `undefined` when not connected.
48
- * @param onTransaction - **Required for on-chain actions.** Receives an unsigned transaction object
49
- * and must return a promise that resolves to `{ status, transactionHash?, error? }`.
50
- * The widget uses this to sign & broadcast swap / send transactions.
51
- * @param language - UI language: `'en'` (English, default), `'ja'` (Japanese), `'cn'` (Chinese).
52
- * @param rpcUrls - Optional map of `chainId → RPC URL`. When provided, these URLs take priority
53
- * over the built-in defaults for balance queries and fee estimation.
54
- * e.g. `{ 1: 'https://...', 137: 'https://...' }`
55
- */
56
- export declare const ChatWidget: ({ position, theme, defaultOpen, onOpen, onClose, account, onTransaction, language, rpcUrls, chatTitle, welcomeMessage, customSuggestions, additionalSuggestions, buttonIcon, chatIcon, customChatButton, styleButtonChat, }: ChatWidgetProps) => JSX.Element | null;
65
+ export declare const ChatWidget: ({ position, theme, defaultOpen, onOpen, onClose, account, language, rpcUrls, chatTitle, welcomeMessage, customSuggestions, additionalSuggestions, buttonIcon, chatIcon, customChatButton, styleButtonChat, modalConfig, onTransaction, }: ChatWidgetProps) => JSX.Element | null;
57
66
 
58
67
  /** Alias kept for backwards-compatibility */
59
68
  export declare type ChatWidgetLanguage = Language;
@@ -65,7 +74,6 @@ export declare interface ChatWidgetProps {
65
74
  onOpen?: () => void;
66
75
  onClose?: () => void;
67
76
  account?: Account;
68
- onTransaction?: (tx: Transaction) => Promise<TransactionResult>;
69
77
  language?: ChatWidgetLanguage;
70
78
  rpcUrls?: Record<number, string>;
71
79
  chatTitle?: string;
@@ -74,8 +82,19 @@ export declare interface ChatWidgetProps {
74
82
  additionalSuggestions?: SuggestionButtonConfig[];
75
83
  buttonIcon?: string;
76
84
  chatIcon?: string;
77
- customChatButton?: React.ReactNode;
78
- styleButtonChat?: React.CSSProperties;
85
+ customChatButton?: ReactNode;
86
+ styleButtonChat?: CSSProperties;
87
+ modalConfig?: {
88
+ isShowIcon?: boolean;
89
+ };
90
+ /**
91
+ * Invoked when the user confirms an `ActionForm` or `BuyTokenConfirmTx`. The
92
+ * widget hands over the unsigned tx `{from, to, data, value, chainId}`; the
93
+ * host signs and broadcasts, then returns
94
+ * `{status, transactionHash?, error?}`. Required for send / approve /
95
+ * wrap / unwrap / send_nft / buy.
96
+ */
97
+ onTransaction?: (tx: Transaction) => Promise<TransactionResult>;
79
98
  }
80
99
 
81
100
  export declare interface ChatWidgetTheme {
@@ -101,29 +120,314 @@ export declare interface Config {
101
120
  [key: string]: unknown;
102
121
  }
103
122
 
123
+ declare interface ConfigContextValue {
124
+ config: Config | null;
125
+ }
126
+
127
+ export declare const ConfigProvider: ({ children, initialConfig, }: ConfigProviderProps) => JSX.Element;
128
+
129
+ declare interface ConfigProviderProps {
130
+ children: React.ReactNode;
131
+ initialConfig?: Config;
132
+ }
133
+
134
+ declare interface ConnectContextDerived extends ConnectContextValue {
135
+ chainData: IChainData | undefined;
136
+ chainId: number | string | undefined;
137
+ chainType: string;
138
+ chainTypeMoralis: string;
139
+ isChainSupported: boolean;
140
+ }
141
+
142
+ declare interface ConnectContextValue {
143
+ account: Account | null;
144
+ }
145
+
146
+ export declare const ConnectProvider: ({ children, initialAccount, }: ConnectProviderProps) => JSX.Element;
147
+
148
+ declare interface ConnectProviderProps {
149
+ children: React.ReactNode;
150
+ initialAccount?: Account | null;
151
+ }
152
+
153
+ declare const _default: {
154
+ "chatTitle": "Keyring Agent",
155
+ "closeChat": "Close chat",
156
+ "messagePlaceholder": "Message ....",
157
+ "sendMessage": "Send message",
158
+ "botIsTyping": "Bot is typing",
159
+ "canIHelpYou": "Can I help you with anything?",
160
+ "suggestionAskText": "Ask a question",
161
+ "suggestionAskUserMessage": "I have a question",
162
+ "suggestionAskBotReply": "Ask me anything",
163
+ "suggestionBuyText": "Buy trending token",
164
+ "walletConnectedChainUnsupported": "Your wallet is connected but the chain is not supported for trading. Please switch to a supported chain to see trending tokens.",
165
+ "walletNotConnected": "Please connect your wallet to see trending tokens.",
166
+ "actionProcessing": "⏳ Processing transaction...",
167
+ "actionSuccess": "Transaction completed",
168
+ "actionFail": "❌ Action cancelled or failed",
169
+ "txSubmitted": "⏳ Transaction submitted. Waiting for confirmation...",
170
+ "txConfirmed": "Transaction confirmed!",
171
+ "txReverted": "❌ Transaction reverted on-chain.",
172
+ "txTimeout": "Transaction submitted but confirmation timed out. Please check manually.",
173
+ "txSuccessful": "Transaction successful!",
174
+ "txFailed": "❌ Transaction failed. Please try again.",
175
+ "txNoHandler": "No transaction handler configured.",
176
+ "txInsufficientGas": "⚠️Insufficient {symbol} for gas! You have {balance} {symbol} but need ~{fee} {symbol} for the transaction fee. Please top up your wallet and try again.",
177
+ "txError": "❌ Error: {message}",
178
+ "txErrRecipientRequired": "Recipient address is required.",
179
+ "txErrAmountRequired": "Amount is required.",
180
+ "txErrTokenContractRequired": "Token contract address is required.",
181
+ "txErrSpenderRequired": "Spender address is required.",
182
+ "txErrNftContractRequired": "NFT contract address is required.",
183
+ "txErrTokenIdRequired": "Token ID is required.",
184
+ "txErrWrapUnsupported": "Wrapped native token is not supported on chain {chainId}.",
185
+ "txErrUnsupportedAction": "Action \"{action}\" is not a supported transaction action.",
186
+ "swapConfirmButton": "Confirm",
187
+ "swapConfirmValue": "Confirm swap",
188
+ "swapReadyToProceed": "Ready to proceed with the swap?",
189
+ "swapEstimationError": "Unable to get swap estimation. Error: {error}",
190
+ "formCancel": "Cancel",
191
+ "formExecute": "Execute",
192
+ "formProcessing": "⏳ Processing...",
193
+ "formBalance": "Balance:",
194
+ "formTokenNotFound": "Token not found in your wallet.",
195
+ "formNoBalance": "You have no {symbol} balance in your wallet.",
196
+ "formInsufficientBalance": "Insufficient balance. Spendable: {balance} {symbol}",
197
+ "formFieldRequired": "{field} is required",
198
+ "formInvalidAddress": "Invalid address (Must contain 0x and 40 hex chars)",
199
+ "formMustBePositive": "Must be a positive number",
200
+ "formMustBeValidNumber": "Must be a valid number",
201
+ "openChat": "Open chat",
202
+ "openChatTitle": "Open chat support",
203
+ "walletBalanceSpendable": "This is the spendable balance of your wallet on {chain} chain. Please choose the coins you want to use for this trade.",
204
+ "walletNoTokensFound": "Sorry, I couldn't find any tokens in your wallet on {chain} chain. Please make sure you have some tokens to trade.",
205
+ "walletFetchFailed": "Sorry, I could not fetch your wallet balance. Please try again.",
206
+ "walletFetchError": "Sorry, I encountered an error fetching your wallet balance.",
207
+ "insufficientFeeToken": "Insufficient fee. Please ensure you have enough {symbol} to cover the transaction fees, or select a different token.",
208
+ "selectAmountOf": "Select the amount of {symbol} to use:\n\nSpendable: {balance} {symbol}",
209
+ "swapFeeWarning": "\n**Insufficient {symbol} for fees!**\n You have {balance} {symbol} but need ~{needed} {symbol}.\n",
210
+ "swapNeedApprove": "You need to approve {symbol} first before swapping.",
211
+ "swapApproveButton": "Approve {symbol}",
212
+ "swapApproveValue": "Approve {symbol} for swap",
213
+ "swapNoSourceToken": "You don't have the source token in your wallet or balance is 0.",
214
+ "swapSelectAmount": "Swap {from} → {to}\n\nSelect the amount of {from} to swap:\n\nSpendable: {balance} {from}",
215
+ "swapApprovalRequired": "Token approval required before swapping.\n\nStep 1: Approve {symbol}\nStep 2: Confirm Swap",
216
+ "swapEstimationFailed": "Failed to get swap estimation. Please try again.",
217
+ "swapInsufficientNativeBalance": "Insufficient balance! You have {balance} {symbol} but need {amount} {symbol}. Please top up your wallet or reduce the amount.",
218
+ "swapTokenNotInWallet": "You don't have {symbol} in your wallet. Please acquire some first before swapping.",
219
+ "swapInsufficientTokenBalance": "Insufficient balance! You have {balance} {symbol} but need {amount} {symbol}. Please reduce the amount or add more tokens.",
220
+ "selectAmountToSwap": "Select the amount of {symbol} to swap:\n\nSpendable: {balance} {symbol}",
221
+ "couldNotLoadTokenList": "Could not load token list. Please specify the destination token.",
222
+ "trendingTokensForReceive": "📈 Trending tokens on {chain} chain. Pick the token you want to receive or type the token you want to receive:",
223
+ "txProcessing": "⏳ Transaction processing... Please confirm in your wallet.",
224
+ "txConfirmedSwap": "Transaction confirmed! Your swap has been completed.",
225
+ "txRevertedSwap": "❌ Transaction reverted on-chain. Please try again.",
226
+ "txSuccessfulSwap": "Transaction successful! Your swap has been completed.",
227
+ "txSuccessfulSendToken": "Sent successfully **{amount} {symbol}** to {to}",
228
+ "txSuccessfulSendNative": "Sent successfully **{amount} {symbol}** to {to}",
229
+ "txSuccessfulSendNft": "Sent successfully NFT **{name}** (#{tokenId}) to {to}",
230
+ "txSuccessfulWrapNative": "Wrapped successfully **{amount} {from}** → **{to}**",
231
+ "txSuccessfulUnwrapNative": "Unwrapped successfully **{amount} {from}** → **{to}**",
232
+ "txDataNotAvailable": "Transaction data not available.",
233
+ "approvalDataNotAvailable": "Approval data not available.",
234
+ "approving": "Approving {symbol}... Please confirm in your wallet.",
235
+ "approvalSuccess": "{symbol} approved successfully!",
236
+ "approvalConfirmSwap": "Now you can execute the swap.",
237
+ "confirmSwapButton": "Confirm Swap",
238
+ "approvalFailed": "❌ Approval failed. Please try again.",
239
+ "couldNotFetchBalance": "Could not fetch your wallet balance.",
240
+ "couldNotLoadBalance": "Could not load balance. Please try again.",
241
+ "couldNotFetchBalanceRetry": "Could not fetch your balance. Please try again.",
242
+ "nftSendReview": "📤 Send **{name}** ({standard} #{tokenId})\n\nPlease review and fill in the recipient address below:",
243
+ "nftCollectionHeader": "Your NFTs :\n\n{list}",
244
+ "nftMoreItems": "\n\nAnd {count} more NFTs...",
245
+ "nftSelectBelow": "\n\nSelect an NFT below to send",
246
+ "nftNoCollection": "You don't have any NFTs in your wallet on this chain.",
247
+ "nftMultipleMatchesForTokenId": "I found {count} NFTs with Token ID #{tokenId} in your wallet. Please select the one you want to send:",
248
+ "nftNotFoundInWallet": "I couldn't find \"{name}\" in your NFT collection. You don't own this NFT on this chain.",
249
+ "nftFetchError": "Sorry, I encountered an error fetching your NFTs.",
250
+ "trendingTokensHeader": "📈 Here is the list of tokens that are currently trending upwards on {chain} chain",
251
+ "trendingTokensQuestion": "\nIs there any token you want to buy?",
252
+ "trendingTokensError": "Sorry, I encountered an error fetching trending tokens.",
253
+ "errorProcessingRequest": "Sorry, I encountered an error processing your request.Please try again in a few moments.",
254
+ "buttonBuyWith": "Buy with {symbol}",
255
+ "buttonUsePercent": "Use {percent}% of {symbol}",
256
+ "buttonBuyToken": "Buy {name} ({symbol})",
257
+ "buttonSendNft": "Send {name}",
258
+ "buttonSwapTo": "Swap to {name} ({symbol})",
259
+ "buttonBuySymbol": "Buy {symbol}",
260
+ "viewBalancesLoading": "Fetching your wallet balances...",
261
+ "viewBalancesHeader": "Your token balances on {chain}:\n\n{list}",
262
+ "viewBalancesEmpty": "You don't have any tokens in your wallet on this chain.",
263
+ "viewBalancesFetchError": "Sorry, I encountered an error fetching your balances.",
264
+ "buttonSendToken": "Send {symbol}",
265
+ "formMax": "MAX",
266
+ "buttonSwapToken": "Swap {symbol}",
267
+ "buttonBuyMoreToken": "Buy more {symbol}",
268
+ "actionSendNativeLabel": "Send Native Token",
269
+ "actionSendNativeDesc": "Send native token (ETH, BNB, MATIC, etc.) to an address",
270
+ "actionSendTokenLabel": "Send Token (ERC20)",
271
+ "actionSendTokenDesc": "Send an ERC20 token to an address",
272
+ "actionSwapTokenLabel": "Swap Token",
273
+ "actionSwapTokenDesc": "Swap one token for another",
274
+ "actionApproveTokenLabel": "Approve Token",
275
+ "actionApproveTokenDesc": "Approve a spender to use your tokens",
276
+ "actionWrapNativeLabel": "Wrap Native Token",
277
+ "actionWrapNativeDesc": "Wrap native token (ETH → WETH)",
278
+ "actionUnwrapNativeLabel": "Unwrap Native Token",
279
+ "actionUnwrapNativeDesc": "Unwrap native token (WETH → ETH)",
280
+ "actionSendNftLabel": "Send NFT",
281
+ "actionSendNftDesc": "Transfer an ERC721 or ERC1155 NFT to another address",
282
+ "fieldToAddress": "Recipient Address",
283
+ "fieldAmount": "Amount",
284
+ "fieldTokenContract": "Token Contract",
285
+ "fieldTokenSymbol": "Token Symbol",
286
+ "fieldDecimals": "Decimals",
287
+ "fieldTokenIn": "From Token",
288
+ "fieldTokenInSymbol": "From Symbol",
289
+ "fieldTokenOut": "To Token",
290
+ "fieldTokenOutSymbol": "To Symbol",
291
+ "fieldTokenInDecimals": "From Decimals",
292
+ "fieldTokenOutDecimals": "To Decimals",
293
+ "fieldSpenderAddress": "Spender Address",
294
+ "fieldAmountUnlimited": "Amount (empty = unlimited)",
295
+ "fieldNftContract": "NFT Contract",
296
+ "fieldTokenId": "Token ID",
297
+ "fieldTokenStandard": "Token Standard",
298
+ "fieldNftName": "NFT Name",
299
+ "formMustBePositiveInteger": "Must be a positive integer",
300
+ "formAmountExceedsNft": "Amount cannot exceed available balance {max}",
301
+ "receivedButtonValue": "Received: {value}",
302
+ "actionExecutedFor": "Action \"{action}\" executed for: {value}",
303
+ "buyTokenHelp": "I'll help you buy {symbol}. Let me show your available tokens to trade with.",
304
+ "tokenNotFoundOnChain": "I couldn't find the token \"{symbol}\" on this chain. Here are the trending tokens you can buy",
305
+ "swapPreparing": "Preparing your swap...",
306
+ "swapConfirmYes": "Yes",
307
+ "swapChooseFrom": "Please choose which token you want to swap from:",
308
+ "swapChooseTo": "You want to swap {symbol}. Please choose which token you want to receive:",
309
+ "swapNeedDetails": "I need more details for your swap. Please specify which tokens you want to swap (e.g. \"Swap 1 ETH to USDC\").",
310
+ "viewNftsLoading": "Let me show you your NFT collection!",
311
+ "sendTokenNotInWallet": "You don't have {symbol} in your wallet on this chain. Please acquire some first before sending.",
312
+ "sendTokenChoose": "Which token would you like to send?",
313
+ "sendNftChoose": "Which NFT would you like to send?",
314
+ "swapChooseToken": "Which token would you like to swap? Here are your current balances:",
315
+ "spendable": "Spendable",
316
+ "welcomeMessage": "**Welcome! 🚀**\nYou’re now connected and ready to explore the world of Blockchain. I can assist you anytime with NFT insights, trading, price tracking, and portfolio analysis.",
317
+ "sendOtherNfts": "\nIf the NFT you want to send is not in the list above, please visit our website to send it.",
318
+ "sendNftViaWebsite": "Please select the NFT you would like to send from the list and proceed via this website.",
319
+ "sendNftViaWebsiteWithLink": "Please select the NFT you would like to send from the list and proceed via [this website]({link}).",
320
+ "viewNftViaWebsite": "Please view your NFT collection on this website for more details.",
321
+ "viewNftViaWebsiteWithLink": "Please view your NFT collection on [this website]({link}) for more details.",
322
+ "buyingOnChain": "Buying {symbol} on {chain}",
323
+ "viewOnExplorer": "View on Explorer",
324
+ "copyWalletAddress": "Copy wallet address",
325
+ "copied": "Copied!",
326
+ "copyAddress": "Copy address",
327
+ "poolGeneralInfoIntro": "💧 **Liquidity Pools** are smart contracts where users deposit token pairs to provide liquidity for DEX trading (like Uniswap). Liquidity providers (LPs) earn trading fees from each swap.",
328
+ "poolGeneralInfoMetricsTitle": "**Key Metrics:**",
329
+ "poolGeneralInfoMetricTVL": "**TVL** - Total Value Locked in the pool",
330
+ "poolGeneralInfoMetricAPR": "**APR** - Estimated annual return from fees",
331
+ "poolGeneralInfoMetricVol24h": "**Volume 24h** - Trading volume in last 24 hours",
332
+ "poolGeneralInfoMetricFeeTier": "**Fee Tier** - Trading fee (0.01%, 0.05%, 0.3%, 1%)",
333
+ "poolGeneralInfoTryAsk": "Try asking something specific, like: *\"ETH/USDC pools on Base\"* or *\"Highest APR pools\"*.",
334
+ "poolNoMatch": "❌ No matching pools found.",
335
+ "poolNoMatchForTokenOnChain": "❌ No matching pools found for **{token}** on **{chain}**.",
336
+ "poolSuggestionsTitle": "💡 **Suggestions:**",
337
+ "poolSuggestionTryChain": "Try a different chain (Ethereum, Base, Arbitrum...)",
338
+ "poolSuggestionTryPair": "Try a more popular pair (ETH/USDC, ETH/USDT)",
339
+ "poolSuggestionRelaxFilters": "Remove filters if too narrow",
340
+ "poolHeaderBest": "🏆 Best Pool",
341
+ "poolHeaderSafe": "🛡️ Safest Pools",
342
+ "poolHeaderTrending": "🔥 Trending Pools",
343
+ "poolHeaderHighApr": "📈 Highest APR Pools",
344
+ "poolHeaderLowFee": "💰 Lowest Fee Pools",
345
+ "poolHeaderCompare": "⚖️ Pool Comparison",
346
+ "poolHeaderDetail": "🔎 Pool Details",
347
+ "poolHeaderGeneral": "💧 Pool Info",
348
+ "poolHeaderSearch": "🔍 Search Results",
349
+ "poolTableMetric": "Metric",
350
+ "poolTableValue": "Value",
351
+ "poolTableLink": "Link",
352
+ "poolLinkView": "View on Uniswap",
353
+ "poolRecommendationHighApr": "👉 **Recommended:** [{pair}]({link}) - Highest APR at **{apr}%**. _Note: Higher APR may come with higher risk._",
354
+ "poolRecommendationLowFee": "👉 **Recommended:** [{pair}]({link}) - Lowest fee at **{fee}%**, ideal for frequent trading.",
355
+ "poolRecommendationSafe": "👉 **Recommended:** [{pair}]({link}) - Highest TVL at **{tvl}**, deep liquidity and stable.",
356
+ "poolRecommendationTrending": "👉 **Most Active:** [{pair}]({link}) - 24h Volume **{volume}**, highest trading activity.",
357
+ "poolRecommendationTopPick": "👉 **Top pick:** [{pair}]({link}) - TVL **{tvl}**, best match for your criteria.",
358
+ "sendPositionNoId": "Please provide your LP position ID to send it. For example: \"send position 12345 to 0x...\".",
359
+ "sendPositionNotFound": "Position #{id} was not found in your wallet on {chain}. Please make sure you own this position.",
360
+ "sendPositionReview": "📤 Send LP Position **#{positionId}** ({pair})\n\nPlease enter the recipient address below:",
361
+ "sendPositionFetchError": "Error fetching your positions. Please try again.",
362
+ "poolUnsupportedChain": "This chain is not supported for data queries. Sorry for the inconvenience.",
363
+ "poolUniswapV3Only": "I can only get information of pools that is on Subgraph Uniswap V3.",
364
+ "today": "Today",
365
+ "yesterday": "Yesterday"
366
+ };
367
+
368
+ declare interface IChainData extends Chain {
369
+ logo?: string;
370
+ chainId?: number | string;
371
+ chainType?: string;
372
+ chainTypeMoralis?: string;
373
+ customName?: string;
374
+ isSupported?: boolean;
375
+ }
376
+
104
377
  export declare type Language = 'en' | 'ja' | 'cn';
105
378
 
379
+ declare interface LanguageContextValue {
380
+ language: Language;
381
+ setLanguage: (language: Language) => void;
382
+ /** Translate `key` into the current language. */
383
+ t: (key: TranslationKey) => string;
384
+ /** Translate `key` and substitute `{placeholder}` tokens in one step. */
385
+ ti: (key: TranslationKey, vars: Record<string, string>) => string;
386
+ }
387
+
388
+ export declare const LanguageProvider: ({ children, initialLanguage, }: LanguageProviderProps) => JSX.Element;
389
+
390
+ declare interface LanguageProviderProps {
391
+ children: React.ReactNode;
392
+ initialLanguage?: Language;
393
+ }
394
+
106
395
  export declare interface Message {
107
396
  id: string;
108
397
  text: string;
109
398
  sender: 'user' | 'bot';
110
399
  timestamp: Date;
111
- replyTo?: {
112
- id: string;
113
- text: string;
114
- sender: 'user' | 'bot';
115
- };
116
400
  buttons?: MessageButton[];
117
- actionData?: {
118
- action: string;
119
- parameters: Record<string, string>;
120
- status?: 'pending' | 'submitted' | 'success' | 'fail' | 'idle';
121
- tokenInfo?: MessageTokenInfo;
122
- nftInfo?: MessageNftInfo;
123
- };
401
+ /**
402
+ * One or more wallet-action forms the FE should render below this message
403
+ * (send/swap/wrap/approve/...). Populated from `AgentResponse.uiActions`.
404
+ */
405
+ walletActions?: MessageWalletAction[];
406
+ /**
407
+ * Agent-suggested follow-up buttons rendered at the bottom of this message.
408
+ * Each one re-submits its `prompt` when clicked. Stacked one-per-line.
409
+ */
410
+ actionButtons?: MessageActionButton[];
124
411
  typeChat?: TypeChat;
125
412
  }
126
413
 
414
+ /**
415
+ * Suggested-action button emitted by the agent (`AgentResponse.actionButtons`).
416
+ * Click submits `prompt` as the next user message.
417
+ */
418
+ export declare interface MessageActionButton {
419
+ /** Display text on the button. */
420
+ label: string;
421
+ /** Text sent back to the agent on click. */
422
+ prompt: string;
423
+ /**
424
+ * BCP-47 language tag of the conversation when this button was emitted.
425
+ * `prompt` is often a synthetic English command, so on click pass this back
426
+ * as `chat(prompt, { language })` to keep the reply in the right language.
427
+ */
428
+ language?: string;
429
+ }
430
+
127
431
  export declare interface MessageButton {
128
432
  id: string;
129
433
  text: string;
@@ -133,7 +437,7 @@ export declare interface MessageButton {
133
437
  fullWidth?: boolean;
134
438
  }
135
439
 
136
- declare interface MessageNftInfo {
440
+ export declare interface MessageNftInfo {
137
441
  name: string;
138
442
  image?: string;
139
443
  tokenId: string;
@@ -146,6 +450,12 @@ export declare interface MessageTokenInfo {
146
450
  name: string;
147
451
  balance: string;
148
452
  balanceFormatted: string;
453
+ /**
454
+ * Spendable balance (held − gas reserve) for native coins, as supplied by
455
+ * core in the action `parameters`. Undefined for ERC-20s and when core
456
+ * couldn't compute it — callers fall back to `balanceFormatted`.
457
+ */
458
+ spendableFormatted?: string;
149
459
  usdValue?: number;
150
460
  usdPrice?: number;
151
461
  decimals: number;
@@ -153,6 +463,55 @@ export declare interface MessageTokenInfo {
153
463
  contractAddress: string;
154
464
  }
155
465
 
466
+ /**
467
+ * One UI payload emitted by a `wallet-action` tool, attached to a bot message.
468
+ *
469
+ * Comes in two shapes:
470
+ * - **Form** payloads (`SendNativeForm`, `SendTokenForm`, `SwapTokenForm`,
471
+ * …): props is a `WalletActionProps` — `action`, `parameters`, etc.
472
+ * populated.
473
+ * - **Custom UI** payloads (`BuyTokenConfirmTx`, …): the tool emits a bespoke
474
+ * shape. `action` is empty; the raw props are in `componentProps` for the
475
+ * matching renderer to consume.
476
+ */
477
+ export declare interface MessageWalletAction {
478
+ /** Component the FE renders (e.g. "SendNativeForm", "BuyTokenConfirmTx"). */
479
+ component: string;
480
+ /** WalletActionType — empty when this is a custom-UI payload. */
481
+ action: string;
482
+ chainId: string;
483
+ walletAddress: string;
484
+ parameters: Record<string, string>;
485
+ /**
486
+ * Verbatim props for custom-UI payloads (e.g. `BuyTokenConfirmTx`). When set,
487
+ * the FE switches on `component` and forwards this to a bespoke renderer
488
+ * instead of `ActionForm`.
489
+ */
490
+ componentProps?: Record<string, unknown>;
491
+ /** Optional BCP-47 tag stamped by AgentCore (en/vi/ja/zh/...). */
492
+ language?: string;
493
+ status?: WalletActionStatus;
494
+ /** Hash returned by `onTransaction` after a successful submit. */
495
+ transactionHash?: string;
496
+ /** Error message if the submit fails. */
497
+ errorMessage?: string;
498
+ /**
499
+ * For a `BuyTokenConfirmTx` with an approve step: true once the ERC-20 approve
500
+ * tx has confirmed on-chain. Persisted with the message so a page reload
501
+ * resumes at the swap step instead of asking the user to approve again.
502
+ */
503
+ approveDone?: boolean;
504
+ /**
505
+ * Pre-resolved ERC-20 / native token info — symbol, balance, logo, USD price.
506
+ * Used by `ActionForm` to render the token info card and to clamp the amount
507
+ * field against the available balance. Built from `agent.invokeTool` lookups
508
+ * before the form is shown.
509
+ */
510
+ tokenInfo?: MessageTokenInfo;
511
+ /** Pre-resolved NFT info for `send_nft` forms. */
512
+ nftInfo?: MessageNftInfo;
513
+ }
514
+
156
515
  export declare interface SuggestionButtonConfig {
157
516
  icon?: string;
158
517
  text: string;
@@ -183,6 +542,32 @@ export declare interface TransactionResult {
183
542
  */
184
543
  export declare type TransactionStatus = 'pending' | 'process' | 'success' | 'fail';
185
544
 
545
+ /** Union of every valid translation key (derived from the English locale). */
546
+ declare type TranslationKey = keyof typeof _default;
547
+
186
548
  declare type TypeChat = 'web3' | 'normal';
187
549
 
550
+ export declare function useAgent(): AgentCore;
551
+
552
+ export declare function useAgentChat({ agent, addMessage }: UseAgentChatParams): {
553
+ send: (rawText: string, language?: string) => Promise<void>;
554
+ isTyping: boolean;
555
+ suggestedPrompts: string[];
556
+ setSuggestedPrompts: Dispatch<SetStateAction<string[]>>;
557
+ };
558
+
559
+ declare interface UseAgentChatParams {
560
+ agent: AgentCore;
561
+ addMessage: (text: string, sender: 'user' | 'bot', options?: AddMessageOptions) => Message;
562
+ }
563
+
564
+ export declare const useConfig: () => ConfigContextValue;
565
+
566
+ export declare const useConnect: () => ConnectContextDerived;
567
+
568
+ export declare const useLanguage: () => LanguageContextValue;
569
+
570
+ /** Status of a wallet-action form attached to a bot message. */
571
+ export declare type WalletActionStatus = 'pending' | 'submitted' | 'success' | 'fail' | 'idle';
572
+
188
573
  export { }