@agentis-hq/cli 0.1.6 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +66 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -71,6 +71,7 @@ List hosted and local wallets:
71
71
 
72
72
  ```bash
73
73
  agentis wallet list
74
+ agentis wallet list --json
74
75
  ```
75
76
 
76
77
  ## Hosted Agents
package/dist/index.js CHANGED
@@ -514,6 +514,33 @@ function formatLocalWalletLine(wallet) {
514
514
  }
515
515
 
516
516
  // src/commands/wallet.ts
517
+ function toHostedWallet(agent) {
518
+ return {
519
+ id: agent.id,
520
+ name: agent.name,
521
+ walletAddress: agent.walletAddress,
522
+ type: "hosted",
523
+ policyMode: agent.policyMode ?? "backend",
524
+ onchainPolicy: agent.onchainPolicy ? {
525
+ initialized: Boolean(agent.onchainPolicy.initialized),
526
+ programId: agent.onchainPolicy.programId
527
+ } : void 0,
528
+ privacyEnabled: Boolean(agent.privacyEnabled),
529
+ umbraStatus: agent.umbraStatus ?? "disabled",
530
+ umbraRegisteredAt: agent.umbraRegisteredAt
531
+ };
532
+ }
533
+ function toLocalWallet(wallet) {
534
+ return {
535
+ id: wallet.id,
536
+ name: wallet.name,
537
+ walletAddress: wallet.solanaAddress,
538
+ solanaAddress: wallet.solanaAddress,
539
+ type: "local",
540
+ createdAt: wallet.createdAt,
541
+ policy: wallet.policy
542
+ };
543
+ }
517
544
  async function walletCreate(args2) {
518
545
  const nameIdx = args2.indexOf("--name");
519
546
  const name = nameIdx !== -1 ? args2[nameIdx + 1] : void 0;
@@ -556,39 +583,60 @@ Wallet created (hosted)`);
556
583
  console.log(` API Key: ${agent.apiKey}
557
584
  `);
558
585
  }
559
- async function walletList() {
586
+ async function walletList(args2 = []) {
587
+ const json = args2.includes("--json");
560
588
  const token = await getToken();
561
589
  const localWallets = listLocalWallets();
590
+ const local = localWallets.map(toLocalWallet);
591
+ const hosted = [];
592
+ let hostedError = null;
562
593
  let printedHosted = false;
563
594
  if (token) {
564
595
  try {
565
596
  const res = await apiFetch("/account/agents", {}, token);
566
597
  if (res.ok) {
567
- const hosted = await res.json();
568
- if (hosted.length > 0) {
598
+ const agents = await res.json();
599
+ hosted.push(...agents.map(toHostedWallet));
600
+ if (!json && hosted.length > 0) {
569
601
  console.log("\nHosted wallets:");
570
- for (const a of hosted) {
602
+ for (const a of agents) {
571
603
  console.log(formatHostedAgentLine(a));
572
604
  }
573
605
  printedHosted = true;
574
- } else {
606
+ } else if (!json) {
575
607
  console.log("\nNo hosted wallets found.");
576
608
  }
577
609
  } else if (res.status === 401) {
578
- console.log(`
579
- Could not list hosted wallets: stored login is expired or invalid. Run \`agentis logout\` and then \`agentis login\`.`);
610
+ hostedError = { status: res.status, message: "Stored login is expired or invalid. Run `agentis logout` and then `agentis login`." };
611
+ if (!json) console.log(`
612
+ Could not list hosted wallets: ${hostedError.message}`);
580
613
  } else {
581
614
  const data = await res.json().catch(() => ({}));
582
- console.log(`
583
- Could not list hosted wallets from ${API_BASE}: ${data.error ?? res.statusText}`);
615
+ hostedError = { status: res.status, message: data.error ?? res.statusText };
616
+ if (!json) console.log(`
617
+ Could not list hosted wallets from ${API_BASE}: ${hostedError.message}`);
584
618
  }
585
619
  } catch (err) {
586
620
  const message = err instanceof Error ? err.message : String(err);
587
- console.log(`
621
+ hostedError = { message };
622
+ if (!json) console.log(`
588
623
  Could not list hosted wallets from ${API_BASE}: ${message}`);
589
624
  }
590
625
  } else {
591
- console.log("\nNot logged in. Run `agentis login` to list hosted wallets.");
626
+ hostedError = { message: "Not logged in. Run `agentis login` to list hosted wallets." };
627
+ if (!json) console.log(`
628
+ ${hostedError.message}`);
629
+ }
630
+ if (json) {
631
+ console.log(JSON.stringify({
632
+ apiBase: API_BASE,
633
+ authenticated: Boolean(token),
634
+ hosted,
635
+ hostedError,
636
+ local,
637
+ wallets: [...hosted, ...local]
638
+ }, null, 2));
639
+ return;
592
640
  }
593
641
  if (localWallets.length > 0) {
594
642
  console.log("\nLocal wallets:");
@@ -1397,9 +1445,12 @@ var helpSpecs = {
1397
1445
  ]
1398
1446
  },
1399
1447
  "wallet list": {
1400
- usage: "agentis wallet list",
1448
+ usage: "agentis wallet list [--json]",
1401
1449
  description: "List hosted wallets from Agentis and local encrypted wallets on this machine.",
1402
- options: [["-h, --help", "display help for command"]]
1450
+ options: [
1451
+ ["--json", "print structured JSON for agent/tool parsing"],
1452
+ ["-h, --help", "display help for command"]
1453
+ ]
1403
1454
  },
1404
1455
  agent: {
1405
1456
  usage: "agentis agent <command>",
@@ -1639,7 +1690,7 @@ ${green}${bold}Commands:${reset}
1639
1690
 
1640
1691
  wallet create --name <name> create hosted wallet (requires login)
1641
1692
  wallet create --name <name> --local create local encrypted wallet
1642
- wallet list list all wallets (hosted + local)
1693
+ wallet list [--json] list all wallets (hosted + local)
1643
1694
 
1644
1695
  agent create <name> create a new hosted agent
1645
1696
  --onchain-policy create with Quasar on-chain policy mode
@@ -1748,7 +1799,7 @@ async function main() {
1748
1799
  await walletCreate(args.slice(2));
1749
1800
  break;
1750
1801
  case "list":
1751
- await walletList();
1802
+ await walletList(args.slice(2));
1752
1803
  break;
1753
1804
  default:
1754
1805
  console.log("Usage: agentis wallet <create|list>");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentis-hq/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "agentis": "dist/index.js"