@t2000/engine 0.7.4 → 0.7.6
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 +2 -1
- package/dist/index.js +19 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -790,6 +790,7 @@ declare const balanceCheckTool: Tool<{}, {
|
|
|
790
790
|
total: number;
|
|
791
791
|
stables: number;
|
|
792
792
|
holdings: any[];
|
|
793
|
+
saveableUsdc: number;
|
|
793
794
|
}>;
|
|
794
795
|
|
|
795
796
|
declare const savingsInfoTool: Tool<{}, SavingsResult>;
|
|
@@ -1175,6 +1176,6 @@ declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<Wal
|
|
|
1175
1176
|
declare function fetchTokenPrices(coinTypes: string[]): Promise<Record<string, number>>;
|
|
1176
1177
|
declare function clearPriceCache(): void;
|
|
1177
1178
|
|
|
1178
|
-
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-
|
|
1179
|
+
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## Savings = USDC only (critical)\n- save_deposit accepts ONLY USDC. No other token can be deposited into savings.\n- When asked \"how much can I save?\", report only the user's USDC wallet balance (saveableUsdc field from balance_check). Other tokens like GOLD, SUI, USDT are NOT saveable and NOT savings positions \u2014 they are just wallet holdings.\n- NEVER say a non-USDC token is \"in savings\" or \"earning APY in savings\" unless it appears in the savings_info positions list. Wallet holdings \u2260 savings.\n- If user wants to save non-USDC tokens, tell them to swap to USDC first. Do NOT auto-chain swap + deposit.\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- 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.";
|
|
1179
1180
|
|
|
1180
1181
|
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
|
@@ -480,7 +480,7 @@ async function callNavi(manager, tool, args = {}) {
|
|
|
480
480
|
}
|
|
481
481
|
var balanceCheckTool = buildTool({
|
|
482
482
|
name: "balance_check",
|
|
483
|
-
description: "Get the user's full balance breakdown
|
|
483
|
+
description: "Get the user's full balance breakdown. Returns wallet holdings (tokens the user owns \u2014 NOT savings), NAVI savings deposits (USDC deposited into NAVI Protocol earning yield), outstanding debt, pending rewards, gas reserve, total net worth, and saveableUsdc (only USDC can be deposited into savings). IMPORTANT: wallet holdings like GOLD, SUI, USDT are NOT savings positions \u2014 they are just tokens sitting in the wallet.",
|
|
484
484
|
inputSchema: z.object({}),
|
|
485
485
|
jsonSchema: { type: "object", properties: {}, required: [] },
|
|
486
486
|
isReadOnly: true,
|
|
@@ -578,6 +578,8 @@ var balanceCheckTool = buildTool({
|
|
|
578
578
|
pendingRewardsUsd = rewardEntries.reduce((sum, r) => sum + r.valueUsd, 0);
|
|
579
579
|
}
|
|
580
580
|
const visibleHoldings = holdings.filter((h) => h.usdValue >= 0.01).sort((a, b) => b.usdValue - a.usdValue);
|
|
581
|
+
const usdcHolding2 = holdings.find((h) => h.symbol === "USDC");
|
|
582
|
+
const saveableUsdc = usdcHolding2 ? usdcHolding2.balance : 0;
|
|
581
583
|
const bal = {
|
|
582
584
|
available: availableUsd,
|
|
583
585
|
savings,
|
|
@@ -586,11 +588,13 @@ var balanceCheckTool = buildTool({
|
|
|
586
588
|
gasReserve: gasReserveUsd2,
|
|
587
589
|
total: availableUsd + savings + gasReserveUsd2 + pendingRewardsUsd - debt,
|
|
588
590
|
stables: stablesUsd,
|
|
589
|
-
holdings: visibleHoldings
|
|
591
|
+
holdings: visibleHoldings,
|
|
592
|
+
saveableUsdc
|
|
590
593
|
};
|
|
594
|
+
const holdingsList = visibleHoldings.map((h) => `${h.symbol}: ${h.balance < 1 ? h.balance.toFixed(6) : h.balance.toFixed(2)} ($${h.usdValue.toFixed(2)})`).join(", ");
|
|
591
595
|
return {
|
|
592
596
|
data: bal,
|
|
593
|
-
displayText: `Balance: $${bal.total.toFixed(2)} (
|
|
597
|
+
displayText: `Balance: $${bal.total.toFixed(2)} total. Wallet holdings (NOT savings): ${holdingsList || "none"}. NAVI savings deposits: $${bal.savings.toFixed(2)}. Saveable USDC (only USDC can be saved): ${saveableUsdc.toFixed(2)} USDC.`
|
|
594
598
|
};
|
|
595
599
|
}
|
|
596
600
|
const agent = requireAgent(context);
|
|
@@ -599,6 +603,8 @@ var balanceCheckTool = buildTool({
|
|
|
599
603
|
const stablesTotal = typeof balance.stables === "number" ? balance.stables : Object.values(balance.stables).reduce((a, b) => a + b, 0);
|
|
600
604
|
const sdkHoldings = balance.holdings;
|
|
601
605
|
const holdingsArr = Array.isArray(sdkHoldings) ? sdkHoldings : [];
|
|
606
|
+
const usdcHolding = holdingsArr.find((h) => h.symbol === "USDC");
|
|
607
|
+
const sdkSaveableUsdc = usdcHolding ? usdcHolding.balance ?? 0 : 0;
|
|
602
608
|
return {
|
|
603
609
|
data: {
|
|
604
610
|
available: balance.available,
|
|
@@ -608,9 +614,10 @@ var balanceCheckTool = buildTool({
|
|
|
608
614
|
gasReserve: gasReserveUsd,
|
|
609
615
|
total: balance.total,
|
|
610
616
|
stables: stablesTotal,
|
|
611
|
-
holdings: holdingsArr
|
|
617
|
+
holdings: holdingsArr,
|
|
618
|
+
saveableUsdc: sdkSaveableUsdc
|
|
612
619
|
},
|
|
613
|
-
displayText: `Balance: $${balance.total.toFixed(2)}
|
|
620
|
+
displayText: `Balance: $${balance.total.toFixed(2)} total. Wallet: $${balance.available.toFixed(2)} available. NAVI savings deposits: $${balance.savings.toFixed(2)}. Saveable USDC (only USDC can be saved): ${sdkSaveableUsdc.toFixed(2)} USDC.`
|
|
614
621
|
};
|
|
615
622
|
}
|
|
616
623
|
});
|
|
@@ -1043,7 +1050,7 @@ var transactionHistoryTool = buildTool({
|
|
|
1043
1050
|
});
|
|
1044
1051
|
var saveDepositTool = buildTool({
|
|
1045
1052
|
name: "save_deposit",
|
|
1046
|
-
description: "Deposit USDC into NAVI savings to earn yield. ONLY USDC is accepted
|
|
1053
|
+
description: "Deposit USDC into NAVI savings to earn yield. ONLY USDC is accepted. If the user asks to save/deposit any other token (USDT, SUI, USDe, etc.), do NOT call this tool and do NOT automatically swap their tokens and deposit. Instead, tell the user that only USDC deposits are supported and ask if they would like to swap to USDC first. Let the user decide \u2014 never auto-chain swap + deposit.",
|
|
1047
1054
|
inputSchema: z.object({
|
|
1048
1055
|
amount: z.number().positive(),
|
|
1049
1056
|
asset: z.string().optional().describe("Must be USDC or omitted. Any other asset is rejected.")
|
|
@@ -2311,12 +2318,17 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
|
|
|
2311
2318
|
- Run multiple read-only tools in parallel when you need several data points.
|
|
2312
2319
|
- If a tool errors, say what went wrong and what to try instead. One sentence.
|
|
2313
2320
|
|
|
2321
|
+
## Savings = USDC only (critical)
|
|
2322
|
+
- save_deposit accepts ONLY USDC. No other token can be deposited into savings.
|
|
2323
|
+
- When asked "how much can I save?", report only the user's USDC wallet balance (saveableUsdc field from balance_check). Other tokens like GOLD, SUI, USDT are NOT saveable and NOT savings positions \u2014 they are just wallet holdings.
|
|
2324
|
+
- NEVER say a non-USDC token is "in savings" or "earning APY in savings" unless it appears in the savings_info positions list. Wallet holdings \u2260 savings.
|
|
2325
|
+
- If user wants to save non-USDC tokens, tell them to swap to USDC first. Do NOT auto-chain swap + deposit.
|
|
2326
|
+
|
|
2314
2327
|
## Multi-step flows
|
|
2315
2328
|
- "How much X for Y?": swap_quote first, then swap_execute if user confirms.
|
|
2316
2329
|
- "Swap then save": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.
|
|
2317
2330
|
- "Buy $X of token": defillama_token_prices \u2192 calculate amount \u2192 swap_execute.
|
|
2318
2331
|
- "Best yield on SUI": compare rates_info (NAVI lending) + defillama_yield_pools (broader) + volo_stats.
|
|
2319
|
-
- save_deposit: USDC only. To save other tokens, swap to USDC first.
|
|
2320
2332
|
- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.
|
|
2321
2333
|
- "Deposit SUI to earn yield": volo_stake for SUI liquid staking. save_deposit is USDC only.
|
|
2322
2334
|
- "What protocols are on Sui?": defillama_sui_protocols \u2192 defillama_protocol_info for details.
|