keyring-agent-core 0.2.43 → 0.2.44
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/README.md +20 -1
- package/dist/index.d.ts +308 -247
- package/dist/index.js +92 -131
- package/dist/index.native.js +209 -248
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -564,12 +564,6 @@ interface ChatMessage {
|
|
|
564
564
|
* Only set on role === 'assistant' (the final user-facing answer).
|
|
565
565
|
*/
|
|
566
566
|
subagents?: string[];
|
|
567
|
-
/**
|
|
568
|
-
* Suggested follow-up prompts attached to this assistant turn. Persisted with
|
|
569
|
-
* history so that when a session is restored, the FE can re-render the same
|
|
570
|
-
* suggestion chips next to the message. Only set on role === 'assistant'.
|
|
571
|
-
*/
|
|
572
|
-
suggestedPrompts?: string[];
|
|
573
567
|
/**
|
|
574
568
|
* UI payloads (forms / confirms / result widgets) emitted by tools during
|
|
575
569
|
* this turn. Persisted with history so the FE can re-render these widgets
|
|
@@ -597,6 +591,20 @@ interface ChatMessage {
|
|
|
597
591
|
_intermediate?: boolean;
|
|
598
592
|
timestamp: number;
|
|
599
593
|
}
|
|
594
|
+
/**
|
|
595
|
+
* Message to return instead of a tool's form, keyed by tool name.
|
|
596
|
+
*
|
|
597
|
+
* The value is the text the assistant should convey to the user — write it in
|
|
598
|
+
* whatever wording you want them to hear (a link is fine). The model still
|
|
599
|
+
* translates it into the user's language, so plain English works.
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* {
|
|
603
|
+
* 'open-swap-token-form': 'You can swap tokens directly in the app: https://app.example',
|
|
604
|
+
* 'open-buy-token-form': 'Buying is available in the app.',
|
|
605
|
+
* }
|
|
606
|
+
*/
|
|
607
|
+
type NoFormToolMessages = Record<string, string>;
|
|
600
608
|
/** Describes a parameter for a tool */
|
|
601
609
|
interface ToolParameter {
|
|
602
610
|
name: string;
|
|
@@ -628,14 +636,6 @@ interface ToolDefinition {
|
|
|
628
636
|
category?: string;
|
|
629
637
|
/** Whether this tool returns plain data, a UI payload, or an unsigned action. Default 'data'. */
|
|
630
638
|
kind?: ToolKind;
|
|
631
|
-
/**
|
|
632
|
-
* When true, AgentCore skips generating `suggestedPrompts` for any turn in
|
|
633
|
-
* which this tool was executed. Use on tools that already drive the user to
|
|
634
|
-
* a concrete next step (e.g. pool action forms, wallet-action forms) where
|
|
635
|
-
* generic suggestions add noise instead of helping.
|
|
636
|
-
* Default false.
|
|
637
|
-
*/
|
|
638
|
-
noSuggestions?: boolean;
|
|
639
639
|
}
|
|
640
640
|
/**
|
|
641
641
|
* UI payload emitted by a tool. The FE has pre-built components keyed by
|
|
@@ -658,6 +658,31 @@ interface UIPayload<TProps = Record<string, unknown>> {
|
|
|
658
658
|
*/
|
|
659
659
|
language?: string;
|
|
660
660
|
}
|
|
661
|
+
/** One NFT card in the {@link WalletNftListProps} gallery. */
|
|
662
|
+
interface WalletNftCardProps {
|
|
663
|
+
/** Display name, e.g. "Bored Ape #1234" (falls back to "#<tokenId>"). */
|
|
664
|
+
name: string;
|
|
665
|
+
/** Token id as a decimal string. */
|
|
666
|
+
tokenId: string;
|
|
667
|
+
/** Collection contract address (0x…). */
|
|
668
|
+
contractAddress: string;
|
|
669
|
+
/**
|
|
670
|
+
* Loadable image: an http(s) URL or a `data:` URI (incl. `data:image/svg+xml`).
|
|
671
|
+
* `null` when no image could be resolved — the FE shows a placeholder card.
|
|
672
|
+
*/
|
|
673
|
+
image: string | null;
|
|
674
|
+
/** Human-readable chain name, e.g. "Base". */
|
|
675
|
+
chain: string;
|
|
676
|
+
}
|
|
677
|
+
/** Props for the `WalletNftList` component — one collection's NFTs to display. */
|
|
678
|
+
interface WalletNftListProps {
|
|
679
|
+
/** Wallet whose NFTs these are (0x…). */
|
|
680
|
+
walletAddress: string;
|
|
681
|
+
/** Collection name shown as the gallery heading. */
|
|
682
|
+
collectionName: string;
|
|
683
|
+
/** The NFTs to render, in display order. */
|
|
684
|
+
nfts: WalletNftCardProps[];
|
|
685
|
+
}
|
|
661
686
|
/** Identifies a chain in BE↔FE payloads. */
|
|
662
687
|
interface ChainRef {
|
|
663
688
|
/** Hex chain id, e.g. "0x2105" for Base */
|
|
@@ -799,6 +824,9 @@ interface WalletActionProps {
|
|
|
799
824
|
action: WalletActionType;
|
|
800
825
|
/** Hex chain id, e.g. "0x1", "0x2105". Falls back to userContext.chain. */
|
|
801
826
|
chainId: string;
|
|
827
|
+
/** Human-readable chain name for display, e.g. "Ethereum", "Base". Derived
|
|
828
|
+
* from `chainId` via `chainLabel`; falls back to the raw id when unknown. */
|
|
829
|
+
chainName: string;
|
|
802
830
|
/** Connected wallet that will sign the tx. */
|
|
803
831
|
walletAddress: string;
|
|
804
832
|
/**
|
|
@@ -1009,10 +1037,8 @@ interface ConfirmAddLiquidityTxProps {
|
|
|
1009
1037
|
* button below the assistant message. When the user clicks, the FE submits
|
|
1010
1038
|
* `prompt` as the next user message.
|
|
1011
1039
|
*
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1014
|
-
* buttons (e.g. "Send USDC", "Send WETH" when the user said "send token"
|
|
1015
|
-
* without naming one).
|
|
1040
|
+
* These are deterministic, tool-emitted picker / disambig buttons (e.g.
|
|
1041
|
+
* "Send USDC", "Send WETH" when the user said "send token" without naming one).
|
|
1016
1042
|
*/
|
|
1017
1043
|
interface SuggestedAction {
|
|
1018
1044
|
/** Button label shown to the user. */
|
|
@@ -1226,17 +1252,32 @@ interface LLMProviderConfig {
|
|
|
1226
1252
|
maxTokens?: number;
|
|
1227
1253
|
/** Temperature (0-2) */
|
|
1228
1254
|
temperature?: number;
|
|
1229
|
-
/**
|
|
1255
|
+
/**
|
|
1256
|
+
* Bring-your-own Gemini API key. When set, the core talks DIRECTLY to
|
|
1257
|
+
* `https://generativelanguage.googleapis.com` with this key instead of
|
|
1258
|
+
* routing through the Keyring proxy — and the {@link AgentConfig.secretKey}
|
|
1259
|
+
* licence gate is skipped, since no Keyring-hosted resource is consumed.
|
|
1260
|
+
* Omit it to use the proxy (which requires a valid `secretKey`).
|
|
1261
|
+
*/
|
|
1262
|
+
apiKey?: string;
|
|
1263
|
+
/**
|
|
1264
|
+
* Base URL override. Defaults to the Keyring proxy
|
|
1265
|
+
* ("https://nft.keyring.app/api/gemini-stable"), or to
|
|
1266
|
+
* "https://generativelanguage.googleapis.com" when {@link apiKey} is set.
|
|
1267
|
+
*/
|
|
1230
1268
|
baseUrl?: string;
|
|
1231
1269
|
}
|
|
1232
1270
|
interface AgentConfig {
|
|
1233
1271
|
/**
|
|
1234
|
-
* License gate
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1272
|
+
* License gate for the Keyring-hosted Gemini proxy. Validated on the first
|
|
1273
|
+
* `chat()` call: if it does not match the key this bundle was built with, the
|
|
1274
|
+
* call throws before any LLM request is made.
|
|
1275
|
+
*
|
|
1276
|
+
* Optional ONLY in bring-your-own-key mode — when {@link LLMProviderConfig.apiKey}
|
|
1277
|
+
* is set the core calls the Gemini API directly and the gate is skipped.
|
|
1278
|
+
* Without an `llm.apiKey`, this is required.
|
|
1238
1279
|
*/
|
|
1239
|
-
secretKey
|
|
1280
|
+
secretKey?: string;
|
|
1240
1281
|
/** LLM provider configuration */
|
|
1241
1282
|
llm: LLMProviderConfig;
|
|
1242
1283
|
/**
|
|
@@ -1309,12 +1350,6 @@ interface AgentConfig {
|
|
|
1309
1350
|
* around 0.7 typically gives better KB recall in production.
|
|
1310
1351
|
*/
|
|
1311
1352
|
kbAnswerThreshold?: number;
|
|
1312
|
-
/**
|
|
1313
|
-
* Whether to generate suggested follow-up prompts after each answer.
|
|
1314
|
-
* Default true. Set to false to skip the extra LLM call and omit
|
|
1315
|
-
* `suggestedPrompts` from every response.
|
|
1316
|
-
*/
|
|
1317
|
-
generateSuggestions?: boolean;
|
|
1318
1353
|
/** Moralis AI tool config. Set to false to disable the built-in Moralis tool. */
|
|
1319
1354
|
moralis?: {
|
|
1320
1355
|
/** Base URL for Moralis proxy (default: https://nft.keyring.app) */
|
|
@@ -1334,14 +1369,6 @@ interface AgentConfig {
|
|
|
1334
1369
|
subagents?: {
|
|
1335
1370
|
wallet?: boolean;
|
|
1336
1371
|
'wallet-action'?: boolean;
|
|
1337
|
-
/**
|
|
1338
|
-
* Redirect-only variant of `wallet-action`. Instead of emitting in-chat
|
|
1339
|
-
* forms, every tool just tells the user they can perform the action
|
|
1340
|
-
* directly in the app (using `walletActionAppLink` when set). Mutually
|
|
1341
|
-
* exclusive with `wallet-action`: enabling this (true) turns
|
|
1342
|
-
* `wallet-action` off. Defaults to false.
|
|
1343
|
-
*/
|
|
1344
|
-
'wallet-action-app'?: boolean;
|
|
1345
1372
|
token?: boolean;
|
|
1346
1373
|
nft?: boolean;
|
|
1347
1374
|
/**
|
|
@@ -1398,22 +1425,24 @@ interface AgentConfig {
|
|
|
1398
1425
|
isProduction?: boolean;
|
|
1399
1426
|
} | false;
|
|
1400
1427
|
/**
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1403
|
-
* construction.
|
|
1428
|
+
* Tools that must NOT open a form in this deployment, mapped to the message
|
|
1429
|
+
* the user gets instead (e.g. "you can swap in the app: <link>").
|
|
1404
1430
|
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1407
|
-
*
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1431
|
+
* Use this when a deployment exposes a smaller surface than the full one —
|
|
1432
|
+
* say an app build with no in-chat swap/buy. A named tool keeps its name and
|
|
1433
|
+
* routing (so the intent still lands on it) but collects nothing and never
|
|
1434
|
+
* runs: it just relays your message, translated into the user's language.
|
|
1435
|
+
*
|
|
1436
|
+
* Any registered tool can be named. Tools left out behave normally, and
|
|
1437
|
+
* omitting this entirely leaves every tool as-is.
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* noFormTools: {
|
|
1441
|
+
* 'open-swap-token-form': 'You can swap tokens in the app: https://app.example',
|
|
1442
|
+
* 'open-buy-token-form': 'Buying is available in the app.',
|
|
1443
|
+
* }
|
|
1415
1444
|
*/
|
|
1416
|
-
|
|
1445
|
+
noFormTools?: NoFormToolMessages;
|
|
1417
1446
|
}
|
|
1418
1447
|
interface LLMToolCall {
|
|
1419
1448
|
toolName: string;
|
|
@@ -1678,8 +1707,6 @@ interface AgentResponse {
|
|
|
1678
1707
|
* Format: 8-char hex derived from timestamp + random — unique within a session.
|
|
1679
1708
|
*/
|
|
1680
1709
|
messageId: string;
|
|
1681
|
-
/** Suggested follow-up prompts for the user */
|
|
1682
|
-
suggestedPrompts?: string[];
|
|
1683
1710
|
/**
|
|
1684
1711
|
* UI components the FE should render this turn. Each entry is emitted by a
|
|
1685
1712
|
* tool with kind='ui' or 'action'. Order preserved (subagent execution order).
|
|
@@ -1688,8 +1715,7 @@ interface AgentResponse {
|
|
|
1688
1715
|
uiActions?: UIPayload[];
|
|
1689
1716
|
/**
|
|
1690
1717
|
* Tool-emitted clickable buttons aggregated across all subagent tool calls
|
|
1691
|
-
* this turn
|
|
1692
|
-
* follow-ups) — these are deterministic disambiguation / picker buttons.
|
|
1718
|
+
* this turn — deterministic disambiguation / picker buttons.
|
|
1693
1719
|
*/
|
|
1694
1720
|
actionButtons?: SuggestedAction[];
|
|
1695
1721
|
/** Full ReAct trace (for debugging / logging) — flattened across all subagents */
|
|
@@ -1727,6 +1753,11 @@ declare class AgentCore {
|
|
|
1727
1753
|
private debug;
|
|
1728
1754
|
/** Caller-supplied license key; validated lazily on first chat() via assertLicense(). */
|
|
1729
1755
|
private readonly secretKey;
|
|
1756
|
+
/**
|
|
1757
|
+
* True when the caller supplied their own Gemini API key (`llm.apiKey`), so
|
|
1758
|
+
* every LLM call goes straight to Google and the licence gate does not apply.
|
|
1759
|
+
*/
|
|
1760
|
+
private readonly ownGeminiKey;
|
|
1730
1761
|
/** True once the license has passed, so we only hash-check once. */
|
|
1731
1762
|
private licenseChecked;
|
|
1732
1763
|
private userContext;
|
|
@@ -1744,7 +1775,6 @@ declare class AgentCore {
|
|
|
1744
1775
|
private vectorKBAutoIngestPromise;
|
|
1745
1776
|
private autoIngestEnabled;
|
|
1746
1777
|
private kbAnswerThreshold;
|
|
1747
|
-
private suggestionsEnabled;
|
|
1748
1778
|
private historyLoaded;
|
|
1749
1779
|
private historyLoadingPromise;
|
|
1750
1780
|
/**
|
|
@@ -1808,8 +1838,8 @@ declare class AgentCore {
|
|
|
1808
1838
|
* args (e.g. a token-info screen that always calls `get-token-info`). Versus
|
|
1809
1839
|
* `chat()` it saves ~3-4 LLM calls (no rewrite, no router, no per-tool ReAct
|
|
1810
1840
|
* reasoning) and removes the risk of the LLM mis-parsing args, while still
|
|
1811
|
-
* turning the raw tool DATA into a natural-language answer (+
|
|
1812
|
-
*
|
|
1841
|
+
* turning the raw tool DATA into a natural-language answer (+ uiActions,
|
|
1842
|
+
* actionButtons) so the FE renders it exactly like a chat turn.
|
|
1813
1843
|
*
|
|
1814
1844
|
* Differs from {@link invokeTool}: invokeTool returns the tool's own `summary`
|
|
1815
1845
|
* (+ UI) with NO LLM pass — right for action/UI tools (forms, redirects).
|
|
@@ -1822,7 +1852,6 @@ declare class AgentCore {
|
|
|
1822
1852
|
*/
|
|
1823
1853
|
runTool(name: string, args: Record<string, unknown>, options?: {
|
|
1824
1854
|
userMessage?: string;
|
|
1825
|
-
generateSuggestions?: boolean;
|
|
1826
1855
|
language?: string;
|
|
1827
1856
|
signal?: AbortSignal;
|
|
1828
1857
|
}): Promise<AgentResponse>;
|
|
@@ -1842,7 +1871,6 @@ declare class AgentCore {
|
|
|
1842
1871
|
* `challenge` is the opaque blob from `X402PaymentRequiredProps.challenge`.
|
|
1843
1872
|
*/
|
|
1844
1873
|
submitX402Payment(challenge: unknown, signature: string, options?: {
|
|
1845
|
-
generateSuggestions?: boolean;
|
|
1846
1874
|
userQuery?: string;
|
|
1847
1875
|
}): Promise<AgentResponse>;
|
|
1848
1876
|
/** Turn paid-API data into a natural-language answer for the original question. */
|
|
@@ -1882,13 +1910,16 @@ declare class AgentCore {
|
|
|
1882
1910
|
* raw key, so the bundle never contains the key itself. When no key was baked
|
|
1883
1911
|
* in (local dev build with no SECRET_KEY) the hash is empty and the gate is a
|
|
1884
1912
|
* no-op. Cached after the first pass so we only hash once.
|
|
1913
|
+
*
|
|
1914
|
+
* The gate exists to protect the Keyring-hosted Gemini proxy. A caller that
|
|
1915
|
+
* brings their own Gemini API key (`llm.apiKey`) talks to Google directly and
|
|
1916
|
+
* consumes nothing of ours, so no secretKey is required in that mode.
|
|
1885
1917
|
*/
|
|
1886
1918
|
private assertLicense;
|
|
1887
1919
|
/**
|
|
1888
1920
|
* Process a user message and return an answer. Main entry point.
|
|
1889
1921
|
*/
|
|
1890
1922
|
chat(userMessage: string, options?: {
|
|
1891
|
-
generateSuggestions?: boolean;
|
|
1892
1923
|
language?: string;
|
|
1893
1924
|
signal?: AbortSignal;
|
|
1894
1925
|
}): Promise<AgentResponse>;
|
|
@@ -1914,13 +1945,6 @@ declare class AgentCore {
|
|
|
1914
1945
|
* 'action' attach a `ui` field to their ToolResult; the FE renders one
|
|
1915
1946
|
* component per entry in the order they were produced.
|
|
1916
1947
|
*/
|
|
1917
|
-
/**
|
|
1918
|
-
* Return true when ANY tool successfully executed across the dispatched
|
|
1919
|
-
* subagents carries `noSuggestions: true` in its registry definition. Used to
|
|
1920
|
-
* skip the suggester for turns where the user is already pointed at a
|
|
1921
|
-
* concrete next action (a form / preview).
|
|
1922
|
-
*/
|
|
1923
|
-
private subResultsTriggerNoSuggestions;
|
|
1924
1948
|
/**
|
|
1925
1949
|
* Aggregate `actionButtons` emitted by tools across all subagent tool calls
|
|
1926
1950
|
* this turn (e.g. a token-picker after the user said "send token" without
|
|
@@ -1997,7 +2021,6 @@ declare class AgentCore {
|
|
|
1997
2021
|
private synthesiserHistory;
|
|
1998
2022
|
private mergeTrace;
|
|
1999
2023
|
private finaliseAnswer;
|
|
2000
|
-
private generateSuggestions;
|
|
2001
2024
|
getHistory(): ChatMessage[];
|
|
2002
2025
|
/**
|
|
2003
2026
|
* History filtered down to user-facing messages only — the user's prompts
|
|
@@ -2007,13 +2030,6 @@ declare class AgentCore {
|
|
|
2007
2030
|
* (a pure tool-call turn). Use this to seed a chat UI on mount.
|
|
2008
2031
|
*/
|
|
2009
2032
|
getDisplayHistory(): ChatMessage[];
|
|
2010
|
-
/**
|
|
2011
|
-
* Suggested follow-up prompts attached to the most recent final assistant
|
|
2012
|
-
* turn, or `[]` if none. Used to re-seed suggestion chips after restoring
|
|
2013
|
-
* a persisted session — the chips travel with the assistant message in
|
|
2014
|
-
* storage, so this just locates the last one.
|
|
2015
|
-
*/
|
|
2016
|
-
getLastSuggestions(): string[];
|
|
2017
2033
|
clearHistory(): Promise<void>;
|
|
2018
2034
|
restoreHistory(data: {
|
|
2019
2035
|
messages: ChatMessage[];
|
|
@@ -2419,7 +2435,7 @@ declare const WALLET_ACTION_AGENT_TOOL_NAMES: readonly ["open-send-native-form",
|
|
|
2419
2435
|
declare function createWalletActionAgent(llm: LLMProvider, registry: ToolRegistry, options?: SubagentOptions): Subagent;
|
|
2420
2436
|
|
|
2421
2437
|
/** Built-in subagent ids. */
|
|
2422
|
-
type DefaultSubagentName = 'wallet' | 'wallet-action' | '
|
|
2438
|
+
type DefaultSubagentName = 'wallet' | 'wallet-action' | 'token' | 'nft' | 'nfc' | 'pool' | 'pool-subgraph' | 'ai';
|
|
2423
2439
|
/**
|
|
2424
2440
|
* Per-subagent enable flags. Default for every key is `true` EXCEPT
|
|
2425
2441
|
* `pool-subgraph`, which defaults to `false` because it is mutually exclusive
|
|
@@ -2431,10 +2447,6 @@ type DefaultSubagentName = 'wallet' | 'wallet-action' | 'wallet-action-app' | 't
|
|
|
2431
2447
|
* Turning `pool-subgraph` on automatically turns `pool` off unless the caller
|
|
2432
2448
|
* has explicitly enabled `pool: true`. This prevents two pool agents from
|
|
2433
2449
|
* competing for the same user query.
|
|
2434
|
-
*
|
|
2435
|
-
* Similarly, `wallet-action-app` (default off) is the redirect-only variant of
|
|
2436
|
-
* `wallet-action`: enabling it turns `wallet-action` off. The two are mutually
|
|
2437
|
-
* exclusive — only one wallet-action agent ever exists.
|
|
2438
2450
|
*/
|
|
2439
2451
|
type SubagentToggles = Partial<Record<DefaultSubagentName, boolean>>;
|
|
2440
2452
|
/**
|
|
@@ -2447,17 +2459,27 @@ type SubagentToggles = Partial<Record<DefaultSubagentName, boolean>>;
|
|
|
2447
2459
|
declare function createDefaultSubagents(llm: LLMProvider, registry: ToolRegistry, options?: SubagentOptions, toggles?: SubagentToggles): Subagent[];
|
|
2448
2460
|
|
|
2449
2461
|
/**
|
|
2450
|
-
* LLM provider
|
|
2451
|
-
*
|
|
2462
|
+
* LLM provider for the Gemini generateContent API. Two transports:
|
|
2463
|
+
*
|
|
2464
|
+
* • **Direct** — when `config.apiKey` is set, requests go straight to
|
|
2465
|
+
* {@link DIRECT_BASE_URL} authenticated with that key (`x-goog-api-key`).
|
|
2466
|
+
* • **Proxy** (default) — no key needed; {@link PROXY_BASE_URL} authenticates
|
|
2467
|
+
* on our behalf. Gated by the AgentCore licence check.
|
|
2468
|
+
*
|
|
2469
|
+
* The wire format is identical either way, so only the URL + headers differ.
|
|
2452
2470
|
*/
|
|
2453
2471
|
declare class GeminiProvider implements LLMProvider {
|
|
2454
2472
|
private model;
|
|
2455
2473
|
private maxTokens;
|
|
2456
2474
|
private temperature;
|
|
2457
2475
|
private baseUrl;
|
|
2476
|
+
/** Caller's own Gemini key. Empty when running through the proxy. */
|
|
2477
|
+
private apiKey;
|
|
2458
2478
|
/** Per-turn signal applied to every request until cleared. See setRequestSignal. */
|
|
2459
2479
|
private requestSignal?;
|
|
2460
2480
|
constructor(config: LLMProviderConfig);
|
|
2481
|
+
/** True when talking to Google directly with the caller's own key. */
|
|
2482
|
+
get isDirect(): boolean;
|
|
2461
2483
|
/** @see LLMProvider.setRequestSignal */
|
|
2462
2484
|
setRequestSignal(signal?: AbortSignal): void;
|
|
2463
2485
|
chat(messages: ChatMessage[], tools?: ToolDefinition[], options?: ChatOptions): Promise<LLMResponse>;
|
|
@@ -2479,6 +2501,37 @@ declare abstract class BaseTool implements Tool {
|
|
|
2479
2501
|
execute(args: Record<string, unknown>, userContext?: UserContext): Promise<ToolResult>;
|
|
2480
2502
|
}
|
|
2481
2503
|
|
|
2504
|
+
/**
|
|
2505
|
+
* Replaces a tool that would open a form with one that just delivers a message.
|
|
2506
|
+
*
|
|
2507
|
+
* Some deployments expose a smaller surface than others — e.g. an app build with
|
|
2508
|
+
* no swap/buy screens in chat. Rather than maintaining a parallel set of
|
|
2509
|
+
* redirect-only tools (which drifts out of sync with the real ones), the real
|
|
2510
|
+
* tool is swapped out for this wrapper at registration time.
|
|
2511
|
+
*
|
|
2512
|
+
* It deliberately keeps the wrapped tool's `name` and `description` so the
|
|
2513
|
+
* router still picks it for the same intents, but drops the parameters (nothing
|
|
2514
|
+
* is collected) and never runs the original tool — so no API calls, no chain
|
|
2515
|
+
* reads, and no chance of a failure in work whose result would be discarded.
|
|
2516
|
+
*/
|
|
2517
|
+
declare class NoFormTool implements Tool {
|
|
2518
|
+
readonly name: string;
|
|
2519
|
+
readonly description: string;
|
|
2520
|
+
readonly category?: string;
|
|
2521
|
+
/** Nothing is collected — the tool only relays a message. */
|
|
2522
|
+
readonly parameters: ToolParameter[];
|
|
2523
|
+
private readonly message;
|
|
2524
|
+
constructor(tool: Tool, message: string);
|
|
2525
|
+
execute(): Promise<ToolResult>;
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Register `tool`, or — when `messages` names it — a {@link NoFormTool} standing
|
|
2529
|
+
* in for it. Centralizes the check so every call site stays a one-liner.
|
|
2530
|
+
*/
|
|
2531
|
+
declare function registerMaybeNoForm(registry: {
|
|
2532
|
+
register: (tool: Tool) => void;
|
|
2533
|
+
}, tool: Tool, messages?: NoFormToolMessages): void;
|
|
2534
|
+
|
|
2482
2535
|
/**
|
|
2483
2536
|
* MoralisService — Moralis Web3 API + Cortex AI proxy.
|
|
2484
2537
|
*
|
|
@@ -2604,6 +2657,22 @@ interface NFTItem {
|
|
|
2604
2657
|
collection_logo?: string;
|
|
2605
2658
|
collection_banner_image?: string;
|
|
2606
2659
|
}
|
|
2660
|
+
/**
|
|
2661
|
+
* One row of `GET /{address}/nft/collections` — an NFT collection the wallet
|
|
2662
|
+
* holds, rather than an individual token.
|
|
2663
|
+
*/
|
|
2664
|
+
interface NFTCollectionItem {
|
|
2665
|
+
token_address: string;
|
|
2666
|
+
contract_type: 'ERC721' | 'ERC1155' | string;
|
|
2667
|
+
name?: string;
|
|
2668
|
+
symbol?: string;
|
|
2669
|
+
/** How many tokens of this collection the wallet holds. */
|
|
2670
|
+
count?: number;
|
|
2671
|
+
possible_spam?: boolean;
|
|
2672
|
+
verified_collection?: boolean;
|
|
2673
|
+
collection_logo?: string;
|
|
2674
|
+
collection_banner_image?: string;
|
|
2675
|
+
}
|
|
2607
2676
|
type NFTContractMetadata = {
|
|
2608
2677
|
token_address: string;
|
|
2609
2678
|
name: string;
|
|
@@ -3108,6 +3177,31 @@ interface WalletDefiSummaryResponse {
|
|
|
3108
3177
|
total_unclaimed_usd_value: number;
|
|
3109
3178
|
protocols: DefiProtocolSummary[];
|
|
3110
3179
|
}
|
|
3180
|
+
/** Raw response from v1 GET /wallets/{address}/defi/summary */
|
|
3181
|
+
interface WalletDefiSummaryV1Response {
|
|
3182
|
+
meta: {
|
|
3183
|
+
syncedAt?: Record<string, number | string>;
|
|
3184
|
+
unsupportedChains?: string[];
|
|
3185
|
+
failedChains?: string[];
|
|
3186
|
+
};
|
|
3187
|
+
result: {
|
|
3188
|
+
activeProtocols?: number;
|
|
3189
|
+
totalPositions?: number;
|
|
3190
|
+
totalUsd?: number;
|
|
3191
|
+
totalUnclaimedUsd?: number | null;
|
|
3192
|
+
protocols?: Array<{
|
|
3193
|
+
protocolId?: string;
|
|
3194
|
+
protocolName?: string;
|
|
3195
|
+
protocolUrl?: string;
|
|
3196
|
+
protocolLogo?: string;
|
|
3197
|
+
chainId?: string;
|
|
3198
|
+
positionCount?: number;
|
|
3199
|
+
totalUsd?: number;
|
|
3200
|
+
totalUnclaimedUsd?: number | null;
|
|
3201
|
+
accountHealthFactor?: number | null;
|
|
3202
|
+
}>;
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3111
3205
|
/**
|
|
3112
3206
|
* A single token line inside a DeFi position (supplied, borrowed, reward, …).
|
|
3113
3207
|
* Mirrors Moralis's `defiPositionToken` shape.
|
|
@@ -3443,7 +3537,16 @@ declare class MoralisService {
|
|
|
3443
3537
|
chain?: string;
|
|
3444
3538
|
}): Promise<MoralisApiResponse<TokenMetadata>>;
|
|
3445
3539
|
/**
|
|
3446
|
-
* Get NFTs owned by a wallet
|
|
3540
|
+
* Get NFTs owned by a wallet, following Moralis' cursor pagination to the END
|
|
3541
|
+
* and aggregating every page into ONE `result` array — so callers get the
|
|
3542
|
+
* wallet's complete set (for the chain / collection filter) in a single call
|
|
3543
|
+
* rather than just the first page. Paging starts from the caller-supplied
|
|
3544
|
+
* `cursor` when given, and stops when Moralis returns no next cursor or the
|
|
3545
|
+
* {@link MAX_NFT_PAGES} safety cap is reached (the trailing `cursor` in the
|
|
3546
|
+
* response is then non-empty, so a caller could resume if it ever needs to).
|
|
3547
|
+
*
|
|
3548
|
+
* A page that fails after we've already gathered rows returns what we have
|
|
3549
|
+
* (best-effort); a failure on the very first page surfaces the error.
|
|
3447
3550
|
*/
|
|
3448
3551
|
getWalletNFTs(params: {
|
|
3449
3552
|
address: string;
|
|
@@ -3460,6 +3563,32 @@ declare class MoralisService {
|
|
|
3460
3563
|
page?: number;
|
|
3461
3564
|
page_size?: number;
|
|
3462
3565
|
}>>;
|
|
3566
|
+
/**
|
|
3567
|
+
* Fetch ONE page of a wallet's NFTs, with retry/backoff. Internal helper for
|
|
3568
|
+
* {@link getWalletNFTs} — the cursor-following loop lives there; this just
|
|
3569
|
+
* resolves a single page (or a failure). A 400 is a deterministic client error,
|
|
3570
|
+
* so it breaks out of the retry loop immediately.
|
|
3571
|
+
*/
|
|
3572
|
+
private fetchWalletNftsPage;
|
|
3573
|
+
/**
|
|
3574
|
+
* Get the NFT collections a wallet holds — one row per collection rather than
|
|
3575
|
+
* one per token. Used to let the user pick a collection before we fetch the
|
|
3576
|
+
* individual NFTs inside it.
|
|
3577
|
+
*
|
|
3578
|
+
* Moralis docs: https://docs.moralis.com/data-api/evm/wallet/nft-collections
|
|
3579
|
+
*/
|
|
3580
|
+
getWalletNftCollections(params: {
|
|
3581
|
+
address: string;
|
|
3582
|
+
chain?: string;
|
|
3583
|
+
limit?: number;
|
|
3584
|
+
excludeSpam?: boolean;
|
|
3585
|
+
cursor?: string;
|
|
3586
|
+
}): Promise<MoralisApiResponse<{
|
|
3587
|
+
result: NFTCollectionItem[];
|
|
3588
|
+
cursor?: string;
|
|
3589
|
+
page?: number;
|
|
3590
|
+
page_size?: number;
|
|
3591
|
+
}>>;
|
|
3463
3592
|
/**
|
|
3464
3593
|
* Get the full metadata for a single NFT identified by its contract address
|
|
3465
3594
|
* and token id via the Moralis `GET /nft/{address}/{token_id}` endpoint.
|
|
@@ -5007,51 +5136,63 @@ declare class TransactionByHashTool extends BaseTool {
|
|
|
5007
5136
|
}>;
|
|
5008
5137
|
}
|
|
5009
5138
|
|
|
5010
|
-
|
|
5011
|
-
interface NftMessageToolConfig {
|
|
5012
|
-
/**
|
|
5013
|
-
* Destination URL. When set, the "this website" phrase in the message becomes
|
|
5014
|
-
* a Markdown link to it; when omitted/blank, the phrase stays plain text.
|
|
5015
|
-
*/
|
|
5016
|
-
url?: string;
|
|
5017
|
-
}
|
|
5018
|
-
/**
|
|
5019
|
-
* Shared base for the canned-message NFT notice tools (`get-wallet-nfts`,
|
|
5020
|
-
* `get-nft-metadata`, `get-nft-contract-info`).
|
|
5021
|
-
*
|
|
5022
|
-
* Each tool emits one fixed sentence that points the user at a website. The
|
|
5023
|
-
* phrase "this website" is rendered as a Markdown link to `config.url` when one
|
|
5024
|
-
* was supplied at AgentCore construction; otherwise it stays plain text. The
|
|
5025
|
-
* tool takes no arguments — it returns the fully-built Markdown message plus
|
|
5026
|
-
* `_instructions` telling the agent to reply with it verbatim.
|
|
5027
|
-
*/
|
|
5028
|
-
declare abstract class BaseNftMessageTool extends BaseTool {
|
|
5029
|
-
kind: ToolKind;
|
|
5030
|
-
category: string;
|
|
5031
|
-
noSuggestions: boolean;
|
|
5032
|
-
parameters: ToolParameter[];
|
|
5033
|
-
/** The phrase inside the template that links to the website. */
|
|
5034
|
-
protected readonly linkPhrase = "this website";
|
|
5035
|
-
/** Message template containing the literal `{link}` placeholder. */
|
|
5036
|
-
protected abstract readonly template: string;
|
|
5037
|
-
/** Resolved (trimmed) URL, or undefined when none was configured. */
|
|
5038
|
-
protected readonly url?: string;
|
|
5039
|
-
constructor(config?: NftMessageToolConfig);
|
|
5040
|
-
protected run(): Promise<unknown>;
|
|
5041
|
-
}
|
|
5042
|
-
|
|
5043
|
-
type WalletNFTsToolConfig = NftMessageToolConfig;
|
|
5139
|
+
type WalletNFTsToolConfig = MoralisServiceConfig;
|
|
5044
5140
|
/**
|
|
5045
5141
|
* Tool: get-wallet-nfts
|
|
5046
5142
|
*
|
|
5047
|
-
*
|
|
5048
|
-
*
|
|
5049
|
-
*
|
|
5143
|
+
* Two-step NFT browser. Only ERC-721 is reported in either step; ERC-1155
|
|
5144
|
+
* (editions / semi-fungibles) is filtered out.
|
|
5145
|
+
*
|
|
5146
|
+
* 1. No collection named ("show my NFTs") → list the wallet's COLLECTIONS via
|
|
5147
|
+
* `GET /{address}/nft/collections` and render one picker button per
|
|
5148
|
+
* collection, labelled with just the collection name.
|
|
5149
|
+
* 2. A collection named (the user typed it, or clicked a button, which submits
|
|
5150
|
+
* the collection name + contract address) → list the NFTs inside it via
|
|
5151
|
+
* `GET /{address}/nft`, each with image, name and token id.
|
|
5152
|
+
*
|
|
5153
|
+
* Moralis docs:
|
|
5154
|
+
* https://docs.moralis.com/data-api/evm/wallet/nft-collections
|
|
5155
|
+
* https://docs.moralis.com/data-api/evm/wallet/nft-balances
|
|
5050
5156
|
*/
|
|
5051
|
-
declare class WalletNFTsTool extends
|
|
5157
|
+
declare class WalletNFTsTool extends BaseTool {
|
|
5052
5158
|
name: string;
|
|
5053
5159
|
description: string;
|
|
5054
|
-
|
|
5160
|
+
category: string;
|
|
5161
|
+
parameters: ToolParameter[];
|
|
5162
|
+
private service;
|
|
5163
|
+
constructor(config?: WalletNFTsToolConfig);
|
|
5164
|
+
protected run(args: Record<string, unknown>, userContext?: UserContext): Promise<{
|
|
5165
|
+
ui: UIPayload<WalletNftListProps>;
|
|
5166
|
+
_instructions: string;
|
|
5167
|
+
walletAddress: string;
|
|
5168
|
+
collectionName: string;
|
|
5169
|
+
nftCount: number;
|
|
5170
|
+
error?: undefined;
|
|
5171
|
+
} | {
|
|
5172
|
+
error: string;
|
|
5173
|
+
} | {
|
|
5174
|
+
actionButtons?: SuggestedAction[] | undefined;
|
|
5175
|
+
_instructions: string;
|
|
5176
|
+
walletAddress: string;
|
|
5177
|
+
collectionCount: number;
|
|
5178
|
+
collections: {
|
|
5179
|
+
name: string;
|
|
5180
|
+
contractAddress: string;
|
|
5181
|
+
chain: string;
|
|
5182
|
+
nftCount: number | null;
|
|
5183
|
+
}[];
|
|
5184
|
+
error?: undefined;
|
|
5185
|
+
}>;
|
|
5186
|
+
private listCollections;
|
|
5187
|
+
private listNfts;
|
|
5188
|
+
/**
|
|
5189
|
+
* Resolve the image of every matched NFT from its on-chain `tokenURI`, grouped
|
|
5190
|
+
* by chain so each chain costs a single Multicall3 round-trip. Returns an array
|
|
5191
|
+
* positionally aligned with `matched`; each entry is a loadable image URL or
|
|
5192
|
+
* `null` when the on-chain URI was missing/unresolvable. Best-effort — any
|
|
5193
|
+
* failure degrades to `null` (and thus the Moralis fallback), never throwing.
|
|
5194
|
+
*/
|
|
5195
|
+
private resolveOnchainImages;
|
|
5055
5196
|
}
|
|
5056
5197
|
|
|
5057
5198
|
/**
|
|
@@ -5140,7 +5281,6 @@ declare class NfcBuyTool extends BaseTool {
|
|
|
5140
5281
|
kind: ToolKind;
|
|
5141
5282
|
name: string;
|
|
5142
5283
|
category: string;
|
|
5143
|
-
noSuggestions: boolean;
|
|
5144
5284
|
description: string;
|
|
5145
5285
|
parameters: ToolParameter[];
|
|
5146
5286
|
private llm?;
|
|
@@ -5624,7 +5764,6 @@ declare class OpenAddLiquidityFormTool extends BaseTool {
|
|
|
5624
5764
|
name: string;
|
|
5625
5765
|
kind: ToolKind;
|
|
5626
5766
|
category: string;
|
|
5627
|
-
noSuggestions: boolean;
|
|
5628
5767
|
description: string;
|
|
5629
5768
|
parameters: ToolParameter[];
|
|
5630
5769
|
private uniswap;
|
|
@@ -5709,7 +5848,6 @@ declare class PreviewAddLiquidityTool extends BaseTool {
|
|
|
5709
5848
|
name: string;
|
|
5710
5849
|
kind: ToolKind;
|
|
5711
5850
|
category: string;
|
|
5712
|
-
noSuggestions: boolean;
|
|
5713
5851
|
description: string;
|
|
5714
5852
|
parameters: ToolParameter[];
|
|
5715
5853
|
private pool;
|
|
@@ -5756,7 +5894,6 @@ declare class PoolPriceRangesTool extends BaseTool {
|
|
|
5756
5894
|
name: string;
|
|
5757
5895
|
description: string;
|
|
5758
5896
|
category: string;
|
|
5759
|
-
noSuggestions: boolean;
|
|
5760
5897
|
parameters: ToolParameter[];
|
|
5761
5898
|
private service;
|
|
5762
5899
|
constructor(config?: PoolPriceRangesToolConfig);
|
|
@@ -5778,7 +5915,6 @@ declare class ManageLiquidityRedirectTool extends BaseTool {
|
|
|
5778
5915
|
name: string;
|
|
5779
5916
|
description: string;
|
|
5780
5917
|
category: string;
|
|
5781
|
-
noSuggestions: boolean;
|
|
5782
5918
|
parameters: ToolParameter[];
|
|
5783
5919
|
protected run(args: Record<string, unknown>): Promise<{
|
|
5784
5920
|
_instructions: string;
|
|
@@ -5801,7 +5937,6 @@ declare class SubgraphPoolSearchTool extends BaseTool {
|
|
|
5801
5937
|
name: string;
|
|
5802
5938
|
description: string;
|
|
5803
5939
|
category: string;
|
|
5804
|
-
noSuggestions: boolean;
|
|
5805
5940
|
parameters: ToolParameter[];
|
|
5806
5941
|
private service;
|
|
5807
5942
|
constructor(config?: SubgraphPoolSearchToolConfig);
|
|
@@ -5876,7 +6011,6 @@ declare class SubgraphTrendingPoolsTool extends BaseTool {
|
|
|
5876
6011
|
name: string;
|
|
5877
6012
|
description: string;
|
|
5878
6013
|
category: string;
|
|
5879
|
-
noSuggestions: boolean;
|
|
5880
6014
|
parameters: ToolParameter[];
|
|
5881
6015
|
private service;
|
|
5882
6016
|
constructor(config?: SubgraphTrendingPoolsToolConfig);
|
|
@@ -5929,7 +6063,6 @@ declare class SubgraphPoolByAddressTool extends BaseTool {
|
|
|
5929
6063
|
name: string;
|
|
5930
6064
|
description: string;
|
|
5931
6065
|
category: string;
|
|
5932
|
-
noSuggestions: boolean;
|
|
5933
6066
|
parameters: ToolParameter[];
|
|
5934
6067
|
private service;
|
|
5935
6068
|
constructor(config?: SubgraphPoolByAddressToolConfig);
|
|
@@ -5993,7 +6126,6 @@ declare class SubgraphPoolByPositionIdTool extends BaseTool {
|
|
|
5993
6126
|
name: string;
|
|
5994
6127
|
description: string;
|
|
5995
6128
|
category: string;
|
|
5996
|
-
noSuggestions: boolean;
|
|
5997
6129
|
parameters: ToolParameter[];
|
|
5998
6130
|
private service;
|
|
5999
6131
|
constructor(config?: SubgraphPoolByPositionIdToolConfig);
|
|
@@ -6069,7 +6201,6 @@ declare class SubgraphPositionDetailTool extends BaseTool {
|
|
|
6069
6201
|
name: string;
|
|
6070
6202
|
description: string;
|
|
6071
6203
|
category: string;
|
|
6072
|
-
noSuggestions: boolean;
|
|
6073
6204
|
parameters: ToolParameter[];
|
|
6074
6205
|
private service;
|
|
6075
6206
|
constructor(config?: SubgraphPositionDetailToolConfig);
|
|
@@ -6178,7 +6309,6 @@ declare class SubgraphCoinPoolPairsTool extends BaseTool {
|
|
|
6178
6309
|
name: string;
|
|
6179
6310
|
description: string;
|
|
6180
6311
|
category: string;
|
|
6181
|
-
noSuggestions: boolean;
|
|
6182
6312
|
parameters: ToolParameter[];
|
|
6183
6313
|
private service;
|
|
6184
6314
|
constructor(config?: SubgraphCoinPoolPairsToolConfig);
|
|
@@ -6243,7 +6373,6 @@ declare class SubgraphAddPoolTool extends BaseTool {
|
|
|
6243
6373
|
name: string;
|
|
6244
6374
|
description: string;
|
|
6245
6375
|
category: string;
|
|
6246
|
-
noSuggestions: boolean;
|
|
6247
6376
|
parameters: ToolParameter[];
|
|
6248
6377
|
private service;
|
|
6249
6378
|
private linkAddLiquidity?;
|
|
@@ -6421,9 +6550,23 @@ interface ResolvedToken {
|
|
|
6421
6550
|
declare abstract class BaseWalletActionTool extends BaseTool {
|
|
6422
6551
|
kind: ToolKind;
|
|
6423
6552
|
category: string;
|
|
6424
|
-
noSuggestions: boolean;
|
|
6425
6553
|
protected abstract readonly actionType: WalletActionType;
|
|
6426
6554
|
protected abstract readonly component: string;
|
|
6555
|
+
/**
|
|
6556
|
+
* Build the UI payload the FE renders for this action. The default wraps the
|
|
6557
|
+
* resolved `parameters` in the shared {@link WalletActionProps} shape under
|
|
6558
|
+
* this tool's own `component` — which is all the send/approve forms need.
|
|
6559
|
+
*
|
|
6560
|
+
* Override to emit a component with a DIFFERENT props shape (the way
|
|
6561
|
+
* BuyTokenTool / SwapTokenTool ship their own): return any `UIPayload` and
|
|
6562
|
+
* the base forwards it untouched. `parameters` stays the tool's own resolved
|
|
6563
|
+
* map, so an override can pick from it or ignore it entirely.
|
|
6564
|
+
*/
|
|
6565
|
+
protected buildUI(input: {
|
|
6566
|
+
parameters: Record<string, string>;
|
|
6567
|
+
chainId: string;
|
|
6568
|
+
walletAddress: string;
|
|
6569
|
+
}): UIPayload<unknown>;
|
|
6427
6570
|
/**
|
|
6428
6571
|
* The fields the *user* is expected to fill in the form, with a friendly,
|
|
6429
6572
|
* user-facing label (in English — the LLM translates to the user's language).
|
|
@@ -6686,25 +6829,36 @@ declare class SendTokenTool extends BaseWalletActionTool {
|
|
|
6686
6829
|
* Resolve the user's named token from their wallet balances in ONE call,
|
|
6687
6830
|
* which doubles as the ownership check: a token to send must be held.
|
|
6688
6831
|
*
|
|
6689
|
-
* - Found with a non-zero balance → `{ token }` (address + symbol
|
|
6832
|
+
* - Found with a non-zero balance → `{ token, spendable }` (address + symbol
|
|
6833
|
+
* + decimals, plus the held balance the form caps the amount against).
|
|
6690
6834
|
* - Found but zero / not held → `{ error: 'no_balance' }`.
|
|
6691
6835
|
* - Balances unavailable (no moralis / no wallet) → fall back to
|
|
6692
6836
|
* {@link BaseWalletActionTool.resolveTokenRef} so resolution still works;
|
|
6693
|
-
* we can't verify ownership in that case, so we don't block.
|
|
6837
|
+
* we can't verify ownership in that case, so we don't block. No balance was
|
|
6838
|
+
* read, so `spendable` is omitted.
|
|
6694
6839
|
*/
|
|
6695
6840
|
private findOwnedTokenForSend;
|
|
6696
6841
|
/**
|
|
6697
6842
|
* Build a token-picker click-prompt from the LLM-supplied, already-localized
|
|
6698
6843
|
* template (in the user's language) by substituting placeholders:
|
|
6699
6844
|
* {symbol} → token symbol {amount} → the amount (or '') {to} → recipient 0x… (or '')
|
|
6700
|
-
*
|
|
6701
|
-
*
|
|
6702
|
-
*
|
|
6703
|
-
*
|
|
6704
|
-
*
|
|
6705
|
-
*
|
|
6845
|
+
* {chain} → chain name (or dropped)
|
|
6846
|
+
* The localized verb ("send"/"gửi"/…), the "to" preposition, and the "on
|
|
6847
|
+
* <chain>" preposition live INSIDE the template, so we only ever substitute
|
|
6848
|
+
* concrete values. The click-prompt is re-submitted as a fresh user turn, so
|
|
6849
|
+
* keeping it in the user's language keeps that follow-up turn in the same
|
|
6850
|
+
* language. Falls back to an English template when the LLM omits one. The full
|
|
6851
|
+
* "{to}"/"{chain}"-phrase (placeholder + its adjacent preposition) is dropped
|
|
6852
|
+
* when its value is unknown, so a trailing "đến"/"to"/"on" never dangles.
|
|
6706
6853
|
*/
|
|
6707
6854
|
private buildSendPrompt;
|
|
6855
|
+
/**
|
|
6856
|
+
* Substitute a placeholder with its value, or — when the value is missing —
|
|
6857
|
+
* drop the placeholder together with its adjacent preposition token, which may
|
|
6858
|
+
* sit BEFORE it ("... to {to}", "... on {chain}") or AFTER it in languages with
|
|
6859
|
+
* postpositions ("{chain} で ..."). Try both, then remove any stray brace.
|
|
6860
|
+
*/
|
|
6861
|
+
private fillOrDropPhrase;
|
|
6708
6862
|
}
|
|
6709
6863
|
|
|
6710
6864
|
/**
|
|
@@ -6778,7 +6932,6 @@ declare class BuyTokenTool extends BaseTool {
|
|
|
6778
6932
|
name: string;
|
|
6779
6933
|
kind: ToolKind;
|
|
6780
6934
|
category: string;
|
|
6781
|
-
noSuggestions: boolean;
|
|
6782
6935
|
private readonly moralis?;
|
|
6783
6936
|
/** Trending tokens come from Pantograph (top-gainers), not Moralis. */
|
|
6784
6937
|
private readonly pantograph?;
|
|
@@ -7086,7 +7239,6 @@ declare class SwapTokenTool extends BaseTool {
|
|
|
7086
7239
|
name: string;
|
|
7087
7240
|
kind: ToolKind;
|
|
7088
7241
|
category: string;
|
|
7089
|
-
noSuggestions: boolean;
|
|
7090
7242
|
private readonly moralis?;
|
|
7091
7243
|
/** Trending tokens come from Pantograph (top-gainers), not Moralis. */
|
|
7092
7244
|
private readonly pantograph?;
|
|
@@ -7269,10 +7421,6 @@ declare class SwapTokenTool extends BaseTool {
|
|
|
7269
7421
|
private formatPrice;
|
|
7270
7422
|
}
|
|
7271
7423
|
|
|
7272
|
-
/** Optional NFT website link, shown when more than one owned NFT matches. */
|
|
7273
|
-
interface SendNftToolConfig {
|
|
7274
|
-
url?: string;
|
|
7275
|
-
}
|
|
7276
7424
|
/**
|
|
7277
7425
|
* Tool: open-send-nft-form
|
|
7278
7426
|
*
|
|
@@ -7281,20 +7429,20 @@ interface SendNftToolConfig {
|
|
|
7281
7429
|
* { contract_address, token_id, to_address, token_standard, amount, maxAmount, nft_name }
|
|
7282
7430
|
*
|
|
7283
7431
|
* Resolution rules (in order):
|
|
7284
|
-
* - No identifier at all →
|
|
7432
|
+
* - No identifier at all → ask the user for the contract, token id and
|
|
7433
|
+
* recipient; nothing to pre-fill, so no form is opened.
|
|
7285
7434
|
* - contract_address + token_id → confirm ownership; emit form (image + name +
|
|
7286
7435
|
* token_standard + maxAmount come from the wallet row). Not held → error.
|
|
7287
7436
|
* - contract_address only → list the user's holdings in that collection.
|
|
7288
|
-
* • 0 → error • 1 → form • >1 →
|
|
7437
|
+
* • 0 → error • 1 → form pre-filled • >1 → empty form.
|
|
7289
7438
|
* - token_id only → list all owned NFTs whose token_id matches.
|
|
7290
|
-
* • 0 → error • 1 → form • >1 →
|
|
7439
|
+
* • 0 → error • 1 → form pre-filled • >1 → empty form.
|
|
7291
7440
|
* - nft_name only → fuzzy-match against owned NFTs' names.
|
|
7292
|
-
* • 0 → error • 1 → form • >1 →
|
|
7441
|
+
* • 0 → error • 1 → form pre-filled • >1 → empty form.
|
|
7293
7442
|
*
|
|
7294
7443
|
* When more than one owned NFT matches we cannot safely pick one for the user,
|
|
7295
|
-
* so we
|
|
7296
|
-
*
|
|
7297
|
-
* by the other NFT notice tools.
|
|
7444
|
+
* so we still open the form (carrying only what the user typed) and let the FE
|
|
7445
|
+
* handle the selection.
|
|
7298
7446
|
*/
|
|
7299
7447
|
declare class SendNftTool extends BaseWalletActionTool {
|
|
7300
7448
|
name: string;
|
|
@@ -7304,25 +7452,9 @@ declare class SendNftTool extends BaseWalletActionTool {
|
|
|
7304
7452
|
readonly key: "to_address";
|
|
7305
7453
|
readonly label: "the recipient address";
|
|
7306
7454
|
}];
|
|
7307
|
-
/** Resolved (trimmed) NFT website URL, used when >1 owned NFTs match. */
|
|
7308
|
-
private readonly url?;
|
|
7309
|
-
constructor(config?: MoralisServiceConfig, options?: SendNftToolConfig);
|
|
7310
7455
|
description: string;
|
|
7311
7456
|
parameters: ToolParameter[];
|
|
7312
|
-
protected buildParameters(args: Record<string, unknown>, userContext?: UserContext): Promise<Record<string, string
|
|
7313
|
-
error: "no_nft_specified" | "multiple_nfts_matched";
|
|
7314
|
-
message: string;
|
|
7315
|
-
_instructions: string;
|
|
7316
|
-
}>;
|
|
7317
|
-
/**
|
|
7318
|
-
* Fixed "go to the NFT website" notice. Used whenever we cannot safely
|
|
7319
|
-
* resolve a single NFT to pre-fill the form — either the user named none
|
|
7320
|
-
* (`no_nft_specified`) or more than one owned NFT matched
|
|
7321
|
-
* (`multiple_nfts_matched`). The phrase "this website" becomes a Markdown
|
|
7322
|
-
* link when a URL is configured; otherwise it stays plain text. Mirrors the
|
|
7323
|
-
* pattern used by the other NFT notice tools.
|
|
7324
|
-
*/
|
|
7325
|
-
private websiteNotice;
|
|
7457
|
+
protected buildParameters(args: Record<string, unknown>, userContext?: UserContext): Promise<Record<string, string>>;
|
|
7326
7458
|
private normaliseString;
|
|
7327
7459
|
private normaliseTokenId;
|
|
7328
7460
|
private normaliseAmountInt;
|
|
@@ -7332,77 +7464,6 @@ declare class SendNftTool extends BaseWalletActionTool {
|
|
|
7332
7464
|
private paramsFromNft;
|
|
7333
7465
|
}
|
|
7334
7466
|
|
|
7335
|
-
/**
|
|
7336
|
-
* Config for the redirect-only wallet-action tools used by the
|
|
7337
|
-
* `wallet-action-app` subagent.
|
|
7338
|
-
*/
|
|
7339
|
-
interface WalletActionAppToolConfig {
|
|
7340
|
-
/**
|
|
7341
|
-
* Optional link to the app where the user performs the action. When set, the
|
|
7342
|
-
* tool surfaces it as plain text so the user can open the app directly. When
|
|
7343
|
-
* omitted, the tool just tells the user the action is done in the app.
|
|
7344
|
-
*/
|
|
7345
|
-
appLink?: string;
|
|
7346
|
-
/**
|
|
7347
|
-
* Optional NFT website link, used ONLY by the send-NFT tool. Mirrors the
|
|
7348
|
-
* `wallet-action` SendNftTool: when set, the notice carries a clickable
|
|
7349
|
-
* Markdown link to this URL; when omitted, the website phrase stays plain
|
|
7350
|
-
* text. Separate from `appLink` because sending an NFT is done on the NFT
|
|
7351
|
-
* website, not the wallet-action app.
|
|
7352
|
-
*/
|
|
7353
|
-
nftLink?: string;
|
|
7354
|
-
}
|
|
7355
|
-
interface ActionSpec {
|
|
7356
|
-
/** Tool name — mirrors the matching `wallet-action` form tool it replaces. */
|
|
7357
|
-
name: string;
|
|
7358
|
-
/** Routing description so the agent picks this tool for the matching intent. */
|
|
7359
|
-
description: string;
|
|
7360
|
-
/** Human phrase used in the redirect message, e.g. "send a token". */
|
|
7361
|
-
what: string;
|
|
7362
|
-
/**
|
|
7363
|
-
* Which link the redirect points to. `'app'` (default) → the wallet-action
|
|
7364
|
-
* app (`appLink`); `'nft'` → the NFT website (`nftLink`), matching how the
|
|
7365
|
-
* `wallet-action` SendNftTool points NFT sends to the NFT site.
|
|
7366
|
-
*/
|
|
7367
|
-
linkKind?: 'app' | 'nft';
|
|
7368
|
-
}
|
|
7369
|
-
/**
|
|
7370
|
-
* Redirect-only wallet-action tool.
|
|
7371
|
-
*
|
|
7372
|
-
* The `wallet-action-app` subagent is a variant of `wallet-action` for
|
|
7373
|
-
* deployments where the action is NOT performed in chat. Instead of emitting a
|
|
7374
|
-
* pre-filled form, every tool returns a static instruction telling the user
|
|
7375
|
-
* they can perform the action directly in the app. No API calls, no chain
|
|
7376
|
-
* reads, no parameters.
|
|
7377
|
-
*/
|
|
7378
|
-
declare class WalletActionAppTool extends BaseTool {
|
|
7379
|
-
name: string;
|
|
7380
|
-
description: string;
|
|
7381
|
-
category: string;
|
|
7382
|
-
noSuggestions: boolean;
|
|
7383
|
-
parameters: ToolParameter[];
|
|
7384
|
-
private readonly what;
|
|
7385
|
-
private readonly linkKind;
|
|
7386
|
-
private readonly appLink?;
|
|
7387
|
-
private readonly nftLink?;
|
|
7388
|
-
constructor(spec: ActionSpec, config?: WalletActionAppToolConfig);
|
|
7389
|
-
protected run(): Promise<{
|
|
7390
|
-
message: string;
|
|
7391
|
-
_instructions: string;
|
|
7392
|
-
} | {
|
|
7393
|
-
url?: string | undefined;
|
|
7394
|
-
_instructions: string;
|
|
7395
|
-
}>;
|
|
7396
|
-
/**
|
|
7397
|
-
* Fixed "go to the NFT website" notice — byte-for-byte the same pattern as
|
|
7398
|
-
* the `wallet-action` SendNftTool: the website phrase becomes a clickable
|
|
7399
|
-
* Markdown link when `nftLink` is configured, plain text otherwise.
|
|
7400
|
-
*/
|
|
7401
|
-
private nftWebsiteNotice;
|
|
7402
|
-
}
|
|
7403
|
-
/** Create the full set of redirect-only wallet-action tools. */
|
|
7404
|
-
declare function createWalletActionAppTools(config?: WalletActionAppToolConfig): WalletActionAppTool[];
|
|
7405
|
-
|
|
7406
7467
|
/**
|
|
7407
7468
|
* Shared JSON-RPC client + default public RPC endpoints.
|
|
7408
7469
|
*
|
|
@@ -8018,4 +8079,4 @@ declare class AbortError extends Error {
|
|
|
8018
8079
|
*/
|
|
8019
8080
|
declare function isAbortError(err: unknown): boolean;
|
|
8020
8081
|
|
|
8021
|
-
export { AI_AGENT_TOOL_NAMES, AbortError, type AddLiquidityFormProps, type AddLiquiditySummary, type AffiliateFee, type AgentConfig, AgentCore, type AgentResponse, ApproveTokenTool, BaseNftAiTool,
|
|
8082
|
+
export { AI_AGENT_TOOL_NAMES, AbortError, type AddLiquidityFormProps, type AddLiquiditySummary, type AffiliateFee, type AgentConfig, AgentCore, type AgentResponse, ApproveTokenTool, BaseNftAiTool, BaseSwapService, BaseTool, BaseWalletActionTool, type BuyTokenConfirmTxProps, type BuyTokenSide, BuyTokenTool, type ChainMeta, type ChainRef, type ChainSelector, ChatHistory, type ChatMessage, type ChatOptions, type ChatRole, type CheckApprovalParams, type CheckApprovalResult, type ConfirmAddLiquidityTxProps, type CortexResponse, DEFAULT_CHAIN, DEFAULT_PROVIDER, DEFAULT_RPC_BY_CHAIN, DebridgeAdapter, type DecodedCall, type DecodedEvent, type DecodedParam, type DefaultSubagentName, type DefiPosition, type DefiPositionDetails, type DefiPositionToken, type DefiProtocolSummary, EstimatePoolYieldTool, type EstimatePoolYieldToolConfig, type ExchangeProviderConfig, type ExecuteSwapParams, type ExecuteSwapResult, GeminiProvider, GeminiSearchAiTool, type GeminiSearchAiToolConfig, HEX_TO_PANTOGRAPH, type HolderChangePeriod, type HolderSupplyTier, type HttpMethod, type IngestKnowledgeBaseInput, type IngestKnowledgeBaseResult, type InputTokenInfo, type KBSearchResult, KnowledgeBase, type KnowledgeBaseEntry, type KnowledgeBaseProvider, type LLMProvider, type LLMProviderConfig, type LLMResponse, type LLMToolCall, ManageLiquidityRedirectTool, type MarketplaceLink, type MoralisApiResponse, MoralisService, type MoralisServiceConfig, NFC_AGENT_TOOL_NAMES, NFC_AMAZON_DEFAULT_DOMAIN, NFC_AMAZON_DOMAINS, type NFTCollectionItem, NFTContractInfoTool, type NFTContractMetadata, type NFTItem, type NFTLastSale, type NFTMetadata, NFTMetadataTool, NFT_AGENT_TOOL_NAMES, type NativeTokenInfo, NfcBuyTool, NfcInfoTool, type NftTransferLastSale, NoFormTool, type NoFormToolMessages, OpenAddLiquidityFormTool, type OpenAddLiquidityFormToolConfig, POOL_AGENT_TOOL_NAMES, PantographService, type PantographServiceConfig, type PaymentToken, PoolByAddressTool, type PoolByAddressToolConfig, PoolDetailTool, type PoolDetailToolConfig, type PoolDisplayInfo, PoolFallbackAiTool, type PoolFallbackAiToolConfig, type PoolOnchainInfo, PoolPriceRangesTool, type PoolPriceRangesToolConfig, PoolSearchTool, type PoolSearchToolConfig, PoolService, type PoolServiceConfig, type PresetInputs, PreviewAddLiquidityTool, type PreviewAddLiquidityToolConfig, type PriceBounds, type PriceRangePrefill, type ProviderName, type QuickRate, type RangePreset, type ReActPhase, type ReActStep, type ReActTrace, RelayAdapter, type ResolvedRange, Router, type RouterAssignment, type RouterDecision, SUPPORTED_CHAINS, SUPPORTED_CHAINS_LABEL, SWAP_PROVIDER_CONFIG, SendNativeTool, SendNftTool, SendTokenTool, type StorageProvider, Subagent, type SubagentCard, type SubagentOptions, type SubagentParams, type SubagentResult, type SubagentTask, type SubagentToggles, SubgraphAddPoolTool, type SubgraphAddPoolToolConfig, SubgraphCoinPoolPairsTool, type SubgraphCoinPoolPairsToolConfig, SubgraphPoolByAddressTool, type SubgraphPoolByAddressToolConfig, SubgraphPoolByPositionIdTool, type SubgraphPoolByPositionIdToolConfig, SubgraphPoolSearchTool, type SubgraphPoolSearchToolConfig, SubgraphPositionDetailTool, type SubgraphPositionDetailToolConfig, SubgraphTrendingPoolsTool, type SubgraphTrendingPoolsToolConfig, type SuggestedAction, Summarizer, type SupportedChainId, type SupportedChainName, type SwapQuoteParams, type SwapQuoteResult, type SwapServiceConfig, SwapServiceFactory, type SwapTokenConfirmTxProps, SwapTokenTool, type SwapTxData, Synthesizer, TOKEN_AGENT_TOOL_NAMES, TRANSFER_TOPIC, TRENDING_DEFAULT_BY_HEX_CHAIN, type TokenAnalyticsResponse, type TokenAnalyticsTimeframeBuckets, TokenAnalyticsTool, type TokenAnalyticsToolConfig, type TokenApproval, type TokenApprovalSpender, type TokenApprovalToken, type TokenBalance, type TokenDisplay, type TokenHoldersResponse, TokenHoldersTool, type TokenHoldersToolConfig, TokenInfoTool, type TokenInfoToolConfig, type TokenMetadata, type TokenScoreMetrics, type TokenScoreResponse, type TokenScoreSupply, type TokenScoreTimeframeBuckets, TokenScoreTool, type TokenScoreToolConfig, type Tool, type ToolDefinition, type ToolKind, type ToolParameter, ToolRegistry, type ToolResult, type TopGainerTimeFrames, type TopGainerToken, type TopGainersTimeFrame, TopGainersTool, type TopGainersToolConfig, TopPoolsTool, type TopPoolsToolConfig, type TrackStatus, type TrackTransactionParams, type TrackTransactionResult, type TransactionByHashResponse, TransactionByHashTool, type TransactionByHashToolConfig, type TransactionLog, type TransactionReceipt, type TransactionReceiptLog, type TrendingToken, type TrendingTokenTimeframeBuckets, TrendingTokensTool, type TrendingTokensToolConfig, type UIPayload, UNISWAP_CHAIN_SLUG, type UnsignedTx, type UpstashEmbedStrategy, type UpstashFusionAlgorithm, type UpstashKBUpsertEntry, UpstashKnowledgeBase, type UpstashKnowledgeBaseConfig, type UserContext, type VectorKBConfig, WALLET_ACTION_AGENT_TOOL_NAMES, WALLET_AGENT_TOOL_NAMES, type WalletActionProps, type WalletActionType, type WalletApprovalsResponse, WalletApprovalsTool, type WalletApprovalsToolConfig, type WalletDefiPositionSummary, WalletDefiPositionsTool, type WalletDefiPositionsToolConfig, type WalletDefiPositionsV1Response, type WalletDefiProtocolPositionsResponse, WalletDefiProtocolPositionsTool, type WalletDefiProtocolPositionsToolConfig, type WalletDefiProtocolPositionsV1Response, type WalletDefiSummaryResponse, WalletDefiSummaryTool, type WalletDefiSummaryToolConfig, type WalletDefiSummaryV1Response, type WalletHistoryCategory, type WalletHistoryContractInteraction, type WalletHistoryErc20Transfer, type WalletHistoryItem, type WalletHistoryNativeTransfer, type WalletHistoryNftTransfer, type WalletHistoryResponse, WalletHistoryTool, type WalletHistoryToolConfig, WalletNFTsTool, type WalletNFTsToolConfig, type WalletNftCardProps, type WalletNftListProps, type WalletNftTransferItem, type WalletNftTransfersResponse, WalletNftTransfersTool, type WalletNftTransfersToolConfig, type WalletPnlDaysWindow, type WalletPnlResponse, type WalletPnlSummaryResponse, WalletPnlSummaryTool, type WalletPnlSummaryToolConfig, type WalletPnlTokenItem, WalletPnlTool, type WalletPnlToolConfig, WalletTokenBalancesTool, type WalletTokenBalancesToolConfig, type WalletTokenTransferItem, type WalletTokenTransfersResponse, WalletTokenTransfersTool, type WalletTokenTransfersToolConfig, type WebsiteTrustExtraData, type WebsiteTrustInput, WebsiteTrustKeyringAgent, type WebsiteTrustKeyringAgentConfig, type WebsiteTrustResult, type X402Authorization, type X402Challenge, type X402Outcome, type X402PaymentRequiredProps, type X402RequestSpec, type X402Requirements, type X402SignRequest, type X402Signer, type X402TypedData, ZERO_ADDRESS, amazonDomainForLanguage, apiClient, buildChallenge, buildRangePresets, buildUniswapPoolUrl, clampTick, completeX402, configureSupportedChains, createAiAgent, createDefaultSubagents, createNfcAgent, createNftAgent, createPoolAgent, createTokenAgent, createWalletActionAgent, createWalletAgent, createX402SignatureProvider, displayFromChallenge, encodeSignedHeader, ethCallAt, ethCallByChain, fetchTopMarketplaces, getAffiliateFee, getChainMeta, getDefaultRpcUrl, getGatewayAddress, getGatewayChains, getNativeTokenInfo, getPositionManagerAddress, getProviderByChain, ingestKnowledgeBase, isAbortError, nfcAmazonSearchUrl, normaliseCountry, normalizePriceRangeToPool, priceToTick, registerMaybeNoForm, requestWithX402, resolveNfcShopLinks, resolveRpcUrl, roundTickToSpacing, rpcCall, setRpcOverrides, swapServiceFactory, tickToPrice, toPantographChain };
|