@t2000/engine 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -2
- package/dist/index.js +18 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -821,7 +821,7 @@ declare const saveDepositTool: Tool<{
|
|
|
821
821
|
success: boolean;
|
|
822
822
|
tx: string;
|
|
823
823
|
amount: number;
|
|
824
|
-
asset:
|
|
824
|
+
asset: string;
|
|
825
825
|
apy: number;
|
|
826
826
|
fee: number;
|
|
827
827
|
gasCost: number;
|
|
@@ -835,6 +835,7 @@ declare const withdrawTool: Tool<{
|
|
|
835
835
|
success: boolean;
|
|
836
836
|
tx: string;
|
|
837
837
|
amount: number;
|
|
838
|
+
asset: string;
|
|
838
839
|
gasCost: number;
|
|
839
840
|
}>;
|
|
840
841
|
|
|
@@ -1086,6 +1087,6 @@ declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<Wal
|
|
|
1086
1087
|
declare function fetchTokenPrices(coinTypes: string[]): Promise<Record<string, number>>;
|
|
1087
1088
|
declare function clearPriceCache(): void;
|
|
1088
1089
|
|
|
1089
|
-
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 supports any NAVI asset: USDC (default), USDT, SUI, USDe, USDsui. Pass asset param for non-USDC.\n- \"Deposit SUI to earn yield\": save_deposit with asset=\"SUI\" for NAVI lending, or volo_stake for liquid staking.\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.";
|
|
1090
|
+
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 supports any NAVI asset: USDC (default), USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui. Pass asset param for non-USDC.\n- withdraw supports any deposited NAVI asset. Pass asset param to withdraw a specific token.\n- \"Deposit WAL/ETH/SUI to earn yield\": save_deposit with asset=\"WAL\"/\"ETH\"/\"SUI\" for NAVI lending, or volo_stake for SUI liquid staking.\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.";
|
|
1090
1091
|
|
|
1091
1092
|
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, extractMcpText, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getWalletAddress, hasNaviMcp, healthCheckTool, mppServicesTool, parseMcpJson, parseSSE, payApiTool, ratesInfoTool, registerEngineTools, repayDebtTool, requireAgent, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, swapExecuteTool, swapQuoteTool, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, withdrawTool };
|
package/dist/index.js
CHANGED
|
@@ -161,7 +161,10 @@ var KNOWN_COINS = {
|
|
|
161
161
|
"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN": { symbol: "USDT", decimals: 6 },
|
|
162
162
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT": { symbol: "USDT", decimals: 6 },
|
|
163
163
|
"0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH": { symbol: "ETH", decimals: 8 },
|
|
164
|
-
"0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC": { symbol: "BTC", decimals: 8 }
|
|
164
|
+
"0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC": { symbol: "BTC", decimals: 8 },
|
|
165
|
+
"0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL": { symbol: "WAL", decimals: 9 },
|
|
166
|
+
"0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX": { symbol: "NAVX", decimals: 9 },
|
|
167
|
+
"0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM": { symbol: "GOLD", decimals: 6 }
|
|
165
168
|
};
|
|
166
169
|
async function fetchWalletCoins(address, rpcUrl) {
|
|
167
170
|
const url = rpcUrl || SUI_MAINNET_URL;
|
|
@@ -995,20 +998,20 @@ var transactionHistoryTool = buildTool({
|
|
|
995
998
|
});
|
|
996
999
|
var saveDepositTool = buildTool({
|
|
997
1000
|
name: "save_deposit",
|
|
998
|
-
description: "Deposit into NAVI lending to earn yield. Supports USDC
|
|
1001
|
+
description: "Deposit into NAVI lending to earn yield. Supports any NAVI-listed asset: USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui. Always call balance_check first to know the available amount.",
|
|
999
1002
|
inputSchema: z.object({
|
|
1000
1003
|
amount: z.number().positive(),
|
|
1001
|
-
asset: z.string().optional().describe("Asset to deposit (default: USDC).
|
|
1004
|
+
asset: z.string().optional().describe("Asset to deposit (default: USDC). Supports: USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui")
|
|
1002
1005
|
}),
|
|
1003
1006
|
jsonSchema: {
|
|
1004
1007
|
type: "object",
|
|
1005
1008
|
properties: {
|
|
1006
1009
|
amount: {
|
|
1007
|
-
description: "Exact amount to save (call balance_check first
|
|
1010
|
+
description: "Exact amount to save in token units (call balance_check first)"
|
|
1008
1011
|
},
|
|
1009
1012
|
asset: {
|
|
1010
1013
|
type: "string",
|
|
1011
|
-
description: "Asset to deposit (default: USDC).
|
|
1014
|
+
description: "Asset to deposit (default: USDC). Supports: USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui"
|
|
1012
1015
|
}
|
|
1013
1016
|
},
|
|
1014
1017
|
required: ["amount"]
|
|
@@ -1030,16 +1033,16 @@ var saveDepositTool = buildTool({
|
|
|
1030
1033
|
gasCost: result.gasCost,
|
|
1031
1034
|
savingsBalance: result.savingsBalance
|
|
1032
1035
|
},
|
|
1033
|
-
displayText: `Saved ${result.amount.toFixed(2)} ${asset} at ${(result.apy * 100).toFixed(2)}% APY (tx: ${result.tx.slice(0, 8)}\u2026)`
|
|
1036
|
+
displayText: `Saved ${result.amount.toFixed(result.amount < 1 ? 6 : 2)} ${asset} at ${(result.apy * 100).toFixed(2)}% APY (tx: ${result.tx.slice(0, 8)}\u2026)`
|
|
1034
1037
|
};
|
|
1035
1038
|
}
|
|
1036
1039
|
});
|
|
1037
1040
|
var withdrawTool = buildTool({
|
|
1038
1041
|
name: "withdraw",
|
|
1039
|
-
description: "Withdraw from NAVI lending back to wallet. Supports any deposited asset (USDC, USDT, SUI, etc). Always call savings_info first. Checks health factor to prevent liquidation if there is outstanding debt.",
|
|
1042
|
+
description: "Withdraw from NAVI lending back to wallet. Supports any deposited asset (USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, etc). Always call savings_info first. Checks health factor to prevent liquidation if there is outstanding debt.",
|
|
1040
1043
|
inputSchema: z.object({
|
|
1041
1044
|
amount: z.number().positive(),
|
|
1042
|
-
asset: z.string().optional().describe("Asset to withdraw (default: picks largest position).
|
|
1045
|
+
asset: z.string().optional().describe("Asset to withdraw (default: picks largest position). Supports: USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui")
|
|
1043
1046
|
}),
|
|
1044
1047
|
jsonSchema: {
|
|
1045
1048
|
type: "object",
|
|
@@ -1049,7 +1052,7 @@ var withdrawTool = buildTool({
|
|
|
1049
1052
|
},
|
|
1050
1053
|
asset: {
|
|
1051
1054
|
type: "string",
|
|
1052
|
-
description: "Asset to withdraw (default: picks largest position).
|
|
1055
|
+
description: "Asset to withdraw (default: picks largest position). Supports: USDC, USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui"
|
|
1053
1056
|
}
|
|
1054
1057
|
},
|
|
1055
1058
|
required: ["amount"]
|
|
@@ -1062,14 +1065,16 @@ var withdrawTool = buildTool({
|
|
|
1062
1065
|
amount: input.amount,
|
|
1063
1066
|
asset: input.asset
|
|
1064
1067
|
});
|
|
1068
|
+
const withdrawnAsset = result.asset ?? input.asset ?? "";
|
|
1065
1069
|
return {
|
|
1066
1070
|
data: {
|
|
1067
1071
|
success: result.success,
|
|
1068
1072
|
tx: result.tx,
|
|
1069
1073
|
amount: result.amount,
|
|
1074
|
+
asset: withdrawnAsset,
|
|
1070
1075
|
gasCost: result.gasCost
|
|
1071
1076
|
},
|
|
1072
|
-
displayText: `Withdrew ${result.amount.toFixed(2)}${
|
|
1077
|
+
displayText: `Withdrew ${result.amount.toFixed(result.amount < 1 ? 6 : 2)}${withdrawnAsset ? " " + withdrawnAsset : ""} (tx: ${result.tx.slice(0, 8)}\u2026)`
|
|
1073
1078
|
};
|
|
1074
1079
|
}
|
|
1075
1080
|
});
|
|
@@ -1852,8 +1857,9 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
|
|
|
1852
1857
|
- "Swap then save": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.
|
|
1853
1858
|
- "Buy $X of token": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.
|
|
1854
1859
|
- "Best yield on SUI": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.
|
|
1855
|
-
- save_deposit supports any NAVI asset: USDC (default), USDT, SUI, USDe, USDsui. Pass asset param for non-USDC.
|
|
1856
|
-
-
|
|
1860
|
+
- save_deposit supports any NAVI asset: USDC (default), USDT, SUI, WAL, ETH, NAVX, GOLD, USDe, USDsui. Pass asset param for non-USDC.
|
|
1861
|
+
- withdraw supports any deposited NAVI asset. Pass asset param to withdraw a specific token.
|
|
1862
|
+
- "Deposit WAL/ETH/SUI to earn yield": save_deposit with asset="WAL"/"ETH"/"SUI" for NAVI lending, or volo_stake for SUI liquid staking.
|
|
1857
1863
|
- "What protocols are on Sui?": defillama_sui_protocols \u2192 defillama_protocol_info for details.
|
|
1858
1864
|
|
|
1859
1865
|
## Safety
|