@t2000/engine 0.5.5 → 0.5.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 +19 -1
- package/dist/index.js +64 -24
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -889,6 +889,24 @@ declare const payApiTool: Tool<{
|
|
|
889
889
|
} | undefined;
|
|
890
890
|
}>;
|
|
891
891
|
|
|
892
|
+
declare const mppServicesTool: Tool<{
|
|
893
|
+
query?: string | undefined;
|
|
894
|
+
}, {
|
|
895
|
+
services: {
|
|
896
|
+
id: string;
|
|
897
|
+
name: string;
|
|
898
|
+
description: string;
|
|
899
|
+
categories: string[];
|
|
900
|
+
endpoints: {
|
|
901
|
+
url: string;
|
|
902
|
+
method: string;
|
|
903
|
+
description: string;
|
|
904
|
+
price: string;
|
|
905
|
+
}[];
|
|
906
|
+
}[];
|
|
907
|
+
total: number;
|
|
908
|
+
}>;
|
|
909
|
+
|
|
892
910
|
declare const swapExecuteTool: Tool<{
|
|
893
911
|
amount: number;
|
|
894
912
|
to: string;
|
|
@@ -1061,4 +1079,4 @@ declare function clearPriceCache(): void;
|
|
|
1061
1079
|
|
|
1062
1080
|
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
1081
|
|
|
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 };
|
|
1082
|
+
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
|
@@ -1129,29 +1129,11 @@ function estimatePayApiCost(url) {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
var payApiTool = buildTool({
|
|
1131
1131
|
name: "pay_api",
|
|
1132
|
-
description: `
|
|
1132
|
+
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
1133
|
|
|
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
|
|
1134
|
+
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
1135
|
|
|
1154
|
-
Always use POST. Construct the URL from the gateway base + path. Pass parameters
|
|
1136
|
+
Always use POST. Construct the URL from the gateway base + service path. Pass parameters as a JSON string in body.`,
|
|
1155
1137
|
inputSchema: z.object({
|
|
1156
1138
|
url: z.string().url(),
|
|
1157
1139
|
method: z.enum(["GET", "POST", "PUT", "DELETE"]).optional(),
|
|
@@ -1193,6 +1175,63 @@ Always use POST. Construct the URL from the gateway base + path. Pass parameters
|
|
|
1193
1175
|
};
|
|
1194
1176
|
}
|
|
1195
1177
|
});
|
|
1178
|
+
var MPP_GATEWAY2 = "https://mpp.t2000.ai";
|
|
1179
|
+
var CATALOG_URL = `${MPP_GATEWAY2}/api/services`;
|
|
1180
|
+
var CACHE_TTL2 = 12e4;
|
|
1181
|
+
var catalogCache = null;
|
|
1182
|
+
async function fetchCatalog() {
|
|
1183
|
+
if (catalogCache && Date.now() - catalogCache.ts < CACHE_TTL2) {
|
|
1184
|
+
return catalogCache.data;
|
|
1185
|
+
}
|
|
1186
|
+
const res = await fetch(CATALOG_URL, { signal: AbortSignal.timeout(1e4) });
|
|
1187
|
+
if (!res.ok) throw new Error(`MPP catalog fetch failed: HTTP ${res.status}`);
|
|
1188
|
+
const data = await res.json();
|
|
1189
|
+
catalogCache = { data, ts: Date.now() };
|
|
1190
|
+
return data;
|
|
1191
|
+
}
|
|
1192
|
+
function matchesQuery(service, q) {
|
|
1193
|
+
const lower = q.toLowerCase();
|
|
1194
|
+
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));
|
|
1195
|
+
}
|
|
1196
|
+
var mppServicesTool = buildTool({
|
|
1197
|
+
name: "mpp_services",
|
|
1198
|
+
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.).",
|
|
1199
|
+
inputSchema: z.object({
|
|
1200
|
+
query: z.string().optional().describe('Filter by keyword (e.g. "postcard", "translate", "weather"). Omit to list all services.')
|
|
1201
|
+
}),
|
|
1202
|
+
jsonSchema: {
|
|
1203
|
+
type: "object",
|
|
1204
|
+
properties: {
|
|
1205
|
+
query: {
|
|
1206
|
+
type: "string",
|
|
1207
|
+
description: 'Filter by keyword (e.g. "postcard", "translate", "weather"). Omit to list all.'
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
required: []
|
|
1211
|
+
},
|
|
1212
|
+
isReadOnly: true,
|
|
1213
|
+
async call(input) {
|
|
1214
|
+
const catalog = await fetchCatalog();
|
|
1215
|
+
const filtered = input.query ? catalog.filter((s) => matchesQuery(s, input.query)) : catalog;
|
|
1216
|
+
const services = filtered.map((s) => ({
|
|
1217
|
+
id: s.id,
|
|
1218
|
+
name: s.name,
|
|
1219
|
+
description: s.description,
|
|
1220
|
+
categories: s.categories,
|
|
1221
|
+
endpoints: s.endpoints.map((e) => ({
|
|
1222
|
+
url: `${MPP_GATEWAY2}/${s.id}${e.path}`,
|
|
1223
|
+
method: e.method,
|
|
1224
|
+
description: e.description,
|
|
1225
|
+
price: `$${e.price}`
|
|
1226
|
+
}))
|
|
1227
|
+
}));
|
|
1228
|
+
const summary = input.query ? `Found ${services.length} service(s) matching "${input.query}"` : `${services.length} services available on MPP gateway`;
|
|
1229
|
+
return {
|
|
1230
|
+
data: { services, total: services.length },
|
|
1231
|
+
displayText: summary
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1196
1235
|
var swapExecuteTool = buildTool({
|
|
1197
1236
|
name: "swap_execute",
|
|
1198
1237
|
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 +1424,11 @@ var saveContactTool = buildTool({
|
|
|
1385
1424
|
var LLAMA_API = "https://api.llama.fi";
|
|
1386
1425
|
var YIELDS_API = "https://yields.llama.fi";
|
|
1387
1426
|
var COINS_API = "https://coins.llama.fi";
|
|
1388
|
-
var
|
|
1427
|
+
var CACHE_TTL3 = 6e4;
|
|
1389
1428
|
var apiCache = /* @__PURE__ */ new Map();
|
|
1390
1429
|
async function cachedFetch(url) {
|
|
1391
1430
|
const hit = apiCache.get(url);
|
|
1392
|
-
if (hit && Date.now() - hit.ts <
|
|
1431
|
+
if (hit && Date.now() - hit.ts < CACHE_TTL3) return hit.data;
|
|
1393
1432
|
const res = await fetch(url, { signal: AbortSignal.timeout(15e3) });
|
|
1394
1433
|
if (!res.ok) throw new Error(`DefiLlama API error: HTTP ${res.status}`);
|
|
1395
1434
|
const data = await res.json();
|
|
@@ -1657,6 +1696,7 @@ var READ_TOOLS = [
|
|
|
1657
1696
|
transactionHistoryTool,
|
|
1658
1697
|
swapQuoteTool,
|
|
1659
1698
|
voloStatsTool,
|
|
1699
|
+
mppServicesTool,
|
|
1660
1700
|
defillamaYieldPoolsTool,
|
|
1661
1701
|
defillamaProtocolInfoTool,
|
|
1662
1702
|
defillamaTokenPricesTool,
|
|
@@ -2947,6 +2987,6 @@ function sanitizeAnthropicMessages(messages) {
|
|
|
2947
2987
|
return merged;
|
|
2948
2988
|
}
|
|
2949
2989
|
|
|
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 };
|
|
2990
|
+
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
2991
|
//# sourceMappingURL=index.js.map
|
|
2952
2992
|
//# sourceMappingURL=index.js.map
|