@clawcard/cli 3.0.23 → 3.1.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/package.json +1 -1
- package/src/agent-api.js +6 -0
- package/src/commands/agent.js +106 -54
- package/src/splash.js +1 -1
package/package.json
CHANGED
package/src/agent-api.js
CHANGED
|
@@ -136,6 +136,12 @@ export const walletFund = (agentId, amount) =>
|
|
|
136
136
|
body: JSON.stringify({ amount }),
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
+
export const walletBridge = (agentId, amount) =>
|
|
140
|
+
agentRequest(`/api/agents/${agentId}/wallet/bridge`, {
|
|
141
|
+
method: "POST",
|
|
142
|
+
body: JSON.stringify({ amount }),
|
|
143
|
+
});
|
|
144
|
+
|
|
139
145
|
export const walletSend = (agentId, data) =>
|
|
140
146
|
agentRequest(`/api/agents/${agentId}/wallet/send`, {
|
|
141
147
|
method: "POST",
|
package/src/commands/agent.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
createWallet as createWalletApi,
|
|
20
20
|
walletAction,
|
|
21
21
|
walletFund,
|
|
22
|
+
walletBridge,
|
|
22
23
|
walletSend,
|
|
23
24
|
walletTransactions as walletTransactionsApi,
|
|
24
25
|
discoverServices,
|
|
@@ -73,6 +74,9 @@ export async function agentInfoCmd(options) {
|
|
|
73
74
|
if (wallet.balanceEth) {
|
|
74
75
|
console.log(` ETH: ${chalk.dim(wallet.balanceEth + " ETH (gas)")}`);
|
|
75
76
|
}
|
|
77
|
+
if (wallet.balancePathUsd && parseFloat(wallet.balancePathUsd) > 0) {
|
|
78
|
+
console.log(` pathUSD: ${chalk.green(wallet.balancePathUsd + " pathUSD (MPP)")}`);
|
|
79
|
+
}
|
|
76
80
|
} else {
|
|
77
81
|
console.log(` Wallet: ${chalk.dim("none — run: clawcard agent wallet")}`);
|
|
78
82
|
}
|
|
@@ -428,9 +432,11 @@ export async function agentWalletCmd(options) {
|
|
|
428
432
|
|
|
429
433
|
console.log();
|
|
430
434
|
console.log(` Address: ${orange(wallet.address)}`);
|
|
431
|
-
console.log(`
|
|
432
|
-
console.log(`
|
|
435
|
+
console.log(` ${chalk.dim("https://basescan.org/address/" + wallet.address)}`);
|
|
436
|
+
console.log(` Network: Base + Tempo`);
|
|
437
|
+
console.log(` USDC: ${chalk.green(wallet.balanceUsdc + " USDC")} ${chalk.dim("(x402)")}`);
|
|
433
438
|
console.log(` ETH: ${chalk.dim((wallet.balanceEth || "0.000000") + " ETH (gas)")}`);
|
|
439
|
+
console.log(` pathUSD: ${chalk.green((wallet.balancePathUsd || "0.000000") + " pathUSD")} ${chalk.dim("(MPP)")}`);
|
|
434
440
|
console.log(` Status: ${wallet.status}`);
|
|
435
441
|
console.log();
|
|
436
442
|
console.log(chalk.dim(` Docs: https://clawcard.sh/docs#wallet`));
|
|
@@ -467,8 +473,9 @@ export async function agentWalletCmd(options) {
|
|
|
467
473
|
console.log();
|
|
468
474
|
console.log(` Address: ${orange(wallet.address)}`);
|
|
469
475
|
console.log(` Network: Base`);
|
|
470
|
-
console.log(` USDC: ${wallet.balanceUsdc} USDC`);
|
|
476
|
+
console.log(` USDC: ${wallet.balanceUsdc} USDC (x402)`);
|
|
471
477
|
console.log(` ETH: ${wallet.balanceEth || "0.000000"} ETH (gas)`);
|
|
478
|
+
console.log(` pathUSD: ${wallet.balancePathUsd || "0.000000"} pathUSD (MPP)`);
|
|
472
479
|
console.log(` Status: ${wallet.status}`);
|
|
473
480
|
console.log();
|
|
474
481
|
console.log(chalk.dim(" Fund via FIAT balance or send USDC directly to the address above."));
|
|
@@ -490,11 +497,14 @@ export async function agentWalletBalanceCmd(options) {
|
|
|
490
497
|
|
|
491
498
|
if (options.json) return output({ ...wallet, fiatBudgetCents: budget.budgetCents, effectiveUsdc: effective.toFixed(2) }, true);
|
|
492
499
|
|
|
500
|
+
const pathUsd = parseFloat(wallet.balancePathUsd || "0");
|
|
501
|
+
|
|
493
502
|
console.log();
|
|
494
|
-
console.log(` USDC Balance:
|
|
495
|
-
console.log(` ETH (gas):
|
|
496
|
-
console.log(`
|
|
497
|
-
console.log(`
|
|
503
|
+
console.log(` USDC Balance: ${chalk.green(wallet.balanceUsdc + " USDC")} ${chalk.dim("(x402)")}`);
|
|
504
|
+
console.log(` ETH (gas): ${chalk.dim((wallet.balanceEth || "0.000000") + " ETH")}`);
|
|
505
|
+
console.log(` pathUSD (MPP): ${chalk.green((wallet.balancePathUsd || "0.000000") + " pathUSD")}`);
|
|
506
|
+
console.log(` FIAT Budget: ${chalk.green("$" + fiatBudget.toFixed(2))} ${chalk.dim("(for cards)")}`);
|
|
507
|
+
console.log(` Effective: ${chalk.green("~$" + (usdcBalance + fiatBudget + pathUsd).toFixed(2))} ${chalk.dim("total spending power")}`);
|
|
498
508
|
console.log();
|
|
499
509
|
} catch (err) {
|
|
500
510
|
if (options.json) return output({ error: err.message }, true);
|
|
@@ -634,31 +644,47 @@ export async function agentWalletFundCmd(options) {
|
|
|
634
644
|
const prompts = await import("@clack/prompts");
|
|
635
645
|
const agentId = await getAgentId();
|
|
636
646
|
|
|
647
|
+
// Show current balances
|
|
648
|
+
let wallet = null;
|
|
649
|
+
try {
|
|
650
|
+
wallet = await getWallet(agentId);
|
|
651
|
+
} catch {}
|
|
652
|
+
|
|
637
653
|
console.log();
|
|
638
654
|
console.log(` ${orange.bold("Fund Your Agent's Wallet")}`);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
655
|
+
if (wallet) {
|
|
656
|
+
console.log();
|
|
657
|
+
console.log(` ${chalk.dim("Wallet:")} ${wallet.address}`);
|
|
658
|
+
console.log(` ${chalk.dim(" https://basescan.org/address/" + wallet.address)}`);
|
|
659
|
+
console.log();
|
|
660
|
+
const ethOk = parseFloat(wallet.balanceEth || "0") > 0;
|
|
661
|
+
const usdcOk = parseFloat(wallet.balanceUsdc || "0") > 0;
|
|
662
|
+
const pathOk = parseFloat(wallet.balancePathUsd || "0") > 0;
|
|
663
|
+
console.log(` ${ethOk ? chalk.green("✓") : chalk.red("✗")} ETH: ${wallet.balanceEth || "0.000000"} ${chalk.dim("(gas)")}`);
|
|
664
|
+
console.log(` ${usdcOk ? chalk.green("✓") : chalk.red("✗")} USDC: ${wallet.balanceUsdc || "0.000000"} ${chalk.dim("(x402)")}`);
|
|
665
|
+
console.log(` ${pathOk ? chalk.green("✓") : chalk.red("✗")} pathUSD: ${wallet.balancePathUsd || "0.000000"} ${chalk.dim("(MPP)")}`);
|
|
666
|
+
}
|
|
643
667
|
console.log();
|
|
644
668
|
|
|
645
|
-
// Step 1: What to
|
|
669
|
+
// Step 1: What to fund
|
|
646
670
|
const asset = await prompts.select({
|
|
647
|
-
message: "What would you like to
|
|
671
|
+
message: "What would you like to fund?",
|
|
648
672
|
options: [
|
|
649
|
-
{ value: "eth", label: "
|
|
650
|
-
{ value: "usdc", label: "
|
|
673
|
+
{ value: "eth", label: "Gas fees (ETH)" },
|
|
674
|
+
{ value: "usdc", label: "x402 services (USDC)" },
|
|
675
|
+
{ value: "pathusd", label: "MPP services (pathUSD)" },
|
|
651
676
|
],
|
|
652
677
|
});
|
|
653
678
|
|
|
654
679
|
if (prompts.isCancel(asset)) return;
|
|
655
680
|
|
|
656
681
|
// Step 2: Amount
|
|
657
|
-
const
|
|
682
|
+
const defaults = { eth: "2", usdc: "10", pathusd: "5" };
|
|
683
|
+
const labels = { eth: "ETH", usdc: "USDC", pathusd: "pathUSD" };
|
|
658
684
|
const amountInput = await prompts.text({
|
|
659
|
-
message: `How much $ of ${asset
|
|
660
|
-
placeholder:
|
|
661
|
-
defaultValue:
|
|
685
|
+
message: `How much $ of ${labels[asset]}?`,
|
|
686
|
+
placeholder: defaults[asset],
|
|
687
|
+
defaultValue: defaults[asset],
|
|
662
688
|
validate: (v) => {
|
|
663
689
|
const n = parseFloat(v);
|
|
664
690
|
if (isNaN(n) || n < 1) return "Minimum is $1.00";
|
|
@@ -669,50 +695,76 @@ export async function agentWalletFundCmd(options) {
|
|
|
669
695
|
|
|
670
696
|
const amount = parseFloat(amountInput);
|
|
671
697
|
|
|
672
|
-
// Step 3:
|
|
673
|
-
|
|
674
|
-
|
|
698
|
+
// Step 3: Execute
|
|
699
|
+
if (asset === "pathusd") {
|
|
700
|
+
// Bridge from USDC → pathUSD on Tempo
|
|
701
|
+
console.log();
|
|
702
|
+
console.log(chalk.dim(` This will convert ${amount.toFixed(2)} USDC from your balance to pathUSD.`));
|
|
703
|
+
console.log();
|
|
675
704
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
s.stop("");
|
|
705
|
+
const s = prompts.spinner();
|
|
706
|
+
s.start("Bridging USDC → pathUSD on Tempo...");
|
|
679
707
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
708
|
+
try {
|
|
709
|
+
const result = await walletBridge(agentId, String(amount));
|
|
684
710
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
711
|
+
if (!result.success && result.error) {
|
|
712
|
+
s.stop("Bridge failed");
|
|
713
|
+
console.log(` Error: ${result.error}`);
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
690
716
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
717
|
+
s.stop(chalk.green("Bridge complete!"));
|
|
718
|
+
console.log();
|
|
719
|
+
console.log(` ${chalk.green("✓")} ${result.amountBridged || amount.toFixed(2)} pathUSD added for MPP payments`);
|
|
720
|
+
if (result.txHash) {
|
|
721
|
+
console.log(` TX: ${chalk.dim("https://basescan.org/tx/" + result.txHash)}`);
|
|
722
|
+
}
|
|
723
|
+
console.log();
|
|
724
|
+
console.log(` ${orange("Verify:")} ${chalk.dim("$ clawcard agent wallet balance --json")}`);
|
|
725
|
+
console.log();
|
|
726
|
+
} catch (err) {
|
|
727
|
+
s.stop("Failed");
|
|
728
|
+
console.log(` Error: ${err.message}`);
|
|
729
|
+
}
|
|
730
|
+
} else {
|
|
731
|
+
// ETH or USDC — open Coinbase Onramp
|
|
732
|
+
const s = prompts.spinner();
|
|
733
|
+
s.start("Preparing Coinbase checkout...");
|
|
696
734
|
|
|
697
735
|
try {
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
} catch {}
|
|
736
|
+
const result = await walletFund(agentId, String(amount));
|
|
737
|
+
s.stop("");
|
|
701
738
|
|
|
702
|
-
|
|
703
|
-
|
|
739
|
+
if (!result.success) {
|
|
740
|
+
console.log(` Error: ${result.error}`);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
704
743
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
console.log(
|
|
744
|
+
let url = result.url;
|
|
745
|
+
if (asset === "eth") {
|
|
746
|
+
url = url.replace("defaultAsset=USDC", "defaultAsset=ETH");
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
console.log();
|
|
750
|
+
console.log(` ${chalk.green("Opening Coinbase...")} Buy $${amount.toFixed(2)} of ${labels[asset]}`);
|
|
751
|
+
console.log();
|
|
752
|
+
console.log(` ${orange(url)}`);
|
|
753
|
+
console.log();
|
|
754
|
+
|
|
755
|
+
try {
|
|
756
|
+
const { default: open } = await import("open");
|
|
757
|
+
await open(url);
|
|
758
|
+
} catch {}
|
|
759
|
+
|
|
760
|
+
console.log(chalk.dim(` After purchasing, wait ~30 seconds for it to arrive.`));
|
|
761
|
+
console.log();
|
|
762
|
+
console.log(` ${orange("Verify:")} ${chalk.dim("$ clawcard agent wallet balance --json")}`);
|
|
763
|
+
console.log();
|
|
764
|
+
} catch (err) {
|
|
765
|
+
s.stop("Failed");
|
|
766
|
+
console.log(` Error: ${err.message}`);
|
|
711
767
|
}
|
|
712
|
-
console.log();
|
|
713
|
-
} catch (err) {
|
|
714
|
-
s.stop("Failed");
|
|
715
|
-
console.log(` Error: ${err.message}`);
|
|
716
768
|
}
|
|
717
769
|
}
|
|
718
770
|
|
package/src/splash.js
CHANGED
|
@@ -73,7 +73,7 @@ export function showSplash() {
|
|
|
73
73
|
console.log();
|
|
74
74
|
console.log(` 🦞 ${o.bold("clawcard.sh")} ${d("v" + VERSION)}`);
|
|
75
75
|
console.log(
|
|
76
|
-
` ${o("
|
|
76
|
+
` ${o("the complete identity for AI agents")}`
|
|
77
77
|
);
|
|
78
78
|
console.log();
|
|
79
79
|
}
|