@t2000/engine 0.6.16 → 0.7.1
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 +9 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +21 -28
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ QueryEngine.submitMessage()
|
|
|
87
87
|
|
|
88
88
|
## Built-in Tools
|
|
89
89
|
|
|
90
|
-
### Read Tools (
|
|
90
|
+
### Read Tools (19 — parallel, auto-approved)
|
|
91
91
|
|
|
92
92
|
| Tool | Description |
|
|
93
93
|
|------|-------------|
|
|
@@ -96,8 +96,13 @@ QueryEngine.submitMessage()
|
|
|
96
96
|
| `health_check` | Health factor with risk assessment |
|
|
97
97
|
| `rates_info` | Current supply/borrow APYs |
|
|
98
98
|
| `transaction_history` | Recent transaction log |
|
|
99
|
+
| `explain_tx` | Human-readable transaction explanation from digest |
|
|
100
|
+
| `web_search` | Web search via Brave Search API |
|
|
99
101
|
| `swap_quote` | Preview swap route, output amount, and price impact (no execution) |
|
|
100
102
|
| `volo_stats` | VOLO liquid staking stats — vSUI/SUI rate, APY, TVL |
|
|
103
|
+
| `portfolio_analysis` | Portfolio breakdown with diversification insights |
|
|
104
|
+
| `protocol_deep_dive` | Deep protocol analysis — TVL, yields, risks, alternatives |
|
|
105
|
+
| `mpp_services` | Browse available MPP gateway services and endpoints |
|
|
101
106
|
| `defillama_yield_pools` | Top yield pools by APY, filterable by chain |
|
|
102
107
|
| `defillama_protocol_info` | Protocol TVL, category, chains |
|
|
103
108
|
| `defillama_token_prices` | Current USD prices for Sui tokens |
|
|
@@ -106,11 +111,11 @@ QueryEngine.submitMessage()
|
|
|
106
111
|
| `defillama_protocol_fees` | Protocol fees/revenue rankings |
|
|
107
112
|
| `defillama_sui_protocols` | Sui ecosystem protocols — TVL, category, changes |
|
|
108
113
|
|
|
109
|
-
### Write Tools (
|
|
114
|
+
### Write Tools (11 — serial, confirmation required)
|
|
110
115
|
|
|
111
116
|
| Tool | Description |
|
|
112
117
|
|------|-------------|
|
|
113
|
-
| `save_deposit` | Deposit to savings (
|
|
118
|
+
| `save_deposit` | Deposit **USDC** to savings (NAVI); non-USDC collateral must be swapped first |
|
|
114
119
|
| `withdraw` | Withdraw from savings (optional `asset` for multi-asset withdrawals) |
|
|
115
120
|
| `send_transfer` | Send USDC to an address |
|
|
116
121
|
| `borrow` | Borrow USDC against collateral |
|
|
@@ -120,6 +125,7 @@ QueryEngine.submitMessage()
|
|
|
120
125
|
| `swap_execute` | Swap any token pair via Cetus Aggregator (20+ DEXs) |
|
|
121
126
|
| `volo_stake` | Stake SUI for vSUI (VOLO liquid staking) |
|
|
122
127
|
| `volo_unstake` | Unstake vSUI back to SUI |
|
|
128
|
+
| `save_contact` | Save a contact name + address for quick sends |
|
|
123
129
|
|
|
124
130
|
## Configuration
|
|
125
131
|
|
package/dist/index.d.ts
CHANGED
|
@@ -823,7 +823,6 @@ declare const transactionHistoryTool: Tool<{
|
|
|
823
823
|
|
|
824
824
|
declare const saveDepositTool: Tool<{
|
|
825
825
|
amount: number;
|
|
826
|
-
asset?: string | undefined;
|
|
827
826
|
}, {
|
|
828
827
|
success: boolean;
|
|
829
828
|
tx: string;
|
|
@@ -1174,6 +1173,6 @@ declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<Wal
|
|
|
1174
1173
|
declare function fetchTokenPrices(coinTypes: string[]): Promise<Record<string, number>>;
|
|
1175
1174
|
declare function clearPriceCache(): void;
|
|
1176
1175
|
|
|
1177
|
-
declare const DEFAULT_SYSTEM_PROMPT = "You are a financial agent on Sui. You manage money and access paid APIs via MPP micropayments.\n\n## Response rules\n- 1-2 sentences max. No bullet lists unless asked. No preambles.\n- Never say \"Would you like me to...\", \"Sure!\", \"Great question!\", \"Absolutely!\" \u2014 just do it or say you can't.\n- Lead with the result. After tool calls, state the outcome with real numbers. Done.\n- Present amounts as $1,234.56 and rates as X.XX% APY.\n- Show top 3 results unless asked for more. Summarize totals in one line.\n\n## Execution rule\nOnly offer to execute actions you have tools for. If you retrieved a quote, data, or information but have no tool to act on it, give the user the result and tell them where to execute manually \u2014 in one sentence. Never say \"Would you like me to proceed?\" unless you have a tool that can actually proceed.\n\n## Before acting\n- ALWAYS call a read tool first before any write tool \u2014 balance_check before save/send/borrow, savings_info before withdraw.\n- Show real numbers from tools \u2014 never fabricate rates, amounts, or balances.\n- When user says \"all\" or an imprecise amount, call the read tool first to get the exact number.\n\n## Tool usage\n- Use tools proactively \u2014 don't refuse requests you can handle.\n- For real-world questions (weather, search, news, prices), use pay_api. Tell the user the cost first.\n- For broad market data (yields across protocols, token prices, TVL, protocol comparisons), use defillama_* tools.\n- To discover Sui protocols, use defillama_sui_protocols first, then defillama_protocol_info with the slug.\n- Run multiple read-only tools in parallel when you need several data points.\n- If a tool errors, say what went wrong and what to try instead. One sentence.\n\n## Multi-step flows\n- \"How much X for Y?\": swap_quote first, then swap_execute if user confirms.\n- \"Swap then save\": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.\n- \"Buy $X of token\": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.\n- save_deposit
|
|
1176
|
+
declare const DEFAULT_SYSTEM_PROMPT = "You are a financial agent on Sui. You manage money and access paid APIs via MPP micropayments.\n\n## Response rules\n- 1-2 sentences max. No bullet lists unless asked. No preambles.\n- Never say \"Would you like me to...\", \"Sure!\", \"Great question!\", \"Absolutely!\" \u2014 just do it or say you can't.\n- Lead with the result. After tool calls, state the outcome with real numbers. Done.\n- Present amounts as $1,234.56 and rates as X.XX% APY.\n- Show top 3 results unless asked for more. Summarize totals in one line.\n\n## Execution rule\nOnly offer to execute actions you have tools for. If you retrieved a quote, data, or information but have no tool to act on it, give the user the result and tell them where to execute manually \u2014 in one sentence. Never say \"Would you like me to proceed?\" unless you have a tool that can actually proceed.\n\n## Before acting\n- ALWAYS call a read tool first before any write tool \u2014 balance_check before save/send/borrow, savings_info before withdraw.\n- Show real numbers from tools \u2014 never fabricate rates, amounts, or balances.\n- When user says \"all\" or an imprecise amount, call the read tool first to get the exact number.\n\n## Tool usage\n- Use tools proactively \u2014 don't refuse requests you can handle.\n- For real-world questions (weather, search, news, prices), use pay_api. Tell the user the cost first.\n- For broad market data (yields across protocols, token prices, TVL, protocol comparisons), use defillama_* tools.\n- To discover Sui protocols, use defillama_sui_protocols first, then defillama_protocol_info with the slug.\n- Run multiple read-only tools in parallel when you need several data points.\n- If a tool errors, say what went wrong and what to try instead. One sentence.\n\n## Multi-step flows\n- \"How much X for Y?\": swap_quote first, then swap_execute if user confirms.\n- \"Swap then save\": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.\n- \"Buy $X of token\": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.\n- save_deposit: USDC only. To save other tokens, swap to USDC first.\n- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.\n- \"Deposit SUI to earn yield\": volo_stake for SUI liquid staking. save_deposit is USDC only.\n- \"What protocols are on Sui?\": defillama_sui_protocols \u2192 defillama_protocol_info for details.\n\n## Safety\n- Never encourage risky financial behavior.\n- Warn when health factor < 1.5.\n- All amounts in USDC unless stated otherwise.";
|
|
1178
1177
|
|
|
1179
1178
|
export { AnthropicProvider, type AnthropicProviderConfig, type BalancePrices, type BalanceResult, type BuildToolOptions, type ChatParams, type CompactOptions, type ContentBlock, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_SYSTEM_PROMPT, type EngineConfig, type EngineEvent, type HealthFactorResult, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, type NaviRawCoin, type NaviRawHealthFactor, type NaviRawPool, type NaviRawPosition, type NaviRawPositionsResponse, type NaviRawProtocolStats, type NaviRawRewardsResponse, type NaviReadOptions, NaviTools, type PendingAction, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionResponse, type PositionEntry, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type SSEEvent, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StopReason, type SuiCoinBalance, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolJsonSchema, type ToolResult, TxMutex, WRITE_TOOLS, type WalletCoin, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, balanceCheckTool, borrowTool, buildMcpTools, buildTool, claimRewardsTool, clearPriceCache, compactMessages, defillamaChainTvlTool, defillamaPriceChangeTool, defillamaProtocolFeesTool, defillamaProtocolInfoTool, defillamaSuiProtocolsTool, defillamaTokenPricesTool, defillamaYieldPoolsTool, engineToSSE, estimateTokens, explainTxTool, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getWalletAddress, hasNaviMcp, healthCheckTool, mppServicesTool, parseMcpJson, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, repayDebtTool, requireAgent, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, swapExecuteTool, swapQuoteTool, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool };
|
package/dist/index.js
CHANGED
|
@@ -336,11 +336,10 @@ function transformRewards(raw) {
|
|
|
336
336
|
var STABLECOIN_SYMBOLS = /* @__PURE__ */ new Set([
|
|
337
337
|
"USDC",
|
|
338
338
|
"USDT",
|
|
339
|
+
"USDe",
|
|
340
|
+
"USDsui",
|
|
339
341
|
"wUSDC",
|
|
340
342
|
"wUSDT",
|
|
341
|
-
"FDUSD",
|
|
342
|
-
"AUSD",
|
|
343
|
-
"BUCK",
|
|
344
343
|
"suiUSDe",
|
|
345
344
|
"USDSUI"
|
|
346
345
|
]);
|
|
@@ -539,7 +538,7 @@ var balanceCheckTool = buildTool({
|
|
|
539
538
|
let availableUsd = 0;
|
|
540
539
|
let stablesUsd = 0;
|
|
541
540
|
let gasReserveUsd2 = 0;
|
|
542
|
-
const STABLE_SYMBOLS = /* @__PURE__ */ new Set(["USDC", "USDT", "
|
|
541
|
+
const STABLE_SYMBOLS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDe", "USDsui", "wUSDC", "wUSDT"]);
|
|
543
542
|
const holdings = [];
|
|
544
543
|
for (const coin of coins) {
|
|
545
544
|
const balance2 = Number(coin.totalBalance) / 10 ** coin.decimals;
|
|
@@ -578,6 +577,7 @@ var balanceCheckTool = buildTool({
|
|
|
578
577
|
debt = posEntries.filter((p) => p.type === "borrow").reduce((sum, p) => sum + p.valueUsd, 0);
|
|
579
578
|
pendingRewardsUsd = rewardEntries.reduce((sum, r) => sum + r.valueUsd, 0);
|
|
580
579
|
}
|
|
580
|
+
const visibleHoldings = holdings.filter((h) => h.usdValue >= 0.01).sort((a, b) => b.usdValue - a.usdValue);
|
|
581
581
|
const bal = {
|
|
582
582
|
available: availableUsd,
|
|
583
583
|
savings,
|
|
@@ -586,7 +586,7 @@ var balanceCheckTool = buildTool({
|
|
|
586
586
|
gasReserve: gasReserveUsd2,
|
|
587
587
|
total: availableUsd + savings + gasReserveUsd2 + pendingRewardsUsd - debt,
|
|
588
588
|
stables: stablesUsd,
|
|
589
|
-
holdings:
|
|
589
|
+
holdings: visibleHoldings
|
|
590
590
|
};
|
|
591
591
|
return {
|
|
592
592
|
data: bal,
|
|
@@ -1020,20 +1020,15 @@ var transactionHistoryTool = buildTool({
|
|
|
1020
1020
|
});
|
|
1021
1021
|
var saveDepositTool = buildTool({
|
|
1022
1022
|
name: "save_deposit",
|
|
1023
|
-
description: "Deposit into NAVI lending to earn yield.
|
|
1023
|
+
description: "Deposit USDC into NAVI lending to earn yield. Amount is in USDC.",
|
|
1024
1024
|
inputSchema: z.object({
|
|
1025
|
-
amount: z.number().positive()
|
|
1026
|
-
asset: z.string().optional().describe("Asset to deposit (default: USDC). Supported: USDC, USDT, SUI, USDe, USDsui")
|
|
1025
|
+
amount: z.number().positive()
|
|
1027
1026
|
}),
|
|
1028
1027
|
jsonSchema: {
|
|
1029
1028
|
type: "object",
|
|
1030
1029
|
properties: {
|
|
1031
1030
|
amount: {
|
|
1032
|
-
description: "Exact amount to deposit
|
|
1033
|
-
},
|
|
1034
|
-
asset: {
|
|
1035
|
-
type: "string",
|
|
1036
|
-
description: "Asset to deposit (default: USDC). Supported: USDC, USDT, SUI, USDe, USDsui"
|
|
1031
|
+
description: "Exact amount of USDC to deposit"
|
|
1037
1032
|
}
|
|
1038
1033
|
},
|
|
1039
1034
|
required: ["amount"]
|
|
@@ -1042,29 +1037,28 @@ var saveDepositTool = buildTool({
|
|
|
1042
1037
|
permissionLevel: "confirm",
|
|
1043
1038
|
async call(input, context) {
|
|
1044
1039
|
const agent = requireAgent(context);
|
|
1045
|
-
const
|
|
1046
|
-
const result = await agent.save({ amount: input.amount, asset });
|
|
1040
|
+
const result = await agent.save({ amount: input.amount });
|
|
1047
1041
|
return {
|
|
1048
1042
|
data: {
|
|
1049
1043
|
success: result.success,
|
|
1050
1044
|
tx: result.tx,
|
|
1051
1045
|
amount: result.amount,
|
|
1052
|
-
asset,
|
|
1046
|
+
asset: "USDC",
|
|
1053
1047
|
apy: result.apy,
|
|
1054
1048
|
fee: result.fee,
|
|
1055
1049
|
gasCost: result.gasCost,
|
|
1056
1050
|
savingsBalance: result.savingsBalance
|
|
1057
1051
|
},
|
|
1058
|
-
displayText: `Saved ${result.amount.toFixed(result.amount < 1 ? 6 : 2)}
|
|
1052
|
+
displayText: `Saved ${result.amount.toFixed(result.amount < 1 ? 6 : 2)} USDC at ${(result.apy * 100).toFixed(2)}% APY (tx: ${result.tx.slice(0, 8)}\u2026)`
|
|
1059
1053
|
};
|
|
1060
1054
|
}
|
|
1061
1055
|
});
|
|
1062
1056
|
var withdrawTool = buildTool({
|
|
1063
1057
|
name: "withdraw",
|
|
1064
|
-
description: "Withdraw from NAVI lending back to wallet.
|
|
1058
|
+
description: "Withdraw from NAVI lending back to wallet. Defaults to USDC. Also supports withdrawing legacy positions (USDe, USDsui, SUI) if the user has them.",
|
|
1065
1059
|
inputSchema: z.object({
|
|
1066
1060
|
amount: z.number().positive(),
|
|
1067
|
-
asset: z.string().optional().describe("Asset to withdraw (default:
|
|
1061
|
+
asset: z.string().optional().describe("Asset to withdraw (default: USDC). Legacy positions: USDe, USDsui, SUI")
|
|
1068
1062
|
}),
|
|
1069
1063
|
jsonSchema: {
|
|
1070
1064
|
type: "object",
|
|
@@ -1074,7 +1068,7 @@ var withdrawTool = buildTool({
|
|
|
1074
1068
|
},
|
|
1075
1069
|
asset: {
|
|
1076
1070
|
type: "string",
|
|
1077
|
-
description: "Asset to withdraw (default:
|
|
1071
|
+
description: "Asset to withdraw (default: USDC). Legacy positions: USDe, USDsui, SUI"
|
|
1078
1072
|
}
|
|
1079
1073
|
},
|
|
1080
1074
|
required: ["amount"]
|
|
@@ -1087,7 +1081,7 @@ var withdrawTool = buildTool({
|
|
|
1087
1081
|
amount: input.amount,
|
|
1088
1082
|
asset: input.asset
|
|
1089
1083
|
});
|
|
1090
|
-
const withdrawnAsset = result.asset ?? input.asset ?? "";
|
|
1084
|
+
const withdrawnAsset = result.asset ?? input.asset ?? "USDC";
|
|
1091
1085
|
return {
|
|
1092
1086
|
data: {
|
|
1093
1087
|
success: result.success,
|
|
@@ -1096,7 +1090,7 @@ var withdrawTool = buildTool({
|
|
|
1096
1090
|
asset: withdrawnAsset,
|
|
1097
1091
|
gasCost: result.gasCost
|
|
1098
1092
|
},
|
|
1099
|
-
displayText: `Withdrew ${result.amount.toFixed(result.amount < 1 ? 6 : 2)}${withdrawnAsset
|
|
1093
|
+
displayText: `Withdrew ${result.amount.toFixed(result.amount < 1 ? 6 : 2)} ${withdrawnAsset} (tx: ${result.tx.slice(0, 8)}\u2026)`
|
|
1100
1094
|
};
|
|
1101
1095
|
}
|
|
1102
1096
|
});
|
|
@@ -1716,7 +1710,7 @@ ${summary}`
|
|
|
1716
1710
|
var inputSchema3 = z.object({
|
|
1717
1711
|
address: z.string().optional().describe("Sui address to analyze (defaults to connected wallet)")
|
|
1718
1712
|
});
|
|
1719
|
-
var STABLECOINS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDe", "USDsui"
|
|
1713
|
+
var STABLECOINS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDe", "USDsui"]);
|
|
1720
1714
|
var portfolioAnalysisTool = buildTool({
|
|
1721
1715
|
name: "portfolio_analysis",
|
|
1722
1716
|
description: "Analyze portfolio allocation, risk exposure, and yield optimization. Shows asset breakdown, diversification score, health factor assessment, and actionable suggestions.",
|
|
@@ -2285,9 +2279,9 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
|
|
|
2285
2279
|
- "Swap then save": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.
|
|
2286
2280
|
- "Buy $X of token": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.
|
|
2287
2281
|
- "Best yield on SUI": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.
|
|
2288
|
-
- save_deposit
|
|
2289
|
-
- withdraw supports: USDC,
|
|
2290
|
-
- "Deposit SUI to earn yield":
|
|
2282
|
+
- save_deposit: USDC only. To save other tokens, swap to USDC first.
|
|
2283
|
+
- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.
|
|
2284
|
+
- "Deposit SUI to earn yield": volo_stake for SUI liquid staking. save_deposit is USDC only.
|
|
2291
2285
|
- "What protocols are on Sui?": defillama_sui_protocols \u2192 defillama_protocol_info for details.
|
|
2292
2286
|
|
|
2293
2287
|
## Safety
|
|
@@ -2766,8 +2760,7 @@ function describeAction(tool, call) {
|
|
|
2766
2760
|
const input = call.input;
|
|
2767
2761
|
switch (tool.name) {
|
|
2768
2762
|
case "save_deposit": {
|
|
2769
|
-
|
|
2770
|
-
return `Save ${input.amount} ${asset} into lending`;
|
|
2763
|
+
return `Save ${input.amount} USDC into lending`;
|
|
2771
2764
|
}
|
|
2772
2765
|
case "withdraw": {
|
|
2773
2766
|
const wAsset = input.asset ?? "";
|