@t2000/cli 0.22.5 → 0.22.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/README.md CHANGED
@@ -308,7 +308,7 @@ t2000 mcp uninstall
308
308
  t2000 mcp
309
309
  ```
310
310
 
311
- 33 tools, 20 prompts, safeguard enforced. See [MCP setup guide](../../docs/mcp-setup.md) for details.
311
+ 35 tools, 20 prompts, safeguard enforced. See [MCP setup guide](../../docs/mcp-setup.md) for details.
312
312
 
313
313
  ### HTTP API Server
314
314
 
package/dist/index.js CHANGED
@@ -503,8 +503,6 @@ var ACTION_LABELS = {
503
503
  send: "\u2197 send",
504
504
  lending: "\u{1F3E6} lend",
505
505
  swap: "\u{1F504} swap",
506
- "mpp payment": "\u{1F4B3} mpp",
507
- split: "\u2702 split",
508
506
  transaction: "\u{1F4E6} tx"
509
507
  };
510
508
  function relativeTime(ts) {
@@ -518,11 +516,53 @@ function relativeTime(ts) {
518
516
  if (days < 7) return `${days}d ago`;
519
517
  return new Date(ts).toLocaleDateString();
520
518
  }
519
+ function formatAmount(tx) {
520
+ if (!tx.amount) return "";
521
+ return pc4.bold(`${tx.amount.toFixed(tx.amount < 0.01 ? 4 : 2)} ${tx.asset ?? ""}`);
522
+ }
523
+ function printTxSummary(tx) {
524
+ const label = ACTION_LABELS[tx.action] ?? `\u{1F4E6} ${tx.action}`;
525
+ const time = tx.timestamp ? relativeTime(tx.timestamp) : "";
526
+ const amount = formatAmount(tx);
527
+ const recipient = tx.recipient ? pc4.dim(`\u2192 ${truncateAddress2(tx.recipient)}`) : "";
528
+ const link = pc4.dim(explorerUrl(tx.digest));
529
+ printLine(`${label} ${amount} ${recipient}`);
530
+ printLine(` ${pc4.dim(truncateAddress2(tx.digest))} ${pc4.dim(time)}`);
531
+ printLine(` ${link}`);
532
+ }
533
+ function printTxDetail(tx) {
534
+ printHeader("Transaction Detail");
535
+ const label = ACTION_LABELS[tx.action] ?? `\u{1F4E6} ${tx.action}`;
536
+ printKeyValue("Type", label);
537
+ printKeyValue("Digest", tx.digest);
538
+ if (tx.amount) printKeyValue("Amount", `${tx.amount.toFixed(tx.amount < 0.01 ? 6 : 4)} ${tx.asset ?? ""}`);
539
+ if (tx.recipient) printKeyValue("Recipient", tx.recipient);
540
+ if (tx.timestamp) {
541
+ printKeyValue("Time", `${new Date(tx.timestamp).toLocaleString()} (${relativeTime(tx.timestamp)})`);
542
+ }
543
+ if (tx.gasCost !== void 0) printKeyValue("Gas", `${tx.gasCost.toFixed(6)} SUI`);
544
+ printBlank();
545
+ printKeyValue("Explorer", explorerUrl(tx.digest));
546
+ printBlank();
547
+ }
521
548
  function registerHistory(program2) {
522
- program2.command("history").description("Show transaction history").option("--limit <n>", "Number of transactions", "20").option("--key <path>", "Key file path").action(async (opts) => {
549
+ program2.command("history").description("Show transaction history, or detail for a specific digest").argument("[digest]", "Transaction digest to view details").option("--limit <n>", "Number of transactions", "20").option("--key <path>", "Key file path").action(async (digest, opts) => {
523
550
  try {
524
551
  const pin = await resolvePin();
525
552
  const agent = await T20006.create({ pin, keyPath: opts.key });
553
+ if (digest) {
554
+ const tx = await agent.transactionDetail(digest);
555
+ if (!tx) {
556
+ handleError(new Error(`Transaction not found: ${digest}`));
557
+ return;
558
+ }
559
+ if (isJsonMode()) {
560
+ printJson(tx);
561
+ return;
562
+ }
563
+ printTxDetail(tx);
564
+ return;
565
+ }
526
566
  const txns = await agent.history({ limit: parseInt(opts.limit, 10) });
527
567
  if (isJsonMode()) {
528
568
  printJson(txns);
@@ -533,14 +573,7 @@ function registerHistory(program2) {
533
573
  printInfo("No transactions yet.");
534
574
  } else {
535
575
  for (const tx of txns) {
536
- const label = ACTION_LABELS[tx.action] ?? `\u{1F4E6} ${tx.action}`;
537
- const time = tx.timestamp ? relativeTime(tx.timestamp) : "";
538
- const amount = tx.amount ? pc4.bold(`${tx.amount.toFixed(tx.amount < 0.01 ? 4 : 2)} ${tx.asset ?? ""}`) : "";
539
- const recipient = tx.recipient ? pc4.dim(`\u2192 ${truncateAddress2(tx.recipient)}`) : "";
540
- const link = pc4.dim(explorerUrl(tx.digest));
541
- printLine(`${label} ${amount} ${recipient}`);
542
- printLine(` ${pc4.dim(truncateAddress2(tx.digest))} ${pc4.dim(time)}`);
543
- printLine(` ${link}`);
576
+ printTxSummary(tx);
544
577
  printBlank();
545
578
  }
546
579
  }
@@ -1572,7 +1605,7 @@ function registerLock(program2) {
1572
1605
  });
1573
1606
  program2.command("unlock").description("Unlock agent \u2014 resume operations").action(async () => {
1574
1607
  try {
1575
- const { T2000: T200027 } = await import("@t2000/sdk");
1608
+ const { T2000: T200028 } = await import("@t2000/sdk");
1576
1609
  const MAX_ATTEMPTS2 = 3;
1577
1610
  let pin;
1578
1611
  for (let attempt = 1; attempt <= MAX_ATTEMPTS2; attempt++) {
@@ -1581,7 +1614,7 @@ function registerLock(program2) {
1581
1614
  throw new Error("PIN required to unlock agent");
1582
1615
  }
1583
1616
  try {
1584
- await T200027.create({ pin });
1617
+ await T200028.create({ pin });
1585
1618
  break;
1586
1619
  } catch (error) {
1587
1620
  const msg = error instanceof Error ? error.message : "";
@@ -2921,6 +2954,69 @@ function registerClaimRewards(program2) {
2921
2954
  });
2922
2955
  }
2923
2956
 
2957
+ // src/commands/gas.ts
2958
+ import pc17 from "picocolors";
2959
+ import { T2000 as T200027, getGasStatus } from "@t2000/sdk";
2960
+ function registerGas(program2) {
2961
+ program2.command("gas").description("Check gas station status and wallet gas balance").option("--key <path>", "Key file path").action(async (opts) => {
2962
+ try {
2963
+ const pin = await resolvePin();
2964
+ const agent = await T200027.create({ pin, keyPath: opts.key });
2965
+ const address = agent.address();
2966
+ const [status, bal] = await Promise.allSettled([
2967
+ getGasStatus(address),
2968
+ agent.balance()
2969
+ ]);
2970
+ const gasStatus = status.status === "fulfilled" ? status.value : null;
2971
+ const balData = bal.status === "fulfilled" ? bal.value : null;
2972
+ if (isJsonMode()) {
2973
+ printJson({
2974
+ gasStation: gasStatus ?? { error: status.status === "rejected" ? String(status.reason) : "unavailable" },
2975
+ wallet: balData ? { sui: balData.gasReserve.sui, available: balData.available } : null
2976
+ });
2977
+ return;
2978
+ }
2979
+ printHeader("Gas Status");
2980
+ if (gasStatus) {
2981
+ const cbStatus = gasStatus.circuitBreaker ? pc17.red("TRIPPED \u2014 sponsorship paused") : pc17.green("OK");
2982
+ printKeyValue("Gas Station", cbStatus);
2983
+ printKeyValue("SUI Price (TWAP)", `$${gasStatus.suiPrice.toFixed(4)}`);
2984
+ if (gasStatus.bootstrapRemaining !== void 0) {
2985
+ printKeyValue("Bootstrap", `${gasStatus.bootstrapUsed}/10 used (${gasStatus.bootstrapRemaining} remaining)`);
2986
+ }
2987
+ } else {
2988
+ printKeyValue("Gas Station", pc17.red("unreachable"));
2989
+ const reason = status.status === "rejected" ? status.reason : "unknown";
2990
+ printLine(` ${pc17.dim(reason instanceof Error ? reason.message : String(reason))}`);
2991
+ }
2992
+ printDivider();
2993
+ if (balData) {
2994
+ const suiBal = balData.gasReserve.sui;
2995
+ const suiColor = suiBal < 0.05 ? pc17.red : pc17.green;
2996
+ printKeyValue("SUI (gas)", suiColor(`${suiBal.toFixed(4)} SUI`));
2997
+ if (suiBal < 0.05) {
2998
+ printLine(` ${pc17.yellow("\u26A0")} Below gas threshold (0.05 SUI) \u2014 transactions will need sponsorship`);
2999
+ }
3000
+ printKeyValue("Available", `$${balData.available.toFixed(2)}`);
3001
+ } else {
3002
+ printKeyValue("Wallet", pc17.dim("could not fetch balances"));
3003
+ }
3004
+ printBlank();
3005
+ if (gasStatus && !gasStatus.circuitBreaker && (balData?.gasReserve.sui ?? 0) >= 0.05) {
3006
+ printLine(` ${pc17.green("\u2713")} Gas is healthy \u2014 transactions should succeed`);
3007
+ } else if (gasStatus && !gasStatus.circuitBreaker) {
3008
+ printLine(` ${pc17.yellow("\u26A0")} Low SUI but gas station is online \u2014 sponsorship available`);
3009
+ } else {
3010
+ printLine(` ${pc17.red("\u2717")} Gas station issues detected \u2014 fund wallet with SUI directly`);
3011
+ printInfo("Send SUI to your address: t2000 address");
3012
+ }
3013
+ printBlank();
3014
+ } catch (error) {
3015
+ handleError(error);
3016
+ }
3017
+ });
3018
+ }
3019
+
2924
3020
  // src/program.ts
2925
3021
  var require2 = createRequire(import.meta.url);
2926
3022
  var { version: CLI_VERSION } = require2("../package.json");
@@ -2960,6 +3056,7 @@ function createProgram() {
2960
3056
  registerInvest(program2);
2961
3057
  registerPortfolio(program2);
2962
3058
  registerClaimRewards(program2);
3059
+ registerGas(program2);
2963
3060
  return program2;
2964
3061
  }
2965
3062