@agentis-hq/cli 0.1.6 → 0.2.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 -0
- package/dist/index.js +113 -30
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -489,6 +489,13 @@ Sent!`);
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
// src/lib/format-agent.ts
|
|
492
|
+
var blue = "\x1B[38;5;117m";
|
|
493
|
+
var purple = "\x1B[38;5;141m";
|
|
494
|
+
var green = "\x1B[38;5;114m";
|
|
495
|
+
var amber = "\x1B[38;5;179m";
|
|
496
|
+
var red = "\x1B[38;5;203m";
|
|
497
|
+
var muted = "\x1B[38;5;244m";
|
|
498
|
+
var reset = "\x1B[0m";
|
|
492
499
|
function formatPolicy(agent) {
|
|
493
500
|
const mode = agent.policyMode ?? "backend";
|
|
494
501
|
if (mode !== "onchain") return "policy=backend";
|
|
@@ -501,19 +508,71 @@ function formatPrivacy(agent) {
|
|
|
501
508
|
function formatLocalPolicy(wallet) {
|
|
502
509
|
return wallet.policy.killSwitch ? "policy=local:killed" : "policy=local";
|
|
503
510
|
}
|
|
511
|
+
function shorten(value, prefix = 6, suffix = 5) {
|
|
512
|
+
if (value.length <= prefix + suffix + 3) return value;
|
|
513
|
+
return `${value.slice(0, prefix)}...${value.slice(-suffix)}`;
|
|
514
|
+
}
|
|
515
|
+
function color(value, ansi) {
|
|
516
|
+
return `${ansi}${value}${reset}`;
|
|
517
|
+
}
|
|
518
|
+
function colorPolicy(policy) {
|
|
519
|
+
if (policy === "policy=onchain:ready") return color(policy, purple);
|
|
520
|
+
if (policy === "policy=onchain:pending") return color(policy, amber);
|
|
521
|
+
if (policy === "policy=local:killed") return color(policy, red);
|
|
522
|
+
return color(policy, muted);
|
|
523
|
+
}
|
|
524
|
+
function colorPrivacy(privacy) {
|
|
525
|
+
if (!privacy) return null;
|
|
526
|
+
if (privacy === "privacy=registered") return color(privacy, green);
|
|
527
|
+
if (privacy === "privacy=pending") return color(privacy, amber);
|
|
528
|
+
if (privacy === "privacy=failed") return color(privacy, red);
|
|
529
|
+
return color(privacy, muted);
|
|
530
|
+
}
|
|
504
531
|
function formatBadges(parts) {
|
|
505
|
-
return parts.filter(Boolean).join("
|
|
532
|
+
return parts.filter(Boolean).join(" ");
|
|
533
|
+
}
|
|
534
|
+
function formatName(name) {
|
|
535
|
+
return color(shorten(name, 17, 4).padEnd(24), blue);
|
|
506
536
|
}
|
|
507
537
|
function formatHostedAgentLine(agent) {
|
|
508
|
-
const badges = formatBadges([
|
|
509
|
-
|
|
538
|
+
const badges = formatBadges([
|
|
539
|
+
colorPolicy(formatPolicy(agent)),
|
|
540
|
+
colorPrivacy(formatPrivacy(agent))
|
|
541
|
+
]);
|
|
542
|
+
return ` ${formatName(agent.name)} ${shorten(agent.walletAddress)} ${badges}`;
|
|
510
543
|
}
|
|
511
544
|
function formatLocalWalletLine(wallet) {
|
|
512
|
-
|
|
513
|
-
return ` ${wallet.name.padEnd(20)} ${wallet.solanaAddress} [${wallet.id}] ${badges}`;
|
|
545
|
+
return ` ${formatName(wallet.name)} ${shorten(wallet.solanaAddress)} ${colorPolicy(formatLocalPolicy(wallet))}`;
|
|
514
546
|
}
|
|
515
547
|
|
|
516
548
|
// src/commands/wallet.ts
|
|
549
|
+
function toHostedWallet(agent) {
|
|
550
|
+
return {
|
|
551
|
+
id: agent.id,
|
|
552
|
+
name: agent.name,
|
|
553
|
+
walletAddress: agent.walletAddress,
|
|
554
|
+
type: "hosted",
|
|
555
|
+
policyMode: agent.policyMode ?? "backend",
|
|
556
|
+
onchainPolicy: agent.onchainPolicy ? {
|
|
557
|
+
initialized: Boolean(agent.onchainPolicy.initialized),
|
|
558
|
+
programId: agent.onchainPolicy.programId
|
|
559
|
+
} : void 0,
|
|
560
|
+
privacyEnabled: Boolean(agent.privacyEnabled),
|
|
561
|
+
umbraStatus: agent.umbraStatus ?? "disabled",
|
|
562
|
+
umbraRegisteredAt: agent.umbraRegisteredAt
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function toLocalWallet(wallet) {
|
|
566
|
+
return {
|
|
567
|
+
id: wallet.id,
|
|
568
|
+
name: wallet.name,
|
|
569
|
+
walletAddress: wallet.solanaAddress,
|
|
570
|
+
solanaAddress: wallet.solanaAddress,
|
|
571
|
+
type: "local",
|
|
572
|
+
createdAt: wallet.createdAt,
|
|
573
|
+
policy: wallet.policy
|
|
574
|
+
};
|
|
575
|
+
}
|
|
517
576
|
async function walletCreate(args2) {
|
|
518
577
|
const nameIdx = args2.indexOf("--name");
|
|
519
578
|
const name = nameIdx !== -1 ? args2[nameIdx + 1] : void 0;
|
|
@@ -556,39 +615,60 @@ Wallet created (hosted)`);
|
|
|
556
615
|
console.log(` API Key: ${agent.apiKey}
|
|
557
616
|
`);
|
|
558
617
|
}
|
|
559
|
-
async function walletList() {
|
|
618
|
+
async function walletList(args2 = []) {
|
|
619
|
+
const json = args2.includes("--json");
|
|
560
620
|
const token = await getToken();
|
|
561
621
|
const localWallets = listLocalWallets();
|
|
622
|
+
const local = localWallets.map(toLocalWallet);
|
|
623
|
+
const hosted = [];
|
|
624
|
+
let hostedError = null;
|
|
562
625
|
let printedHosted = false;
|
|
563
626
|
if (token) {
|
|
564
627
|
try {
|
|
565
628
|
const res = await apiFetch("/account/agents", {}, token);
|
|
566
629
|
if (res.ok) {
|
|
567
|
-
const
|
|
568
|
-
|
|
630
|
+
const agents = await res.json();
|
|
631
|
+
hosted.push(...agents.map(toHostedWallet));
|
|
632
|
+
if (!json && hosted.length > 0) {
|
|
569
633
|
console.log("\nHosted wallets:");
|
|
570
|
-
for (const a of
|
|
634
|
+
for (const a of agents) {
|
|
571
635
|
console.log(formatHostedAgentLine(a));
|
|
572
636
|
}
|
|
573
637
|
printedHosted = true;
|
|
574
|
-
} else {
|
|
638
|
+
} else if (!json) {
|
|
575
639
|
console.log("\nNo hosted wallets found.");
|
|
576
640
|
}
|
|
577
641
|
} else if (res.status === 401) {
|
|
578
|
-
|
|
579
|
-
|
|
642
|
+
hostedError = { status: res.status, message: "Stored login is expired or invalid. Run `agentis logout` and then `agentis login`." };
|
|
643
|
+
if (!json) console.log(`
|
|
644
|
+
Could not list hosted wallets: ${hostedError.message}`);
|
|
580
645
|
} else {
|
|
581
646
|
const data = await res.json().catch(() => ({}));
|
|
582
|
-
|
|
583
|
-
|
|
647
|
+
hostedError = { status: res.status, message: data.error ?? res.statusText };
|
|
648
|
+
if (!json) console.log(`
|
|
649
|
+
Could not list hosted wallets from ${API_BASE}: ${hostedError.message}`);
|
|
584
650
|
}
|
|
585
651
|
} catch (err) {
|
|
586
652
|
const message = err instanceof Error ? err.message : String(err);
|
|
587
|
-
|
|
653
|
+
hostedError = { message };
|
|
654
|
+
if (!json) console.log(`
|
|
588
655
|
Could not list hosted wallets from ${API_BASE}: ${message}`);
|
|
589
656
|
}
|
|
590
657
|
} else {
|
|
591
|
-
|
|
658
|
+
hostedError = { message: "Not logged in. Run `agentis login` to list hosted wallets." };
|
|
659
|
+
if (!json) console.log(`
|
|
660
|
+
${hostedError.message}`);
|
|
661
|
+
}
|
|
662
|
+
if (json) {
|
|
663
|
+
console.log(JSON.stringify({
|
|
664
|
+
apiBase: API_BASE,
|
|
665
|
+
authenticated: Boolean(token),
|
|
666
|
+
hosted,
|
|
667
|
+
hostedError,
|
|
668
|
+
local,
|
|
669
|
+
wallets: [...hosted, ...local]
|
|
670
|
+
}, null, 2));
|
|
671
|
+
return;
|
|
592
672
|
}
|
|
593
673
|
if (localWallets.length > 0) {
|
|
594
674
|
console.log("\nLocal wallets:");
|
|
@@ -1347,11 +1427,11 @@ async function earnSweep(args2) {
|
|
|
1347
1427
|
var args = process.argv.slice(2);
|
|
1348
1428
|
var cmd = args[0];
|
|
1349
1429
|
var sub = args[1];
|
|
1350
|
-
var
|
|
1351
|
-
var
|
|
1352
|
-
var
|
|
1430
|
+
var blue2 = "\x1B[38;5;117m";
|
|
1431
|
+
var green2 = "\x1B[38;5;114m";
|
|
1432
|
+
var muted2 = "\x1B[38;5;244m";
|
|
1353
1433
|
var bold = "\x1B[1m";
|
|
1354
|
-
var
|
|
1434
|
+
var reset2 = "\x1B[0m";
|
|
1355
1435
|
function readCliVersion() {
|
|
1356
1436
|
try {
|
|
1357
1437
|
const packageJsonPath = join3(dirname2(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
@@ -1397,9 +1477,12 @@ var helpSpecs = {
|
|
|
1397
1477
|
]
|
|
1398
1478
|
},
|
|
1399
1479
|
"wallet list": {
|
|
1400
|
-
usage: "agentis wallet list",
|
|
1480
|
+
usage: "agentis wallet list [--json]",
|
|
1401
1481
|
description: "List hosted wallets from Agentis and local encrypted wallets on this machine.",
|
|
1402
|
-
options: [
|
|
1482
|
+
options: [
|
|
1483
|
+
["--json", "print structured JSON for agent/tool parsing"],
|
|
1484
|
+
["-h, --help", "display help for command"]
|
|
1485
|
+
]
|
|
1403
1486
|
},
|
|
1404
1487
|
agent: {
|
|
1405
1488
|
usage: "agentis agent <command>",
|
|
@@ -1620,18 +1703,18 @@ var helpSpecs = {
|
|
|
1620
1703
|
}
|
|
1621
1704
|
};
|
|
1622
1705
|
function showHelp() {
|
|
1623
|
-
console.log(`${
|
|
1706
|
+
console.log(`${blue2}${bold}
|
|
1624
1707
|
\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
1625
1708
|
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
1626
1709
|
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
1627
1710
|
\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551
|
|
1628
1711
|
\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
|
|
1629
1712
|
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
1630
|
-
${
|
|
1713
|
+
${reset2}${muted2}v${version}${reset2}
|
|
1631
1714
|
|
|
1632
|
-
${bold}Agentis${
|
|
1715
|
+
${bold}Agentis${reset2} \u2014 financial infrastructure for AI agents
|
|
1633
1716
|
|
|
1634
|
-
${
|
|
1717
|
+
${green2}${bold}Commands:${reset2}
|
|
1635
1718
|
login authenticate with your Agentis account
|
|
1636
1719
|
logout remove stored credentials
|
|
1637
1720
|
whoami show current account
|
|
@@ -1639,7 +1722,7 @@ ${green}${bold}Commands:${reset}
|
|
|
1639
1722
|
|
|
1640
1723
|
wallet create --name <name> create hosted wallet (requires login)
|
|
1641
1724
|
wallet create --name <name> --local create local encrypted wallet
|
|
1642
|
-
wallet list
|
|
1725
|
+
wallet list [--json] list all wallets (hosted + local)
|
|
1643
1726
|
|
|
1644
1727
|
agent create <name> create a new hosted agent
|
|
1645
1728
|
--onchain-policy create with Quasar on-chain policy mode
|
|
@@ -1700,7 +1783,7 @@ function helpPath(values) {
|
|
|
1700
1783
|
}
|
|
1701
1784
|
function printRows(title, rows) {
|
|
1702
1785
|
console.log(`
|
|
1703
|
-
${
|
|
1786
|
+
${green2}${bold}${title}:${reset2}`);
|
|
1704
1787
|
for (const [left, right] of rows) {
|
|
1705
1788
|
console.log(` ${left.padEnd(38)} ${right}`);
|
|
1706
1789
|
}
|
|
@@ -1715,7 +1798,7 @@ function showCommandHelp(path) {
|
|
|
1715
1798
|
showHelp();
|
|
1716
1799
|
return;
|
|
1717
1800
|
}
|
|
1718
|
-
console.log(`${bold}Usage:${
|
|
1801
|
+
console.log(`${bold}Usage:${reset2} ${spec.usage}
|
|
1719
1802
|
`);
|
|
1720
1803
|
console.log(spec.description);
|
|
1721
1804
|
if (spec.commands) printRows("Commands", spec.commands);
|
|
@@ -1748,7 +1831,7 @@ async function main() {
|
|
|
1748
1831
|
await walletCreate(args.slice(2));
|
|
1749
1832
|
break;
|
|
1750
1833
|
case "list":
|
|
1751
|
-
await walletList();
|
|
1834
|
+
await walletList(args.slice(2));
|
|
1752
1835
|
break;
|
|
1753
1836
|
default:
|
|
1754
1837
|
console.log("Usage: agentis wallet <create|list>");
|