@t2000/engine 1.22.2 → 1.23.1
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 +7 -4
- package/dist/index.js +96 -13
- 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 { T2000 } from '@t2000/sdk';
|
|
6
|
+
import { PendingReward as PendingReward$1, T2000 } from '@t2000/sdk';
|
|
7
7
|
|
|
8
8
|
type ProactiveType = 'idle_balance' | 'hf_warning' | 'apy_drift' | 'goal_progress';
|
|
9
9
|
interface ProactiveMarker {
|
|
@@ -3363,13 +3363,16 @@ declare const repayDebtTool: Tool<{
|
|
|
3363
3363
|
gasCost: number;
|
|
3364
3364
|
}>;
|
|
3365
3365
|
|
|
3366
|
-
|
|
3366
|
+
interface ClaimRewardsResult {
|
|
3367
3367
|
success: boolean;
|
|
3368
3368
|
tx: string | null;
|
|
3369
|
-
rewards:
|
|
3369
|
+
rewards: PendingReward$1[];
|
|
3370
3370
|
totalValueUsd: number;
|
|
3371
3371
|
gasCost: number;
|
|
3372
|
-
|
|
3372
|
+
degraded: boolean;
|
|
3373
|
+
degradationReason: string | null;
|
|
3374
|
+
}
|
|
3375
|
+
declare const claimRewardsTool: Tool<{}, ClaimRewardsResult>;
|
|
3373
3376
|
|
|
3374
3377
|
declare const payApiTool: Tool<{
|
|
3375
3378
|
url: string;
|
package/dist/index.js
CHANGED
|
@@ -3389,7 +3389,25 @@ var claimRewardsTool = buildTool({
|
|
|
3389
3389
|
flags: { mutating: true },
|
|
3390
3390
|
async call(_input, context) {
|
|
3391
3391
|
const agent = requireAgent(context);
|
|
3392
|
-
|
|
3392
|
+
let result;
|
|
3393
|
+
try {
|
|
3394
|
+
result = await agent.claimRewards();
|
|
3395
|
+
} catch (err) {
|
|
3396
|
+
const errAny = err;
|
|
3397
|
+
const isProtocolDown = errAny?.code === "PROTOCOL_UNAVAILABLE";
|
|
3398
|
+
const detail = typeof errAny?.message === "string" ? errAny.message.replace(/^[^:]*:\s*/, "") : "";
|
|
3399
|
+
const displayText2 = isProtocolDown ? `Could not check pending rewards \u2014 NAVI is degraded right now${detail ? ` (${detail.slice(0, 80)})` : ""}. Try again in a moment.` : "Could not check pending rewards \u2014 protocol error. Try again in a moment.";
|
|
3400
|
+
const data2 = {
|
|
3401
|
+
success: false,
|
|
3402
|
+
tx: null,
|
|
3403
|
+
rewards: [],
|
|
3404
|
+
totalValueUsd: 0,
|
|
3405
|
+
gasCost: 0,
|
|
3406
|
+
degraded: true,
|
|
3407
|
+
degradationReason: errAny?.code ?? "UNKNOWN"
|
|
3408
|
+
};
|
|
3409
|
+
return { data: data2, displayText: displayText2 };
|
|
3410
|
+
}
|
|
3393
3411
|
const priceCache = context.priceCache;
|
|
3394
3412
|
const enrichedRewards = result.rewards.map((r) => {
|
|
3395
3413
|
if (r.estimatedValueUsd > 0) return r;
|
|
@@ -3411,16 +3429,16 @@ var claimRewardsTool = buildTool({
|
|
|
3411
3429
|
const txSuffix = txShort ? ` (tx: ${txShort})` : "";
|
|
3412
3430
|
displayText = `Claimed ${breakdown}${usdSuffix}${txSuffix}`;
|
|
3413
3431
|
}
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
displayText
|
|
3432
|
+
const data = {
|
|
3433
|
+
success: result.success,
|
|
3434
|
+
tx: result.tx || null,
|
|
3435
|
+
rewards: enrichedRewards,
|
|
3436
|
+
totalValueUsd,
|
|
3437
|
+
gasCost: result.gasCost,
|
|
3438
|
+
degraded: false,
|
|
3439
|
+
degradationReason: null
|
|
3423
3440
|
};
|
|
3441
|
+
return { data, displayText };
|
|
3424
3442
|
}
|
|
3425
3443
|
});
|
|
3426
3444
|
var MPP_GATEWAY = "https://mpp.t2000.ai";
|
|
@@ -5191,6 +5209,70 @@ var resolveSuinsTool = buildTool({
|
|
|
5191
5209
|
}
|
|
5192
5210
|
}
|
|
5193
5211
|
});
|
|
5212
|
+
function formatAmount2(amount) {
|
|
5213
|
+
if (!Number.isFinite(amount) || amount <= 0) return "0";
|
|
5214
|
+
if (amount >= 1) return amount.toFixed(4).replace(/\.?0+$/, "");
|
|
5215
|
+
if (amount >= 1e-4) return amount.toFixed(6).replace(/\.?0+$/, "");
|
|
5216
|
+
return amount.toExponential(2);
|
|
5217
|
+
}
|
|
5218
|
+
var pendingRewardsTool = buildTool({
|
|
5219
|
+
name: "pending_rewards",
|
|
5220
|
+
description: "Inspect unclaimed protocol rewards for the signed-in user without claiming them. Returns a per-asset breakdown \u2014 symbol, amount, USD value (when oracle prices are known) \u2014 plus the total claimable USD. Use BEFORE calling claim_rewards or harvest_rewards so you can tell the user exactly what's claimable; if zero rewards or NAVI is degraded, surface that truthfully instead of jumping to a write. Read-only, never opens a confirm card.",
|
|
5221
|
+
inputSchema: z.object({}),
|
|
5222
|
+
jsonSchema: { type: "object", properties: {}, required: [] },
|
|
5223
|
+
isReadOnly: true,
|
|
5224
|
+
// Rewards accrue continuously and are zeroed on claim — never dedupe
|
|
5225
|
+
// across turns within the same session.
|
|
5226
|
+
cacheable: false,
|
|
5227
|
+
async call(_input, context) {
|
|
5228
|
+
const agent = requireAgent(context);
|
|
5229
|
+
let rewards;
|
|
5230
|
+
try {
|
|
5231
|
+
rewards = await agent.getPendingRewards();
|
|
5232
|
+
} catch (err) {
|
|
5233
|
+
const errAny = err;
|
|
5234
|
+
const isProtocolDown = errAny?.code === "PROTOCOL_UNAVAILABLE";
|
|
5235
|
+
const detail = typeof errAny?.message === "string" ? errAny.message.replace(/^[^:]*:\s*/, "") : "";
|
|
5236
|
+
const displayText2 = isProtocolDown ? `Could not check pending rewards \u2014 NAVI is degraded right now${detail ? ` (${detail.slice(0, 80)})` : ""}. Try again in a moment.` : "Could not check pending rewards \u2014 protocol error. Try again in a moment.";
|
|
5237
|
+
const data2 = {
|
|
5238
|
+
rewards: [],
|
|
5239
|
+
totalValueUsd: 0,
|
|
5240
|
+
degraded: true,
|
|
5241
|
+
degradationReason: errAny?.code ?? "UNKNOWN"
|
|
5242
|
+
};
|
|
5243
|
+
return { data: data2, displayText: displayText2 };
|
|
5244
|
+
}
|
|
5245
|
+
const priceCache = context.priceCache;
|
|
5246
|
+
const enriched = rewards.map((r) => {
|
|
5247
|
+
if (r.estimatedValueUsd > 0) return r;
|
|
5248
|
+
const price = priceCache?.get(r.symbol.toUpperCase());
|
|
5249
|
+
if (!price || !Number.isFinite(price) || price <= 0) return r;
|
|
5250
|
+
return { ...r, estimatedValueUsd: r.amount * price };
|
|
5251
|
+
});
|
|
5252
|
+
const totalValueUsd = enriched.reduce(
|
|
5253
|
+
(s, r) => s + (Number.isFinite(r.estimatedValueUsd) ? r.estimatedValueUsd : 0),
|
|
5254
|
+
0
|
|
5255
|
+
);
|
|
5256
|
+
let displayText;
|
|
5257
|
+
if (enriched.length === 0) {
|
|
5258
|
+
displayText = "No pending rewards.";
|
|
5259
|
+
} else {
|
|
5260
|
+
const breakdown = enriched.map((r) => {
|
|
5261
|
+
const usd = Number.isFinite(r.estimatedValueUsd) && r.estimatedValueUsd > 0 ? ` (~$${r.estimatedValueUsd.toFixed(r.estimatedValueUsd >= 1 ? 2 : 4)})` : "";
|
|
5262
|
+
return `${formatAmount2(r.amount)} ${r.symbol}${usd}`;
|
|
5263
|
+
}).join(", ");
|
|
5264
|
+
const totalSuffix = totalValueUsd > 0 ? ` \u2014 total ~$${totalValueUsd.toFixed(2)}` : "";
|
|
5265
|
+
displayText = `Pending rewards: ${breakdown}${totalSuffix}`;
|
|
5266
|
+
}
|
|
5267
|
+
const data = {
|
|
5268
|
+
rewards: enriched,
|
|
5269
|
+
totalValueUsd,
|
|
5270
|
+
degraded: false,
|
|
5271
|
+
degradationReason: null
|
|
5272
|
+
};
|
|
5273
|
+
return { data, displayText };
|
|
5274
|
+
}
|
|
5275
|
+
});
|
|
5194
5276
|
var todoStatusSchema = z.enum(["pending", "in_progress", "completed"]);
|
|
5195
5277
|
var todoItemSchema = z.object({
|
|
5196
5278
|
id: z.string().min(1, "id must be a non-empty string").max(40, "id must be \u226440 chars (use a slug, not a sentence)"),
|
|
@@ -5323,8 +5405,8 @@ var ADD_RECIPIENT_FORM = {
|
|
|
5323
5405
|
// the resolution.
|
|
5324
5406
|
kind: "sui-recipient",
|
|
5325
5407
|
required: true,
|
|
5326
|
-
placeholder: "mom
|
|
5327
|
-
helpText: "Type @
|
|
5408
|
+
placeholder: "mom@audric / alex.sui / 0x40cd\u20263e62",
|
|
5409
|
+
helpText: "Type alice@audric for an Audric user, alex.sui for any SuiNS, or paste a 0x address. We'll resolve it to the canonical wallet automatically."
|
|
5328
5410
|
}
|
|
5329
5411
|
]
|
|
5330
5412
|
};
|
|
@@ -5472,7 +5554,8 @@ var READ_TOOLS = [
|
|
|
5472
5554
|
spendingAnalyticsTool,
|
|
5473
5555
|
yieldSummaryTool,
|
|
5474
5556
|
activitySummaryTool,
|
|
5475
|
-
resolveSuinsTool
|
|
5557
|
+
resolveSuinsTool,
|
|
5558
|
+
pendingRewardsTool
|
|
5476
5559
|
];
|
|
5477
5560
|
var WRITE_TOOLS = [
|
|
5478
5561
|
saveDepositTool,
|