@t2000/engine 1.24.6 → 1.24.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 +23 -10
- package/dist/index.js +46 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
|
3
3
|
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
4
4
|
import { Tool as Tool$1 } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import * as _t2000_sdk from '@t2000/sdk';
|
|
6
|
-
import { PendingReward as PendingReward$1, T2000 } from '@t2000/sdk';
|
|
6
|
+
import { PendingReward as PendingReward$1, SwapQuoteResult, T2000 } from '@t2000/sdk';
|
|
7
7
|
|
|
8
8
|
type ProactiveType = 'idle_balance' | 'hf_warning' | 'apy_drift' | 'goal_progress';
|
|
9
9
|
interface ProactiveMarker {
|
|
@@ -3423,13 +3423,7 @@ declare const mppServicesTool: Tool<{
|
|
|
3423
3423
|
mode?: "summary" | "full" | undefined;
|
|
3424
3424
|
}, Record<string, unknown>>;
|
|
3425
3425
|
|
|
3426
|
-
|
|
3427
|
-
to: string;
|
|
3428
|
-
amount: number;
|
|
3429
|
-
from: string;
|
|
3430
|
-
byAmountIn?: boolean | undefined;
|
|
3431
|
-
slippage?: number | undefined;
|
|
3432
|
-
}, {
|
|
3426
|
+
interface SwapExecuteSuccessData {
|
|
3433
3427
|
tx: string;
|
|
3434
3428
|
fromToken: string;
|
|
3435
3429
|
toToken: string;
|
|
@@ -3438,14 +3432,33 @@ declare const swapExecuteTool: Tool<{
|
|
|
3438
3432
|
priceImpact: number;
|
|
3439
3433
|
route: string;
|
|
3440
3434
|
gasCost: number;
|
|
3441
|
-
}
|
|
3435
|
+
}
|
|
3436
|
+
type SwapExecuteToolResult = SwapExecuteSuccessData | {
|
|
3437
|
+
error: string;
|
|
3438
|
+
errorCode: 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED';
|
|
3439
|
+
hint: string;
|
|
3440
|
+
recoverable: true;
|
|
3441
|
+
};
|
|
3442
|
+
declare const swapExecuteTool: Tool<{
|
|
3443
|
+
to: string;
|
|
3444
|
+
amount: number;
|
|
3445
|
+
from: string;
|
|
3446
|
+
byAmountIn?: boolean | undefined;
|
|
3447
|
+
slippage?: number | undefined;
|
|
3448
|
+
}, SwapExecuteToolResult>;
|
|
3442
3449
|
|
|
3450
|
+
type SwapQuoteToolResult = SwapQuoteResult | {
|
|
3451
|
+
error: string;
|
|
3452
|
+
errorCode: 'ASSET_NOT_SUPPORTED' | 'SWAP_FAILED';
|
|
3453
|
+
hint: string;
|
|
3454
|
+
recoverable: true;
|
|
3455
|
+
};
|
|
3443
3456
|
declare const swapQuoteTool: Tool<{
|
|
3444
3457
|
to: string;
|
|
3445
3458
|
amount: number;
|
|
3446
3459
|
from: string;
|
|
3447
3460
|
byAmountIn?: boolean | undefined;
|
|
3448
|
-
},
|
|
3461
|
+
}, SwapQuoteToolResult>;
|
|
3449
3462
|
|
|
3450
3463
|
declare const voloStakeTool: Tool<{
|
|
3451
3464
|
amount: number;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ALL_NAVI_ASSETS, getDecimalsForCoinType, resolveSymbol, isInRegistry, normalizeCoinType, assertAllowedAsset, normalizeAsset, SUPPORTED_ASSETS, getSwapQuote, getPendingRewardsByAddress, resolveTokenType, extractTransferDetails, classifyTransaction } from '@t2000/sdk';
|
|
2
|
+
import { ALL_NAVI_ASSETS, getDecimalsForCoinType, resolveSymbol, isInRegistry, normalizeCoinType, assertAllowedAsset, normalizeAsset, SUPPORTED_ASSETS, T2000Error, getSwapQuote, getPendingRewardsByAddress, resolveTokenType, extractTransferDetails, classifyTransaction } from '@t2000/sdk';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
4
|
import { readdirSync, readFileSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
@@ -3657,6 +3657,10 @@ var mppServicesTool = buildTool({
|
|
|
3657
3657
|
};
|
|
3658
3658
|
}
|
|
3659
3659
|
});
|
|
3660
|
+
var RECOVERY_HINTS = {
|
|
3661
|
+
ASSET_NOT_SUPPORTED: "This token symbol is not in the standard registry. Call `navi_navi_search_tokens` with the symbol to find its full coin type, then retry `swap_execute` with the full type string.",
|
|
3662
|
+
SWAP_FAILED: "No route or insufficient liquidity for this pair. Try a different amount, a different intermediate token, or check `balance_check` to confirm the source token is held."
|
|
3663
|
+
};
|
|
3660
3664
|
var swapExecuteTool = buildTool({
|
|
3661
3665
|
name: "swap_execute",
|
|
3662
3666
|
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. Payment Intent: composable \u2014 when paired with another composable write in the same request (e.g. "swap to USDC and save", "swap and send to Mom"), emit all calls in the same assistant turn so the engine compiles them into one atomic Payment Intent the user signs once.',
|
|
@@ -3716,10 +3720,26 @@ var swapExecuteTool = buildTool({
|
|
|
3716
3720
|
};
|
|
3717
3721
|
} catch (err) {
|
|
3718
3722
|
sink.counter("cetus.swap_execute_count", { outcome: "error" });
|
|
3723
|
+
if (err instanceof T2000Error && (err.code === "ASSET_NOT_SUPPORTED" || err.code === "SWAP_FAILED")) {
|
|
3724
|
+
const hint = RECOVERY_HINTS[err.code];
|
|
3725
|
+
return {
|
|
3726
|
+
data: {
|
|
3727
|
+
error: err.message,
|
|
3728
|
+
errorCode: err.code,
|
|
3729
|
+
hint,
|
|
3730
|
+
recoverable: true
|
|
3731
|
+
},
|
|
3732
|
+
displayText: err.code === "ASSET_NOT_SUPPORTED" ? `Token "${input.from}" not in standard registry \u2014 searching for full coin type.` : `No swap route available for ${input.from} \u2192 ${input.to}.`
|
|
3733
|
+
};
|
|
3734
|
+
}
|
|
3719
3735
|
throw err;
|
|
3720
3736
|
}
|
|
3721
3737
|
}
|
|
3722
3738
|
});
|
|
3739
|
+
var RECOVERY_HINTS2 = {
|
|
3740
|
+
ASSET_NOT_SUPPORTED: 'This token symbol is not in the standard registry. Call `navi_navi_search_tokens` with the symbol to find its full coin type, then retry `swap_quote` with the full type string (e.g. "0x83556...::spring_sui::SPRING_SUI").',
|
|
3741
|
+
SWAP_FAILED: "No route or insufficient liquidity for this pair. Try a different amount, a different intermediate token, or check `balance_check` to confirm the source token is held."
|
|
3742
|
+
};
|
|
3723
3743
|
var swapQuoteTool = buildTool({
|
|
3724
3744
|
name: "swap_quote",
|
|
3725
3745
|
description: "Get a swap quote without executing. Shows expected output amount, price impact, and route. Use before swap_execute to preview a trade.",
|
|
@@ -3760,6 +3780,18 @@ var swapQuoteTool = buildTool({
|
|
|
3760
3780
|
};
|
|
3761
3781
|
} catch (err) {
|
|
3762
3782
|
sink.counter("cetus.find_route_count", { outcome: "error" });
|
|
3783
|
+
if (err instanceof T2000Error && (err.code === "ASSET_NOT_SUPPORTED" || err.code === "SWAP_FAILED")) {
|
|
3784
|
+
const hint = RECOVERY_HINTS2[err.code];
|
|
3785
|
+
return {
|
|
3786
|
+
data: {
|
|
3787
|
+
error: err.message,
|
|
3788
|
+
errorCode: err.code,
|
|
3789
|
+
hint,
|
|
3790
|
+
recoverable: true
|
|
3791
|
+
},
|
|
3792
|
+
displayText: err.code === "ASSET_NOT_SUPPORTED" ? `Token "${input.from === input.to ? input.from : `${input.from}/${input.to}`}" not in standard registry \u2014 searching for full coin type.` : `No swap route available for ${input.from} \u2192 ${input.to}.`
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3763
3795
|
throw err;
|
|
3764
3796
|
}
|
|
3765
3797
|
}
|
|
@@ -5721,6 +5753,17 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
|
|
|
5721
5753
|
- "Is protocol X safe?" / "Tell me about NAVI": protocol_deep_dive with the slug.
|
|
5722
5754
|
- "Full account report" / "account summary" / "give me everything" / "complete overview": triggers the \`account_report\` recipe \u2014 when the recipe block appears, follow EVERY step including all six tool calls. Each step renders a distinct rich card; skipping a step means a missing card.
|
|
5723
5755
|
|
|
5756
|
+
## Recoverable tool errors (deterministic recovery paths)
|
|
5757
|
+
- **\`swap_quote\` or \`swap_execute\` returns \`{ errorCode: 'ASSET_NOT_SUPPORTED', recoverable: true, hint: ... }\`**: the symbol isn't in the standard registry. Call \`navi_navi_search_tokens\` with the symbol \u2192 take the returned full coin type \u2192 retry the swap with that full coin type string (e.g. \`0x83556457...::spring_sui::SPRING_SUI\` instead of \`SSUI\`). Don't apologize, just recover.
|
|
5758
|
+
- **\`swap_quote\` returns \`{ errorCode: 'SWAP_FAILED', recoverable: true }\`**: no route or insufficient liquidity. Call \`balance_check\` to confirm the source token is held with the expected amount, then either: try a smaller amount, or ask the user if they want to swap via an intermediate token (e.g. via SUI).
|
|
5759
|
+
- **Always check \`recoverable: true\` first** \u2014 if a tool result has that flag, do the suggested next action without asking the user. Recovery is the agent's job.
|
|
5760
|
+
|
|
5761
|
+
## Authentication (you CANNOT log users in or out)
|
|
5762
|
+
- You have NO tool to log users in, log users out, sign them in, or sign them out. You cannot end their session, switch accounts, or clear cookies.
|
|
5763
|
+
- If a user types "logout", "sign out", "log out", "exit", or any variant: tell them "Tap the avatar in the top-right and choose Sign Out" \u2014 do NOT narrate fake success. Saying "you're logged out" when they aren't is the worst possible behavior.
|
|
5764
|
+
- If a user types "login", "sign in", "log in": tell them "Tap Sign In with Google in the top-right" \u2014 same rule.
|
|
5765
|
+
- If their session has expired (you'll see \`_sessionExpired: true\` on a tool result, or a "Your sign-in session has expired" message): tell them to tap **Sign back in** \u2014 the session-expired card has a button right there. Don't tell them to "logout and log back in" \u2014 there's nothing to log out from.
|
|
5766
|
+
|
|
5724
5767
|
## Safety
|
|
5725
5768
|
- Never encourage risky financial behavior.
|
|
5726
5769
|
- Warn when health factor < 1.5.
|
|
@@ -7075,6 +7118,8 @@ var EarlyToolDispatcher = class {
|
|
|
7075
7118
|
}
|
|
7076
7119
|
return result;
|
|
7077
7120
|
});
|
|
7121
|
+
promise.catch(() => {
|
|
7122
|
+
});
|
|
7078
7123
|
this.entries.push({ call, tool, promise, deduped: false, readAttemptCount });
|
|
7079
7124
|
return true;
|
|
7080
7125
|
}
|