@agentis-hq/cli 0.1.1 → 0.1.3

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 +9 -3
  2. package/dist/index.js +86 -4
  3. package/package.json +20 -1
package/README.md CHANGED
@@ -4,9 +4,7 @@ Command line tools for Agentis, the financial infrastructure layer for AI agents
4
4
 
5
5
  The CLI lets you create agent wallets, manage spend policies, pay MPP and x402 URLs, work with Umbra privacy flows, deposit idle USDC into Jupiter Earn, and scaffold x402 facilitators.
6
6
 
7
- ![Agentis CLI help](./assets/agentis-help.png)
8
-
9
- > Add the screenshot at `packages/cli/assets/agentis-help.png` before publishing if it is not already present in the package.
7
+ ![Agentis CLI help](https://unpkg.com/@agentis-hq/cli/assets/agentis-help.png)
10
8
 
11
9
  ## Install
12
10
 
@@ -171,6 +169,13 @@ Deposit USDC into Jupiter Earn:
171
169
  agentis earn deposit research-agent --asset USDC --amount 1 --mainnet
172
170
  ```
173
171
 
172
+ Withdraw USDC from Jupiter Earn. Omit `--amount` to redeem the full USDC Earn position:
173
+
174
+ ```bash
175
+ agentis earn withdraw research-agent --asset USDC --mainnet
176
+ agentis earn withdraw research-agent --asset USDC --amount 1 --mainnet
177
+ ```
178
+
174
179
  Show positions:
175
180
 
176
181
  ```bash
@@ -255,6 +260,7 @@ agentis wallet create --help
255
260
  agentis agent send --help
256
261
  agentis fetch --help
257
262
  agentis earn deposit --help
263
+ agentis earn withdraw --help
258
264
  agentis privacy create-utxo --help
259
265
  agentis facilitator publish --help
260
266
  ```
package/dist/index.js CHANGED
@@ -269,6 +269,31 @@ function recordLocalSpend(wallet, spend) {
269
269
  return updated;
270
270
  }
271
271
 
272
+ // src/lib/format-agent.ts
273
+ function formatPolicy(agent) {
274
+ const mode = agent.policyMode ?? "backend";
275
+ if (mode !== "onchain") return "policy=backend";
276
+ return `policy=onchain:${agent.onchainPolicy?.initialized ? "ready" : "pending"}`;
277
+ }
278
+ function formatPrivacy(agent) {
279
+ if (!agent.privacyEnabled && !agent.umbraStatus) return null;
280
+ return `privacy=${agent.umbraStatus ?? "enabled"}`;
281
+ }
282
+ function formatLocalPolicy(wallet) {
283
+ return wallet.policy.killSwitch ? "policy=local:killed" : "policy=local";
284
+ }
285
+ function formatBadges(parts) {
286
+ return parts.filter(Boolean).join(", ");
287
+ }
288
+ function formatHostedAgentLine(agent) {
289
+ const badges = formatBadges(["hosted", formatPolicy(agent), formatPrivacy(agent)]);
290
+ return ` ${agent.name.padEnd(20)} ${agent.walletAddress} [${agent.id}] ${badges}`;
291
+ }
292
+ function formatLocalWalletLine(wallet) {
293
+ const badges = formatBadges(["local", formatLocalPolicy(wallet)]);
294
+ return ` ${wallet.name.padEnd(20)} ${wallet.solanaAddress} [${wallet.id}] ${badges}`;
295
+ }
296
+
272
297
  // src/commands/agent.ts
273
298
  import { checkPolicy } from "@agentis-hq/core";
274
299
  import {
@@ -329,7 +354,7 @@ async function agentList() {
329
354
  }
330
355
  console.log();
331
356
  for (const a of agents) {
332
- console.log(` ${a.name.padEnd(20)} ${a.walletAddress} [${a.id}]`);
357
+ console.log(formatHostedAgentLine(a));
333
358
  }
334
359
  console.log();
335
360
  }
@@ -550,7 +575,7 @@ async function walletList() {
550
575
  if (hosted.length > 0) {
551
576
  console.log("\nHosted wallets:");
552
577
  for (const a of hosted) {
553
- console.log(` ${a.name.padEnd(20)} ${a.walletAddress} [${a.id}]`);
578
+ console.log(formatHostedAgentLine(a));
554
579
  }
555
580
  }
556
581
  }
@@ -560,7 +585,7 @@ async function walletList() {
560
585
  if (localWallets.length > 0) {
561
586
  console.log("\nLocal wallets:");
562
587
  for (const w of localWallets) {
563
- console.log(` ${w.name.padEnd(20)} ${w.solanaAddress} [${w.id}]`);
588
+ console.log(formatLocalWalletLine(w));
564
589
  }
565
590
  }
566
591
  if (localWallets.length === 0 && !token) {
@@ -1044,6 +1069,9 @@ async function earnCommand(args2) {
1044
1069
  case "deposit":
1045
1070
  await earnDeposit(args2.slice(1));
1046
1071
  break;
1072
+ case "withdraw":
1073
+ await earnWithdraw(args2.slice(1));
1074
+ break;
1047
1075
  case "positions":
1048
1076
  await earnPositions(args2.slice(1));
1049
1077
  break;
@@ -1051,7 +1079,7 @@ async function earnCommand(args2) {
1051
1079
  await earnSweep(args2.slice(1));
1052
1080
  break;
1053
1081
  default:
1054
- console.log("Usage: agentis earn <deposit|positions|sweep>");
1082
+ console.log("Usage: agentis earn <deposit|withdraw|positions|sweep>");
1055
1083
  }
1056
1084
  }
1057
1085
  async function earnDeposit(args2) {
@@ -1091,6 +1119,47 @@ Depositing ${amountNum} ${asset.toUpperCase()} into Jupiter Earn from ${agent.na
1091
1119
  console.log(` Explorer: https://solscan.io/tx/${data.signature}
1092
1120
  `);
1093
1121
  }
1122
+ async function earnWithdraw(args2) {
1123
+ const agentName = args2[0];
1124
+ const asset = getFlag3(args2, "--asset") ?? "USDC";
1125
+ const amount = getFlag3(args2, "--amount");
1126
+ const mainnet = args2.includes("--mainnet");
1127
+ if (!agentName || !mainnet) {
1128
+ console.error("Usage: agentis earn withdraw <agent> --asset USDC [--amount <amount>] --mainnet");
1129
+ process.exit(1);
1130
+ }
1131
+ if (amount !== void 0) {
1132
+ const amountNum = Number(amount);
1133
+ if (!Number.isFinite(amountNum) || amountNum <= 0) {
1134
+ console.error("Invalid amount");
1135
+ process.exit(1);
1136
+ }
1137
+ }
1138
+ const token = await requireAuth3();
1139
+ const agent = await resolveAccountAgent(agentName, token);
1140
+ const amountLabel = amount === void 0 ? "all supplied" : `${amount} ${asset.toUpperCase()}`;
1141
+ console.log(`
1142
+ Withdrawing ${amountLabel} from Jupiter Earn to ${agent.name} on mainnet...`);
1143
+ const res = await apiFetch(`/agents/${agent.id}/earn/withdraw`, {
1144
+ method: "POST",
1145
+ body: JSON.stringify({
1146
+ network: "mainnet",
1147
+ asset,
1148
+ amount
1149
+ })
1150
+ }, token);
1151
+ const data = await res.json().catch(() => ({}));
1152
+ if (!res.ok) {
1153
+ console.error("Earn withdraw failed:", data.error ?? res.statusText);
1154
+ process.exit(1);
1155
+ }
1156
+ console.log("\nEarn withdraw submitted.");
1157
+ console.log(` Signature: ${data.signature}`);
1158
+ console.log(` Amount: ${data.amount} ${asset.toUpperCase()}`);
1159
+ console.log(` Mode: ${data.mode}`);
1160
+ console.log(` Explorer: https://solscan.io/tx/${data.signature}
1161
+ `);
1162
+ }
1094
1163
  async function earnPositions(args2) {
1095
1164
  const agentName = args2[0];
1096
1165
  const mainnet = args2.includes("--mainnet");
@@ -1359,6 +1428,7 @@ var helpSpecs = {
1359
1428
  description: "Manage Jupiter Earn deposits and positions for hosted agent wallets.",
1360
1429
  commands: [
1361
1430
  ["deposit <agent> --asset USDC --amount <amount> --mainnet", "deposit mainnet USDC into Jupiter Earn"],
1431
+ ["withdraw <agent> --asset USDC [--amount <amount>] --mainnet", "withdraw mainnet USDC from Jupiter Earn"],
1362
1432
  ["positions <agent> --mainnet [--all]", "show Jupiter Earn positions"],
1363
1433
  ["sweep [--dry-run|--no-dry-run]", "sweep all hosted agents mainnet USDC into Jupiter Earn"]
1364
1434
  ]
@@ -1373,6 +1443,16 @@ var helpSpecs = {
1373
1443
  ["-h, --help", "display help for command"]
1374
1444
  ]
1375
1445
  },
1446
+ "earn withdraw": {
1447
+ usage: "agentis earn withdraw <agent> --asset USDC [--amount <amount>] --mainnet",
1448
+ description: "Withdraw mainnet USDC from Jupiter Earn back to a hosted agent wallet. Omitting --amount redeems the full USDC Earn position.",
1449
+ options: [
1450
+ ["--asset USDC", "asset to withdraw; currently USDC"],
1451
+ ["--amount <amount>", "optional UI amount, for example 1 for 1 USDC"],
1452
+ ["--mainnet", "required safety flag"],
1453
+ ["-h, --help", "display help for command"]
1454
+ ]
1455
+ },
1376
1456
  "earn positions": {
1377
1457
  usage: "agentis earn positions <agent> --mainnet [--all]",
1378
1458
  description: "Show Jupiter Earn positions for a hosted agent wallet.",
@@ -1556,6 +1636,8 @@ ${green}${bold}Commands:${reset}
1556
1636
  --asset USDC asset to deposit
1557
1637
  --amount <amount> UI amount, e.g. 1 for 1 USDC
1558
1638
  --mainnet required safety flag
1639
+ earn withdraw <agent> --mainnet withdraw all USDC from Jupiter Earn
1640
+ --amount <amount> optional UI amount, e.g. 1 for 1 USDC
1559
1641
  earn positions <agent> --mainnet show Jupiter Earn positions
1560
1642
  earn sweep [--dry-run|--no-dry-run] sweep all agents' mainnet USDC into Earn
1561
1643
 
package/package.json CHANGED
@@ -1,11 +1,30 @@
1
1
  {
2
2
  "name": "@agentis-hq/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "agentis": "dist/index.js"
7
7
  },
8
8
  "description": "Agentis CLI",
9
+ "keywords": [
10
+ "agentis",
11
+ "ai",
12
+ "agents",
13
+ "ai-agents",
14
+ "agentic",
15
+ "cli",
16
+ "solana",
17
+ "payments",
18
+ "crypto",
19
+ "wallet",
20
+ "agent-wallets",
21
+ "crypto-payments",
22
+ "x402",
23
+ "mpp",
24
+ "jupiter",
25
+ "umbra",
26
+ "mcp"
27
+ ],
9
28
  "exports": {
10
29
  "./package.json": "./package.json"
11
30
  },