@t2000/engine 0.5.5 → 0.5.7
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 +29 -2
- package/dist/index.js +169 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -798,10 +798,19 @@ declare const healthCheckTool: Tool<{}, {
|
|
|
798
798
|
|
|
799
799
|
declare const ratesInfoTool: Tool<{}, _t2000_sdk.RatesResult>;
|
|
800
800
|
|
|
801
|
+
interface TxRecord {
|
|
802
|
+
digest: string;
|
|
803
|
+
action: string;
|
|
804
|
+
amount?: number;
|
|
805
|
+
asset?: string;
|
|
806
|
+
recipient?: string;
|
|
807
|
+
timestamp: number;
|
|
808
|
+
gasCost?: number;
|
|
809
|
+
}
|
|
801
810
|
declare const transactionHistoryTool: Tool<{
|
|
802
811
|
limit?: number | undefined;
|
|
803
812
|
}, {
|
|
804
|
-
transactions:
|
|
813
|
+
transactions: TxRecord[];
|
|
805
814
|
count: number;
|
|
806
815
|
}>;
|
|
807
816
|
|
|
@@ -889,6 +898,24 @@ declare const payApiTool: Tool<{
|
|
|
889
898
|
} | undefined;
|
|
890
899
|
}>;
|
|
891
900
|
|
|
901
|
+
declare const mppServicesTool: Tool<{
|
|
902
|
+
query?: string | undefined;
|
|
903
|
+
}, {
|
|
904
|
+
services: {
|
|
905
|
+
id: string;
|
|
906
|
+
name: string;
|
|
907
|
+
description: string;
|
|
908
|
+
categories: string[];
|
|
909
|
+
endpoints: {
|
|
910
|
+
url: string;
|
|
911
|
+
method: string;
|
|
912
|
+
description: string;
|
|
913
|
+
price: string;
|
|
914
|
+
}[];
|
|
915
|
+
}[];
|
|
916
|
+
total: number;
|
|
917
|
+
}>;
|
|
918
|
+
|
|
892
919
|
declare const swapExecuteTool: Tool<{
|
|
893
920
|
amount: number;
|
|
894
921
|
to: string;
|
|
@@ -1061,4 +1088,4 @@ declare function clearPriceCache(): void;
|
|
|
1061
1088
|
|
|
1062
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.";
|
|
1063
1090
|
|
|
1064
|
-
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, 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 };
|
|
1091
|
+
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
|
@@ -866,6 +866,97 @@ var ratesInfoTool = buildTool({
|
|
|
866
866
|
};
|
|
867
867
|
}
|
|
868
868
|
});
|
|
869
|
+
var SUI_TYPE = "0x2::sui::SUI";
|
|
870
|
+
var KNOWN_TARGETS = [
|
|
871
|
+
[/::suilend|::obligation/, "lending"],
|
|
872
|
+
[/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
|
|
873
|
+
[/::cetus|::pool/, "swap"],
|
|
874
|
+
[/::deepbook/, "swap"],
|
|
875
|
+
[/::transfer::public_transfer/, "send"]
|
|
876
|
+
];
|
|
877
|
+
function resolveOwner(owner) {
|
|
878
|
+
if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
|
|
879
|
+
if (typeof owner === "string") return owner;
|
|
880
|
+
return null;
|
|
881
|
+
}
|
|
882
|
+
function classifyAction(targets, commandTypes) {
|
|
883
|
+
for (const target of targets) {
|
|
884
|
+
for (const [pattern, label] of KNOWN_TARGETS) {
|
|
885
|
+
if (pattern.test(target)) return label;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
|
|
889
|
+
return "transaction";
|
|
890
|
+
}
|
|
891
|
+
function parseRpcTx(tx, address) {
|
|
892
|
+
const gasUsed = tx.effects?.gasUsed;
|
|
893
|
+
const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
|
|
894
|
+
const moveCallTargets = [];
|
|
895
|
+
const commandTypes = [];
|
|
896
|
+
try {
|
|
897
|
+
const data = tx.transaction?.data;
|
|
898
|
+
const inner = data?.transaction;
|
|
899
|
+
const commands = inner?.commands;
|
|
900
|
+
if (commands) {
|
|
901
|
+
for (const cmd of commands) {
|
|
902
|
+
if (cmd.MoveCall) {
|
|
903
|
+
const mc = cmd.MoveCall;
|
|
904
|
+
moveCallTargets.push(`${mc.package}::${mc.module}::${mc.function}`);
|
|
905
|
+
commandTypes.push("MoveCall");
|
|
906
|
+
} else if (cmd.TransferObjects) {
|
|
907
|
+
commandTypes.push("TransferObjects");
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
} catch {
|
|
912
|
+
}
|
|
913
|
+
const changes = tx.balanceChanges ?? [];
|
|
914
|
+
const outflows = changes.filter((c) => resolveOwner(c.owner) === address && BigInt(c.amount) < 0n);
|
|
915
|
+
const inflows = changes.filter((c) => resolveOwner(c.owner) !== address && BigInt(c.amount) > 0n);
|
|
916
|
+
const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE).sort((a, b) => Number(BigInt(a.amount) - BigInt(b.amount)))[0] ?? outflows[0];
|
|
917
|
+
let amount;
|
|
918
|
+
let asset;
|
|
919
|
+
let recipient;
|
|
920
|
+
if (primaryOutflow) {
|
|
921
|
+
const coinType = primaryOutflow.coinType;
|
|
922
|
+
const decimals = coinType.includes("::usdc::") ? 6 : 9;
|
|
923
|
+
amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
|
|
924
|
+
asset = coinType === SUI_TYPE ? "SUI" : coinType.includes("::usdc::") ? "USDC" : coinType.split("::").pop() ?? "unknown";
|
|
925
|
+
const recipientChange = inflows.find((c) => c.coinType === coinType);
|
|
926
|
+
recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
digest: tx.digest,
|
|
930
|
+
action: classifyAction(moveCallTargets, commandTypes),
|
|
931
|
+
amount,
|
|
932
|
+
asset,
|
|
933
|
+
recipient,
|
|
934
|
+
timestamp: Number(tx.timestampMs ?? 0),
|
|
935
|
+
gasCost
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
async function queryHistoryRpc(rpcUrl, address, limit) {
|
|
939
|
+
const res = await fetch(rpcUrl, {
|
|
940
|
+
method: "POST",
|
|
941
|
+
headers: { "Content-Type": "application/json" },
|
|
942
|
+
body: JSON.stringify({
|
|
943
|
+
jsonrpc: "2.0",
|
|
944
|
+
id: 1,
|
|
945
|
+
method: "suix_queryTransactionBlocks",
|
|
946
|
+
params: [
|
|
947
|
+
{ filter: { FromAddress: address }, options: { showEffects: true, showInput: true, showBalanceChanges: true } },
|
|
948
|
+
null,
|
|
949
|
+
limit,
|
|
950
|
+
true
|
|
951
|
+
]
|
|
952
|
+
}),
|
|
953
|
+
signal: AbortSignal.timeout(1e4)
|
|
954
|
+
});
|
|
955
|
+
if (!res.ok) throw new Error(`Sui RPC error: ${res.status}`);
|
|
956
|
+
const json = await res.json();
|
|
957
|
+
if (json.error) throw new Error(`RPC error: ${json.error.message}`);
|
|
958
|
+
return (json.result?.data ?? []).map((tx) => parseRpcTx(tx, address));
|
|
959
|
+
}
|
|
869
960
|
var transactionHistoryTool = buildTool({
|
|
870
961
|
name: "transaction_history",
|
|
871
962
|
description: "Retrieve recent transaction history: past sends, saves, withdrawals, borrows, repayments, and rewards claims. Optionally limit the number of results.",
|
|
@@ -883,13 +974,21 @@ var transactionHistoryTool = buildTool({
|
|
|
883
974
|
},
|
|
884
975
|
isReadOnly: true,
|
|
885
976
|
async call(input, context) {
|
|
886
|
-
const
|
|
887
|
-
|
|
977
|
+
const limit = input.limit ?? 10;
|
|
978
|
+
if (context.agent) {
|
|
979
|
+
const agent = requireAgent(context);
|
|
980
|
+
const records2 = await agent.history({ limit });
|
|
981
|
+
return {
|
|
982
|
+
data: { transactions: records2, count: records2.length },
|
|
983
|
+
displayText: `${records2.length} recent transaction(s)`
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
if (!context.walletAddress || !context.suiRpcUrl) {
|
|
987
|
+
throw new Error("Transaction history requires a wallet address");
|
|
988
|
+
}
|
|
989
|
+
const records = await queryHistoryRpc(context.suiRpcUrl, context.walletAddress, limit);
|
|
888
990
|
return {
|
|
889
|
-
data: {
|
|
890
|
-
transactions: records,
|
|
891
|
-
count: records.length
|
|
892
|
-
},
|
|
991
|
+
data: { transactions: records, count: records.length },
|
|
893
992
|
displayText: `${records.length} recent transaction(s)`
|
|
894
993
|
};
|
|
895
994
|
}
|
|
@@ -1129,29 +1228,11 @@ function estimatePayApiCost(url) {
|
|
|
1129
1228
|
}
|
|
1130
1229
|
var payApiTool = buildTool({
|
|
1131
1230
|
name: "pay_api",
|
|
1132
|
-
description: `
|
|
1231
|
+
description: `Execute any MPP gateway service via on-chain USDC micropayment. The gateway at ${MPP_GATEWAY} hosts 40+ services (88 endpoints). Payment is handled automatically.
|
|
1133
1232
|
|
|
1134
|
-
|
|
1135
|
-
- Weather: ${MPP_GATEWAY}/openweather/v1/weather (body: {"city":"London"}) \u2014 $0.005
|
|
1136
|
-
- Forecast: ${MPP_GATEWAY}/openweather/v1/forecast (body: {"city":"London"}) \u2014 $0.005
|
|
1137
|
-
- Web search: ${MPP_GATEWAY}/brave/v1/web/search (body: {"q":"search query"}) \u2014 $0.005
|
|
1138
|
-
- AI search: ${MPP_GATEWAY}/perplexity/v1/chat/completions (body: {"model":"sonar","messages":[...]}) \u2014 $0.01
|
|
1139
|
-
- Google search: ${MPP_GATEWAY}/serper/v1/search (body: {"q":"query"}) \u2014 $0.005
|
|
1140
|
-
- News headlines: ${MPP_GATEWAY}/newsapi/v1/headlines (body: {"country":"us"}) \u2014 $0.005
|
|
1141
|
-
- Crypto prices: ${MPP_GATEWAY}/coingecko/v1/price (body: {"ids":"bitcoin,sui","vs_currencies":"usd"}) \u2014 $0.005
|
|
1142
|
-
- Stock quotes: ${MPP_GATEWAY}/alphavantage/v1/quote (body: {"symbol":"AAPL"}) \u2014 $0.005
|
|
1143
|
-
- FX rates: ${MPP_GATEWAY}/exchangerate/v1/rates (body: {"base":"USD"}) \u2014 $0.005
|
|
1144
|
-
- Translate: ${MPP_GATEWAY}/deepl/v1/translate (body: {"text":["hello"],"target_lang":"ES"}) \u2014 $0.005
|
|
1145
|
-
- Scrape URL: ${MPP_GATEWAY}/firecrawl/v1/scrape (body: {"url":"https://..."}) \u2014 $0.01
|
|
1146
|
-
- Read URL: ${MPP_GATEWAY}/jina/v1/read (body: {"url":"https://..."}) \u2014 $0.005
|
|
1147
|
-
- Geocode: ${MPP_GATEWAY}/googlemaps/v1/geocode (body: {"address":"..."}) \u2014 $0.01
|
|
1148
|
-
- Directions: ${MPP_GATEWAY}/googlemaps/v1/directions (body: {"origin":"...","destination":"..."}) \u2014 $0.01
|
|
1149
|
-
- Places: ${MPP_GATEWAY}/googlemaps/v1/places (body: {"query":"restaurants in Sydney"}) \u2014 $0.01
|
|
1150
|
-
- Image gen: ${MPP_GATEWAY}/fal/fal-ai/flux/dev (body: {"prompt":"..."}) \u2014 $0.03
|
|
1151
|
-
- Send email: ${MPP_GATEWAY}/resend/v1/emails (body: {"from":"...","to":"...","subject":"...","html":"..."}) \u2014 $0.005
|
|
1152
|
-
- Flights: ${MPP_GATEWAY}/serpapi/v1/flights (body: {"departure_id":"SYD","arrival_id":"NRT","outbound_date":"2026-03-01"}) \u2014 $0.01
|
|
1233
|
+
Use mpp_services tool first to discover available services and get the correct endpoint URL, required body parameters, and pricing. Then call this tool with the full URL and JSON body.
|
|
1153
1234
|
|
|
1154
|
-
Always use POST. Construct the URL from the gateway base + path. Pass parameters
|
|
1235
|
+
Always use POST. Construct the URL from the gateway base + service path. Pass parameters as a JSON string in body.`,
|
|
1155
1236
|
inputSchema: z.object({
|
|
1156
1237
|
url: z.string().url(),
|
|
1157
1238
|
method: z.enum(["GET", "POST", "PUT", "DELETE"]).optional(),
|
|
@@ -1193,6 +1274,63 @@ Always use POST. Construct the URL from the gateway base + path. Pass parameters
|
|
|
1193
1274
|
};
|
|
1194
1275
|
}
|
|
1195
1276
|
});
|
|
1277
|
+
var MPP_GATEWAY2 = "https://mpp.t2000.ai";
|
|
1278
|
+
var CATALOG_URL = `${MPP_GATEWAY2}/api/services`;
|
|
1279
|
+
var CACHE_TTL2 = 12e4;
|
|
1280
|
+
var catalogCache = null;
|
|
1281
|
+
async function fetchCatalog() {
|
|
1282
|
+
if (catalogCache && Date.now() - catalogCache.ts < CACHE_TTL2) {
|
|
1283
|
+
return catalogCache.data;
|
|
1284
|
+
}
|
|
1285
|
+
const res = await fetch(CATALOG_URL, { signal: AbortSignal.timeout(1e4) });
|
|
1286
|
+
if (!res.ok) throw new Error(`MPP catalog fetch failed: HTTP ${res.status}`);
|
|
1287
|
+
const data = await res.json();
|
|
1288
|
+
catalogCache = { data, ts: Date.now() };
|
|
1289
|
+
return data;
|
|
1290
|
+
}
|
|
1291
|
+
function matchesQuery(service, q) {
|
|
1292
|
+
const lower = q.toLowerCase();
|
|
1293
|
+
return service.id.toLowerCase().includes(lower) || service.name.toLowerCase().includes(lower) || service.description.toLowerCase().includes(lower) || service.categories.some((c) => c.toLowerCase().includes(lower)) || service.endpoints.some((e) => e.description.toLowerCase().includes(lower));
|
|
1294
|
+
}
|
|
1295
|
+
var mppServicesTool = buildTool({
|
|
1296
|
+
name: "mpp_services",
|
|
1297
|
+
description: "Discover available MPP gateway services. Returns service names, descriptions, endpoints with required parameters, and pricing. Use this BEFORE calling pay_api to find the correct URL and body format for any real-world API (weather, search, translation, image generation, email, maps, etc.).",
|
|
1298
|
+
inputSchema: z.object({
|
|
1299
|
+
query: z.string().optional().describe('Filter by keyword (e.g. "postcard", "translate", "weather"). Omit to list all services.')
|
|
1300
|
+
}),
|
|
1301
|
+
jsonSchema: {
|
|
1302
|
+
type: "object",
|
|
1303
|
+
properties: {
|
|
1304
|
+
query: {
|
|
1305
|
+
type: "string",
|
|
1306
|
+
description: 'Filter by keyword (e.g. "postcard", "translate", "weather"). Omit to list all.'
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
required: []
|
|
1310
|
+
},
|
|
1311
|
+
isReadOnly: true,
|
|
1312
|
+
async call(input) {
|
|
1313
|
+
const catalog = await fetchCatalog();
|
|
1314
|
+
const filtered = input.query ? catalog.filter((s) => matchesQuery(s, input.query)) : catalog;
|
|
1315
|
+
const services = filtered.map((s) => ({
|
|
1316
|
+
id: s.id,
|
|
1317
|
+
name: s.name,
|
|
1318
|
+
description: s.description,
|
|
1319
|
+
categories: s.categories,
|
|
1320
|
+
endpoints: s.endpoints.map((e) => ({
|
|
1321
|
+
url: `${MPP_GATEWAY2}/${s.id}${e.path}`,
|
|
1322
|
+
method: e.method,
|
|
1323
|
+
description: e.description,
|
|
1324
|
+
price: `$${e.price}`
|
|
1325
|
+
}))
|
|
1326
|
+
}));
|
|
1327
|
+
const summary = input.query ? `Found ${services.length} service(s) matching "${input.query}"` : `${services.length} services available on MPP gateway`;
|
|
1328
|
+
return {
|
|
1329
|
+
data: { services, total: services.length },
|
|
1330
|
+
displayText: summary
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1196
1334
|
var swapExecuteTool = buildTool({
|
|
1197
1335
|
name: "swap_execute",
|
|
1198
1336
|
description: "Swap tokens on Sui via Cetus Aggregator (20+ DEXs). Supports any token pair with liquidity. Use user-friendly names (SUI, USDC, CETUS, DEEP, etc.) or full coin types.",
|
|
@@ -1385,11 +1523,11 @@ var saveContactTool = buildTool({
|
|
|
1385
1523
|
var LLAMA_API = "https://api.llama.fi";
|
|
1386
1524
|
var YIELDS_API = "https://yields.llama.fi";
|
|
1387
1525
|
var COINS_API = "https://coins.llama.fi";
|
|
1388
|
-
var
|
|
1526
|
+
var CACHE_TTL3 = 6e4;
|
|
1389
1527
|
var apiCache = /* @__PURE__ */ new Map();
|
|
1390
1528
|
async function cachedFetch(url) {
|
|
1391
1529
|
const hit = apiCache.get(url);
|
|
1392
|
-
if (hit && Date.now() - hit.ts <
|
|
1530
|
+
if (hit && Date.now() - hit.ts < CACHE_TTL3) return hit.data;
|
|
1393
1531
|
const res = await fetch(url, { signal: AbortSignal.timeout(15e3) });
|
|
1394
1532
|
if (!res.ok) throw new Error(`DefiLlama API error: HTTP ${res.status}`);
|
|
1395
1533
|
const data = await res.json();
|
|
@@ -1657,6 +1795,7 @@ var READ_TOOLS = [
|
|
|
1657
1795
|
transactionHistoryTool,
|
|
1658
1796
|
swapQuoteTool,
|
|
1659
1797
|
voloStatsTool,
|
|
1798
|
+
mppServicesTool,
|
|
1660
1799
|
defillamaYieldPoolsTool,
|
|
1661
1800
|
defillamaProtocolInfoTool,
|
|
1662
1801
|
defillamaTokenPricesTool,
|
|
@@ -2947,6 +3086,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
2947
3086
|
return merged;
|
|
2948
3087
|
}
|
|
2949
3088
|
|
|
2950
|
-
export { AnthropicProvider, CostTracker, DEFAULT_SYSTEM_PROMPT, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, NaviTools, QueryEngine, READ_TOOLS, TxMutex, WRITE_TOOLS, 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, 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 };
|
|
3089
|
+
export { AnthropicProvider, CostTracker, DEFAULT_SYSTEM_PROMPT, McpClientManager, McpResponseCache, MemorySessionStore, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, NaviTools, QueryEngine, READ_TOOLS, TxMutex, WRITE_TOOLS, 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 };
|
|
2951
3090
|
//# sourceMappingURL=index.js.map
|
|
2952
3091
|
//# sourceMappingURL=index.js.map
|