@t2000/cli 5.3.0 → 5.5.0
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/README.md +1 -1
- package/dist/{dist-U65BYMC5.js → dist-4JZ33TE5.js} +117 -35
- package/dist/{dist-U65BYMC5.js.map → dist-4JZ33TE5.js.map} +1 -1
- package/dist/index.js +352 -137
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -22105,7 +22105,7 @@ var {
|
|
|
22105
22105
|
} = import_index.default;
|
|
22106
22106
|
|
|
22107
22107
|
// src/program.ts
|
|
22108
|
-
import { createRequire } from "module";
|
|
22108
|
+
import { createRequire as createRequire2 } from "module";
|
|
22109
22109
|
|
|
22110
22110
|
// src/output.ts
|
|
22111
22111
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -26711,6 +26711,7 @@ __export(token_registry_exports, {
|
|
|
26711
26711
|
getCoinMeta: () => getCoinMeta,
|
|
26712
26712
|
getDecimalsForCoinType: () => getDecimalsForCoinType,
|
|
26713
26713
|
isInRegistry: () => isInRegistry,
|
|
26714
|
+
resolveCoinDecimals: () => resolveCoinDecimals,
|
|
26714
26715
|
resolveSymbol: () => resolveSymbol,
|
|
26715
26716
|
resolveTokenType: () => resolveTokenType
|
|
26716
26717
|
});
|
|
@@ -26732,6 +26733,16 @@ function getDecimalsForCoinType(coinType) {
|
|
|
26732
26733
|
}
|
|
26733
26734
|
return 9;
|
|
26734
26735
|
}
|
|
26736
|
+
async function resolveCoinDecimals(client, coinType) {
|
|
26737
|
+
if (isInRegistry(coinType)) return getDecimalsForCoinType(coinType);
|
|
26738
|
+
try {
|
|
26739
|
+
const res = await client.core.getCoinMetadata({ coinType });
|
|
26740
|
+
const d = res?.metadata?.decimals ?? res?.decimals;
|
|
26741
|
+
if (typeof d === "number" && Number.isFinite(d)) return d;
|
|
26742
|
+
} catch {
|
|
26743
|
+
}
|
|
26744
|
+
return getDecimalsForCoinType(coinType);
|
|
26745
|
+
}
|
|
26735
26746
|
function resolveSymbol(coinType) {
|
|
26736
26747
|
const direct = BY_TYPE.get(coinType);
|
|
26737
26748
|
if (direct) return direct.symbol;
|
|
@@ -27236,7 +27247,7 @@ async function getSwapQuote(params) {
|
|
|
27236
27247
|
);
|
|
27237
27248
|
}
|
|
27238
27249
|
const byAmountIn = params.byAmountIn ?? true;
|
|
27239
|
-
const fromDecimals = getDecimalsForCoinType(fromType);
|
|
27250
|
+
const fromDecimals = params.fromDecimals ?? getDecimalsForCoinType(fromType);
|
|
27240
27251
|
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
27241
27252
|
const route = await findSwapRoute2({
|
|
27242
27253
|
walletAddress: params.walletAddress,
|
|
@@ -27250,7 +27261,7 @@ async function getSwapQuote(params) {
|
|
|
27250
27261
|
if (route.insufficientLiquidity) {
|
|
27251
27262
|
throw new T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
|
|
27252
27263
|
}
|
|
27253
|
-
const toDecimals = getDecimalsForCoinType(toType);
|
|
27264
|
+
const toDecimals = params.toDecimals ?? getDecimalsForCoinType(toType);
|
|
27254
27265
|
const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
|
|
27255
27266
|
const toAmount = Number(route.amountOut) / 10 ** toDecimals;
|
|
27256
27267
|
const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
|
|
@@ -27797,6 +27808,7 @@ async function buildSendTx({
|
|
|
27797
27808
|
});
|
|
27798
27809
|
return tx;
|
|
27799
27810
|
}
|
|
27811
|
+
init_token_registry();
|
|
27800
27812
|
var SUI_PRICE_FALLBACK = 1;
|
|
27801
27813
|
var _cachedSuiPrice = 0;
|
|
27802
27814
|
var _priceLastFetched = 0;
|
|
@@ -27829,30 +27841,67 @@ async function fetchSuiPrice(client) {
|
|
|
27829
27841
|
}
|
|
27830
27842
|
return _cachedSuiPrice || SUI_PRICE_FALLBACK;
|
|
27831
27843
|
}
|
|
27844
|
+
function safeNorm(coinType) {
|
|
27845
|
+
try {
|
|
27846
|
+
return normalizeStructTag(coinType);
|
|
27847
|
+
} catch {
|
|
27848
|
+
return coinType;
|
|
27849
|
+
}
|
|
27850
|
+
}
|
|
27851
|
+
var SUI_TYPE_NORM = safeNorm(SUPPORTED_ASSETS.SUI.type);
|
|
27852
|
+
var STABLE_BY_NORM = (() => {
|
|
27853
|
+
const m = {};
|
|
27854
|
+
for (const asset of STABLE_ASSETS) m[safeNorm(SUPPORTED_ASSETS[asset].type)] = asset;
|
|
27855
|
+
return m;
|
|
27856
|
+
})();
|
|
27832
27857
|
async function queryBalance(client, address) {
|
|
27833
|
-
const
|
|
27834
|
-
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
|
|
27858
|
+
const held = [];
|
|
27859
|
+
let cursor;
|
|
27860
|
+
do {
|
|
27861
|
+
const page = await client.core.listBalances({ owner: address, cursor: cursor ?? void 0 });
|
|
27862
|
+
for (const b of page.balances) {
|
|
27863
|
+
const raw = BigInt(b.balance);
|
|
27864
|
+
if (raw > 0n) held.push({ coinType: b.coinType, raw });
|
|
27865
|
+
}
|
|
27866
|
+
cursor = page.hasNextPage ? page.cursor : null;
|
|
27867
|
+
} while (cursor);
|
|
27868
|
+
const suiPriceUsd = await fetchSuiPrice(client);
|
|
27841
27869
|
const stables = {};
|
|
27870
|
+
for (const asset of STABLE_ASSETS) stables[asset] = 0;
|
|
27842
27871
|
let totalStables = 0;
|
|
27843
|
-
|
|
27844
|
-
|
|
27845
|
-
|
|
27872
|
+
let suiAmount = 0;
|
|
27873
|
+
const otherCoins = [];
|
|
27874
|
+
for (const { coinType, raw } of held) {
|
|
27875
|
+
const norm = safeNorm(coinType);
|
|
27876
|
+
if (norm === SUI_TYPE_NORM) {
|
|
27877
|
+
suiAmount = Number(raw) / Number(MIST_PER_SUI);
|
|
27878
|
+
} else if (STABLE_BY_NORM[norm]) {
|
|
27879
|
+
const asset = STABLE_BY_NORM[norm];
|
|
27880
|
+
const amount = Number(raw) / 10 ** SUPPORTED_ASSETS[asset].decimals;
|
|
27881
|
+
stables[asset] = amount;
|
|
27882
|
+
totalStables += amount;
|
|
27883
|
+
} else {
|
|
27884
|
+
otherCoins.push({ coinType, raw });
|
|
27885
|
+
}
|
|
27846
27886
|
}
|
|
27847
|
-
const
|
|
27887
|
+
const tokens = await Promise.all(
|
|
27888
|
+
otherCoins.map(async ({ coinType, raw }) => {
|
|
27889
|
+
const decimals = await resolveCoinDecimals(client, coinType);
|
|
27890
|
+
return {
|
|
27891
|
+
coinType,
|
|
27892
|
+
symbol: resolveSymbol(coinType),
|
|
27893
|
+
amount: Number(raw) / 10 ** decimals,
|
|
27894
|
+
usdValue: null
|
|
27895
|
+
};
|
|
27896
|
+
})
|
|
27897
|
+
);
|
|
27898
|
+
tokens.sort((a, b) => a.symbol.localeCompare(b.symbol));
|
|
27848
27899
|
const suiUsdValue = suiAmount * suiPriceUsd;
|
|
27849
27900
|
return {
|
|
27850
27901
|
stables,
|
|
27851
27902
|
available: totalStables,
|
|
27852
|
-
sui: {
|
|
27853
|
-
|
|
27854
|
-
usdValue: suiUsdValue
|
|
27855
|
-
},
|
|
27903
|
+
sui: { amount: suiAmount, usdValue: suiUsdValue },
|
|
27904
|
+
tokens,
|
|
27856
27905
|
totalUsd: totalStables + suiUsdValue
|
|
27857
27906
|
};
|
|
27858
27907
|
}
|
|
@@ -28435,7 +28484,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28435
28484
|
if (!toType) throw new T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.to}. Provide the full coin type.`);
|
|
28436
28485
|
const byAmountIn = params.byAmountIn ?? true;
|
|
28437
28486
|
const slippage = Math.min(params.slippage ?? 0.01, 0.05);
|
|
28438
|
-
const fromDecimals =
|
|
28487
|
+
const fromDecimals = await resolveCoinDecimals(this.client, fromType);
|
|
28439
28488
|
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
28440
28489
|
const route = await findSwapRoute2({
|
|
28441
28490
|
walletAddress: this._address,
|
|
@@ -28449,7 +28498,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28449
28498
|
if (route.priceImpact > 0.05) {
|
|
28450
28499
|
console.warn(`[swap] High price impact: ${(route.priceImpact * 100).toFixed(2)}%`);
|
|
28451
28500
|
}
|
|
28452
|
-
const toDecimals =
|
|
28501
|
+
const toDecimals = await resolveCoinDecimals(this.client, toType);
|
|
28453
28502
|
let preBalRaw = 0n;
|
|
28454
28503
|
try {
|
|
28455
28504
|
const preBal = await this.client.core.getBalance({ owner: this._address, coinType: toType });
|
|
@@ -28542,13 +28591,18 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28542
28591
|
*/
|
|
28543
28592
|
async swapQuote(params) {
|
|
28544
28593
|
const { getSwapQuote: getSwapQuote2 } = await Promise.resolve().then(() => (init_swap_quote(), swap_quote_exports));
|
|
28594
|
+
const { resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
28595
|
+
const fromType = resolveTokenType2(params.from);
|
|
28596
|
+
const toType = resolveTokenType2(params.to);
|
|
28545
28597
|
return getSwapQuote2({
|
|
28546
28598
|
walletAddress: this._address,
|
|
28547
28599
|
from: params.from,
|
|
28548
28600
|
to: params.to,
|
|
28549
28601
|
amount: params.amount,
|
|
28550
28602
|
byAmountIn: params.byAmountIn,
|
|
28551
|
-
providers: params.providers
|
|
28603
|
+
providers: params.providers,
|
|
28604
|
+
fromDecimals: fromType ? await resolveCoinDecimals(this.client, fromType) : void 0,
|
|
28605
|
+
toDecimals: toType ? await resolveCoinDecimals(this.client, toType) : void 0
|
|
28552
28606
|
});
|
|
28553
28607
|
}
|
|
28554
28608
|
// -- Wallet --
|
|
@@ -28684,8 +28738,8 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28684
28738
|
/**
|
|
28685
28739
|
* [SPEC_AGENTIC_STACK P1 / SDK F2 — 2026-05-25; refreshed S.342 / 2026-05-26]
|
|
28686
28740
|
* Preferred alias of `deposit()`. Was introduced to mirror the v3 `t2000 fund`
|
|
28687
|
-
* CLI command; the v4 CLI surface is `t2
|
|
28688
|
-
* S.
|
|
28741
|
+
* CLI command; the v4 CLI surface is `t2 fund` (renamed back from the
|
|
28742
|
+
* interim `t2 receive` in S.464). `deposit()` stays as the canonical method name for
|
|
28689
28743
|
* back-compat; `fund()` stays as a programmatic alias for audric + other
|
|
28690
28744
|
* SDK consumers that prefer the verb.
|
|
28691
28745
|
*/
|
|
@@ -31234,6 +31288,17 @@ async function withAgent(options = {}) {
|
|
|
31234
31288
|
rpcUrl: options.rpcUrl
|
|
31235
31289
|
});
|
|
31236
31290
|
}
|
|
31291
|
+
async function tryWithAgent(options = {}) {
|
|
31292
|
+
try {
|
|
31293
|
+
const agent = await T2000.create({
|
|
31294
|
+
keyPath: options.keyPath,
|
|
31295
|
+
rpcUrl: options.rpcUrl
|
|
31296
|
+
});
|
|
31297
|
+
return { kind: "ok", agent };
|
|
31298
|
+
} catch (error) {
|
|
31299
|
+
return { kind: "error", error };
|
|
31300
|
+
}
|
|
31301
|
+
}
|
|
31237
31302
|
|
|
31238
31303
|
// src/commands/export.ts
|
|
31239
31304
|
function registerExport(program3) {
|
|
@@ -31265,16 +31330,17 @@ function registerExport(program3) {
|
|
|
31265
31330
|
});
|
|
31266
31331
|
}
|
|
31267
31332
|
|
|
31268
|
-
// src/commands/
|
|
31333
|
+
// src/commands/fund.ts
|
|
31269
31334
|
var import_qrcode = __toESM(require_lib4(), 1);
|
|
31270
31335
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
31271
|
-
|
|
31272
|
-
|
|
31336
|
+
var VALUE_PROMISE = "$5 USDC \u2248 ~250 paid API calls (at the $0.02 floor).";
|
|
31337
|
+
function registerFund(program3) {
|
|
31338
|
+
program3.command("fund").description("Show your wallet address + QR to fund it (USDC / USDsui / SUI on Sui)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--qr-only", "Print only the QR code (no address text)").action(async (opts) => {
|
|
31273
31339
|
try {
|
|
31274
31340
|
const agent = await withAgent({ keyPath: opts.key });
|
|
31275
31341
|
const address = agent.address();
|
|
31276
31342
|
if (isJsonMode()) {
|
|
31277
|
-
printJson({ address, qrEncodedFor: address });
|
|
31343
|
+
printJson({ address, qrEncodedFor: address, valuePromise: VALUE_PROMISE });
|
|
31278
31344
|
return;
|
|
31279
31345
|
}
|
|
31280
31346
|
printBlank();
|
|
@@ -31282,6 +31348,7 @@ function registerReceive(program3) {
|
|
|
31282
31348
|
printKeyValue("Address", address);
|
|
31283
31349
|
printBlank();
|
|
31284
31350
|
printLine(import_picocolors2.default.dim("Accepts USDC, USDsui, or SUI on Sui mainnet."));
|
|
31351
|
+
printLine(import_picocolors2.default.dim(VALUE_PROMISE));
|
|
31285
31352
|
printLine(import_picocolors2.default.dim("Scan to send to this wallet:"));
|
|
31286
31353
|
printBlank();
|
|
31287
31354
|
}
|
|
@@ -31304,8 +31371,11 @@ function registerReceive(program3) {
|
|
|
31304
31371
|
|
|
31305
31372
|
// src/commands/balance.ts
|
|
31306
31373
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
31374
|
+
function formatTokenAmount(n) {
|
|
31375
|
+
return n.toLocaleString("en-US", { maximumFractionDigits: 6, useGrouping: false });
|
|
31376
|
+
}
|
|
31307
31377
|
function registerBalance(program3) {
|
|
31308
|
-
program3.command("balance").description("Show
|
|
31378
|
+
program3.command("balance").description("Show all wallet holdings \u2014 USDC / USDsui / SUI (USD-priced) + any other tokens (amount-only)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
31309
31379
|
try {
|
|
31310
31380
|
const agent = await withAgent({ keyPath: opts.key });
|
|
31311
31381
|
const bal = await agent.balance();
|
|
@@ -31314,6 +31384,7 @@ function registerBalance(program3) {
|
|
|
31314
31384
|
available: bal.available,
|
|
31315
31385
|
stables: bal.stables,
|
|
31316
31386
|
sui: bal.sui,
|
|
31387
|
+
tokens: bal.tokens,
|
|
31317
31388
|
totalUsd: bal.totalUsd
|
|
31318
31389
|
});
|
|
31319
31390
|
return;
|
|
@@ -31329,14 +31400,25 @@ function registerBalance(program3) {
|
|
|
31329
31400
|
printKeyValue(label, formatUsd(amount));
|
|
31330
31401
|
}
|
|
31331
31402
|
}
|
|
31332
|
-
if (bal.sui && bal.sui.
|
|
31403
|
+
if (bal.sui && bal.sui.amount > 0) {
|
|
31333
31404
|
printKeyValue(
|
|
31334
31405
|
"SUI",
|
|
31335
|
-
`${formatUsd(bal.sui.usdValue)} ${import_picocolors3.default.dim(`(${bal.sui.amount.toFixed(4)} SUI \
|
|
31406
|
+
`${formatUsd(bal.sui.usdValue)} ${import_picocolors3.default.dim(`(${bal.sui.amount.toFixed(4)} SUI \xB7 gas)`)}`
|
|
31336
31407
|
);
|
|
31337
31408
|
}
|
|
31409
|
+
const tokens = bal.tokens ?? [];
|
|
31410
|
+
for (const t of tokens) {
|
|
31411
|
+
printKeyValue(t.symbol.padEnd(8), import_picocolors3.default.dim(formatTokenAmount(t.amount)));
|
|
31412
|
+
}
|
|
31338
31413
|
printSeparator();
|
|
31339
|
-
printKeyValue("Wallet total", formatUsd(bal.totalUsd));
|
|
31414
|
+
printKeyValue("Wallet total", `${formatUsd(bal.totalUsd)} ${import_picocolors3.default.dim("(priced holdings)")}`);
|
|
31415
|
+
if (tokens.length > 0) {
|
|
31416
|
+
printLine(
|
|
31417
|
+
import_picocolors3.default.dim(
|
|
31418
|
+
` + ${tokens.length} token${tokens.length === 1 ? "" : "s"} above with no USD price \u2014 not counted in the total`
|
|
31419
|
+
)
|
|
31420
|
+
);
|
|
31421
|
+
}
|
|
31340
31422
|
printBlank();
|
|
31341
31423
|
} catch (error) {
|
|
31342
31424
|
handleError(error);
|
|
@@ -31432,8 +31514,171 @@ function registerHistory(program3) {
|
|
|
31432
31514
|
});
|
|
31433
31515
|
}
|
|
31434
31516
|
|
|
31435
|
-
// src/commands/
|
|
31517
|
+
// src/commands/status.ts
|
|
31436
31518
|
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
31519
|
+
import { createRequire } from "module";
|
|
31520
|
+
|
|
31521
|
+
// src/commands/mcp/platforms.ts
|
|
31522
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
31523
|
+
import { join as join3, dirname as dirname2 } from "path";
|
|
31524
|
+
import { homedir as homedir2 } from "os";
|
|
31525
|
+
import { existsSync as existsSync2 } from "fs";
|
|
31526
|
+
var MCP_SERVER_ENTRY = {
|
|
31527
|
+
command: "t2000",
|
|
31528
|
+
args: ["mcp", "start"]
|
|
31529
|
+
};
|
|
31530
|
+
var MCP_SERVER_KEY = "t2000";
|
|
31531
|
+
function getPlatformConfigs() {
|
|
31532
|
+
const home = homedir2();
|
|
31533
|
+
return [
|
|
31534
|
+
{
|
|
31535
|
+
name: "Claude Desktop",
|
|
31536
|
+
slug: "claude-desktop",
|
|
31537
|
+
path: join3(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
|
|
31538
|
+
},
|
|
31539
|
+
{
|
|
31540
|
+
name: "Cursor",
|
|
31541
|
+
slug: "cursor",
|
|
31542
|
+
path: join3(home, ".cursor", "mcp.json")
|
|
31543
|
+
},
|
|
31544
|
+
{
|
|
31545
|
+
name: "Windsurf",
|
|
31546
|
+
slug: "windsurf",
|
|
31547
|
+
path: join3(home, ".codeium", "windsurf", "mcp_config.json")
|
|
31548
|
+
}
|
|
31549
|
+
];
|
|
31550
|
+
}
|
|
31551
|
+
async function readJsonFile(path2) {
|
|
31552
|
+
try {
|
|
31553
|
+
const content = await readFile2(path2, "utf-8");
|
|
31554
|
+
return JSON.parse(content);
|
|
31555
|
+
} catch {
|
|
31556
|
+
return {};
|
|
31557
|
+
}
|
|
31558
|
+
}
|
|
31559
|
+
async function writeJsonFile(path2, data) {
|
|
31560
|
+
const dir = dirname2(path2);
|
|
31561
|
+
if (!existsSync2(dir)) {
|
|
31562
|
+
await mkdir2(dir, { recursive: true });
|
|
31563
|
+
}
|
|
31564
|
+
await writeFile2(path2, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
31565
|
+
}
|
|
31566
|
+
function withMcpEntry(config) {
|
|
31567
|
+
return {
|
|
31568
|
+
...config,
|
|
31569
|
+
mcpServers: {
|
|
31570
|
+
...config.mcpServers ?? {},
|
|
31571
|
+
[MCP_SERVER_KEY]: { ...MCP_SERVER_ENTRY }
|
|
31572
|
+
}
|
|
31573
|
+
};
|
|
31574
|
+
}
|
|
31575
|
+
function hasMcpEntry(config) {
|
|
31576
|
+
return typeof config.mcpServers === "object" && config.mcpServers !== null && MCP_SERVER_KEY in config.mcpServers;
|
|
31577
|
+
}
|
|
31578
|
+
function withoutMcpEntry(config) {
|
|
31579
|
+
if (!hasMcpEntry(config)) return config;
|
|
31580
|
+
const servers = { ...config.mcpServers };
|
|
31581
|
+
delete servers[MCP_SERVER_KEY];
|
|
31582
|
+
return { ...config, mcpServers: servers };
|
|
31583
|
+
}
|
|
31584
|
+
|
|
31585
|
+
// src/commands/status.ts
|
|
31586
|
+
var require2 = createRequire(import.meta.url);
|
|
31587
|
+
var { version: CLI_VERSION } = require2("../package.json");
|
|
31588
|
+
var GATEWAY_URL = process.env.T2000_GATEWAY_URL ?? "https://mpp.t2000.ai";
|
|
31589
|
+
var GATEWAY_TIMEOUT_MS = 3e3;
|
|
31590
|
+
async function checkGateway() {
|
|
31591
|
+
const start = Date.now();
|
|
31592
|
+
try {
|
|
31593
|
+
const controller = new AbortController();
|
|
31594
|
+
const timer = setTimeout(() => controller.abort(), GATEWAY_TIMEOUT_MS);
|
|
31595
|
+
const res = await fetch(`${GATEWAY_URL}/api/services`, { signal: controller.signal });
|
|
31596
|
+
clearTimeout(timer);
|
|
31597
|
+
return { url: GATEWAY_URL, reachable: res.ok, latencyMs: Date.now() - start };
|
|
31598
|
+
} catch {
|
|
31599
|
+
return { url: GATEWAY_URL, reachable: false, latencyMs: null };
|
|
31600
|
+
}
|
|
31601
|
+
}
|
|
31602
|
+
async function checkMcpClients() {
|
|
31603
|
+
const platforms = getPlatformConfigs();
|
|
31604
|
+
return Promise.all(
|
|
31605
|
+
platforms.map(async (p) => ({ name: p.name, wired: hasMcpEntry(await readJsonFile(p.path)) }))
|
|
31606
|
+
);
|
|
31607
|
+
}
|
|
31608
|
+
function registerStatus(program3) {
|
|
31609
|
+
program3.command("status").description("Health check: wallet, balances, limits, MCP wiring, gateway reachability").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
31610
|
+
try {
|
|
31611
|
+
const [agentResult, gateway, mcpClients] = await Promise.all([
|
|
31612
|
+
tryWithAgent({ keyPath: opts.key }),
|
|
31613
|
+
checkGateway(),
|
|
31614
|
+
checkMcpClients()
|
|
31615
|
+
]);
|
|
31616
|
+
let wallet = { created: false };
|
|
31617
|
+
let balance = null;
|
|
31618
|
+
let limits = null;
|
|
31619
|
+
if (agentResult.kind === "ok") {
|
|
31620
|
+
const agent = agentResult.agent;
|
|
31621
|
+
wallet = { created: true, address: agent.address() };
|
|
31622
|
+
try {
|
|
31623
|
+
const b = await agent.balance();
|
|
31624
|
+
balance = { totalUsd: b.totalUsd, stables: b.stables, sui: b.sui.amount };
|
|
31625
|
+
} catch {
|
|
31626
|
+
balance = null;
|
|
31627
|
+
}
|
|
31628
|
+
const lim = agent.limits.getLimits();
|
|
31629
|
+
limits = {
|
|
31630
|
+
perTxUsd: lim?.perTxUsd,
|
|
31631
|
+
dailyUsd: lim?.dailyUsd,
|
|
31632
|
+
spentTodayUsd: agent.limits.dailySpentToday()
|
|
31633
|
+
};
|
|
31634
|
+
}
|
|
31635
|
+
if (isJsonMode()) {
|
|
31636
|
+
printJson({ cliVersion: CLI_VERSION, wallet, balance, limits, gateway, mcpClients });
|
|
31637
|
+
return;
|
|
31638
|
+
}
|
|
31639
|
+
printBlank();
|
|
31640
|
+
printLine(import_picocolors5.default.bold("t2000 Agent Wallet \u2014 status"));
|
|
31641
|
+
printBlank();
|
|
31642
|
+
printKeyValue("CLI version", CLI_VERSION);
|
|
31643
|
+
if (wallet.created && wallet.address) {
|
|
31644
|
+
const short = `${wallet.address.slice(0, 6)}\u2026${wallet.address.slice(-4)}`;
|
|
31645
|
+
printKeyValue("Wallet", `${short} ${import_picocolors5.default.green("\u2713")}`);
|
|
31646
|
+
if (balance) {
|
|
31647
|
+
const parts = Object.entries(balance.stables).map(([k, v]) => `${k} ${v}`).concat(`SUI ${balance.sui}`).join(", ");
|
|
31648
|
+
printKeyValue("Balance", `$${balance.totalUsd.toFixed(2)} ${import_picocolors5.default.dim(`(${parts})`)}`);
|
|
31649
|
+
} else {
|
|
31650
|
+
printKeyValue("Balance", import_picocolors5.default.dim("(could not read \u2014 network?)"));
|
|
31651
|
+
}
|
|
31652
|
+
if (limits && (limits.perTxUsd !== void 0 || limits.dailyUsd !== void 0)) {
|
|
31653
|
+
const caps = [
|
|
31654
|
+
limits.perTxUsd !== void 0 ? `$${limits.perTxUsd}/tx` : null,
|
|
31655
|
+
limits.dailyUsd !== void 0 ? `$${limits.dailyUsd}/day` : null
|
|
31656
|
+
].filter(Boolean).join(" \xB7 ");
|
|
31657
|
+
printKeyValue("Limits", `${caps} ${import_picocolors5.default.dim(`(spent today: $${limits.spentTodayUsd.toFixed(2)})`)}`);
|
|
31658
|
+
} else {
|
|
31659
|
+
printKeyValue("Limits", import_picocolors5.default.dim("off (no caps set)"));
|
|
31660
|
+
}
|
|
31661
|
+
} else {
|
|
31662
|
+
printKeyValue("Wallet", `${import_picocolors5.default.yellow("not created")} ${import_picocolors5.default.dim("\u2014 run `t2 init`")}`);
|
|
31663
|
+
}
|
|
31664
|
+
printKeyValue(
|
|
31665
|
+
"Gateway",
|
|
31666
|
+
gateway.reachable ? `${import_picocolors5.default.green("\u2713 reachable")} ${import_picocolors5.default.dim(`(${gateway.latencyMs}ms)`)}` : `${import_picocolors5.default.red("\u2717 unreachable")} ${import_picocolors5.default.dim(`(${gateway.url})`)}`
|
|
31667
|
+
);
|
|
31668
|
+
const mcpSummary = mcpClients.map((c) => `${c.name} ${c.wired ? import_picocolors5.default.green("\u2713") : import_picocolors5.default.dim("\u2717")}`).join(" \xB7 ");
|
|
31669
|
+
printKeyValue("MCP wired", mcpSummary);
|
|
31670
|
+
if (!mcpClients.some((c) => c.wired)) {
|
|
31671
|
+
printLine(import_picocolors5.default.dim(" Run `t2 mcp install` to connect Claude / Cursor / Windsurf."));
|
|
31672
|
+
}
|
|
31673
|
+
printBlank();
|
|
31674
|
+
} catch (err) {
|
|
31675
|
+
handleError(err);
|
|
31676
|
+
}
|
|
31677
|
+
});
|
|
31678
|
+
}
|
|
31679
|
+
|
|
31680
|
+
// src/commands/send.ts
|
|
31681
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
31437
31682
|
var ACCEPTED_ASSETS = ["USDC", "USDsui", "SUI"];
|
|
31438
31683
|
var ACCEPTED_ASSETS_LIST = ACCEPTED_ASSETS.join(", ");
|
|
31439
31684
|
function parseSendArgs(args) {
|
|
@@ -31478,7 +31723,7 @@ function registerSend(program3) {
|
|
|
31478
31723
|
program3.command("send").argument("<amount>", "Amount of <asset> to send (denominated in asset units, NOT USD)").argument(
|
|
31479
31724
|
"[args...]",
|
|
31480
31725
|
'Asset (USDC | USDsui | SUI), optional "to" keyword, and recipient (0x address, SuiNS name like alice.sui, or @audric handle)'
|
|
31481
|
-
).description("Send USDC, USDsui, or SUI. USDC + USDsui are gasless (no SUI required).").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--force", "Override
|
|
31726
|
+
).description("Send USDC, USDsui, or SUI. USDC + USDsui are gasless (no SUI required).").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--force", "Override spending limits for this call (see `t2 limit`)").addHelpText(
|
|
31482
31727
|
"after",
|
|
31483
31728
|
`
|
|
31484
31729
|
Examples:
|
|
@@ -31507,12 +31752,12 @@ Examples:
|
|
|
31507
31752
|
});
|
|
31508
31753
|
return;
|
|
31509
31754
|
}
|
|
31510
|
-
const displayTo = result.suinsName ? `${result.suinsName} ${
|
|
31755
|
+
const displayTo = result.suinsName ? `${result.suinsName} ${import_picocolors6.default.dim(`(${truncateAddress(result.to)})`)}` : truncateAddress(result.to);
|
|
31511
31756
|
const amountDisplay = asset === "SUI" ? `${result.amount.toFixed(4)} SUI` : `${formatUsd(result.amount)} ${asset}`;
|
|
31512
31757
|
printBlank();
|
|
31513
31758
|
printSuccess(`Sent ${amountDisplay} \u2192 ${displayTo}`);
|
|
31514
31759
|
if (result.gasCost === 0) {
|
|
31515
|
-
printKeyValue("Gas",
|
|
31760
|
+
printKeyValue("Gas", import_picocolors6.default.green("gasless \u26A1"));
|
|
31516
31761
|
} else {
|
|
31517
31762
|
printKeyValue("Gas", `${result.gasCost.toFixed(6)} ${result.gasCostUnit}`);
|
|
31518
31763
|
}
|
|
@@ -31525,7 +31770,7 @@ Examples:
|
|
|
31525
31770
|
}
|
|
31526
31771
|
|
|
31527
31772
|
// src/commands/swap.ts
|
|
31528
|
-
var
|
|
31773
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
31529
31774
|
function parseSwapArgs(amountStr, from, to) {
|
|
31530
31775
|
const amount = parseFloat(amountStr);
|
|
31531
31776
|
if (Number.isNaN(amount) || amount <= 0) {
|
|
@@ -31539,7 +31784,7 @@ function parseSwapArgs(amountStr, from, to) {
|
|
|
31539
31784
|
return { amount, from, to };
|
|
31540
31785
|
}
|
|
31541
31786
|
function registerSwap(program3) {
|
|
31542
|
-
program3.command("swap").argument("<amount>", "Amount of <from> to swap (denominated in <from> units)").argument("<from>", "Source token symbol (
|
|
31787
|
+
program3.command("swap").argument("<amount>", "Amount of <from> to swap (denominated in <from> units)").argument("<from>", "Source token \u2014 symbol (USDC, SUI, \u2026) or full coin type (0x\u2026::mod::TOK)").argument("<to>", "Destination token \u2014 symbol (SUI, USDC, \u2026) or full coin type (0x\u2026::mod::TOK)").description("Swap any token pair via Cetus aggregator (20+ DEXs). Unknown coin types resolve decimals on-chain.").option("--quote", "Preview the swap (price, route, impact) without executing").option("--slippage <pct>", "Max slippage percentage (default: 1)", "1").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--force", "Override spending limits for this call (see `t2 limit`)").addHelpText(
|
|
31543
31788
|
"after",
|
|
31544
31789
|
`
|
|
31545
31790
|
Examples:
|
|
@@ -31565,9 +31810,9 @@ Examples:
|
|
|
31565
31810
|
}
|
|
31566
31811
|
printBlank();
|
|
31567
31812
|
printKeyValue("Input", `${quote.fromAmount} ${quote.fromToken}`);
|
|
31568
|
-
printKeyValue("Output",
|
|
31813
|
+
printKeyValue("Output", import_picocolors7.default.green(`${quote.toAmount.toFixed(6)} ${quote.toToken}`));
|
|
31569
31814
|
if (quote.priceImpact > 1e-3) {
|
|
31570
|
-
printKeyValue("Price impact",
|
|
31815
|
+
printKeyValue("Price impact", import_picocolors7.default.yellow(`${(quote.priceImpact * 100).toFixed(2)}%`));
|
|
31571
31816
|
}
|
|
31572
31817
|
printKeyValue("Route", `${quote.fromToken} \u2192 ${quote.toToken} (${quote.route})`);
|
|
31573
31818
|
printBlank();
|
|
@@ -31587,10 +31832,10 @@ Examples:
|
|
|
31587
31832
|
}
|
|
31588
31833
|
printBlank();
|
|
31589
31834
|
printSuccess(
|
|
31590
|
-
`Swapped ${
|
|
31835
|
+
`Swapped ${import_picocolors7.default.yellow(String(result.fromAmount))} ${result.fromToken} \u2192 ${import_picocolors7.default.green(result.toAmount.toFixed(6))} ${result.toToken}`
|
|
31591
31836
|
);
|
|
31592
31837
|
if (result.priceImpact > 5e-3) {
|
|
31593
|
-
printKeyValue("Price impact",
|
|
31838
|
+
printKeyValue("Price impact", import_picocolors7.default.yellow(`${(result.priceImpact * 100).toFixed(2)}%`));
|
|
31594
31839
|
}
|
|
31595
31840
|
printKeyValue("Route", `${result.fromToken} \u2192 ${result.toToken} (${result.route})`);
|
|
31596
31841
|
printKeyValue("Gas", `${result.gasCost.toFixed(6)} SUI`);
|
|
@@ -31604,12 +31849,12 @@ Examples:
|
|
|
31604
31849
|
}
|
|
31605
31850
|
|
|
31606
31851
|
// src/commands/pay.ts
|
|
31607
|
-
var
|
|
31852
|
+
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
31608
31853
|
function registerPay(program3) {
|
|
31609
31854
|
program3.command("pay <url>").description("Pay an MPP / x402 service (USDC on Sui)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--method <method>", "HTTP method (GET, POST, PUT)", "GET").option("--data <json>", "Request body for POST/PUT (auto-promotes --method to POST)").option("--header <key=value>", "Additional HTTP header (repeatable)", collectHeaders, {}).option("--max-price <amount>", "Max USDC price to auto-approve", "1.00").option(
|
|
31610
31855
|
"--estimate",
|
|
31611
31856
|
"Preview the price + service info (no signing, no payment). Exits 0 if the service responds with a 402 challenge."
|
|
31612
|
-
).option("--force", "Override
|
|
31857
|
+
).option("--force", "Override spending limits for this call (see `t2 limit`)").addHelpText(
|
|
31613
31858
|
"after",
|
|
31614
31859
|
`
|
|
31615
31860
|
Examples:
|
|
@@ -31663,10 +31908,10 @@ Examples:
|
|
|
31663
31908
|
return;
|
|
31664
31909
|
}
|
|
31665
31910
|
if (result.paid && result.receipt) {
|
|
31666
|
-
const gasNote = typeof result.gasCostSui === "number" ? result.gasCostSui === 0 ?
|
|
31667
|
-
printSuccess(`Paid via
|
|
31911
|
+
const gasNote = typeof result.gasCostSui === "number" ? result.gasCostSui === 0 ? import_picocolors8.default.green(" \xB7 gasless \u26A1") : import_picocolors8.default.dim(` \xB7 gas: ${result.gasCostSui.toFixed(6)} SUI`) : "";
|
|
31912
|
+
printSuccess(`Paid via ${result.dialect ?? "x402"} (tx: ${result.receipt.reference.slice(0, 10)}\u2026)${gasNote}`);
|
|
31668
31913
|
}
|
|
31669
|
-
printInfo(`\u2190 ${result.status} OK ${
|
|
31914
|
+
printInfo(`\u2190 ${result.status} OK ${import_picocolors8.default.dim(`[${elapsed}ms]`)}`);
|
|
31670
31915
|
printBlank();
|
|
31671
31916
|
if (typeof result.body === "string") {
|
|
31672
31917
|
console.log(result.body);
|
|
@@ -31684,7 +31929,7 @@ async function runEstimate(url, opts) {
|
|
|
31684
31929
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
31685
31930
|
if (!isJsonMode()) {
|
|
31686
31931
|
printBlank();
|
|
31687
|
-
printInfo(`\u2192 ${method} ${url} ${
|
|
31932
|
+
printInfo(`\u2192 ${method} ${url} ${import_picocolors8.default.dim("(estimate \u2014 no payment)")}`);
|
|
31688
31933
|
}
|
|
31689
31934
|
const response = await fetch(url, {
|
|
31690
31935
|
method,
|
|
@@ -31734,6 +31979,7 @@ async function runEstimate(url, opts) {
|
|
|
31734
31979
|
const recipient = req.payTo ?? "unknown";
|
|
31735
31980
|
const looksLikeUsdc = /::usdc::USDC/i.test(asset);
|
|
31736
31981
|
const display = amountRaw && looksLikeUsdc ? `$${(Number(amountRaw) / 1e6).toFixed(4)} USDC` : amountRaw ?? "unknown";
|
|
31982
|
+
const inputSchema = await fetchInputSchema(url, method);
|
|
31737
31983
|
if (isJsonMode()) {
|
|
31738
31984
|
printJson({
|
|
31739
31985
|
url,
|
|
@@ -31747,19 +31993,28 @@ async function runEstimate(url, opts) {
|
|
|
31747
31993
|
amount: amountRaw,
|
|
31748
31994
|
amountDisplay: display,
|
|
31749
31995
|
asset,
|
|
31750
|
-
recipient
|
|
31996
|
+
recipient,
|
|
31997
|
+
inputSchema
|
|
31751
31998
|
}
|
|
31752
31999
|
});
|
|
31753
32000
|
return;
|
|
31754
32001
|
}
|
|
31755
32002
|
printBlank();
|
|
31756
32003
|
printSuccess(`Service requires payment (x402 ${req.scheme ?? "exact"} on ${req.network ?? "sui"})`);
|
|
31757
|
-
printKeyValue("Price",
|
|
32004
|
+
printKeyValue("Price", import_picocolors8.default.green(display));
|
|
31758
32005
|
printKeyValue("Asset", asset);
|
|
31759
32006
|
printKeyValue("Recipient", recipient);
|
|
31760
32007
|
if (req.resource) {
|
|
31761
32008
|
printKeyValue("Resource", req.resource);
|
|
31762
32009
|
}
|
|
32010
|
+
const fields = describeSchemaFields(inputSchema);
|
|
32011
|
+
if (fields.length > 0) {
|
|
32012
|
+
printBlank();
|
|
32013
|
+
printInfo("Input (request body):");
|
|
32014
|
+
for (const f of fields) {
|
|
32015
|
+
printLine(" " + import_picocolors8.default.dim(f));
|
|
32016
|
+
}
|
|
32017
|
+
}
|
|
31763
32018
|
printBlank();
|
|
31764
32019
|
printInfo(`Run without --estimate to pay and execute.`);
|
|
31765
32020
|
printBlank();
|
|
@@ -31771,9 +32026,31 @@ function collectHeaders(value, previous) {
|
|
|
31771
32026
|
}
|
|
31772
32027
|
return previous;
|
|
31773
32028
|
}
|
|
32029
|
+
async function fetchInputSchema(url, method) {
|
|
32030
|
+
try {
|
|
32031
|
+
const u = new URL(url);
|
|
32032
|
+
const res = await fetch(`${u.origin}/openapi.json`);
|
|
32033
|
+
if (!res.ok) return null;
|
|
32034
|
+
const doc = await res.json();
|
|
32035
|
+
const op = doc.paths?.[u.pathname]?.[method.toLowerCase()];
|
|
32036
|
+
return op?.requestBody?.content?.["application/json"]?.schema ?? null;
|
|
32037
|
+
} catch {
|
|
32038
|
+
return null;
|
|
32039
|
+
}
|
|
32040
|
+
}
|
|
32041
|
+
function describeSchemaFields(schema) {
|
|
32042
|
+
if (!schema || schema.type !== "object" || !schema.properties) return [];
|
|
32043
|
+
const required = new Set(schema.required ?? []);
|
|
32044
|
+
return Object.entries(schema.properties).map(([name, prop]) => {
|
|
32045
|
+
const type = prop.type ?? (prop.enum ? `enum(${prop.enum.join("|")})` : "any");
|
|
32046
|
+
const opt = required.has(name) ? "" : "?";
|
|
32047
|
+
const desc = prop.description ? ` \u2014 ${prop.description}` : "";
|
|
32048
|
+
return `${name}${opt}: ${type}${desc}`;
|
|
32049
|
+
});
|
|
32050
|
+
}
|
|
31774
32051
|
|
|
31775
32052
|
// src/commands/services/search.ts
|
|
31776
|
-
var
|
|
32053
|
+
var import_picocolors9 = __toESM(require_picocolors(), 1);
|
|
31777
32054
|
|
|
31778
32055
|
// src/commands/services/catalog.ts
|
|
31779
32056
|
var DEFAULT_GATEWAY_URL = "https://mpp.t2000.ai";
|
|
@@ -31875,9 +32152,9 @@ Examples:
|
|
|
31875
32152
|
}
|
|
31876
32153
|
function renderServiceLine(svc) {
|
|
31877
32154
|
const minPrice = cheapestEndpointPrice(svc);
|
|
31878
|
-
const priceTag = minPrice !== null ?
|
|
31879
|
-
const catTag = svc.categories.length > 0 ?
|
|
31880
|
-
printKeyValue(
|
|
32155
|
+
const priceTag = minPrice !== null ? import_picocolors9.default.green(`from $${minPrice}`) : import_picocolors9.default.dim("no pricing");
|
|
32156
|
+
const catTag = svc.categories.length > 0 ? import_picocolors9.default.dim(`[${svc.categories.join(", ")}]`) : "";
|
|
32157
|
+
printKeyValue(import_picocolors9.default.bold(svc.name), `${priceTag} ${catTag}`);
|
|
31881
32158
|
printKeyValue(" url", svc.serviceUrl);
|
|
31882
32159
|
printKeyValue(" about", svc.description);
|
|
31883
32160
|
printBlank();
|
|
@@ -31891,7 +32168,7 @@ function cheapestEndpointPrice(svc) {
|
|
|
31891
32168
|
}
|
|
31892
32169
|
|
|
31893
32170
|
// src/commands/services/inspect.ts
|
|
31894
|
-
var
|
|
32171
|
+
var import_picocolors10 = __toESM(require_picocolors(), 1);
|
|
31895
32172
|
function registerServicesInspect(parent) {
|
|
31896
32173
|
parent.command("inspect").description("Show pricing + endpoints for an MPP service or endpoint URL").argument("<url>", "Service base URL or endpoint URL").option("--gateway <url>", "Override gateway base URL (default: https://mpp.t2000.ai)").addHelpText(
|
|
31897
32174
|
"after",
|
|
@@ -31928,7 +32205,7 @@ Examples:
|
|
|
31928
32205
|
return;
|
|
31929
32206
|
}
|
|
31930
32207
|
printBlank();
|
|
31931
|
-
printKeyValue("Service",
|
|
32208
|
+
printKeyValue("Service", import_picocolors10.default.bold(service.name));
|
|
31932
32209
|
printKeyValue("URL", service.serviceUrl);
|
|
31933
32210
|
printKeyValue("About", service.description);
|
|
31934
32211
|
if (service.categories.length > 0) {
|
|
@@ -31958,7 +32235,7 @@ Examples:
|
|
|
31958
32235
|
function renderEndpoint(ep, serviceUrl) {
|
|
31959
32236
|
const price = `$${ep.price}`;
|
|
31960
32237
|
const label = `${ep.method} ${ep.path}`.padEnd(40);
|
|
31961
|
-
printKeyValue(label, `${
|
|
32238
|
+
printKeyValue(label, `${import_picocolors10.default.green(price)} ${import_picocolors10.default.dim(ep.description)}`);
|
|
31962
32239
|
printKeyValue(" url", `${serviceUrl}${ep.path}`);
|
|
31963
32240
|
printBlank();
|
|
31964
32241
|
}
|
|
@@ -31981,7 +32258,7 @@ T2000_GATEWAY_URL or --gateway <url> for local development.
|
|
|
31981
32258
|
}
|
|
31982
32259
|
|
|
31983
32260
|
// src/commands/limit/show.ts
|
|
31984
|
-
var
|
|
32261
|
+
var import_picocolors11 = __toESM(require_picocolors(), 1);
|
|
31985
32262
|
function registerLimitShow(parent) {
|
|
31986
32263
|
parent.command("show").description("Show current spending limits").action(async (opts) => {
|
|
31987
32264
|
try {
|
|
@@ -32004,10 +32281,10 @@ function registerLimitShow(parent) {
|
|
|
32004
32281
|
}
|
|
32005
32282
|
printBlank();
|
|
32006
32283
|
if (limits.perTxUsd !== void 0) {
|
|
32007
|
-
printKeyValue("Per-transaction",
|
|
32284
|
+
printKeyValue("Per-transaction", import_picocolors11.default.green(`$${limits.perTxUsd}`));
|
|
32008
32285
|
}
|
|
32009
32286
|
if (limits.dailyUsd !== void 0) {
|
|
32010
|
-
printKeyValue("Daily (cumulative)",
|
|
32287
|
+
printKeyValue("Daily (cumulative)", import_picocolors11.default.green(`$${limits.dailyUsd}`));
|
|
32011
32288
|
}
|
|
32012
32289
|
printBlank();
|
|
32013
32290
|
printInfo("Use `--force` on `t2 send` / `t2 swap` / `t2 pay` to override per-call.");
|
|
@@ -32019,7 +32296,7 @@ function registerLimitShow(parent) {
|
|
|
32019
32296
|
}
|
|
32020
32297
|
|
|
32021
32298
|
// src/commands/limit/set.ts
|
|
32022
|
-
var
|
|
32299
|
+
var import_picocolors12 = __toESM(require_picocolors(), 1);
|
|
32023
32300
|
function parseLimitSetArgs(opts) {
|
|
32024
32301
|
const perTx = opts.perTx !== void 0 ? parseUsdFlag("--per-tx", opts.perTx) : void 0;
|
|
32025
32302
|
const daily = opts.daily !== void 0 ? parseUsdFlag("--daily", opts.daily) : void 0;
|
|
@@ -32061,10 +32338,10 @@ Examples:
|
|
|
32061
32338
|
printBlank();
|
|
32062
32339
|
printSuccess("Spending limits updated.");
|
|
32063
32340
|
if (next?.perTxUsd !== void 0) {
|
|
32064
|
-
printKeyValue("Per-transaction",
|
|
32341
|
+
printKeyValue("Per-transaction", import_picocolors12.default.green(`$${next.perTxUsd}`));
|
|
32065
32342
|
}
|
|
32066
32343
|
if (next?.dailyUsd !== void 0) {
|
|
32067
|
-
printKeyValue("Daily (cumulative)",
|
|
32344
|
+
printKeyValue("Daily (cumulative)", import_picocolors12.default.green(`$${next.dailyUsd}`));
|
|
32068
32345
|
}
|
|
32069
32346
|
printBlank();
|
|
32070
32347
|
printInfo("Use `t2 limit show` to view; `t2 limit reset` to clear.");
|
|
@@ -32106,7 +32383,7 @@ function registerLimitReset(parent) {
|
|
|
32106
32383
|
|
|
32107
32384
|
// src/commands/limit/index.ts
|
|
32108
32385
|
function registerLimit(program3) {
|
|
32109
|
-
const group = program3.command("limit").description("Manage
|
|
32386
|
+
const group = program3.command("limit").description("Manage spending limits (on by default: $25/tx, $100/day)").addHelpText(
|
|
32110
32387
|
"after",
|
|
32111
32388
|
`
|
|
32112
32389
|
Subcommands:
|
|
@@ -32126,7 +32403,7 @@ function registerMcpStart(parent) {
|
|
|
32126
32403
|
parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
32127
32404
|
let mod2;
|
|
32128
32405
|
try {
|
|
32129
|
-
mod2 = await import("./dist-
|
|
32406
|
+
mod2 = await import("./dist-4JZ33TE5.js");
|
|
32130
32407
|
} catch {
|
|
32131
32408
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
32132
32409
|
process.exit(1);
|
|
@@ -32135,70 +32412,6 @@ function registerMcpStart(parent) {
|
|
|
32135
32412
|
});
|
|
32136
32413
|
}
|
|
32137
32414
|
|
|
32138
|
-
// src/commands/mcp/platforms.ts
|
|
32139
|
-
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
32140
|
-
import { join as join3, dirname as dirname2 } from "path";
|
|
32141
|
-
import { homedir as homedir2 } from "os";
|
|
32142
|
-
import { existsSync as existsSync2 } from "fs";
|
|
32143
|
-
var MCP_SERVER_ENTRY = {
|
|
32144
|
-
command: "t2000",
|
|
32145
|
-
args: ["mcp", "start"]
|
|
32146
|
-
};
|
|
32147
|
-
var MCP_SERVER_KEY = "t2000";
|
|
32148
|
-
function getPlatformConfigs() {
|
|
32149
|
-
const home = homedir2();
|
|
32150
|
-
return [
|
|
32151
|
-
{
|
|
32152
|
-
name: "Claude Desktop",
|
|
32153
|
-
slug: "claude-desktop",
|
|
32154
|
-
path: join3(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
|
|
32155
|
-
},
|
|
32156
|
-
{
|
|
32157
|
-
name: "Cursor",
|
|
32158
|
-
slug: "cursor",
|
|
32159
|
-
path: join3(home, ".cursor", "mcp.json")
|
|
32160
|
-
},
|
|
32161
|
-
{
|
|
32162
|
-
name: "Windsurf",
|
|
32163
|
-
slug: "windsurf",
|
|
32164
|
-
path: join3(home, ".codeium", "windsurf", "mcp_config.json")
|
|
32165
|
-
}
|
|
32166
|
-
];
|
|
32167
|
-
}
|
|
32168
|
-
async function readJsonFile(path2) {
|
|
32169
|
-
try {
|
|
32170
|
-
const content = await readFile2(path2, "utf-8");
|
|
32171
|
-
return JSON.parse(content);
|
|
32172
|
-
} catch {
|
|
32173
|
-
return {};
|
|
32174
|
-
}
|
|
32175
|
-
}
|
|
32176
|
-
async function writeJsonFile(path2, data) {
|
|
32177
|
-
const dir = dirname2(path2);
|
|
32178
|
-
if (!existsSync2(dir)) {
|
|
32179
|
-
await mkdir2(dir, { recursive: true });
|
|
32180
|
-
}
|
|
32181
|
-
await writeFile2(path2, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
32182
|
-
}
|
|
32183
|
-
function withMcpEntry(config) {
|
|
32184
|
-
return {
|
|
32185
|
-
...config,
|
|
32186
|
-
mcpServers: {
|
|
32187
|
-
...config.mcpServers ?? {},
|
|
32188
|
-
[MCP_SERVER_KEY]: { ...MCP_SERVER_ENTRY }
|
|
32189
|
-
}
|
|
32190
|
-
};
|
|
32191
|
-
}
|
|
32192
|
-
function hasMcpEntry(config) {
|
|
32193
|
-
return typeof config.mcpServers === "object" && config.mcpServers !== null && MCP_SERVER_KEY in config.mcpServers;
|
|
32194
|
-
}
|
|
32195
|
-
function withoutMcpEntry(config) {
|
|
32196
|
-
if (!hasMcpEntry(config)) return config;
|
|
32197
|
-
const servers = { ...config.mcpServers };
|
|
32198
|
-
delete servers[MCP_SERVER_KEY];
|
|
32199
|
-
return { ...config, mcpServers: servers };
|
|
32200
|
-
}
|
|
32201
|
-
|
|
32202
32415
|
// src/commands/mcp/install.ts
|
|
32203
32416
|
async function runInstall() {
|
|
32204
32417
|
const platforms = getPlatformConfigs();
|
|
@@ -32530,31 +32743,33 @@ For MCP-aware clients (Claude Desktop, Cursor, Windsurf), prefer
|
|
|
32530
32743
|
}
|
|
32531
32744
|
|
|
32532
32745
|
// src/program.ts
|
|
32533
|
-
var
|
|
32534
|
-
var { version:
|
|
32746
|
+
var require3 = createRequire2(import.meta.url);
|
|
32747
|
+
var { version: CLI_VERSION2 } = require3("../package.json");
|
|
32535
32748
|
function createProgram() {
|
|
32536
32749
|
const program3 = new Command();
|
|
32537
|
-
program3.name("t2").description("Agent Wallet \u2014 autonomous Sui USDC + USDsui wallet for AI agents").version(`${
|
|
32750
|
+
program3.name("t2").description("Agent Wallet \u2014 autonomous Sui USDC + USDsui wallet for AI agents").version(`${CLI_VERSION2}`).option("--json", "Output in JSON format").hook("preAction", (thisCommand) => {
|
|
32538
32751
|
const opts = thisCommand.optsWithGlobals();
|
|
32539
32752
|
if (opts.json) setJsonMode(true);
|
|
32540
32753
|
}).addHelpText("after", `
|
|
32541
32754
|
Examples:
|
|
32542
32755
|
$ t2 init Create a new Agent Wallet
|
|
32543
32756
|
$ t2 init --import Import an existing Bech32 secret (interactive)
|
|
32544
|
-
$ t2
|
|
32757
|
+
$ t2 fund Show address + QR to fund the wallet
|
|
32758
|
+
$ t2 status Health check: wallet, balances, limits, MCP, gateway
|
|
32545
32759
|
$ t2 balance Show USDC / USDsui / SUI holdings
|
|
32546
32760
|
$ t2 send 5 USDC alice.sui Send 5 USDC (gasless; asset required)
|
|
32547
32761
|
$ t2 swap 100 USDC SUI Swap 100 USDC for SUI via Cetus
|
|
32548
|
-
$ t2 pay <
|
|
32549
|
-
$ t2 services search "image" Discover
|
|
32550
|
-
$ t2 limit set --daily 100
|
|
32762
|
+
$ t2 pay <url> --estimate Preview an x402 service's price + input schema (no payment)
|
|
32763
|
+
$ t2 services search "image" Discover x402 services in the gateway catalog
|
|
32764
|
+
$ t2 limit set --daily 100 Change the daily spend cap (default $100/day)
|
|
32551
32765
|
$ t2 mcp install Connect Claude / Cursor / Windsurf
|
|
32552
32766
|
$ t2 skills install Install skills as local SKILL.md files`);
|
|
32553
32767
|
registerInit(program3);
|
|
32554
32768
|
registerExport(program3);
|
|
32555
|
-
|
|
32769
|
+
registerFund(program3);
|
|
32556
32770
|
registerBalance(program3);
|
|
32557
32771
|
registerHistory(program3);
|
|
32772
|
+
registerStatus(program3);
|
|
32558
32773
|
registerSend(program3);
|
|
32559
32774
|
registerSwap(program3);
|
|
32560
32775
|
registerPay(program3);
|